From be5205a0cd70afe53b40d8078bfb08d38e5250c0 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 19 Nov 2024 17:13:23 +0100 Subject: [PATCH] www/dbq/html/default.js --- www/dbq/dbq.php | 6 ------ www/dbq/html/default.js | 23 +++++++++++++++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 39f89de3..87c9d422 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -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; diff --git a/www/dbq/html/default.js b/www/dbq/html/default.js index f0adb46e..32c8948d 100644 --- a/www/dbq/html/default.js +++ b/www/dbq/html/default.js @@ -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; -- 2.47.3