Sort by title option

This commit is contained in:
Mo Bitar
2017-08-22 16:06:47 -05:00
parent f85741e411
commit e1f6316e01
2 changed files with 13 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ angular.module('app.frontend')
.controller('NotesCtrl', function (authManager, $timeout, $rootScope, modelManager) {
this.sortBy = localStorage.getItem("sortBy") || "created_at";
this.sortDescending = this.sortBy != "title";
$rootScope.$on("editorFocused", function(){
this.showMenu = false;
@@ -120,10 +121,17 @@ angular.module('app.frontend')
this.selectedSortByCreated = function() {
this.setSortBy("created_at");
this.sortDescending = true;
}
this.selectedSortByUpdated = function() {
this.setSortBy("updated_at");
this.sortDescending = true;
}
this.selectedSortByTitle = function() {
this.setSortBy("title");
this.sortDescending = false;
}
this.setSortBy = function(type) {

View File

@@ -19,10 +19,14 @@
%label{"ng-click" => "ctrl.selectedMenuItem($event); ctrl.selectedSortByUpdated()"}
%span.top.mt-5.mr-5{"ng-if" => "ctrl.sortBy == 'updated_at'"} ✓
By date modified
%li
%label{"ng-click" => "ctrl.selectedMenuItem($event); ctrl.selectedSortByTitle()"}
%span.top.mt-5.mr-5{"ng-if" => "ctrl.sortBy == 'title'"} ✓
By title
.scrollable
.infinite-scroll{"infinite-scroll" => "ctrl.paginate()", "can-load" => "true", "threshold" => "200"}
.note{"ng-repeat" => "note in (ctrl.sortedNotes = (ctrl.tag.notes | filter: ctrl.filterNotes | orderBy: ctrl.sortBy:true | limitTo:ctrl.notesToDisplay))",
.note{"ng-repeat" => "note in (ctrl.sortedNotes = (ctrl.tag.notes | filter: ctrl.filterNotes | orderBy: ctrl.sortBy:ctrl.sortDescending | limitTo:ctrl.notesToDisplay))",
"ng-click" => "ctrl.selectNote(note)", "ng-class" => "{'selected' : ctrl.selectedNote == note}"}
%strong.red.medium{"ng-if" => "note.conflict_of"} Conflicted copy
%strong.red.medium{"ng-if" => "note.errorDecrypting"} Error decrypting