]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/html/default.js
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 19 Nov 2024 16:13:23 +0000 (17:13 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 19 Nov 2024 16:13:23 +0000 (17:13 +0100)
www/dbq/dbq.php
www/dbq/html/default.js

index 39f89de3abc232a3296966b12c6624d2a3f0d1a2..87c9d422b8e3ceea19fa23836b3a96f85d473abc 100644 (file)
@@ -561,14 +561,8 @@ class DbQ extends nb {
 
        private function table_rows($fct=null) {
                $ropt = [
-                       #'html_menu' => empty($this->_nopage),
-
                        # With limit or criterias or page next
                        'is_html' => $this->is_html,
-
-                       # Without limit or criterias or page next
-# NB 20.06.18                  'is_html' => ($this->is_html and empty($this->_nopage)),
-
                ];
                $this->db->is_html = $ropt['is_html'];
                $this->db->limit = empty($ropt['html_menu']) ? $this->limit() : null;
index f0adb46ed3c4e0002825eb5e4da30a86c13b5a2f..32c8948d4becc94559a341e6306237c74020d853 100644 (file)
@@ -161,24 +161,43 @@ function dbqLoad(DBQ) {
        //
        // h1 to select links
        //
-// NB 03.10.18         if (document.querySelector("body.no-db"))
        document.querySelectorAll("body > h1 a.title-nav-db, body > h1 a.title-nav-table").forEach(function(e) {
 
+               var title = e.innerHTML;
                //console.log(e.className+': '+window._dbq[e.className+'.base']);
                var cname = e.className.replace('title-nav-','')
                var base = window._dbq[cname+'.base'].replace(/\/[^\/]+$/,'');
-// NB 11.06.18                 var url = base + (base == '' ? '/ls' : '') + '.json';
                var url = base + '/ls' + '.json';
                var fields = cname == 'db' ? ['id','id'] : ['name','name'];
 
 // NB 11.06.18                 console.log(url+' | '+cname);
                dbqGet(url,function(o){
                        //console.log(window._dbq['body.no-db param.'+cname]);
+                       //console.log(o);
+
                        var s = o.select(fields[0],fields[1], window._dbq['param.'+cname]);
+
+                       // Add missing is action is not db
+                       var exists = 0;
+                       for (const option of s.options) {
+                               console.log(title + ' <> ' + option.value);
+                               if (option.value != title && option.innerHTML != title) continue;
+                               exists = 1;
+                               break;
+                       }
+                       if (!exists) {
+                               var opt = document.createElement('option');
+                               opt.value = title;
+                               opt.innerHTML = dbqPrettyText(title);
+                       }
+                       s.prepend(opt);
+
+                       //console.log(s);
                        s.onchange = function() {
                                window.location = base + '/' + this.value + ext;
                                //console.log(base + '/' + this.value + ext);
                        };
+
                        var crit = document.getElementById(cname);
                        if (crit) crit.parentNode.style.display = 'none';
                        s.className = e.className;