support for cssClass label on note

This commit is contained in:
azivner
2018-08-13 10:59:31 +02:00
parent 12d82e3b33
commit cd9eef32b0
6 changed files with 73 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
"use strict";
const Entity = require('./entity');
const Attribute = require('./attribute');
const protectedSessionService = require('../services/protected_session');
const repository = require('../services/repository');
const dateUtils = require('../services/date_utils');
@@ -131,6 +132,37 @@ class Note extends Entity {
return attributes.find(attr => attr.type === 'label' && attr.name === name);
}
async getLabelValue(name) {
const label = await this.getLabel(name);
return label ? label.value : null;
}
async setLabel(name, value = "") {
let label = await this.getLabel(name);
if (!label) {
label = new Attribute({
noteId: this.noteId,
type: 'label',
name: name
});
}
label.value = value;
await label.save();
}
async removeLabel(name) {
const label = await this.getLabel(name);
if (label) {
label.isDeleted = true;
await label.save();
}
}
async getRevisions() {
return await repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]);
}