diff --git a/changelog/62_UNRELEASED_xxxx-xx-xx.md b/changelog/62_UNRELEASED_xxxx-xx-xx.md index 3fba5663..b3e3ccea 100644 --- a/changelog/62_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/62_UNRELEASED_xxxx-xx-xx.md @@ -76,7 +76,8 @@ - => The on chore execution tracking entered information is then visible on the corresponding chore journal entry - Fixed that tracking chores with "Done by" a different user was not possible -### Userfield fixes +### Userfield improvements/fixes +- Userfields can now be configured as mandatory (new Userfield option, defaults to disabled) - Fixed that numeric Userfields were initialised with `1.0` - Fixed that shortcuts (up/down key) and the format did not work correctly when using multiple date/time Userfields per object - Fixed that Userfields were not saved when adding a product or a recipe (only on editing) diff --git a/localization/strings.pot b/localization/strings.pot index ad9acd4b..468e5db2 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2157,3 +2157,12 @@ msgstr "" msgid "Mark this item as undone" msgstr "" + +msgid "Mandatory" +msgstr "" + +msgid "Mandatory Userfield" +msgstr "" + +msgid "When enabled, then this field must be filled on the destination form" +msgstr "" diff --git a/migrations/0145.sql b/migrations/0145.sql new file mode 100644 index 00000000..18b1beb9 --- /dev/null +++ b/migrations/0145.sql @@ -0,0 +1,2 @@ +ALTER TABLE userfields +ADD input_required TINYINT NOT NULL DEFAULT 0 CHECK(input_required IN (0, 1)); diff --git a/public/viewjs/components/userfieldsform.js b/public/viewjs/components/userfieldsform.js index eca3f2d0..968dd638 100644 --- a/public/viewjs/components/userfieldsform.js +++ b/public/viewjs/components/userfieldsform.js @@ -158,6 +158,11 @@ Grocy.Components.UserfieldsForm.Load = function() input.val(value); } }); + + $("form").each(function() + { + Grocy.FrontendHelpers.ValidateForm(this.id); + }); }, function(xhr) { @@ -179,3 +184,11 @@ $(".userfield-link").keyup(function(e) formRow.find(".userfield-input").val(JSON.stringify(value)); }); + +$(".userfield-input").change(function(e) +{ + $("form").each(function() + { + Grocy.FrontendHelpers.ValidateForm(this.id); + }); +}); diff --git a/views/components/userfieldsform.blade.php b/views/components/userfieldsform.blade.php index becb74ce..8bfc6543 100644 --- a/views/components/userfieldsform.blade.php +++ b/views/components/userfieldsform.blade.php @@ -19,14 +19,18 @@ + data-userfield-name="{{ $userfield->name }}" + @if($userfield->input_required == 1) required @endif> +