adjustments
This commit is contained in:
@@ -2,6 +2,7 @@ class Action {
|
||||
constructor(json) {
|
||||
_.merge(this, json);
|
||||
|
||||
this.running = false; // in case running=true was synced with server since model is uploaded nondiscriminatory
|
||||
this.actionVerb = this.type;
|
||||
|
||||
var comps = this.type.split(":");
|
||||
@@ -9,12 +10,16 @@ class Action {
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
structureContentTypes() {
|
||||
return this.structures.map(function(structure){
|
||||
return structure.type;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
class Extension extends Item {
|
||||
|
||||
@@ -234,8 +234,6 @@ angular.module('app.frontend')
|
||||
return this.createRequestParamsForItem(item, options.additionalFields);
|
||||
}.bind(this));
|
||||
|
||||
// console.log("syncing items", request.items);
|
||||
|
||||
if(this.syncToken) {
|
||||
request.sync_token = this.syncToken;
|
||||
}
|
||||
@@ -273,6 +271,10 @@ angular.module('app.frontend')
|
||||
return this.paramsForItem(item, !item.isPublic(), additionalFields, false);
|
||||
}
|
||||
|
||||
this.paramsForExternalUse = function(item) {
|
||||
return _.omit(this.paramsForItem(item, false, ["created_at", "updated_at"], true), ["deleted"]);
|
||||
}
|
||||
|
||||
this.paramsForItem = function(item, encrypted, additionalFields, forExportFile) {
|
||||
var itemCopy = _.cloneDeep(item);
|
||||
|
||||
@@ -288,7 +290,7 @@ angular.module('app.frontend')
|
||||
params.auth_hash = itemCopy.auth_hash;
|
||||
}
|
||||
else {
|
||||
params.content = forExportFile ? itemCopy.content : "000" + Neeto.crypto.base64(JSON.stringify(itemCopy.createContentJSONFromProperties()));
|
||||
params.content = forExportFile ? itemCopy.createContentJSONFromProperties() : "000" + Neeto.crypto.base64(JSON.stringify(itemCopy.createContentJSONFromProperties()));
|
||||
if(!forExportFile) {
|
||||
params.enc_item_key = null;
|
||||
params.auth_hash = null;
|
||||
@@ -378,8 +380,8 @@ angular.module('app.frontend')
|
||||
return textFile;
|
||||
}.bind(this);
|
||||
|
||||
var items = _.map(modelManager.items, function(item){
|
||||
return _.omit(this.paramsForItem(item, false, ["created_at", "updated_at"], true), ["deleted"]);
|
||||
var items = _.map(modelManager.allItemsMatchingTypes(["Tag", "Note"]), function(item){
|
||||
return this.paramsForExternalUse(item);
|
||||
}.bind(this));
|
||||
|
||||
var data = {
|
||||
|
||||
@@ -90,7 +90,7 @@ class ExtensionManager {
|
||||
}
|
||||
|
||||
else if(action.actionType == "all") {
|
||||
var allItems = this.modelManager.allItems();
|
||||
var allItems = this.modelManager.allItemsMatchingTypes(action.structureContentTypes());
|
||||
this.performPost(action, allItems, function(items){
|
||||
callback(items);
|
||||
});
|
||||
@@ -143,7 +143,7 @@ class ExtensionManager {
|
||||
}
|
||||
|
||||
outgoingParamsForItem(item) {
|
||||
return this.apiController.paramsForItem(item, false, null, true);
|
||||
return this.apiController.paramsForExternalUse(item);
|
||||
}
|
||||
|
||||
triggerWatchAction(action, changedItems) {
|
||||
|
||||
@@ -9,8 +9,8 @@ class ModelManager {
|
||||
this.extensions = [];
|
||||
}
|
||||
|
||||
allItems() {
|
||||
return this.items.filter(function(item){return !item.dummy})
|
||||
allItemsMatchingTypes(contentTypes) {
|
||||
return this.items.filter(function(item){return contentTypes.includes(item.content_type) && !item.dummy})
|
||||
}
|
||||
|
||||
findItem(itemId) {
|
||||
|
||||
Reference in New Issue
Block a user