configpanel: fix choices

This commit is contained in:
axolotle 2023-04-13 14:05:03 +02:00
parent c439c47d67
commit fe2761da4a

View file

@ -30,6 +30,8 @@ from moulinette.utils.log import getActionLogger
from yunohost.utils.error import YunohostError, YunohostValidationError from yunohost.utils.error import YunohostError, YunohostValidationError
from yunohost.utils.form import ( from yunohost.utils.form import (
OPTIONS, OPTIONS,
BaseChoicesOption,
BaseInputOption,
BaseOption, BaseOption,
FileOption, FileOption,
ask_questions_and_parse_answers, ask_questions_and_parse_answers,
@ -148,9 +150,11 @@ class ConfigPanel:
option["ask"] = ask option["ask"] = ask
question_class = OPTIONS[option.get("type", "string")] question_class = OPTIONS[option.get("type", "string")]
# FIXME : maybe other properties should be taken from the question, not just choices ?. # FIXME : maybe other properties should be taken from the question, not just choices ?.
option["choices"] = question_class(option).choices if issubclass(question_class, BaseChoicesOption):
option["default"] = question_class(option).default option["choices"] = question_class(option).choices
option["pattern"] = question_class(option).pattern if issubclass(question_class, BaseInputOption):
option["default"] = question_class(option).default
option["pattern"] = question_class(option).pattern
else: else:
result[key] = {"ask": ask} result[key] = {"ask": ask}
if "current_value" in option: if "current_value" in option: