[fix] No validate function in config panel

This commit is contained in:
ljf 2021-06-01 01:29:26 +02:00
parent 27ba82bd30
commit 5fec35ccea

View file

@ -123,7 +123,7 @@ EOL
local _dot_setting=$(echo "$param_source" | cut -d= -f1) local _dot_setting=$(echo "$param_source" | cut -d= -f1)
local _snake_setting="YNH_CONFIG_$(ynh_lowerdot_to_uppersnake $dot_setting)" local _snake_setting="YNH_CONFIG_$(ynh_lowerdot_to_uppersnake $dot_setting)"
local short_setting=$(echo "$_dot_setting" | cut -d. -f3) local short_setting=$(echo "$_dot_setting" | cut -d. -f3)
local _getter="get__${short_setting}" local getter="get__${short_setting}"
local source="$(echo $param_source | cut -d= -f2)" local source="$(echo $param_source | cut -d= -f2)"
# Get value from getter if exists # Get value from getter if exists
@ -216,10 +216,13 @@ _ynh_panel_validate() {
for short_setting in "${!dot_settings[@]}" for short_setting in "${!dot_settings[@]}"
do do
local result="$(validate__$short_setting)" local result=""
local key="YNH_ERROR_$(ynh_lowerdot_to_uppersnake $dot_settings[$short_setting])" if type validate__$short_setting | grep -q '^function$' 2>/dev/null; then
result="$(validate__$short_setting)"
fi
if [ -n "$result" ] if [ -n "$result" ]
then then
local key="YNH_ERROR_$(ynh_lowerdot_to_uppersnake $dot_settings[$short_setting])"
ynh_return "$key=$result" ynh_return "$key=$result"
is_error=true is_error=true
fi fi
@ -237,14 +240,6 @@ ynh_panel_get() {
_ynh_panel_get _ynh_panel_get
} }
ynh_panel_init() {
declare -A old=()
declare -A changed=()
declare -A file_hash=()
ynh_panel_get
}
ynh_panel_show() { ynh_panel_show() {
_ynh_panel_show _ynh_panel_show
} }
@ -257,3 +252,15 @@ ynh_panel_apply() {
_ynh_panel_apply _ynh_panel_apply
} }
ynh_panel_run() {
declare -A old=()
declare -A changed=()
declare -A file_hash=()
ynh_panel_get
case $1 in
show) ynh_panel_show;;
apply) ynh_panel_validate && ynh_panel_apply;;
esac
}