email-dns-tools/assets/scripts/fields/Field.js
2026-01-14 15:46:37 +01:00

67 lines
858 B
JavaScript

export class Field {
separator = null;
isRequired = false;
allowMultiple = false;
defaultValue = null;
displayName = null;
description = null;
categoryName = null;
position = null;
constructor(key) {
this.key = key;
this.id = "field-" + key;
}
// Virtual methods
validate() {
return true;
}
getInputHtml() {
return null;
}
getInputValue() {
return null;
}
// Builder methods
required() {
this.isRequired = true;
return this;
}
multiple() {
this.allowMultiple = true;
return this;
}
default(value) {
this.defaultValue = value;
return this;
}
label(label) {
this.displayName = label;
return this;
}
desc(description) {
this.description = description;
return this;
}
category(category) {
this.categoryName = category;
return this;
}
pos(i) {
this.position = i;
return this;
}
}