usercss config: delete only missing vars on save
This commit is contained in:
parent
0b57fa4810
commit
f3cf6e1856
|
@ -53,15 +53,16 @@ function configDialog(style) {
|
||||||
const bgva = bgVars[va.name];
|
const bgva = bgVars[va.name];
|
||||||
let error;
|
let error;
|
||||||
if (!bgva) {
|
if (!bgva) {
|
||||||
error = `${va.name}: deleted`;
|
error = 'deleted';
|
||||||
|
delete styleVars[va.name];
|
||||||
} else
|
} else
|
||||||
if (bgva.type !== va.type) {
|
if (bgva.type !== va.type) {
|
||||||
error = `${va.name}: type '${va.type}' != '${bgva.type}'`;
|
error = ['type ', '*' + va.type, ' != ', '*' + bgva.type];
|
||||||
} else
|
} else
|
||||||
if ((va.type === 'select' || va.type === 'dropdown') &&
|
if ((va.type === 'select' || va.type === 'dropdown') &&
|
||||||
va.value !== null && va.value !== undefined &&
|
va.value !== null && va.value !== undefined &&
|
||||||
bgva.options.every(o => o.name !== va.value)) {
|
bgva.options.every(o => o.name !== va.value)) {
|
||||||
error = `${va.name}: '${va.value}' not in the updated '${va.type}' list`;
|
error = `'${va.value}' not in the updated '${va.type}' list`;
|
||||||
} else if (!va.dirty) {
|
} else if (!va.dirty) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -69,16 +70,19 @@ function configDialog(style) {
|
||||||
numValid++;
|
numValid++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
invalid.push(error);
|
invalid.push(['*' + va.name, ': ', ...error].map(e =>
|
||||||
delete styleVars[va.name];
|
e[0] === '*' && $element({tag: 'b', textContent: e.slice(1)}) || e));
|
||||||
|
if (bgva) {
|
||||||
|
styleVars[va.name].value = deepCopy(bgva);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (invalid.length) {
|
if (invalid.length) {
|
||||||
messageBox.alert([
|
messageBox.alert([
|
||||||
$element({textContent: t('usercssConfigIncomplete'), style: 'max-width: 34em'}),
|
$element({textContent: t('usercssConfigIncomplete'), style: 'max-width: 34em'}),
|
||||||
$element({
|
$element({
|
||||||
tag: 'ol',
|
tag: 'ol',
|
||||||
style: 'text-align: left; font-weight: bold;',
|
style: 'text-align: left',
|
||||||
appendChild: invalid.map(s => $element({tag: 'li', textContent: s})),
|
appendChild: invalid.map(msg => $element({tag: 'li', appendChild: msg})),
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user