@datalabz_/dashboard-kit 6.0.4 → 6.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -6
- package/package.json +1 -1
- package/v4.js +1 -1
- package/v5.js +1 -1
- package/v6.js +199 -28
package/README.md
CHANGED
|
@@ -53,6 +53,20 @@ A major's files are one served bundle; the repo's per-file line budget
|
|
|
53
53
|
(AGENTS.md #2) does not apply to it — it cannot be split without changing the
|
|
54
54
|
URLs already pinned by live dashboards.
|
|
55
55
|
|
|
56
|
+
## Filters from the parent
|
|
57
|
+
|
|
58
|
+
Any key in the `filters` of `CUSTOM_DASHBOARDS_PARAMS` other than `dateFrom`, `dateTo`, `timezone` and
|
|
59
|
+
`hierarchyId` is a header filter of the dashboard. At its first boot the kit writes the value into the
|
|
60
|
+
control with that `id` (for a radio group, the `name` its radios share), reads it back, and locks it. Later
|
|
61
|
+
messages never touch it. `null`, `undefined` and an empty string are errors, and so is a value the control
|
|
62
|
+
does not keep, such as an option that is not there, a date in the wrong format or text in a number field.
|
|
63
|
+
An error, or a key with no control, means the dashboard does not load: it says why and posts
|
|
64
|
+
`{ type: 'DK_FILTERS_REFUSED', message }` to its parent. It never opens unfiltered.
|
|
65
|
+
|
|
66
|
+
A select with no option but the empty one at boot gets its options from a query that runs later, so the
|
|
67
|
+
value cannot be checked against them. It goes in as an option of its own, selected, and stays selected
|
|
68
|
+
while the dashboard fills in the rest. A static select keeps the check.
|
|
69
|
+
|
|
56
70
|
## Asking a dashboard for its filters
|
|
57
71
|
|
|
58
72
|
A parent may post `{ type: 'DK_GET_FILTERS_INFO' }` to a dashboard's frame; the kit answers the parent with
|
|
@@ -62,7 +76,7 @@ what the kit can write into a header control at its first boot, one entry each:
|
|
|
62
76
|
|
|
63
77
|
```js
|
|
64
78
|
{ id: 'playerUsername', label: 'Player username', type: 'text', // type: the input's type, 'select' or 'textarea'
|
|
65
|
-
required: true,
|
|
79
|
+
required: true, defaultValue: '',
|
|
66
80
|
placeholder, min, max, // only when the control sets them
|
|
67
81
|
disabled: true, // only when it is disabled
|
|
68
82
|
multiple: false, optionsTotal: 2, // select only
|
|
@@ -71,14 +85,21 @@ what the kit can write into a header control at its first boot, one entry each:
|
|
|
71
85
|
|
|
72
86
|
The list follows the fill, so it holds only what a filter can actually be given:
|
|
73
87
|
|
|
74
|
-
- Left out: a control with no `id`, a second control with an `id` already listed, and
|
|
75
|
-
|
|
88
|
+
- Left out: a control with no `id`, a second control with an `id` already listed, and file, hidden,
|
|
89
|
+
password and button controls, which the kit refuses to fill.
|
|
90
|
+
- A radio group is one filter, keyed by the `name` its radios share (a radio with no name is left out): it
|
|
91
|
+
is listed once, labelled by its `<fieldset><legend>`, with the radios as `options`; filling it checks
|
|
92
|
+
the radio with that value and locks the group, and a value that is none of them is refused.
|
|
76
93
|
- A select lists only options with a value, since an empty value is refused, and `optionsTotal` counts
|
|
77
|
-
those. A select with none is
|
|
94
|
+
those. A select with none at boot is dynamic: its options come from a query that runs later, so it is
|
|
95
|
+
listed with `dynamicOptions: true` and no options, and takes any value (below).
|
|
78
96
|
- What exists when the dashboard boots is what counts. Once it has booted, the answer is the list taken
|
|
79
97
|
at that moment, so options a section loads later by query, and controls added later, are not in it, as
|
|
80
|
-
they were not there for the fill.
|
|
81
|
-
|
|
98
|
+
they were not there for the fill. Nothing is read again, so `defaultValue` is the value the dashboard starts with.
|
|
99
|
+
- A dynamic select cannot be checked against options that are not there yet. The value goes in as an
|
|
100
|
+
option of its own, selected, and stays selected while the dashboard fills in the rest: whatever
|
|
101
|
+
replaces the options, the filter is still the one asked for, so the dashboard never opens unfiltered.
|
|
102
|
+
A static select keeps the check: a value that is not one of its options is refused.
|
|
82
103
|
|
|
83
104
|
The answer always goes to the dashboard's parent, whoever asked.
|
|
84
105
|
|
package/package.json
CHANGED
package/v4.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
let _activeTabId = '';
|
|
21
21
|
let _sections = []; // { id, label, load, loaded, errors }
|
|
22
22
|
let _title = '';
|
|
23
|
-
let _gitVer = '
|
|
23
|
+
let _gitVer = 'b7798b2'; // replaced at deploy: sed -i "s/b7798b2/$(git rev-parse --short HEAD)/g" v4.js
|
|
24
24
|
let _calls = []; // System Info call log
|
|
25
25
|
let _sectionErrors = {}; // sectionId → error count
|
|
26
26
|
let _generation = 0;
|
package/v5.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
let _activeTabId = '';
|
|
21
21
|
let _sections = []; // { id, label, load, loaded, errors }
|
|
22
22
|
let _title = '';
|
|
23
|
-
let _gitVer = '
|
|
23
|
+
let _gitVer = 'b7798b2'; // replaced at deploy: sed -i "s/b7798b2/$(git rev-parse --short HEAD)/g" v4.js
|
|
24
24
|
let _calls = []; // System Info call log
|
|
25
25
|
let _sectionErrors = {}; // sectionId → error count
|
|
26
26
|
let _generation = 0;
|
package/v6.js
CHANGED
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
let _activeTabId = '';
|
|
21
21
|
let _sections = []; // { id, label, load, loaded, errors }
|
|
22
22
|
let _title = '';
|
|
23
|
-
let _gitVer = '
|
|
23
|
+
let _gitVer = 'b7798b2'; // replaced at deploy: sed -i "s/b7798b2/$(git rev-parse --short HEAD)/g" v6.js
|
|
24
24
|
let _calls = []; // System Info call log
|
|
25
25
|
let _sectionErrors = {}; // sectionId → error count
|
|
26
26
|
let _generation = 0;
|
|
27
27
|
let _ttEl = null;
|
|
28
|
+
let _pendingFilters = {}; // header filters a parent sent before boot, applied at boot
|
|
29
|
+
let _filtersRefused = false;
|
|
28
30
|
|
|
29
31
|
// ── Inject CSS ───────────────────────────────────────────────────────────────
|
|
30
32
|
// The kit carries its own CSS: Claude artifacts may load scripts from jsDelivr but not
|
|
@@ -937,11 +939,12 @@ details.dk-call summary::-webkit-details-marker {
|
|
|
937
939
|
// the list follows that flow and nothing else: a control it cannot fill is not listed (radio,
|
|
938
940
|
// file, hidden, password, buttons; no id; a second control with an id already listed), a select
|
|
939
941
|
// lists only options a value may name, since an empty value is refused, and a select with none
|
|
940
|
-
// is
|
|
941
|
-
//
|
|
942
|
-
//
|
|
942
|
+
// is dynamic: its options come later, so it is listed with dynamicOptions: true and takes any value.
|
|
943
|
+
// What exists when the dashboard boots is what counts: once it has booted, the list is the one
|
|
944
|
+
// taken at that moment, so options a section loads later by query are not in it, as they were not
|
|
945
|
+
// there for the fill. Nothing is read again. It needs no token or
|
|
943
946
|
// period, so a parent can ask as soon as the frame has loaded.
|
|
944
|
-
const UNFILLABLE_TYPES = ['
|
|
947
|
+
const UNFILLABLE_TYPES = ['file', 'hidden', 'password', 'button', 'submit', 'reset', 'image'];
|
|
945
948
|
let _bootFilters = null; // the list as it was when the dashboard booted
|
|
946
949
|
const FILTER_MAX_OPTIONS = 100;
|
|
947
950
|
const FILTER_MAX_TEXT = 500;
|
|
@@ -962,9 +965,36 @@ details.dk-call summary::-webkit-details-marker {
|
|
|
962
965
|
return _clip(el.getAttribute('aria-label') || el.getAttribute('placeholder') || '', 200);
|
|
963
966
|
}
|
|
964
967
|
|
|
968
|
+
// A radio group is one filter, keyed by its name: the radios share the name and each has its own
|
|
969
|
+
// value. Filling it checks the radio with the value; listing it is one entry with the radios as options.
|
|
970
|
+
function _radioGroup(header, name) {
|
|
971
|
+
return Array.from(header.querySelectorAll('input[type="radio"]')).filter(function (r) { return r.name === name; });
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
function _radioInfo(header, name) {
|
|
975
|
+
const group = _radioGroup(header, name);
|
|
976
|
+
const legend = group[0].closest('fieldset') && group[0].closest('fieldset').querySelector('legend');
|
|
977
|
+
const checked = group.find(function (r) { return r.checked; });
|
|
978
|
+
const f = {
|
|
979
|
+
id: name,
|
|
980
|
+
label: _clip((legend && legend.textContent.replace(/\s+/g, ' ').trim()) || name, 200),
|
|
981
|
+
type: 'radio',
|
|
982
|
+
required: group.some(function (r) { return r.required; }),
|
|
983
|
+
optionsTotal: group.length,
|
|
984
|
+
options: group.slice(0, FILTER_MAX_OPTIONS).map(function (r) {
|
|
985
|
+
return { value: _clip(r.value, 200), label: _filterLabel(r) || _clip(r.value, 200) };
|
|
986
|
+
}),
|
|
987
|
+
defaultValue: checked ? checked.value : '',
|
|
988
|
+
};
|
|
989
|
+
if (group.every(function (r) { return r.disabled; })) f.disabled = true;
|
|
990
|
+
return f;
|
|
991
|
+
}
|
|
992
|
+
|
|
965
993
|
function _controlValue(el) {
|
|
966
994
|
if (el.tagName === 'SELECT') {
|
|
967
|
-
return el.multiple
|
|
995
|
+
return el.multiple
|
|
996
|
+
? Array.from(el.selectedOptions).slice(0, FILTER_MAX_OPTIONS).map(function (o) { return _clip(o.value, 200); })
|
|
997
|
+
: _clip(el.value, 200);
|
|
968
998
|
}
|
|
969
999
|
return el.type === 'checkbox' ? el.checked : _clip(el.value, FILTER_MAX_TEXT);
|
|
970
1000
|
}
|
|
@@ -973,13 +1003,19 @@ details.dk-call summary::-webkit-details-marker {
|
|
|
973
1003
|
const header = document.querySelector('[data-dk-header]');
|
|
974
1004
|
const out = [];
|
|
975
1005
|
if (!header) return out;
|
|
976
|
-
const seen =
|
|
1006
|
+
const seen = new Set();
|
|
1007
|
+
const seenRadio = new Set();
|
|
977
1008
|
header.querySelectorAll('input, select, textarea').forEach(function (el) {
|
|
978
|
-
if (
|
|
1009
|
+
if (el.type === 'radio') {
|
|
1010
|
+
if (!el.name || seenRadio.has(el.name)) return;
|
|
1011
|
+
seenRadio.add(el.name);
|
|
1012
|
+
out.push(_radioInfo(header, el.name));
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
if (!el.id || seen.has(el.id) || UNFILLABLE_TYPES.indexOf(el.type) >= 0) return;
|
|
979
1016
|
const isSelect = el.tagName === 'SELECT';
|
|
980
1017
|
const named = isSelect ? Array.from(el.options).filter(function (o) { return o.value !== ''; }) : null;
|
|
981
|
-
|
|
982
|
-
seen[el.id] = true;
|
|
1018
|
+
seen.add(el.id);
|
|
983
1019
|
const f = {
|
|
984
1020
|
id: el.id,
|
|
985
1021
|
label: _filterLabel(el),
|
|
@@ -994,40 +1030,46 @@ details.dk-call summary::-webkit-details-marker {
|
|
|
994
1030
|
}
|
|
995
1031
|
if (isSelect) {
|
|
996
1032
|
f.multiple = el.multiple;
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1033
|
+
if (named.length) {
|
|
1034
|
+
f.optionsTotal = named.length;
|
|
1035
|
+
f.options = named.slice(0, FILTER_MAX_OPTIONS).map(function (o) {
|
|
1036
|
+
return { value: _clip(o.value, 200), label: _clip(o.textContent.trim(), 200) };
|
|
1037
|
+
});
|
|
1038
|
+
} else {
|
|
1039
|
+
// Its options come later and differ from one time to the next, so none are listed: the
|
|
1040
|
+
// select takes any value.
|
|
1041
|
+
f.dynamicOptions = true;
|
|
1042
|
+
}
|
|
1001
1043
|
}
|
|
1002
|
-
f.
|
|
1044
|
+
f.defaultValue = _controlValue(el);
|
|
1003
1045
|
out.push(f);
|
|
1004
1046
|
});
|
|
1005
1047
|
return out;
|
|
1006
1048
|
}
|
|
1007
1049
|
|
|
1008
|
-
// What DK_FILTERS_INFO carries: the
|
|
1050
|
+
// What DK_FILTERS_INFO carries: the dashboard as it starts, not as it is now. Once it has booted
|
|
1051
|
+
// that is the list taken then, before the fill wrote or locked anything, so what a reader typed
|
|
1052
|
+
// since is never in it, and what a host stores with the dashboard does not depend on who asked.
|
|
1009
1053
|
function _filtersInfo() {
|
|
1010
|
-
|
|
1011
|
-
const header = document.querySelector('[data-dk-header]');
|
|
1012
|
-
list.forEach(function (f) {
|
|
1013
|
-
const el = header ? header.querySelector('#' + CSS.escape(f.id)) : null;
|
|
1014
|
-
if (!el) return;
|
|
1015
|
-
f.value = _controlValue(el);
|
|
1016
|
-
if (el.disabled) f.disabled = true; else delete f.disabled;
|
|
1017
|
-
});
|
|
1018
|
-
return list;
|
|
1054
|
+
return (_bootFilters || _dashboardFilters()).map(function (f) { return Object.assign({}, f); });
|
|
1019
1055
|
}
|
|
1020
1056
|
|
|
1021
|
-
|
|
1022
1057
|
function _onMessage(e) {
|
|
1023
1058
|
if (!e.data || typeof e.data !== 'object') return;
|
|
1024
1059
|
if (e.data.type === 'DK_GET_FILTERS_INFO') {
|
|
1025
|
-
|
|
1060
|
+
let reply;
|
|
1061
|
+
try { reply = { type: 'DK_FILTERS_INFO', filters: _filtersInfo() }; }
|
|
1062
|
+
catch (err) {
|
|
1063
|
+
console.error('[DashboardKit] could not describe the filters:', err);
|
|
1064
|
+
reply = { type: 'DK_FILTERS_INFO', filters: [], error: String((err && err.message) || err) };
|
|
1065
|
+
}
|
|
1066
|
+
window.parent.postMessage(reply, '*');
|
|
1026
1067
|
return;
|
|
1027
1068
|
}
|
|
1028
1069
|
if (e.data.type === 'RK_SNAPSHOT') { _snapshot(); return; }
|
|
1029
1070
|
if (e.data.type === 'CHAT_MODE') { document.documentElement.dataset.chatMode = 'true'; return; }
|
|
1030
1071
|
if (e.data.type !== 'CUSTOM_DASHBOARDS_PARAMS') return;
|
|
1072
|
+
if (_filtersRefused) return;
|
|
1031
1073
|
|
|
1032
1074
|
if (typeof e.data.token === 'string') _authToken = e.data.token;
|
|
1033
1075
|
|
|
@@ -1049,10 +1091,19 @@ details.dk-call summary::-webkit-details-marker {
|
|
|
1049
1091
|
if (typeof f.timezone === 'string') _timezone = f.timezone;
|
|
1050
1092
|
if ('hierarchyId' in f)
|
|
1051
1093
|
_hierarchyId = f.hierarchyId == null ? null : Number(f.hierarchyId);
|
|
1094
|
+
// Any other key is a header filter. It is applied once, at boot, never by a later message.
|
|
1095
|
+
if (!_hasBooted) Object.keys(f).forEach(function (k) {
|
|
1096
|
+
if (CONTEXT_KEYS.indexOf(k) < 0) _pendingFilters[k] = f[k];
|
|
1097
|
+
});
|
|
1052
1098
|
}
|
|
1053
1099
|
|
|
1054
1100
|
if (!_hasBooted && _authToken && _dateFromIso && _dateToIso && _timezone) {
|
|
1055
|
-
|
|
1101
|
+
// Before the fill locks anything and before a section runs. A fault in describing the filters
|
|
1102
|
+
// must never keep the dashboard from booting, so it only costs the list.
|
|
1103
|
+
try { _bootFilters = _dashboardFilters(); }
|
|
1104
|
+
catch (err) { console.error('[DashboardKit] could not describe the filters:', err); _bootFilters = null; }
|
|
1105
|
+
const refusal = _fillHeaderFilters(_pendingFilters);
|
|
1106
|
+
if (refusal) { _refuseFilters(refusal); return; }
|
|
1056
1107
|
_hasBooted = true;
|
|
1057
1108
|
const wait = document.getElementById('dk-wait');
|
|
1058
1109
|
if (wait) wait.hidden = true;
|
|
@@ -1064,6 +1115,126 @@ details.dk-call summary::-webkit-details-marker {
|
|
|
1064
1115
|
}
|
|
1065
1116
|
}
|
|
1066
1117
|
|
|
1118
|
+
// ── Filters a parent passes ───────────────────────────────────────────────────
|
|
1119
|
+
// dateFrom, dateTo, timezone and hierarchyId are context the host owns. Any other key in
|
|
1120
|
+
// `filters` is a header filter: written into the control with that id, read back, and locked.
|
|
1121
|
+
// What the control kept was valid; what the browser dropped (an <option> that is not there, a
|
|
1122
|
+
// date in the wrong format, text in a number field) was not. Anything else is a refusal and the
|
|
1123
|
+
// dashboard does not boot — it never opens unfiltered. No input or change event is fired:
|
|
1124
|
+
// a section reads its filters from the controls when it loads.
|
|
1125
|
+
const CONTEXT_KEYS = ['dateFrom', 'dateTo', 'timezone', 'hierarchyId'];
|
|
1126
|
+
|
|
1127
|
+
function _show(v) {
|
|
1128
|
+
let s;
|
|
1129
|
+
try { s = JSON.stringify(v); } catch { s = String(v); }
|
|
1130
|
+
if (s === undefined) s = 'undefined';
|
|
1131
|
+
return s.length > 60 ? s.slice(0, 57) + '…' : s;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
// null when the control took the value, otherwise why not.
|
|
1135
|
+
// A select with no option but the empty one gets its options from a query that runs after the
|
|
1136
|
+
// boot, so nothing can be checked against them. The value goes in as an option of its own, selected,
|
|
1137
|
+
// and stays selected while the dashboard fills in the rest: whatever replaces the options, the
|
|
1138
|
+
// filter is still the one asked for, so the dashboard never opens unfiltered.
|
|
1139
|
+
function _fillLateSelect(el, v) {
|
|
1140
|
+
if (el.multiple ? (!Array.isArray(v) || !v.length) : (typeof v !== 'string' && typeof v !== 'number'))
|
|
1141
|
+
return el.multiple ? 'a multiple select takes a non-empty array' : 'a filter takes a string or a number';
|
|
1142
|
+
const values = (el.multiple ? v : [v]).map(String);
|
|
1143
|
+
if (values.indexOf('') >= 0) return 'there is no value';
|
|
1144
|
+
function apply() {
|
|
1145
|
+
values.forEach(function (s) {
|
|
1146
|
+
if (!Array.from(el.options).some(function (o) { return o.value === s; })) el.appendChild(new Option(s, s));
|
|
1147
|
+
});
|
|
1148
|
+
Array.from(el.options).forEach(function (o) { o.selected = values.indexOf(o.value) >= 0; });
|
|
1149
|
+
}
|
|
1150
|
+
apply();
|
|
1151
|
+
const watch = { childList: true };
|
|
1152
|
+
let repairs = 0;
|
|
1153
|
+
const keep = new MutationObserver(function () {
|
|
1154
|
+
const got = Array.from(el.selectedOptions).map(function (o) { return o.value; });
|
|
1155
|
+
if (got.length === values.length && values.every(function (s) { return got.indexOf(s) >= 0; })) return;
|
|
1156
|
+
// A dashboard that rebuilds the options each time it sees them change would trade blows with
|
|
1157
|
+
// this forever and freeze the page; past this many repairs the kit stops.
|
|
1158
|
+
// Then it says so and shows no data: a filter it could not keep must not leave figures on screen.
|
|
1159
|
+
if (++repairs > 100) {
|
|
1160
|
+
keep.disconnect();
|
|
1161
|
+
_refuseFilters('The filter "' + el.id + '" keeps being reset by the dashboard.');
|
|
1162
|
+
document.querySelectorAll('.dk-panel, nav.dk-tabs').forEach(function (n) { n.hidden = true; });
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
keep.disconnect();
|
|
1166
|
+
apply();
|
|
1167
|
+
keep.takeRecords();
|
|
1168
|
+
keep.observe(el, watch);
|
|
1169
|
+
});
|
|
1170
|
+
keep.observe(el, watch);
|
|
1171
|
+
return null;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
function _writeControl(el, v) {
|
|
1175
|
+
if (v === null || v === undefined || v === '') return 'there is no value';
|
|
1176
|
+
if (el.tagName === 'SELECT' && !Array.from(el.options).some(function (o) { return o.value !== ''; }))
|
|
1177
|
+
return _fillLateSelect(el, v);
|
|
1178
|
+
if (el.tagName === 'SELECT' && el.multiple) {
|
|
1179
|
+
if (!Array.isArray(v) || !v.length) return 'a multiple select takes a non-empty array';
|
|
1180
|
+
const want = v.map(String);
|
|
1181
|
+
Array.from(el.options).forEach(function (o) { o.selected = want.indexOf(o.value) >= 0; });
|
|
1182
|
+
const got = Array.from(el.selectedOptions).map(function (o) { return o.value; });
|
|
1183
|
+
return got.length === want.length ? null : 'not every value is one of its options';
|
|
1184
|
+
}
|
|
1185
|
+
if (el.type === 'checkbox') {
|
|
1186
|
+
if (typeof v !== 'boolean') return 'a checkbox takes true or false';
|
|
1187
|
+
el.checked = v;
|
|
1188
|
+
return null;
|
|
1189
|
+
}
|
|
1190
|
+
if (el.type === 'radio') return 'a radio group is filled by the name its radios share';
|
|
1191
|
+
if (UNFILLABLE_TYPES.indexOf(el.type) >= 0)
|
|
1192
|
+
return 'this kind of control cannot be filled';
|
|
1193
|
+
if (typeof v !== 'string' && typeof v !== 'number') return 'a filter takes a string or a number';
|
|
1194
|
+
const s = String(v);
|
|
1195
|
+
el.value = s;
|
|
1196
|
+
return el.value === s ? null : 'the control does not accept it';
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// null when every key found its control and was accepted, otherwise the refusal in words.
|
|
1200
|
+
function _fillHeaderFilters(values) {
|
|
1201
|
+
const keys = Object.keys(values);
|
|
1202
|
+
if (!keys.length) return null;
|
|
1203
|
+
const header = document.querySelector('[data-dk-header]');
|
|
1204
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1205
|
+
const k = keys[i];
|
|
1206
|
+
const el = header ? header.querySelector('#' + CSS.escape(k)) : null;
|
|
1207
|
+
// A radio group is named, not identified: the key is the name the radios share.
|
|
1208
|
+
const group = header && !(el && el.type !== 'radio') ? _radioGroup(header, k) : [];
|
|
1209
|
+
if (group.length) {
|
|
1210
|
+
const v = values[k];
|
|
1211
|
+
if (v === null || v === undefined || v === '') return 'The filter "' + k + '" cannot take ' + _show(v) + ': there is no value.';
|
|
1212
|
+
const hit = (typeof v === 'string' || typeof v === 'number') ? group.find(function (r) { return r.value === String(v); }) : null;
|
|
1213
|
+
if (!hit) return 'The filter "' + k + '" cannot take ' + _show(v) + ': it is not one of its options.';
|
|
1214
|
+
hit.checked = true;
|
|
1215
|
+
group.forEach(function (r) { r.disabled = true; });
|
|
1216
|
+
continue;
|
|
1217
|
+
}
|
|
1218
|
+
if (!el || !/^(INPUT|SELECT|TEXTAREA)$/.test(el.tagName)) return 'The dashboard has no filter "' + k + '".';
|
|
1219
|
+
const why = _writeControl(el, values[k]);
|
|
1220
|
+
if (why) return 'The filter "' + k + '" cannot take ' + _show(values[k]) + ': ' + why + '.';
|
|
1221
|
+
el.disabled = true;
|
|
1222
|
+
}
|
|
1223
|
+
return null;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
function _refuseFilters(message) {
|
|
1227
|
+
_filtersRefused = true;
|
|
1228
|
+
const wait = document.getElementById('dk-wait');
|
|
1229
|
+
if (wait) {
|
|
1230
|
+
wait.hidden = false;
|
|
1231
|
+
wait.textContent = message;
|
|
1232
|
+
wait.style.color = 'var(--err)';
|
|
1233
|
+
wait.style.fontStyle = 'normal';
|
|
1234
|
+
}
|
|
1235
|
+
window.parent.postMessage({ type: 'DK_FILTERS_REFUSED', message: message }, '*');
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1067
1238
|
// ── Tab state machine ─────────────────────────────────────────────────────────
|
|
1068
1239
|
function _buildTabNav() {
|
|
1069
1240
|
const nav = document.getElementById('dk-tabs');
|