diff --git a/src/components/tabs/NumberGeneratorTab.vue b/src/components/tabs/NumberGeneratorTab.vue
index de792b5..4aef3e9 100644
--- a/src/components/tabs/NumberGeneratorTab.vue
+++ b/src/components/tabs/NumberGeneratorTab.vue
@@ -6,6 +6,13 @@
+
+
-
-
@@ -31,6 +31,23 @@
{{ $t('numgen.warning') }}
+
+
{{ $t('numgen.td2-wiki') }}
@@ -55,10 +72,11 @@ import genData from '../../constants/numberGeneratorData.json';
const i18n = useI18n();
type RegionName = keyof typeof genData.regionNumbers;
+type Category = keyof typeof genData.categories;
const beginRegionName = ref(null) as Ref;
const endRegionName = ref(null) as Ref;
-const categoryRules = ref(null) as Ref;
+const chosenCategory = ref(null) as Ref;
const trainNumber = ref(null) as Ref;
@@ -70,7 +88,7 @@ const copyNumber = () => {
};
const randomizeTrainNumber = (randomizeRegions = false) => {
- if (categoryRules.value == null) return;
+ // if (categoryRules.value == null) return;
const regionKeys = Object.keys(genData.regionNumbers);
@@ -93,13 +111,15 @@ const randomizeTrainNumber = (randomizeRegions = false) => {
number += `${beginRegionNumber}${endRegionNumber}`;
}
- // Do not roll the rest of number again if only randomize regions
- if (randomizeRegions) {
+ // Do not roll the rest of number again if only randomize regions and category rules are already selected
+ if (randomizeRegions && chosenCategory.value != null) {
trainNumber.value = number + trainNumber.value?.substring(2);
return;
}
- const rulesArray = categoryRules.value.split(';').map((r) => ({
+ if (chosenCategory.value == null) chosenCategory.value = 'EI';
+
+ const rulesArray = genData.categories[chosenCategory.value].split(';').map((r) => ({
index: r.split(':')[0],
rule: r.split(':')[1],
nums: Number(r.split(':')[2] || '1'),
@@ -126,12 +146,12 @@ const randomizeTrainNumber = (randomizeRegions = false) => {
@import '../../styles/global.scss';
.options {
- display: flex;
- flex-wrap: wrap;
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 0.5em;
select {
- width: calc(50% - 0.5em);
+ width: 100%;
}
}
diff --git a/src/locales/en.json b/src/locales/en.json
index 5b95535..98c3ddf 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -96,7 +96,7 @@
"end-region": "Terminating construction region",
"train-category": "Train category",
"number-info": "Generated train number:",
- "warning": "Choose category and construction regions (optionally)",
+ "warning": "Choose category and (optionally) construction regions",
"td2-wiki": "> Polish rules of train numbering (TD2 wiki)",
"td2-wiki-link": "https://wiki.td2.info.pl/index.php?title=Zasady_numeracji_poci%C4%85g%C3%B3w/en",
"action-random-region": "DRAW REGIONS",
@@ -109,6 +109,15 @@
"TM": "mass transport freight (TM)",
"TK": "non-mass transport freight (TK)",
"LT": "locomotive alone (LT)"
+ },
+ "rules": {
+ "EI": "4 digits - ends within the range of 00-99",
+ "MP/RP": "5 digits - ends within the range of 050-169",
+ "RO": "5 digits - ends within the range of 200-999",
+ "PW": "6 digits - '6' on the 3rd place; ends within the range of 000-899",
+ "TM": "6 digits - '4' on the 3rd place; ends within the range of 000-899",
+ "TK": "6 digits - '3' on the 3rd place; ends within the range of 000-899",
+ "LT": "6 digits - '5' on the 3rd place; ends within the range of 000-899"
}
},
"wiki": {
diff --git a/src/locales/pl.json b/src/locales/pl.json
index 915a0b0..9306942 100644
--- a/src/locales/pl.json
+++ b/src/locales/pl.json
@@ -96,7 +96,7 @@
"end-region": "Końcowy obszar konstrukcyjny",
"train-category": "Kategoria pociągu",
"number-info": "Wygenerowany numer pociągu:",
- "warning": "Wybierz kategorię oraz obszary konstrukcyjne (opcjonalnie)",
+ "warning": "Wybierz kategorię oraz (opcjonalnie) obszary konstrukcyjne",
"td2-wiki": "> Szczegółowe zasady numeracji (wikipedia TD2)",
"td2-wiki-link": "https://wiki.td2.info.pl/index.php?title=Zasady_numeracji_poci%C4%85g%C3%B3w",
"action-random-region": "LOSUJ OBSZARY",
@@ -109,6 +109,15 @@
"TM": "towarowy do przewozów masowych (TM)",
"TK": "towarowy do obsługi stacji (TK)",
"LT": "lokomotywa luzem (LT)"
+ },
+ "rules": {
+ "EI": "4 cyfry - końcówka z przedziału 00-99",
+ "MP/RP": "5 cyfr - końcówka z przedziału 050-169",
+ "RO": "5 cyfr - końcówka z przedziału 200-999",
+ "PW": "6 cyfr - '6' na 3. miejscu; końcówka z przedziału 000-899",
+ "TM": "6 cyfr - '4' na 3. miejscu; końcówka z przedziału 000-899",
+ "TK": "6 cyfr - '3' na 3. miejscu; końcówka z przedziału 000-899",
+ "LT": "6 cyfr - '5' na 3. miejscu; końcówka z przedziału 000-899"
}
},
"wiki": {