Sidebar layout improvements

This commit is contained in:
yflory 2025-01-15 18:41:43 +01:00
parent b135e815e7
commit 7c816f488c
3 changed files with 42 additions and 1 deletions

View File

@ -236,6 +236,12 @@
margin-bottom: 0;
}
}
.cp-sidebarlayout-description-item {
display: block;
color: @cp_sidebar-hint;
margin-top: @sidebar_base-margin;
margin-bottom: 0;
}
label.noTitle {
display: inline-flex;
.fa {

View File

@ -40,7 +40,6 @@ Decrees.create = (name, commands) => {
var args = line[1];
if (typeof(commands[command]) !== 'function') {
console.log('ici', command, commands);
throw new Error("DECREE_UNSUPPORTED_COMMAND");
}

View File

@ -156,6 +156,35 @@ define([
return box;
};
// opts.values = { key1:label1, key2:label2 }
blocks.radio = (key, state, opts, onChange) => {
if (!opts?.values) {
return void console.error('NO_VALUES');
}
let all = Object.keys(opts.values).map(k => {
let v = opts.values[k];
let r = UI.createRadio(
`cp-${app}-${key}`,
`cp-${app}-${key}-${k}`,
v, state === k, {
input: { value: k },
label: { class: 'noTitle' }
}
);
if (typeof(onChange) === "function"){
$(r).find('input').on('change', function() {
onChange(k);
});
}
return r;
});
let block = h('div.cp-sidebar-flex-block', all);
if (opts && opts.spinner) {
block.spinner = UI.makeSpinner($(block));
}
return block;
};
blocks.table = function (header, entries) {
const table = h('table.cp-sidebar-table');
if (header) {
@ -255,6 +284,13 @@ define([
return box;
};
blocks.hintItem = (hint, item) => {
return blocks.form([
h('span.cp-sidebarlayout-description-item', hint),
item
]);
};
return blocks;
};