mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-06 16:27:12 +01:00
sch: capitalized type name
This commit is contained in:
@@ -226,3 +226,13 @@ export function assert(value, message = "") {
|
||||
export function count(values, callback) {
|
||||
return values.filter(callback).length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @returns {string}
|
||||
*/
|
||||
export function capitalize(value) {
|
||||
return value === ""
|
||||
? value
|
||||
: `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { addFromTemplate, addFromTemplateWithSchema } from './template.mjs';
|
||||
import { addEnumerables, groupSettingsOnAddElem, variableListeners } from './settings.mjs';
|
||||
import { reportValidityForInputOrSelect } from './validate.mjs';
|
||||
import { capitalize } from './core.mjs';
|
||||
|
||||
/** @param {function(HTMLElement): void} callback */
|
||||
function withSchedules(callback) {
|
||||
@@ -54,7 +55,10 @@ function listeners() {
|
||||
onValidate(value);
|
||||
},
|
||||
"schTypes": (_, value) => {
|
||||
addEnumerables("schType", value);
|
||||
const tuples =
|
||||
/** @type {import('./settings.mjs').EnumerableTuple[]} */(value);
|
||||
addEnumerables("schType",
|
||||
tuples.map((x) => [x[0], capitalize(x[1])]));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { notifyError } from './errors.mjs';
|
||||
import {
|
||||
count,
|
||||
capitalize,
|
||||
pageReloadIn,
|
||||
showPanelByName,
|
||||
} from './core.mjs';
|
||||
@@ -797,9 +798,7 @@ function prepareSpanValue(span, value) {
|
||||
value = value.toString();
|
||||
|
||||
if (value) {
|
||||
const capitalized =
|
||||
`${value.at(0).toUpperCase()}${value.slice(1)}`;
|
||||
value = span.dataset[`value${capitalized}`] ?? value;
|
||||
value = span.dataset[`value${capitalize(value)}`] ?? value;
|
||||
}
|
||||
|
||||
const out = [
|
||||
|
||||
Reference in New Issue
Block a user