[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [BP][FIX][UI] Tracker Fields: standardize admin modals and update requireConfirm to use Tiki UI
"MAGENE Sem Joel \(@Jomagene\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <69a12652110d2_3b1877d48370@gitlab-sidekiq-low-urgency-cpu-bound-v2-bbcfb95b-29wq4.mail> |
MAGENE Sem Joel pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki
Commits:
5b748014 by MAGENE Sem Joel at 2026-02-27T04:59:00+00:00
[BP][FIX][UI] Tracker Fields: standardize admin modals and update requireConfirm to use Tiki UI
---
* [BP][FIX][UI] Tracker Fields: standardize admin modals and update requireConfirm to use Tiki UI
---
* [FIX][UI] Tracker Fields: standardize admin modals and update requireConfirm to use Tiki UI
---
* [FIX][UI] Tracker Fields: standardize admin modals and update requireConfirm to use Tiki UI
See merge request tikiwiki/tiki!9582
(cherry picked from commit 37c0f809f3996460f675eb5f36e826a13f9923e5)
See merge request tikiwiki/tiki!9585
(cherry picked from commit e19b9679f0e7081ad0f2a5a624151519a4b38b0d)
See merge request tikiwiki/tiki!9653
- - - - -
2 changed files:
- lib/jquery_tiki/tiki-trackers.js
- templates/tiki-admin_tracker_fields.tpl
Changes:
=====================================
lib/jquery_tiki/tiki-trackers.js
=====================================
@@ -184,12 +184,25 @@
$row.append($('<td class="action"/>').append($('<a href="#" class="text-danger"><span class="icon fas fa-times"/></a>')
.attr('href', $.service('tracker', 'remove_fields', {trackerId: trackerId, 'fields~0': field.fieldId}))
- .requireConfirm({
- message: tr('Removing the field will result in data loss. Are you sure?'),
- success: function (data) {
- $(this).closest('tr').remove();
- $.fn.resetFieldsCache();
- }
+ .on('click', function(e) {
+ e.preventDefault();
+ var $link = $(this);
+ // Use confirmationDialog to bypass the native browser confirm
+ $link.confirmationDialog({
+ title: tr('Confirm Delete'),
+ message: tr('Removing the field will result in data loss. Are you sure?'),
+ success: function() {
+ $.ajax($link.attr('href'), {
+ type: 'POST',
+ dataType: 'json',
+ data: { 'confirm': 1 },
+ success: function () {
+ $link.closest('tr').remove();
+ $.fn.resetFieldsCache();
+ }
+ });
+ }
+ });
})
));
} else if (data.typesDisabled) {
=====================================
templates/tiki-admin_tracker_fields.tpl
=====================================
@@ -55,15 +55,35 @@
{jq}
var trackerId = {{$trackerId|escape}};
$('.save-fields').on("submit", function () {
- var form = this, confirmed = false
-
- if ($(form.action).val() === 'remove_fields') {
- confirmed = confirm(tr('Do you really want to delete the selected fields?'));
- $(form.confirm).val(confirmed ? '1' : '0');
+ var form = this;
+ var action = $(form.action).val();
- if (! confirmed) {
- return false;
+ // Internal helper to perform the Ajax submission logic
+ var executeAjax = function () {
+ $.ajax($(form).attr('action'), {
+ type: 'POST',
+ data: $(form).serialize(),
+ dataType: 'json',
+ success: function () {
+ $container.tracker_load_fields(trackerId);
+ if (action === 'remove_fields') {
+ $.fn.resetFieldsCache();
+ }
+ }
+ });
+ };
+ if (action === 'remove_fields') {
+ if (validateForm()) {
+ $(form).confirmationDialog({
+ title: tr('Delete Fields'),
+ message: tr('Do you really want to delete the selected fields?'),
+ success: function() {
+ $(form.confirm).val('1');
+ executeAjax();
+ }
+ });
}
+ return false;
}
if ($(form.action).val() === 'export_fields') {
@@ -76,17 +96,7 @@
return false;
} else {
- $.ajax($(form).attr('action'), {
- type: 'POST',
- data: $(form).serialize(),
- dataType: 'json',
- success: function () {
- $container.tracker_load_fields(trackerId);
- if ($(form.action).val() === 'remove_fields') {
- $.fn.resetFieldsCache();
- }
- }
- });
+ executeAjax();
}
return false;
});
@@ -188,5 +198,27 @@
}
}
};
+ function validateForm() {
+ // Get all checkbox elements with the name "fields[]"
+ const checkboxes = document.querySelectorAll('input[name="fields[]"]');
+
+ // Check if at least one checkbox is checked
+ let isChecked = false;
+ checkboxes.forEach(checkbox => {
+ if (checkbox.checked) {
+ isChecked = true;
+ return;
+ }
+ });
+
+ // If no checkbox is checked, show an alert and prevent submission
+ if (!isChecked) {
+ feedback(tr("Please select at least one element."), "error");
+ return false;
+ }
+
+ // If at least one checkbox is checked, allow form submission
+ return true;
+ }
{/jq}
{/block}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/5b748014330e3f46ad225e8c5dfcc7d07aa4a6a3
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/5b748014330e3f46ad225e8c5dfcc7d07aa4a6a3
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs