diff --git a/src/app/components/calculator-list/calculator-list.component.ts b/src/app/components/calculator-list/calculator-list.component.ts index de47224867986a16984f4c67de69682c862028af..7e3ad572542450414bba6a72f86336a2090bb250 100644 --- a/src/app/components/calculator-list/calculator-list.component.ts +++ b/src/app/components/calculator-list/calculator-list.component.ts @@ -31,53 +31,57 @@ export class CalculatorListComponent implements OnInit { if (themes) { // group by themes for (const theme of themes) { - // get theme details from config - const themeTitleKey = "INFO_THEME_" + theme.name + "_TITRE"; - const themeDescriptionKey = "INFO_THEME_" + theme.name + "_DESCRIPTION"; - const credits = ServiceFactory.instance.i18nService.localizeText("INFO_THEME_CREDITS"); - const item = { - title: ServiceFactory.instance.i18nService.localizeText(themeTitleKey), - description: ServiceFactory.instance.i18nService.localizeText(themeDescriptionKey), - image: { - path: "assets/images/themes/" + theme.image.path, - title: theme.image.title, - credits: credits + " : " + theme.image.credits - }, - calculators: [] - }; - // get calculators for this theme - for (const calcType of theme.calculators) { - item.calculators.push({ - type: calcType, - label: ServiceFactory.instance.formulaireService.getLocalisedTitleFromCalculatorType(calcType) - }); - // mark as used - const index = unusedCalculators.indexOf(calcType); - if (index > -1) { - unusedCalculators.splice(index, 1); + if (theme.name) { + // get theme details from config + const themeTitleKey = "INFO_THEME_" + theme.name + "_TITRE"; + const themeDescriptionKey = "INFO_THEME_" + theme.name + "_DESCRIPTION"; + const credits = ServiceFactory.instance.i18nService.localizeText("INFO_THEME_CREDITS"); + const item = { + title: ServiceFactory.instance.i18nService.localizeText(themeTitleKey), + description: ServiceFactory.instance.i18nService.localizeText(themeDescriptionKey), + image: { + path: "assets/images/themes/" + theme.image.path, + title: theme.image.title, + credits: credits + " : " + theme.image.credits + }, + calculators: [] + }; + // get calculators for this theme + for (const calcType of theme.calculators) { + item.calculators.push({ + type: calcType, + label: ServiceFactory.instance.formulaireService.getLocalisedTitleFromCalculatorType(calcType) + }); + // mark as used + const index = unusedCalculators.indexOf(calcType); + if (index > -1) { + unusedCalculators.splice(index, 1); + } } + this._items.push(item); } - this._items.push(item); + // else special theme for unused calculators } - } - // extra card for unused calculators - if (unusedCalculators.length > 0) { - const unusedTheme = { - title: "Pas utilisées", - description: "Tout ce qu'est pas dans les autres thèmes", - calculators: [] - }; - for (const t of unusedCalculators) { - if (t !== CalculatorType.Structure) { - unusedTheme.calculators.push({ - type: t, - label: ServiceFactory.instance.formulaireService.getLocalisedTitleFromCalculatorType(t) - }); + // extra card for unused calculators + if (unusedCalculators.length > 0) { + const unusedTheme = themes.find(i => i.name === undefined); + unusedTheme.calculators = []; + unusedTheme.title = ServiceFactory.instance.i18nService.localizeText("INFO_THEME_MODULES_INUTILISES_TITRE"); + unusedTheme.description = ServiceFactory.instance.i18nService.localizeText("INFO_THEME_MODULES_INUTILISES_DESCRIPTION"); + unusedTheme.image.path = "assets/images/themes/" + unusedTheme.image.path; + + for (const t of unusedCalculators) { + if (t !== CalculatorType.Structure) { + unusedTheme.calculators.push({ + type: t, + label: ServiceFactory.instance.formulaireService.getLocalisedTitleFromCalculatorType(t) + }); + } } + if (unusedTheme.calculators.length > 0) { + this._items.push(unusedTheme); + } // else the only remaining calculator was "Structure", the one we don't want } - if (unusedTheme.calculators.length > 0) { - this._items.push(unusedTheme); - } // else the only remaining calculator was "Structure", the one we don't want } } diff --git a/src/app/config.json b/src/app/config.json index ea088447def95b3860b3820c9bb71754e5739dd8..37d246e537e9563904298e5848554378446dbf22 100644 --- a/src/app/config.json +++ b/src/app/config.json @@ -13,7 +13,8 @@ "title": "Passe à poisson sur le Lez, entre Bollène et Suze", "credits": "Hervé Capra / Irstea" }, - "calculators": [ 5, 6, 10, 9 ] + "calculators": [ 6, 10, 9 ], + "_calculators": [ 5, 6, 10, 9 ] }, { "name": "PASSE_NATURELLE", @@ -50,6 +51,14 @@ "credits": "David Dorchies / Irstea" }, "calculators": [ 8, 9, 10 ] + }, + { + "_comment": "card for calculators not used in any theme", + "image": { + "path": "autres.jpg", + "title": "", + "credits": "" + } } ] } diff --git a/src/assets/images/themes/autres.jpg b/src/assets/images/themes/autres.jpg new file mode 100644 index 0000000000000000000000000000000000000000..504bcc57bfb9ca3731a109a8ef3866653dc0ef07 Binary files /dev/null and b/src/assets/images/themes/autres.jpg differ diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 7a1b82c67a32224e2cc61e6e45fe1a02ff13fcd8..aa6e3a1d456b317d784d6f980b159bb0cc551523 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -126,6 +126,8 @@ "INFO_SETUP_PRECISION_CALCUL": "Computation accuracy", "INFO_SETUP_TITLE": "Application setup", "INFO_THEME_CREDITS": "Credit", + "INFO_THEME_MODULES_INUTILISES_TITRE": "Other calculator modules", + "INFO_THEME_MODULES_INUTILISES_DESCRIPTION": "Calculator modules not used in themes above", "INFO_THEME_PASSE_A_BASSIN_TITRE": "Basin pass", "INFO_THEME_PASSE_A_BASSIN_DESCRIPTION": "A great pass with a great basin", "INFO_THEME_PASSE_NATURELLE_TITRE": "Natural pass", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 58cadd7b38b05729c10b942e479daae3091e6631..cf8f201c4d032abb0d21c71afc61a6de496dc12e 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -141,6 +141,8 @@ "INFO_SETUP_PRECISION_CALCUL": "Précision de calcul", "INFO_SETUP_TITLE": "Paramètres de l'application", "INFO_THEME_CREDITS": "Crédit", + "INFO_THEME_MODULES_INUTILISES_TITRE": "Autres modules de calcul", + "INFO_THEME_MODULES_INUTILISES_DESCRIPTION": "Modules de calculs non utilisés dans les thèmes ci-dessus", "INFO_THEME_PASSE_A_BASSIN_TITRE": "Passe à bassin", "INFO_THEME_PASSE_A_BASSIN_DESCRIPTION": "Une super passe avec un super bassin", "INFO_THEME_PASSE_NATURELLE_TITRE": "Passe naturelle",