[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Perspectives: Fix object selector initialization in perspective edit...

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69e2679d9ef9c_3b18de1887713@gitlab-sidekiq-low-urgency-cpu-bound-v2-55d79d45dd-fkfd5.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
ef33065e by Espoir Baraka at 2026-04-17T16:55:04+00:00
[FIX] Perspectives: Fix object selector initialization in perspective edit form to display the preferences input fields
---
* [FIX] Fix object selector initialization in perspective edit form to display the wikiHomePage input

See merge request tikiwiki/tiki!9545

- - - - -


2 changed files:

- lib/jquery_tiki/tiki-jquery.js
- templates/tiki-edit_perspective.tpl


Changes:

=====================================
lib/jquery_tiki/tiki-jquery.js
=====================================
@@ -2089,6 +2089,11 @@ $(document).tiki('copy')(
         }
     };
 
+    /**
+     * Transform an input field into an interactive object selector widget.
+     * Reads configuration from data attributes (threshold, filters, format, etc.).
+     * Actions: none (initialize), 'set' (set value), 'setfilter' (update filter).
+     */
     $.fn.object_selector = function (action, value, title) {
         var args = arguments;
 


=====================================
templates/tiki-edit_perspective.tpl
=====================================
@@ -137,21 +137,41 @@
                 </div>
             </form>
             {jq}
+                var initObjectSelectors = function($container) {
+                    $container.find('.object-selector input[data-threshold]').each(function() {
+                        var $input = $(this);
+                        // Needed when items are dragged from resultzone (already initialized) to preferences
+                        if (!$input.hasClass('primary')) {
+                            $input.object_selector();
+                        }
+                    });
+                };
+
+                // Case 1: Initialize for existing preferences on page load
+                initObjectSelectors($('#preferences'));
+
                 Sortable.create($('#preferences .card-body')[0], {
                     group: 'preferences',
                     animation: 150,
-                    sort: false
+                    sort: false,
+                    onAdd: function(evt) {
+                        // Case 2: Initialize for items added via drag-and-drop
+                        initObjectSelectors($(evt.item));
+                    }
                 });
                 $('#searchform').on("submit", function(e) {
                     e.preventDefault();
                     if (typeof ajaxLoadingShow == 'function') { ajaxLoadingShow('resultzone'); }
+                    var $form = $(this);
                     $('#resultzone').load( this.action, $(this).serialize(), function() {
                          Sortable.create($('#resultzone')[0], {
                             group: 'preferences',
                             animation: 150,
                             sort: false
                          });
-                        $(this).tiki_popover();
+                        $form.tiki_popover();
+                        // Case 3: Initialize for search results loaded via AJAX (load callback fires after DOM insertion)
+                        initObjectSelectors($('#resultzone'));
                         if (typeof ajaxLoadingHide == 'function') { ajaxLoadingHide(); }
                     } );
                 } );



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/ef33065e6cbe91090d8e67e9dcbc02ff6a5bcdda

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/ef33065e6cbe91090d8e67e9dcbc02ff6a5bcdda
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
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.