This commit is contained in:
Mo Bitar
2016-12-28 15:22:53 -06:00
parent 195d219e88
commit 96006e3dca
11 changed files with 48 additions and 28 deletions

View File

@@ -3,10 +3,8 @@
var Neeto = Neeto || {};
if(window.crypto.subtle) {
// console.log("using WebCrypto");
Neeto.crypto = new SNCryptoWeb();
} else {
// console.log("using CryptoJS");
Neeto.crypto = new SNCryptoJS();
}

View File

@@ -67,6 +67,7 @@ angular.module('app.frontend')
this.setNote = function(note, oldNote) {
this.editorMode = 'edit';
if(note.content.text.length == 0 && note.dummy) {
this.focusTitle(100);
}

View File

@@ -126,7 +126,7 @@ angular.module('app.frontend')
this.downloadDataArchive = function() {
var link = document.createElement('a');
link.setAttribute('download', 'neeto.json');
link.setAttribute('download', 'notes.json');
link.href = apiController.itemsDataFile();
link.click();
}

View File

@@ -62,7 +62,7 @@ angular.module('app.frontend')
if(this.editingTag) {
return;
}
this.newTag = new Tag();
this.selectedTag = this.newTag;
this.editingTag = this.newTag;

View File

@@ -43,6 +43,10 @@ class Note extends Item {
return {uuid: this.uuid}
}
isSharedIndividually() {
return this.presentation_name;
}
isPublic() {
return super.isPublic() || this.hasOnePublicTag;
}

View File

@@ -240,8 +240,7 @@ angular.module('app.frontend')
var request = Restangular.one("users", this.user.uuid).one("items");
request.get(updatedAfter ? {"updated_after" : updatedAfter.toString()} : {})
.then(function(response){
console.log("refresh response", response.items);
var items = this.handleItemsResponse(response.items);
var items = this.handleItemsResponse(response.items, null);
callback(items);
}.bind(this))
.catch(function(response) {
@@ -261,14 +260,15 @@ angular.module('app.frontend')
}.bind(this));
request.post().then(function(response) {
// this.handleItemsResponse(response.items);
var omitFields = ["content", "enc_item_key", "auth_hash"];
this.handleItemsResponse(response.items, omitFields);
callback(response);
}.bind(this))
}
this.handleItemsResponse = function(responseItems) {
this.handleItemsResponse = function(responseItems, omitFields) {
this.decryptItems(responseItems);
return modelManager.mapResponseItemsToLocalModels(responseItems);
return modelManager.mapResponseItemsToLocalModelsOmittingFields(responseItems, omitFields);
}
this.createRequestParamsForItem = function(item) {

View File

@@ -17,8 +17,13 @@ class ItemManager {
}
mapResponseItemsToLocalModels(items) {
return this.mapResponseItemsToLocalModelsOmittingFields(items, null)
}
mapResponseItemsToLocalModelsOmittingFields(items, omitFields) {
var models = []
for (var json_obj of items) {
json_obj = _.omit(json_obj, omitFields || [])
var item = this.findItem(json_obj["uuid"]);
if(json_obj["deleted"] == true) {
if(item) {

View File

@@ -3,19 +3,19 @@ class ModelManager extends ItemManager {
constructor() {
super();
this.notes = [];
this.groups = [];
this.tags = [];
this.dirtyItems = [];
}
resolveReferences() {
super.resolveReferences()
this.notes = this.itemsForContentType("Note");
this.notes.push.apply(this.notes, _.difference(this.itemsForContentType("Note"), this.notes));
this.notes.forEach(function(note){
note.updateReferencesLocalMapping();
})
this.tags = this.itemsForContentType("Tag");
this.tags.push.apply(this.tags, _.difference(this.itemsForContentType("Tag"), this.tags));
this.tags.forEach(function(tag){
tag.updateReferencesLocalMapping();
})
@@ -48,6 +48,7 @@ class ModelManager extends ItemManager {
addTag(tag) {
this.tags.unshift(tag);
this.addItem(tag);
console.log("adding tag", tag, "tags", this.tags);
}
addTagToNote(tag, note) {