[TikiWiki-commits] [Git][tikiwiki/tiki][tiki-fix-tracker-edit-jquery] 5 commits: [FIX] maps: Sometimes (according to permissions) links are not rendered and...

"Sammy Ndabo \(@ndabosam084\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6996b9347c52d_3b186a5090434@gitlab-sidekiq-low-urgency-cpu-bound-v2-9d6ddd889-lvccq.mail>

Sammy Ndabo pushed to branch tiki-fix-tracker-edit-jquery at Tiki Wiki CMS Groupware / Tiki


Commits:
bbea470b by Jonny Bradley at 2026-02-18T15:44:04+00:00
[FIX] maps: Sometimes (according to permissions) links are not rendered and...
---
* [FIX] maps: Sometimes (according to permissions) links are not rendered and can cause a jQuery exception, breaking feature loading, so absorb any errors and try to carry on.

See merge request tikiwiki/tiki!9597

- - - - -
2c84c5a4 by Jonny Bradley at 2026-02-18T17:12:23+00:00
[FIX] trackers: Exclude AutoIncrement and GeographicFeature type fields from...
---
* [FIX] trackers: Exclude AutoIncrement and GeographicFeature type fields from mandatory validation as they don't have a value in the default edit form (as seen on Cartograf upgrades)

See merge request tikiwiki/tiki!9600

- - - - -
a386667e by Jonny Bradley at 2026-02-18T19:26:37+00:00
[FIX] maps: Fix GeographicFeature edit data loss by propagating the current...
---
* [FIX] maps: Fix GeographicFeature edit data loss by propagating the current value in the hidden input.
Needed in Cartograf following changes in trackers since 24.x

See merge request tikiwiki/tiki!9604

- - - - -
5db69b7a by Jean-Marc Kadimba at 2026-02-19T05:26:10+00:00
[FIX] Tracker Field Category: revert the change made in the MR 7783 and fix...
---
* fix phpcs

* [FIX] Tracker Field Category: revert the change made in the MR 7783 and fix the issue with the field when using the wiki plugin tracker

See merge request tikiwiki/tiki!9596

- - - - -
7f17bf86 by Sammy Ndabo at 2026-02-19T09:17:30+02:00
[FIX] js buildParams avoid object object query serialization

- - - - -


6 changed files:

- lib/core/Tracker/Field/Category.php
- lib/core/Tracker/Field/GeographicFeature.php
- lib/jquery_tiki/tiki-jquery.js
- lib/trackers/trackerlib.php
- lib/validatorslib.php
- src/js/jquery-tiki/tiki-maps-ol3.js


Changes:

=====================================
lib/core/Tracker/Field/Category.php
=====================================
@@ -196,9 +196,10 @@ class Tracker_Field_Category extends \Tracker\Field\AbstractItemField implements
         $selected = array_intersect($selected, $this->getIds($categories));
 
         if (isset($requestData[$key])) {
-            $selectedCategoryIds = is_array($requestData[$key]) ? $requestData[$key] : [$requestData[$key]];
-            $selected = array_unique(array_merge($selected, $selectedCategoryIds));
-            $value = implode(',', $selected);
+            $value = $requestData[$key];
+            if (is_array($value)) {
+                $value = implode(',', $value);
+            }
         } elseif (isset($requestData["cat_managed_$key"])) {
             $value = '';
         } elseif ($this->getValue()) {
@@ -207,7 +208,11 @@ class Tracker_Field_Category extends \Tracker\Field\AbstractItemField implements
             $value = implode(',', $selected);
         }
 
-        $selected_categories = array_filter(explode(',', $value), fn ($c) => in_array($c, $selected));
+        $selected_categories = explode(',', $value);
+
+        if (! empty($selected)) {
+            $selected_categories = array_filter($selected_categories, fn ($c) => in_array($c, $selected));
+        }
 
         $data = [
             'value' => $value,


=====================================
lib/core/Tracker/Field/GeographicFeature.php
=====================================
@@ -44,8 +44,9 @@ class Tracker_Field_GeographicFeature extends \Tracker\Field\AbstractItemField i
     public function renderInput($context = [])
     {
         $ins_id = $this->getInsertId();
+        $value = $this->getValue();
         //This input is useful for facilitating the execution of rules
-        $hiddenInput = "<input type='hidden' name='$ins_id'>";
+        $hiddenInput = "<input type='hidden' name='$ins_id' value='$value'>";
         $translatedText = tr("Feature cannot be set or modified through this interface.");
         return $hiddenInput . $translatedText;
     }


=====================================
lib/jquery_tiki/tiki-jquery.js
=====================================
@@ -1489,7 +1489,6 @@ $.fn.tiki = function(func) {
         return $.service(controller, action, o);
     };
 
-    $.paramsToProcessLength = 0;
     $.buildParams = function (query, prefix, suffix, _keysNamespace = []) {
         prefix = prefix || '';
         suffix = suffix || '';
@@ -1498,31 +1497,29 @@ $.fn.tiki = function(func) {
             return query;
         }
 
-        const params = [];
-        $.paramsToProcessLength = $.paramsToProcessLength || Object.keys(query).length;
+        function collectParams(input, inputPrefix, inputSuffix, keysNamespace) {
+            const params = [];
 
-        for (const [key, value] of Object.entries(query)) {
-            if ($.isPlainObject(value)) {
-                _keysNamespace.push(key);
-                const keyNamespace = _keysNamespace.at(-2);
-                const prefixInner = (keyNamespace ? `${keyNamespace}~`: '') + key + '[';
+            for (const [key, value] of Object.entries(input)) {
+                if ($.isPlainObject(value)) {
+                    const nextKeysNamespace = [...keysNamespace, key];
+                    const keyNamespace = nextKeysNamespace.at(-2);
+                    const prefixInner = (keyNamespace ? `${keyNamespace}~` : '') + key + '[';
 
-                $.paramsToProcessLength++;
-
-                params.push(...$.buildParams(value, prefixInner, ']', _keysNamespace));
-            } else if (Array.isArray(value)) {
-                value.forEach(function (av) {
-                    params.push({[`${prefix}${key}${suffix}[]`]: av});
-                });
-            } else {
-                params.push({[`${prefix}${key}${suffix}`]: value});
-                $.paramsToProcessLength--;
+                    params.push(...collectParams(value, prefixInner, ']', nextKeysNamespace));
+                } else if (Array.isArray(value)) {
+                    value.forEach(function (arrayValue) {
+                        params.push({ [`${inputPrefix}${key}${inputSuffix}[]`]: arrayValue });
+                    });
+                } else {
+                    params.push({ [`${inputPrefix}${key}${inputSuffix}`]: value });
+                }
             }
-        }
 
-        if ($.paramsToProcessLength) return params;
+            return params;
+        }
 
-        return params.map(function (param) {
+        return collectParams(query, prefix, suffix, _keysNamespace).map(function (param) {
             const k = Object.keys(param)[0];
             return k + '=' + encodeURIComponent(param[k]);
         }).join('&');


=====================================
lib/trackers/trackerlib.php
=====================================
@@ -2962,7 +2962,8 @@ class TrackerLib extends TikiLib
                     $f['errorMsg'] = tra('Confirmation %0 do not match', $f['name']);
                     $erroneous_values[] = $f;
                 }
-                if ($f['type'] != 'q' and isset($f['isMandatory']) && $f['isMandatory'] == 'y') {
+                // exclude AutoIncrement and GeographicFeature type fields as they are read-only in the default edit form
+                if (! in_array($f['type'], ['q', 'GF']) && isset($f['isMandatory']) && $f['isMandatory'] == 'y') {
                     if (($f['type'] == 'e' || in_array($f['fieldId'], $categorized_fields)) && empty($f['value'])) {    // category: value is now categ id's
                         $mandatory_fields[] = $f;
                     } elseif (in_array($f['type'], ['a', 't']) && ($this->is_multilingual($f['fieldId']) == 'y')) {


=====================================
lib/validatorslib.php
=====================================
@@ -103,7 +103,8 @@ class Validators
                             $validationjs .= $field_name . 'Hour: {required_in_group: [' . $date_ins_num . ', "select[name^=\'' . $field_name . '\']"]}, ' .
                                 $field_name . 'Minute: {required_in_group: [' . $date_ins_num . ', "select[name^=\'' . $field_name . '\']"], ';
                         }
-                    } else {
+                    } elseif (! in_array($field_value['type'], ['q', 'GF'])) {
+                        // exclude AutoIncrement and GeographicFeature type fields as they are read-only in the default edit form
                         if ($field_value['isMultilingual'] == 'y') {
                             $required_script = "required: function(e) { ";
                             $condition = "";


=====================================
src/js/jquery-tiki/tiki-maps-ol3.js
=====================================
@@ -1476,14 +1476,16 @@ import { defaults as defaultControls } from "ol/control";
                                         form.autoLayers.push(layerName);
                                     }
 
-                                    var icon;
-                                    $(i.link).each(function () {
-                                        // if the object has an img with it (tracker status for instance) then we need to find the <a>
-                                        if ($(this).is("a")) {
-                                            // and just using $(i.link).find("a") doesn"t work for some reason
-                                            icon = $(this).data("icon-src");
-                                        }
-                                    });
+                                    let icon = "";
+                                    try {
+                                        $(i.link).each(function () {
+                                            // if the object has an img with it (tracker status for instance) then we need to find the <a>
+                                            if ($(this).is("a")) {
+                                                // and just using $(i.link).find("a") doesn't work for some reason
+                                                icon = $(this).data("icon-src");
+                                            }
+                                        });
+                                    } catch (e) {}
 
                                     if (i.geo_location) {
                                         $(container).addMapMarker({



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/compare/4a226e53ea5a414c49fa52f4330265d0bcece9dc...7f17bf8664c83b78dd3fbbbab94e012a4346833c

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/compare/4a226e53ea5a414c49fa52f4330265d0bcece9dc...7f17bf8664c83b78dd3fbbbab94e012a4346833c
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.