all extension type
This commit is contained in:
@@ -4,6 +4,8 @@ class Item {
|
||||
|
||||
this.updateFromJSON(json_obj);
|
||||
|
||||
this.observers = [];
|
||||
|
||||
if(!this.uuid) {
|
||||
this.uuid = Neeto.crypto.generateUUID();
|
||||
}
|
||||
@@ -44,6 +46,30 @@ class Item {
|
||||
}
|
||||
}
|
||||
|
||||
setDirty(dirty) {
|
||||
this.dirty = dirty;
|
||||
|
||||
if(dirty) {
|
||||
this.notifyObserversOfChange();
|
||||
}
|
||||
}
|
||||
|
||||
addObserver(observer, callback) {
|
||||
if(!_.find(this.observers, observer)) {
|
||||
this.observers.push({observer: observer, callback: callback});
|
||||
}
|
||||
}
|
||||
|
||||
removeObserver(observer) {
|
||||
_.remove(this.observers, {observer: observer})
|
||||
}
|
||||
|
||||
notifyObserversOfChange() {
|
||||
for(var observer of this.observers) {
|
||||
observer.callback(this);
|
||||
}
|
||||
}
|
||||
|
||||
mapContentToLocalProperties(contentObj) {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,16 @@ class Action {
|
||||
constructor(json) {
|
||||
_.merge(this, json);
|
||||
|
||||
this.actionVerb = this.type;
|
||||
|
||||
var comps = this.type.split(":");
|
||||
if(comps.length > 0) {
|
||||
this.repeatable = true;
|
||||
this.repeatType = comps[0]; // 'watch' or 'poll'
|
||||
this.repeatVerb = comps[1]; // http verb
|
||||
if(comps.length > 1) {
|
||||
|
||||
this.actionType = comps[0]; // 'watch', 'poll', or 'all'
|
||||
this.repeatable = this.actionType == "watch" || this.actionType == "poll";
|
||||
|
||||
this.actionVerb = comps[1]; // http verb : "get", "post", "show"
|
||||
|
||||
this.repeatFrequency = comps[2];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class Note extends Item {
|
||||
removeAllRelationships() {
|
||||
this.tags.forEach(function(tag){
|
||||
_.pull(tag.notes, this);
|
||||
tag.dirty = true;
|
||||
tag.setDirty(true);
|
||||
}.bind(this))
|
||||
this.tags = [];
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class Tag extends Item {
|
||||
removeAllRelationships() {
|
||||
this.notes.forEach(function(note){
|
||||
_.pull(note.tags, this);
|
||||
note.dirty = true;
|
||||
note.setDirty(true);
|
||||
}.bind(this))
|
||||
|
||||
this.notes = [];
|
||||
|
||||
Reference in New Issue
Block a user