import fix
This commit is contained in:
@@ -92,7 +92,6 @@ angular.module('app.frontend')
|
||||
Neeto.crypto.computeEncryptionKeysForUser(_.merge({email: email, password: password}, authParams), function(keys){
|
||||
this.setMk(keys.mk);
|
||||
var request = Restangular.one("auth/sign_in");
|
||||
console.log("sending pw", keys.pw);
|
||||
var params = {password: keys.pw, email: email};
|
||||
_.merge(request, params);
|
||||
request.post().then(function(response){
|
||||
@@ -100,7 +99,6 @@ angular.module('app.frontend')
|
||||
callback(response);
|
||||
})
|
||||
.catch(function(response){
|
||||
console.log(response.data);
|
||||
callback(response.data);
|
||||
})
|
||||
}.bind(this));
|
||||
@@ -119,7 +117,6 @@ angular.module('app.frontend')
|
||||
callback(response);
|
||||
})
|
||||
.catch(function(response){
|
||||
console.log(response.data);
|
||||
callback(response.data);
|
||||
})
|
||||
}.bind(this));
|
||||
@@ -219,7 +216,7 @@ angular.module('app.frontend')
|
||||
Items
|
||||
*/
|
||||
|
||||
this.sync = function(callback) {
|
||||
this.syncWithOptions = function(callback, options = {}) {
|
||||
if(!this.user.uuid) {
|
||||
this.writeItemsToLocalStorage();
|
||||
callback();
|
||||
@@ -229,7 +226,7 @@ angular.module('app.frontend')
|
||||
var dirtyItems = modelManager.dirtyItems;
|
||||
var request = Restangular.one("items/sync");
|
||||
request.items = _.map(dirtyItems, function(item){
|
||||
return this.createRequestParamsForItem(item);
|
||||
return this.createRequestParamsForItem(item, options.additionalFields);
|
||||
}.bind(this));
|
||||
|
||||
if(this.syncToken) {
|
||||
@@ -253,13 +250,17 @@ angular.module('app.frontend')
|
||||
})
|
||||
}
|
||||
|
||||
this.sync = function(callback) {
|
||||
this.syncWithOptions(callback, undefined);
|
||||
}
|
||||
|
||||
this.handleItemsResponse = function(responseItems, omitFields) {
|
||||
this.decryptItems(responseItems);
|
||||
return modelManager.mapResponseItemsToLocalModelsOmittingFields(responseItems, omitFields);
|
||||
}
|
||||
|
||||
this.createRequestParamsForItem = function(item) {
|
||||
return this.paramsForItem(item, !item.isPublic(), null, false);
|
||||
this.createRequestParamsForItem = function(item, additionalFields) {
|
||||
return this.paramsForItem(item, !item.isPublic(), additionalFields, false);
|
||||
}
|
||||
|
||||
this.paramsForItem = function(item, encrypted, additionalFields, forExportFile) {
|
||||
@@ -295,7 +296,6 @@ angular.module('app.frontend')
|
||||
|
||||
this.deleteItem = function(item, callback) {
|
||||
item.deleted = true;
|
||||
console.log("adding dirty item", item);
|
||||
modelManager.addDirtyItems([item]);
|
||||
this.sync(callback);
|
||||
}
|
||||
@@ -344,11 +344,11 @@ angular.module('app.frontend')
|
||||
|
||||
this.importJSONData = function(jsonString, callback) {
|
||||
var data = JSON.parse(jsonString);
|
||||
var customModelManager = new ModelManager();
|
||||
customModelManager.mapResponseItemsToLocalModels(data.items);
|
||||
// var customModelManager = new ModelManager();
|
||||
modelManager.mapResponseItemsToLocalModels(data.items);
|
||||
console.log("Importing data", JSON.parse(jsonString));
|
||||
modelManager.addDirtyItems(customModelManager.items);
|
||||
this.sync(callback);
|
||||
modelManager.addDirtyItems(modelManager.items);
|
||||
this.syncWithOptions(callback, {additionalFields: ["created_at", "updated_at"]});
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -373,7 +373,7 @@ angular.module('app.frontend')
|
||||
}.bind(this);
|
||||
|
||||
var items = _.map(modelManager.items, function(item){
|
||||
return this.paramsForItem(item, false, ["created_at", "updated_at"], true)
|
||||
return _.omit(this.paramsForItem(item, false, ["created_at", "updated_at"], true), ["deleted"]);
|
||||
}.bind(this));
|
||||
|
||||
var data = {
|
||||
|
||||
Reference in New Issue
Block a user