Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,24 @@
|
||||
// Generated, do not edit. sha256:b5a4abd8ddb07f0a2874418e2afd4b67b87a2f07cb6b67fe7d38692911fdc843
|
||||
export function seedValues(columns, row, newDefaults) {
|
||||
const v = {};
|
||||
for (const c of columns) {
|
||||
if (!c.edit) continue;
|
||||
v[c.key] = c.edit.value ? c.edit.value(row) : (row ? row[c.key] : undefined);
|
||||
}
|
||||
if (!row && newDefaults) Object.assign(v, newDefaults);
|
||||
return v;
|
||||
}
|
||||
|
||||
export function normalizeOptions(list) {
|
||||
return (list || []).map(x => ((typeof x === 'object') ? x : { value: x, label: x }));
|
||||
}
|
||||
|
||||
export async function loadOptions(columns, vals, cache) {
|
||||
cache.clear();
|
||||
for (const col of columns) {
|
||||
if (!col.edit || col.edit.options === undefined) continue;
|
||||
const o = typeof col.edit.options === 'function' ? await col.edit.options(vals) : col.edit.options;
|
||||
cache.set(col.key, normalizeOptions(o));
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
Reference in new issue
Block a user