all extension type

This commit is contained in:
Mo Bitar
2017-01-05 19:22:34 -06:00
parent 54ac4ffd15
commit 6306f2a316
16 changed files with 508 additions and 272 deletions

View File

@@ -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) {
}

View File

@@ -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];
}
}

View File

@@ -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 = [];
}

View File

@@ -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 = [];