Skip to content

Commit e5ec69f

Browse files
committed
#99 tags complete
1 parent c820099 commit e5ec69f

File tree

7 files changed

+50
-29
lines changed

7 files changed

+50
-29
lines changed

OpenNote/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
<!-- Controllers -->
6363
<script src="openNote/controllers/folderController.js"></script>
64+
<script src="openNote/controllers/tagController.js"></script>
6465
<script src="openNote/controllers/noteController.js"></script>
6566
<script src="openNote/controllers/tagListController.js"></script>
6667
<script src="openNote/controllers/searchController.js"></script>

OpenNote/openNote/controllers/noteController.js

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,32 +96,6 @@ openNote.controller("noteController", function( $scope,
9696
});
9797
};
9898

99-
//Load or new
100-
if(!$routeParams.id){//new
101-
$scope.note._id = null;
102-
$scope.note.parentFolderID = $location.search().folderID;
103-
$scope.note.title = "Note Title";
104-
105-
activateEditMode();
106-
$(".notePartial").fadeIn(config.fadeSpeedLong());
107-
}
108-
else{
109-
/**
110-
* Load note
111-
*/
112-
storageService.database().get($routeParams.id).then(function(doc){
113-
$scope.note=doc;
114-
$(".notePartial").fadeIn(config.fadeSpeedLong());
115-
116-
//Add buttons
117-
$rootScope.buttons.push(upButton($scope.note.parentFolderID));
118-
$rootScope.buttons.push(copyButton($scope.note));
119-
$rootScope.buttons.push(editButton());
120-
121-
$scope.$apply();
122-
});
123-
}
124-
12599
/**
126100
* Save a note
127101
*/
@@ -172,6 +146,7 @@ openNote.controller("noteController", function( $scope,
172146
var folderID = $scope.note.parentFolderID;//need to keep track of this because we are about to delete it
173147
$(".notePartial").fadeOut(config.fadeSpeedShort());
174148
storageService.database().remove($scope.note).then(function(){
149+
$rootScope.$emit("noteDeleted",$scope.note);
175150
detachWindowUnload();
176151
alertify.success("Note Deleted"); //all done. close the notify dialog
177152
$location.url("/folder/"+folderID);
@@ -221,4 +196,30 @@ openNote.controller("noteController", function( $scope,
221196
var detachWindowUnload = function(){
222197
window.onbeforeunload = null;
223198
};
199+
200+
//Load or new
201+
if(!$routeParams.id){//new
202+
$scope.note._id = null;
203+
$scope.note.parentFolderID = $location.search().folderID;
204+
$scope.note.title = "Note Title";
205+
206+
activateEditMode();
207+
$(".notePartial").fadeIn(config.fadeSpeedLong());
208+
}
209+
else{
210+
/**
211+
* Load note
212+
*/
213+
storageService.database().get($routeParams.id).then(function(doc){
214+
$scope.note=doc;
215+
$(".notePartial").fadeIn(config.fadeSpeedLong());
216+
217+
//Add buttons
218+
$rootScope.buttons.push(upButton($scope.note.parentFolderID));
219+
$rootScope.buttons.push(copyButton($scope.note));
220+
$rootScope.buttons.push(editButton());
221+
222+
$scope.$apply();
223+
});
224+
}
224225
});

OpenNote/openNote/controllers/tagListController.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
openNote.controller("tagListController", function( $scope,
1010
$rootScope,
1111
tagService,
12+
$location,
1213
storageService) {
1314
$scope.tags = [];
1415

@@ -22,6 +23,14 @@ openNote.controller("tagListController", function( $scope,
2223
});
2324
};
2425

26+
/**
27+
* Open a tag
28+
* @param tag - Tag to open
29+
*/
30+
$scope.openTag = function(tag){
31+
$location.url("/tag/"+encodeURIComponent(tag));
32+
};
33+
2534
/**
2635
* Move key
2736
* @param request.destFolder -

OpenNote/openNote/partials/tagListPartial.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<div>
77
<h4>Tags</h4>
88
<ul class=" list-unstyled">
9-
<li ng-repeat="tag in tags" class="startHidden randomFadeInDirective">{{tag}}</li>
9+
<li ng-repeat="tag in tags" class="startHidden randomFadeInDirective" ng-click="openTag(tag);">{{tag}}</li>
10+
<li ng-if="!tags || !tags.length" class="startHidden randomFadeInDirective">No tags found. Add a # to a note to add a tag.</li>
1011
</ul>
1112
</div>
1213
</div>

OpenNote/openNote/router.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ openNote.config(function($routeProvider){
66
controller: "folderController",
77
templateUrl: "openNote/partials/folderPartial.html",
88
})
9+
.when("/tag/:tag",
10+
{
11+
controller: "tagController",
12+
templateUrl: "openNote/partials/tagPartial.html",
13+
})
914
.when("/note/:id?",
1015
{
1116
controller: "noteController",
@@ -32,4 +37,4 @@ openNote.config(function($routeProvider){
3237
templateUrl: "openNote/partials/settings/legacyPartial.html"
3338
})
3439
.otherwise({ redirectTo: "/folder" });
35-
});
40+
});

OpenNote/openNote/services/tagService.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ openNote.service("tagService", function ($rootScope,storageService) {
1414
addTagsToMap(results,note._id);
1515
});
1616
});
17+
18+
$rootScope.$on("noteDeleted", function(event, note) {
19+
deleteTagsFromMap(note._id);
20+
});
1721
};
1822

1923
/**

OpenNote/openNote/style/invert/style.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ input:focus, select:focus, textarea:focus, button:focus {
9494
}
9595

9696
#folderTitleBar{
97-
padding: 15px 0px;
97+
padding: 0px 0px 15px 0px;
9898
overflow: hidden;
9999
font-size: 18px;
100100

0 commit comments

Comments
 (0)