mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
configpanel: filter as a simple_js_expression
This commit is contained in:
parent
ab5580cb11
commit
f2b95e5fbe
2 changed files with 7 additions and 7 deletions
|
@ -14,7 +14,7 @@ i18n = "domain_config"
|
||||||
[feature.app]
|
[feature.app]
|
||||||
[feature.app.default_app]
|
[feature.app.default_app]
|
||||||
type = "app"
|
type = "app"
|
||||||
filters = ["is_webapp"]
|
filter = "is_webapp"
|
||||||
default = "_none"
|
default = "_none"
|
||||||
|
|
||||||
[feature.mail]
|
[feature.mail]
|
||||||
|
|
|
@ -440,7 +440,7 @@ class ConfigPanel:
|
||||||
"step",
|
"step",
|
||||||
"accept",
|
"accept",
|
||||||
"redact",
|
"redact",
|
||||||
"filters",
|
"filter",
|
||||||
],
|
],
|
||||||
"defaults": {},
|
"defaults": {},
|
||||||
},
|
},
|
||||||
|
@ -706,7 +706,7 @@ class Question:
|
||||||
self.ask = question.get("ask", {"en": self.name})
|
self.ask = question.get("ask", {"en": self.name})
|
||||||
self.help = question.get("help")
|
self.help = question.get("help")
|
||||||
self.redact = question.get("redact", False)
|
self.redact = question.get("redact", False)
|
||||||
self.filters = question.get("filters", [])
|
self.filter = question.get("filter", [])
|
||||||
# .current_value is the currently stored value
|
# .current_value is the currently stored value
|
||||||
self.current_value = question.get("current_value")
|
self.current_value = question.get("current_value")
|
||||||
# .value is the "proposed" value which we got from the user
|
# .value is the "proposed" value which we got from the user
|
||||||
|
@ -1142,12 +1142,12 @@ class AppQuestion(Question):
|
||||||
super().__init__(question, context, hooks)
|
super().__init__(question, context, hooks)
|
||||||
|
|
||||||
apps = app_list(full=True)["apps"]
|
apps = app_list(full=True)["apps"]
|
||||||
for _filter in self.filters:
|
|
||||||
apps = [app for app in apps if _filter in app and app[_filter]]
|
apps = [app for app in apps if evaluate_simple_js_expression(self.filter, context=app)]
|
||||||
|
|
||||||
def _app_display(app):
|
def _app_display(app):
|
||||||
domain_path = f" ({app['domain_path']})" if "domain_path" in app else ""
|
domain_path_or_id = f" ({app.get('domain_path', app['id'])})"
|
||||||
return app["label"] + domain_path
|
return app["label"] + domain_path_or_id
|
||||||
|
|
||||||
self.choices = {"_none": "---"}
|
self.choices = {"_none": "---"}
|
||||||
self.choices.update({app["id"]: _app_display(app) for app in apps})
|
self.choices.update({app["id"]: _app_display(app) for app in apps})
|
||||||
|
|
Loading…
Add table
Reference in a new issue