fixes in attribute persistence + WIP on display of promoted attrs

This commit is contained in:
azivner
2018-08-06 08:59:26 +02:00
parent 194ce4f10f
commit 2aab3ad281
16 changed files with 138 additions and 37 deletions

View File

@@ -10,13 +10,24 @@ class Attribute extends Entity {
static get primaryKeyName() { return "attributeId"; }
static get hashedProperties() { return ["attributeId", "noteId", "type", "name", "value", "isInheritable", "dateModified", "dateCreated"]; }
constructor(row) {
super(row);
try {
this.value = JSON.parse(this.value);
}
catch(e) {}
}
async getNote() {
return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);
}
async beforeSaving() {
super.beforeSaving();
isDefinition() {
return this.type === 'label' || this.type === 'relation';
}
async beforeSaving() {
if (!this.value) {
// null value isn't allowed
this.value = "";
@@ -39,6 +50,8 @@ class Attribute extends Entity {
}
this.dateModified = dateUtils.nowDate();
super.beforeSaving();
}
}