Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected build() {
super.build();
this.$input = this.$node.append('input').attr('type', (this.desc.options || {}).type || 'text');
this.setAttributes(this.$input, this.desc.attributes);
const defaultValue = (this.desc.options || {}).type === 'number' ? '0' : '';
if (this.desc.useSession) {
this.$input.property('value', session.retrieve(this.id + '_value', defaultValue));
} else {
this.$input.property('value', defaultValue);
}
this.handleShowIf();
// propagate change action with the data of the selected option
this.$input.on('change.propagate', () => {
if (this.desc.useSession) {
session.store(this.id+'_value', this.value);
}
this.fire('change', this.value, this.$input);
});
}
protected build() {
super.build();
const $label = this.$node.select('label');
if ($label.empty()) {
this.$input = this.$node.append('input').attr('type', 'checkbox');
} else {
this.$input = $label.html(`<input type="checkbox">${$label.text()}`).select('input');
}
this.setAttributes(this.$input, this.desc.attributes);
this.$input.classed('form-control', false); //remove falsy class again
const options = this.desc.options;
if (this.desc.useSession) {
this.$input.property('checked', session.retrieve(this.id + '_value', options.unchecked) === options.checked);
} else {
this.$input.property('checked', false);
}
this.handleShowIf();
// propagate change action with the data of the selected option
this.$input.on('change.propagate', () => {
if (this.desc.useSession) {
session.store(this.id+'_value', this.value);
}
this.fire('change', this.value, this.$input);
});
}
sets = sets.filter((d) => d.creator === retrieve('username'));
return sets;
export function saveNamedSet(name: string, idType: IDType|string, ids: RangeLike, subType: {key:string, value:string}, description = '') {
const data = {
name,
type: ENamedSetType.NAMEDSET,
creator: retrieve('username', 'Anonymous'),
idType: resolve(idType).id,
ids: parse(ids).toString(),
subTypeKey: subType.key,
subTypeValue: subType.value,
description
};
return sendAPI('/targid/storage/namedsets/', data, 'POST');
}