From 1d3f9a73be56831867146c29548a0ebfac0b010c Mon Sep 17 00:00:00 2001 From: aynsix Date: Thu, 6 Jan 2022 18:38:47 +0300 Subject: [PATCH] fix choose option --- lib/classes/databox/subdefsStructure.php | 2 ++ templates/web/admin/subdefs.html.twig | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/classes/databox/subdefsStructure.php b/lib/classes/databox/subdefsStructure.php index 06f8b22425..6feb183a5b 100644 --- a/lib/classes/databox/subdefsStructure.php +++ b/lib/classes/databox/subdefsStructure.php @@ -197,6 +197,8 @@ class databox_subdefsStructure implements IteratorAggregate, Countable $subdef = $dom_struct->createElement('subdef'); $subdef->setAttribute('class', $class); $subdef->setAttribute('name', mb_strtolower($name)); + + $preset = ($preset == 'Choose') ? 'Custom' : $preset ; $subdef->setAttribute('presets', $preset); $mediaTypeElement = $dom_struct->createElement('mediatype'); diff --git a/templates/web/admin/subdefs.html.twig b/templates/web/admin/subdefs.html.twig index a1400ba4af..1a707036d8 100644 --- a/templates/web/admin/subdefs.html.twig +++ b/templates/web/admin/subdefs.html.twig @@ -227,6 +227,17 @@ } } + function isOptionChosen(o) { + console.log(o.val()); + if (o.val() != 'Choose') { + return true; + } else { + o.addClass("ui-state-error"); + updateTips("Choose an option"); + return false; + } + } + function checkPresence(mediaType, o) { var el = $('input[name="subdefs[]"][value="' + mediaType + '_' + o.val() + '"]'); @@ -268,6 +279,8 @@ allFields.removeClass("ui-state-error"); bValid = bValid && checkLength(name, "subdef name", 3, 16); + bValid = bValid && isOptionChosen(subviewType); + bValid = bValid && isOptionChosen(mediaType); bValid = bValid && checkSpecialChar(name); bValid = bValid && checkPresence(subviewType.val(), name); bValid = bValid && isNotEmpty(subviewPath);