- add classes inside app/library for creting Tethys xml: Field.ts, Strategy.ts, XmlModel.ts
Some checks failed
CI Pipeline / japa-tests (push) Failing after 51s
Some checks failed
CI Pipeline / japa-tests (push) Failing after 51s
- added model DocumentXmlCache.ts - npm updates - changed all models inside app/Models to use corrected BaseModel.ts - added extra extension class DatasetExtension.ts for app/dataset.ts for caching internal and external fields
This commit is contained in:
parent
4ad281bcd4
commit
ebb24cc75c
24 changed files with 1170 additions and 324 deletions
69
app/Library/Field.ts
Normal file
69
app/Library/Field.ts
Normal file
|
@ -0,0 +1,69 @@
|
|||
export default class Field {
|
||||
// private _multiplicity: number | string = 1;
|
||||
private _hasMultipleValues: boolean = false;
|
||||
private _valueModelClass: string | null = null;
|
||||
private _linkModelClass: string | null = null;
|
||||
// private _owningModelClass: string | null = null;
|
||||
private _value: any;
|
||||
private _name: string;
|
||||
|
||||
constructor(name: string) {
|
||||
this._name = name;
|
||||
this._value = null;
|
||||
}
|
||||
|
||||
getValueModelClass(): any {
|
||||
return this._valueModelClass;
|
||||
}
|
||||
|
||||
setValueModelClass(classname: any): Field {
|
||||
this._valueModelClass = classname;
|
||||
return this;
|
||||
}
|
||||
|
||||
getName(): string {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
// setOwningModelClass(classname: string): Field {
|
||||
// this._owningModelClass = classname;
|
||||
// return this;
|
||||
// }
|
||||
|
||||
public setValue(value: string | string[] | number | boolean): Field {
|
||||
if (value === null || value === this._value) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (Array.isArray(value) && value.length === 0) {
|
||||
value = [];
|
||||
} else if (typeof value === 'boolean') {
|
||||
value = value ? 1 : 0;
|
||||
} else {
|
||||
this._value = value;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public getValue() {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
hasMultipleValues(): boolean {
|
||||
return this._hasMultipleValues;
|
||||
}
|
||||
|
||||
setMultiplicity(max: number | '*'): Field {
|
||||
if (max !== '*') {
|
||||
if (typeof max !== 'number' || max < 1) {
|
||||
throw new Error('Only integer values > 1 or "*" allowed.');
|
||||
}
|
||||
}
|
||||
// this._multiplicity = max;
|
||||
this._hasMultipleValues = (typeof max == 'number' && max > 1) || max === '*';
|
||||
return this;
|
||||
}
|
||||
|
||||
getLinkModelClass(): string | null {
|
||||
return this._linkModelClass;
|
||||
}
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue