email-dns-tools/assets/scripts/fields/Field.js
2026-01-14 13:55:59 +01:00

65 lines
856 B
JavaScript

export class Field {
isRequired = false;
defaultValue = null;
displayName = null;
description = null;
categoryName = null;
requiredIndex = null;
afterFieldName = 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;
}
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;
}
atIndex(i) {
this.requiredIndex = i;
return this;
}
after(field) {
this.afterFieldName = field;
return this;
}
}