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

"Baraka Kinywa \(@bkinywa24\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69e3f8d59af64_3b18e1108046b@gitlab-sidekiq-low-urgency-cpu-bound-v2-5cf6b587c7-d9lzg.mail>

Baraka Kinywa pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki


Commits:
f4e644c2 by Espoir Baraka at 2026-04-19T00:26:54+03:00
[FIX] Perspectives: Fix object selector initialization in perspective edit...
---
* [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

(cherry picked from commit ef33065e6cbe91090d8e67e9dcbc02ff6a5bcdda)

See merge request tikiwiki/tiki!10041

- - - - -


2 changed files:

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


Changes:

=====================================
lib/jquery_tiki/tiki-jquery.js
=====================================
@@ -1955,6 +1955,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/f4e644c2882935f5a480548b766ca54c9df857f4

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