N°2039 - Improve title / message for set input with a minimum item constraint

This commit is contained in:
Molkobain
2024-05-02 13:46:51 +02:00
parent 848c4bb979
commit 188a3fe3cc
4 changed files with 11 additions and 4 deletions

View File

@@ -19,6 +19,7 @@
// Input // Input
Dict::Add('EN US', 'English', 'English', array( Dict::Add('EN US', 'English', 'English', array(
'UI:Component:Input:ChangeNotAllowed' => 'This change is not allowed',
'UI:Component:Input:Password:DoesNotMatch' => 'Passwords do not match', 'UI:Component:Input:Password:DoesNotMatch' => 'Passwords do not match',
'UI:Component:Input:Set:MinimumItems' => 'Minimum %1$s items required', 'UI:Component:Input:Set:MinimumItems' => 'Minimum %1$s item(s) required',
)); ));

View File

@@ -18,5 +18,7 @@
*/ */
// Input // Input
Dict::Add('FR FR', 'French', 'Français', array( Dict::Add('FR FR', 'French', 'Français', array(
'UI:Component:Input:Password:DoesNotMatch' => 'Passwords do not match~~', 'UI:Component:Input:ChangeNotAllowed' => 'Cette modification n\'est pas autorisée',
'UI:Component:Input:Password:DoesNotMatch' => 'Les mots de passe ne correspondent pas',
'UI:Component:Input:Set:MinimumItems' => 'Minimum %1$s élément(s) requis',
)); ));

View File

@@ -6,6 +6,7 @@ Selectize.define("combodo_min_items", function (aOptions) {
// Plugin options // Plugin options
aOptions = $.extend({ aOptions = $.extend({
minItems: 0, minItems: 0,
errorTitle: 'This change is not allowed',
errorMessage: 'Minimum ' + aOptions.minItems + ' item(s) required.' errorMessage: 'Minimum ' + aOptions.minItems + ' item(s) required.'
}, },
aOptions aOptions
@@ -16,7 +17,9 @@ Selectize.define("combodo_min_items", function (aOptions) {
let oOriginal = oSelf.removeItem; let oOriginal = oSelf.removeItem;
return function () { return function () {
if(oSelf.items.length <= aOptions.minItems) { if(oSelf.items.length <= aOptions.minItems) {
CombodoModal.OpenErrorModal(aOptions.errorMessage, []); CombodoModal.OpenErrorModal(aOptions.errorMessage, {
title: aOptions.errorTitle
});
return; return;
} }
return oOriginal.apply(this, arguments); return oOriginal.apply(this, arguments);

View File

@@ -54,7 +54,8 @@ let oWidget{{ oUIBlock.GetId() }} = $('#{{ oUIBlock.GetId() }}').selectize({
{% if oUIBlock.GetMinItems() is not empty %} {% if oUIBlock.GetMinItems() is not empty %}
'combodo_min_items' : { 'combodo_min_items' : {
minItems: {{ oUIBlock.GetMinItems() }}, minItems: {{ oUIBlock.GetMinItems() }},
errorMessage: '{{ 'UI:Component:Input:Set:MinimumItems'|dict_format(oUIBlock.GetMinItems()) }}' errorTitle: '{{ 'UI:Component:Input:ChangeNotAllowed'|dict_s()|escape('js') }}',
errorMessage: '{{ 'UI:Component:Input:Set:MinimumItems'|dict_format(oUIBlock.GetMinItems())|escape('js') }}'
}, },
{% endif %} {% endif %}
}, },