Transition archived tag to smart tag
This commit is contained in:
@@ -246,6 +246,12 @@ angular.module('app')
|
|||||||
this.saveNote = function($event) {
|
this.saveNote = function($event) {
|
||||||
var note = this.note;
|
var note = this.note;
|
||||||
note.dummy = false;
|
note.dummy = false;
|
||||||
|
// Make sure the note exists. A safety measure, as toggling between tags triggers deletes for dummy notes.
|
||||||
|
// Race conditions have been fixed, but we'll keep this here just in case.
|
||||||
|
if(!modelManager.findItem(note.uuid)) {
|
||||||
|
alert("The note you are attempting to save can not be found or has been deleted. Changes you make will not be synced. Please copy this note's text and start a new note.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.save()(note, function(success){
|
this.save()(note, function(success){
|
||||||
if(success) {
|
if(success) {
|
||||||
if(statusTimeout) $timeout.cancel(statusTimeout);
|
if(statusTimeout) $timeout.cancel(statusTimeout);
|
||||||
|
|||||||
@@ -112,10 +112,13 @@ angular.module('app')
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadArchivedTag() {
|
function loadArchivedTag() {
|
||||||
var archiveTag = new Tag({content: {title: "Archived"}});
|
var archiveTag = new SmartTag({content: {title: "Archived", predicate: ["archived", "=", true]}});
|
||||||
archiveTag.archiveTag = true;
|
Object.defineProperty(archiveTag, "notes", {
|
||||||
|
get: () => {
|
||||||
|
return modelManager.notesMatchingPredicate(archiveTag.content.predicate);
|
||||||
|
}
|
||||||
|
});
|
||||||
$scope.archiveTag = archiveTag;
|
$scope.archiveTag = archiveTag;
|
||||||
$scope.archiveTag.notes = modelManager.notes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -157,8 +160,15 @@ angular.module('app')
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$scope.tagsSelectionMade = function(tag) {
|
$scope.tagsSelectionMade = function(tag) {
|
||||||
|
// If a tag is selected twice, then the needed dummy note is removed.
|
||||||
|
// So we perform this check.
|
||||||
|
if($scope.selectedTag && tag && $scope.selectedTag.uuid == tag.uuid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if($scope.selectedNote && $scope.selectedNote.dummy) {
|
if($scope.selectedNote && $scope.selectedNote.dummy) {
|
||||||
modelManager.removeItemLocally($scope.selectedNote);
|
modelManager.removeItemLocally($scope.selectedNote);
|
||||||
|
$scope.selectedNote = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.selectedTag = tag;
|
$scope.selectedTag = tag;
|
||||||
@@ -200,7 +210,7 @@ angular.module('app')
|
|||||||
$scope.notesAddNew = function(note) {
|
$scope.notesAddNew = function(note) {
|
||||||
modelManager.addItem(note);
|
modelManager.addItem(note);
|
||||||
|
|
||||||
if(!$scope.selectedTag.all && !$scope.selectedTag.archiveTag && !$scope.selectedTag.isSmartTag()) {
|
if(!$scope.selectedTag.all && !$scope.selectedTag.isSmartTag()) {
|
||||||
$scope.selectedTag.addItemAsRelationship(note);
|
$scope.selectedTag.addItemAsRelationship(note);
|
||||||
$scope.selectedTag.setDirty(true);
|
$scope.selectedTag.setDirty(true);
|
||||||
}
|
}
|
||||||
@@ -246,7 +256,6 @@ angular.module('app')
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.deleteNote = function(note) {
|
$scope.deleteNote = function(note) {
|
||||||
|
|
||||||
modelManager.setItemToBeDeleted(note);
|
modelManager.setItemToBeDeleted(note);
|
||||||
|
|
||||||
if(note == $scope.selectedNote) {
|
if(note == $scope.selectedNote) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ angular.module('app')
|
|||||||
bindToController: true,
|
bindToController: true,
|
||||||
|
|
||||||
link:function(scope, elem, attrs, ctrl) {
|
link:function(scope, elem, attrs, ctrl) {
|
||||||
scope.$watch('ctrl.tag', function(tag, oldTag){
|
scope.$watch('ctrl.tag', (tag, oldTag) => {
|
||||||
if(tag) {
|
if(tag) {
|
||||||
if(tag.needsLoad) {
|
if(tag.needsLoad) {
|
||||||
scope.$watch('ctrl.tag.didLoad', function(didLoad){
|
scope.$watch('ctrl.tag.didLoad', function(didLoad){
|
||||||
@@ -133,12 +133,14 @@ angular.module('app')
|
|||||||
base += " Title";
|
base += " Title";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.showArchived && (!this.tag || !this.tag.archiveTag)) {
|
if(!this.tag || !this.tag.isSmartTag()) {
|
||||||
base += " | + Archived"
|
// These rules don't apply for smart tags
|
||||||
}
|
if(this.showArchived) {
|
||||||
|
base += " | + Archived"
|
||||||
if(this.hidePinned) {
|
}
|
||||||
base += " | – Pinned"
|
if(this.hidePinned) {
|
||||||
|
base += " | – Pinned"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
@@ -227,9 +229,16 @@ angular.module('app')
|
|||||||
this.noteFilter = {text : ''};
|
this.noteFilter = {text : ''};
|
||||||
|
|
||||||
this.filterNotes = function(note) {
|
this.filterNotes = function(note) {
|
||||||
|
var canShowArchived = false, canShowPinned = true;
|
||||||
var isSmartTag = this.tag.isSmartTag();
|
var isSmartTag = this.tag.isSmartTag();
|
||||||
|
if(isSmartTag) {
|
||||||
|
canShowArchived = this.tag.isReferencingArchivedNotes();
|
||||||
|
} else {
|
||||||
|
canShowArchived = this.showArchived;
|
||||||
|
canShowPinned = !this.hidePinned;
|
||||||
|
}
|
||||||
|
|
||||||
if((!isSmartTag && note.archived && !this.showArchived && !this.tag.archiveTag) || (note.pinned && this.hidePinned)) {
|
if((note.archived && !canShowArchived) || (note.pinned && !canShowPinned)) {
|
||||||
note.visible = false;
|
note.visible = false;
|
||||||
return note.visible;
|
return note.visible;
|
||||||
}
|
}
|
||||||
@@ -244,9 +253,9 @@ angular.module('app')
|
|||||||
note.visible = matchesTitle || matchesBody;
|
note.visible = matchesTitle || matchesBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.tag.archiveTag) {
|
// if(this.tag.archiveTag) {
|
||||||
note.visible = note.visible && note.archived;
|
// note.visible = note.visible && note.archived;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return note.visible;
|
return note.visible;
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
|
|||||||
@@ -71,12 +71,10 @@ angular.module('app')
|
|||||||
this.selectTag(tag);
|
this.selectTag(tag);
|
||||||
}
|
}
|
||||||
} else if(data.item.content_type == "SN|SmartTag") {
|
} else if(data.item.content_type == "SN|SmartTag") {
|
||||||
var params = data.item.content.predicate;
|
var tag = new SmartTag(data.item);
|
||||||
var predicate = new SFPredicate(params.keypath, params.operator, params.value);
|
|
||||||
var tag = new Tag(data.item);
|
|
||||||
Object.defineProperty(tag, "notes", {
|
Object.defineProperty(tag, "notes", {
|
||||||
get: () => {
|
get: () => {
|
||||||
return modelManager.notesMatchingPredicate(predicate);
|
return modelManager.notesMatchingPredicate(tag.content.predicate);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.selectTag(tag);
|
this.selectTag(tag);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
SFModelManager.ContentTypeClassMapping = {
|
SFModelManager.ContentTypeClassMapping = {
|
||||||
"Note" : Note,
|
"Note" : Note,
|
||||||
"Tag" : Tag,
|
"Tag" : Tag,
|
||||||
|
"SN|SmartTag" : SmartTag,
|
||||||
"Extension" : Extension,
|
"Extension" : Extension,
|
||||||
"SN|Editor" : Editor,
|
"SN|Editor" : Editor,
|
||||||
"SN|Theme" : Theme,
|
"SN|Theme" : Theme,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
%menu-row{"label" => "'Date Modified'", "circle" => "ctrl.sortBy == 'client_updated_at' && 'success'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.selectedSortByUpdated()", "desc" => "'Sort notes with the most recently updated first'"}
|
%menu-row{"label" => "'Date Modified'", "circle" => "ctrl.sortBy == 'client_updated_at' && 'success'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.selectedSortByUpdated()", "desc" => "'Sort notes with the most recently updated first'"}
|
||||||
%menu-row{"label" => "'Title'", "circle" => "ctrl.sortBy == 'title' && 'success'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.selectedSortByTitle()", "desc" => "'Sort notes alphabetically by their title'"}
|
%menu-row{"label" => "'Title'", "circle" => "ctrl.sortBy == 'title' && 'success'", "ng-click" => "ctrl.selectedMenuItem($event); ctrl.selectedSortByTitle()", "desc" => "'Sort notes alphabetically by their title'"}
|
||||||
|
|
||||||
.section{"ng-if" => "!ctrl.tag.archiveTag"}
|
.section{"ng-if" => "!ctrl.tag.isSmartTag()"}
|
||||||
.header
|
.header
|
||||||
%h4.title Display
|
%h4.title Display
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
%i.icon.ion-bookmark
|
%i.icon.ion-bookmark
|
||||||
%strong.medium-text Pinned
|
%strong.medium-text Pinned
|
||||||
|
|
||||||
.archived.tinted{"ng-if" => "note.archived && !ctrl.tag.archiveTag", "ng-class" => "{'tinted-selected' : ctrl.selectedNote == note}"}
|
.archived.tinted{"ng-if" => "note.archived && !ctrl.tag.isSmartTag()", "ng-class" => "{'tinted-selected' : ctrl.selectedNote == note}"}
|
||||||
%i.icon.ion-ios-box
|
%i.icon.ion-ios-box
|
||||||
%strong.medium-text Archived
|
%strong.medium-text Archived
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user