Skip to content

Commit 8a82ad4

Browse files
benoitblancmanisandro
authored andcommitted
Merge pull request #96 from benoitblanc/feat/disable-theme
Allow to disable themes in configuration
1 parent ab51008 commit 8a82ad4

File tree

8 files changed

+56
-18
lines changed

8 files changed

+56
-18
lines changed

src/plugins/themes/controllers/themes_controller.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def index(self):
139139
for item in self.themesconfig["themes"].get("items", []):
140140
themes["items"].append({
141141
"name": item["title"] if "title" in item else item["url"],
142-
"url": item["url"]
142+
"url": item["url"],
143+
"disabled": item.get("disabled", False)
143144
})
144145

145146
# TODO: nested groups
@@ -151,7 +152,8 @@ def index(self):
151152
for item in group["items"]:
152153
groupEntry["items"].append({
153154
"name": item["title"] if "title" in item else item["url"],
154-
"url": item["url"]
155+
"url": item["url"],
156+
"disabled": item.get("disabled", False)
155157
})
156158
themes["groups"].append(groupEntry)
157159

@@ -440,6 +442,8 @@ def create_form(self, theme=None):
440442
form.url.data = None
441443
if "title" in theme:
442444
form.title.data = theme["title"]
445+
if "disabled" in theme:
446+
form.disabled.data = theme["disabled"]
443447
if "default" in theme:
444448
form.default.data = theme["default"]
445449
if "tiled" in theme:
@@ -546,6 +550,10 @@ def create_or_update_theme(self, theme, form, tid=None, gid=None):
546550
else:
547551
if "title" in item: del item["title"]
548552

553+
item["disabled"] = False
554+
if form.disabled.data:
555+
item["disabled"] = True
556+
549557
item["default"] = False
550558
if form.default.data:
551559
item["default"] = True

src/plugins/themes/forms/theme_form.py

+5
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ class ThemeForm(FlaskForm):
119119
description=i18n('plugins.themes.theme.form_collapseLayerGroupsBelowLevel_description'),
120120
validators=[Optional()]
121121
)
122+
disabled = BooleanField(
123+
i18n('plugins.themes.theme.form_disabled'),
124+
description=i18n('plugins.themes.theme.form_disabled_description'),
125+
validators=[Optional()]
126+
)
122127
default = BooleanField(
123128
i18n('plugins.themes.theme.form_default'),
124129
description=i18n('plugins.themes.theme.form_default_description'),

src/plugins/themes/templates/theme.html

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ <h1>{{ title }}</h1>
225225
{{ wtf.render_field(form.printResolutions, form_type="horizontal", horizontal_columns=('sm', 2, 5)) }}
226226
{{ wtf.render_field(form.printLabelBlacklist, form_type="horizontal", horizontal_columns=('sm', 2, 5)) }}
227227
{{ wtf.render_field(form.collapseLayerGroupsBelowLevel, form_type="horizontal", horizontal_columns=('sm', 2, 5)) }}
228+
{{ wtf.render_field(form.disabled, form_type="horizontal", horizontal_columns=('sm', 0, 7)) }}
228229
{{ wtf.render_field(form.default, form_type="horizontal", horizontal_columns=('sm', 0, 7)) }}
229230
{{ wtf.render_field(form.tiled, form_type="horizontal", horizontal_columns=('sm', 0, 7)) }}
230231
{{ wtf.render_field(form.mapTips, form_type="horizontal", horizontal_columns=('sm', 0, 7)) }}

src/plugins/themes/templates/themes.html

+28-6
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,26 @@ <h3>{{ i18n('plugins.themes.themes.themes') }}</h3>
5252
<th>ID</th>
5353
<th>{{ i18n('plugins.themes.themes.theme') }}</th>
5454
<th>{{ i18n('interface.common.url') }}</th>
55+
<th>{{ i18n('plugins.themes.themes.disabled') }}</th>
5556
<th></th>
5657
<th></th>
5758
</thead>
5859
<tbody>
5960
{% for item in list %}
6061
<tr>
61-
<td style="vertical-align: middle">{{ loop.index }}</td>
62-
<td style="vertical-align: middle">{{ item.name }}</td>
63-
<td style="vertical-align: middle">{{ item.url }}</td>
62+
<td {% if item.disabled %}class="text-muted"{% endif %} style="vertical-align: middle">{{ loop.index }}</td>
63+
<td {% if item.disabled %}class="text-muted"{% endif %} style="vertical-align: middle">{{ item.name }}</td>
64+
<td {% if item.disabled %}class="text-muted"{% endif %} style="vertical-align: middle">{{ item.url }}</td>
65+
<td style="vertical-align: middle">
66+
<input class="form-check-input"
67+
id="disable-theme-{{ item.name }}"
68+
name="disable-theme-{{ item.name }}"
69+
type="checkbox" disabled value="disabled"
70+
{% if item.disabled %}
71+
checked
72+
{% endif %}
73+
/>
74+
</td>
6475
<td>
6576
<a href="#" onclick="copyToClipboard('{{ item.url }}')" class="btn btn-default copy" role="button" title="{{ i18n('plugins.themes.themes.copy_url') }}">
6677
{{ utils.render_icon('copy') }}
@@ -140,15 +151,26 @@ <h3>{{ i18n('plugins.themes.themes.theme_groups') }}</h3>
140151
<th>ID</th>
141152
<th>{{ i18n('plugins.themes.themes.theme') }}</th>
142153
<th>{{ i18n('interface.common.url') }}</th>
154+
<th>{{ i18n('plugins.themes.themes.disabled') }}</th>
143155
<th></th>
144156
<th></th>
145157
</thead>
146158
<tbody>
147159
{% for item in group["items"] %}
148160
<tr>
149-
<td style="vertical-align: middle">{{ loop.index }}</td>
150-
<td style="vertical-align: middle">{{ item.name }}</td>
151-
<td style="vertical-align: middle">{{ item.url }}</td>
161+
<td {% if item.disabled %}class="text-muted"{% endif %} style="vertical-align: middle">{{ loop.index }}</td>
162+
<td {% if item.disabled %}class="text-muted"{% endif %} style="vertical-align: middle">{{ item.name }}</td>
163+
<td {% if item.disabled %}class="text-muted"{% endif %} style="vertical-align: middle">{{ item.url }}</td>
164+
<td style="vertical-align: middle">
165+
<input class="form-check-input"
166+
id="disable-theme-{{ item.name }}"
167+
name="disable-theme-{{ item.name }}"
168+
type="checkbox" disabled value="disabled"
169+
{% if item.disabled %}
170+
checked
171+
{% endif %}
172+
/>
173+
</td>
152174
<td>
153175
<a href="#" onclick="copyToClipboard('{{ item.url }}')" class="btn btn-default copy" role="button" title="{{ i18n('plugins.themes.themes.copy_url') }}">
154176
{{ utils.render_icon('copy') }}

src/translations/de.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@
185185
"title": "Konfigurationseditor",
186186
"update_message_success": "wurde aktualisiert"
187187
},
188-
"json_editor": {
189-
"title": "title"
190-
},
191188
"themes": {
192189
"backgroundlayers": {
193190
"action_created": "erstellt",
@@ -285,6 +282,8 @@
285282
"form_crs_description": "Die Kartenprojektion.",
286283
"form_default": "Standard",
287284
"form_default_description": "Ob dieses Thema als Initialthema verwendet werden soll.",
285+
"form_disabled": "Deaktivieren",
286+
"form_disabled_description": "Dieses Thema beim Konfigurieren überspringen",
288287
"form_format_description": "Über WMS angefragtes Bildformat. Standard ist 'image/png'.",
289288
"form_mapTips": "Kartentips standardmässig aktivieren",
290289
"form_mapTips_description": "Kartentips standardmässig aktivieren",
@@ -321,6 +320,7 @@
321320
"create_theme_title": "Thema erstellen",
322321
"delete_theme": "Thema löschen",
323322
"delete_theme_message_error": "Konnte die Ressource für das Thema nicht löschen",
323+
"disabled": "Deaktiviert",
324324
"edit_theme": "Thema editieren",
325325
"edit_theme_title": "Thema editieren",
326326
"group_confirm_message_delete": "Themengruppe wirklich löschen?",

src/translations/en.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@
185185
"title": "Config Editor",
186186
"update_message_success": "has been updated"
187187
},
188-
"json_editor": {
189-
"title": "title"
190-
},
191188
"themes": {
192189
"backgroundlayers": {
193190
"action_created": "created",
@@ -285,6 +282,8 @@
285282
"form_crs_description": "The map projection.",
286283
"form_default": "Default",
287284
"form_default_description": "Whether to use this theme as initial theme.",
285+
"form_disabled": "Disable this theme",
286+
"form_disabled_description": "Skip this theme from configuration.",
288287
"form_format_description": "Image format requested from the WMS Service. Default is 'image/png'.",
289288
"form_mapTips": "Enable tooltip by default",
290289
"form_mapTips_description": "Enable the theme tooltip by default",
@@ -321,6 +320,7 @@
321320
"create_theme_title": "Create theme",
322321
"delete_theme": "Delete theme",
323322
"delete_theme_message_error": "Could not delete resource for map",
323+
"disabled": "Disabled",
324324
"edit_theme": "Edit theme",
325325
"edit_theme_title": "Edit theme",
326326
"group_confirm_message_delete": "Really delete theme group?",

src/translations/fr.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@
185185
"title": "Editeur des configurations",
186186
"update_message_success": "a été mis à jour"
187187
},
188-
"json_editor": {
189-
"title": "title"
190-
},
191188
"themes": {
192189
"backgroundlayers": {
193190
"action_created": "créé",
@@ -285,6 +282,8 @@
285282
"form_crs_description": "Projection de la carte.",
286283
"form_default": "Par défaut",
287284
"form_default_description": "Utiliser ce thème comme thème ouvert par défaut.",
285+
"form_disabled": "Désactiver ce thème",
286+
"form_disabled_description": "Ne pas prendre en compte ce thème dans la configuration.",
288287
"form_format_description": "Le format d'image est obligatoire pour le service WMS. Par défaut, 'image/png'.",
289288
"form_mapTips": "Activer l'infobulle par défaut",
290289
"form_mapTips_description": "Activer l'infobulle par défaut sur ce thème",
@@ -321,6 +320,7 @@
321320
"create_theme_title": "Créer un thème",
322321
"delete_theme": "Supprimer un thème",
323322
"delete_theme_message_error": "Impossible de supprimer la ressource pour la carte",
323+
"disabled": "Désactivé",
324324
"edit_theme": "Modifier le thème",
325325
"edit_theme_title": "Modifier le thème",
326326
"group_confirm_message_delete": "Voulez-vous vraiment supprimer ce groupe de thèmes?",

src/translations/tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@
169169
"plugins.config_editor.subtitle",
170170
"plugins.config_editor.title",
171171
"plugins.config_editor.update_message_success",
172-
"plugins.json_editor.title",
173172
"plugins.themes.backgroundlayers.action_created",
174173
"plugins.themes.backgroundlayers.action_updated",
175174
"plugins.themes.backgroundlayers.create_message_error",
@@ -255,6 +254,8 @@
255254
"plugins.themes.theme.form_crs_description",
256255
"plugins.themes.theme.form_default",
257256
"plugins.themes.theme.form_default_description",
257+
"plugins.themes.theme.form_disabled",
258+
"plugins.themes.theme.form_disabled_description",
258259
"plugins.themes.theme.form_format_description",
259260
"plugins.themes.theme.form_mapTips",
260261
"plugins.themes.theme.form_mapTips_description",
@@ -289,6 +290,7 @@
289290
"plugins.themes.themes.create_theme_title",
290291
"plugins.themes.themes.delete_theme",
291292
"plugins.themes.themes.delete_theme_message_error",
293+
"plugins.themes.themes.disabled",
292294
"plugins.themes.themes.edit_theme",
293295
"plugins.themes.themes.edit_theme_title",
294296
"plugins.themes.themes.group_confirm_message_delete",

0 commit comments

Comments
 (0)