From 49e35f31856b46b4da27df9d4b56cf710a0bec6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e?= <tpoussard@neogeo.fr> Date: Tue, 14 Jun 2022 17:24:58 +0200 Subject: [PATCH] add possibility to customize colors for boolean custom fields --- src/services/map-service.js | 22 +++++++++++-------- .../FeatureType/FeatureTypeSymbology.vue | 17 ++++++++++++-- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/services/map-service.js b/src/services/map-service.js index 87156fe6..5cbfa07a 100644 --- a/src/services/map-service.js +++ b/src/services/map-service.js @@ -336,18 +336,22 @@ const mapService = { const fieldType = customfield_set.find((el) => el.name === colors_style.custom_field_name).field_type; const currentValue = properties[colors_style.custom_field_name]; - if (currentValue) { - switch (fieldType) { - case 'list' : + switch (fieldType) { + case 'list' : + if (currentValue) { color = colors_style.colors[currentValue]; opacity = colors_style.opacities[currentValue]; - break; - case 'char': //* if the custom field is supposed to be a string - //* check if its current value is empty or not, to select a color | https://redmine.neogeo.fr/issues/14048 - color = colors_style.value.colors[currentValue ? 'Non vide' : 'Vide']; - opacity = colors_style.value.opacities[currentValue ? 'Non vide' : 'Vide']; - break; } + break; + case 'char': //* if the custom field is supposed to be a string + //* check if its current value is empty or not, to select a color | https://redmine.neogeo.fr/issues/14048 + color = colors_style.value.colors[currentValue ? 'Non vide' : 'Vide']; + opacity = colors_style.value.opacities[currentValue ? 'Non vide' : 'Vide']; + break; + case 'boolean': + color = colors_style.value.colors[currentValue ? 'Coché' : 'Décoché']; + opacity = colors_style.value.opacities[currentValue ? 'Coché' : 'Décoché']; + break; } } return { color, opacity }; diff --git a/src/views/FeatureType/FeatureTypeSymbology.vue b/src/views/FeatureType/FeatureTypeSymbology.vue index 148221be..813803bd 100644 --- a/src/views/FeatureType/FeatureTypeSymbology.vue +++ b/src/views/FeatureType/FeatureTypeSymbology.vue @@ -174,9 +174,9 @@ export default { ]), customizableFields() { if (this.feature_type) { - let options = this.feature_type.customfield_set.filter(el => el.field_type === 'list' || el.field_type === 'char'); + let options = this.feature_type.customfield_set.filter(el => el.field_type === 'list' || el.field_type === 'char' || el.field_type === 'boolean'); options = options.map((el) => { - return { name: [el.name, `(${el.field_type === 'list' ? 'Liste de valeurs' : 'Chaîne de caractères'})`], value: el }; + return { name: [el.name, this.getFieldLabel(el.field_type)], value: el }; }); return options; } @@ -189,6 +189,8 @@ export default { return customFieldSet.options; } else if (customFieldSet.field_type === 'char') { return ['Vide', 'Non vide']; + } else if (customFieldSet.field_type === 'boolean') { + return ['Décoché', 'Coché']; } } return []; @@ -336,6 +338,17 @@ export default { return feature_type.colors_style.value.opacities[optionName]; } return null; + }, + + getFieldLabel(fieldType) { + switch (fieldType) { + case 'list': + return'Liste de valeurs'; + case 'char': + return 'Chaîne de caractères'; + case 'boolean': + return 'Champs de types booléen'; + } } } }; -- GitLab