sync providers wip

This commit is contained in:
Mo Bitar
2017-01-24 20:55:55 -06:00
parent c656024959
commit 13e6ac59a9
6 changed files with 258 additions and 78 deletions

View File

@@ -56,9 +56,13 @@ class Extension extends Item {
this.content_type = "Extension";
}
syncProviderAction() {
return _.find(this.actions, {sync_provider: true})
}
actionsInGlobalContext() {
return this.actions.filter(function(action){
return action.context == "global";
return action.context == "global" || action.sync_provider == true;
})
}

View File

@@ -0,0 +1,36 @@
class SyncProvider {
constructor(obj) {
_.merge(this, obj);
}
addPendingItems(items) {
if(!this.pendingItems) {
this.pendingItems = [];
}
this.pendingItems = this.pendingItems.concat(items);
}
removePendingItems(items) {
this.pendingItems = _.difference(this.pendingItems, items);
}
get status() {
if(!this.enabled) {
return null;
}
if(this.primary) return "primary";
else return "secondary";
}
asJSON() {
return {
enabled: this.enabled,
url: this.url,
encrypted: this.encrypted,
ek: this.ek
}
}
}