From cb456df1224e2d0c54f5789416e3c1b09b38beae Mon Sep 17 00:00:00 2001 From: Sander van de Graaf Date: Wed, 2 Aug 2017 11:14:53 +0200 Subject: [PATCH 1/7] added favorites --- app/js/app.js | 20 ++++++++++++++++++++ app/js/controllers.js | 16 ++++++++++++++++ app/partials/bookmarks/show.html | 14 ++++++++++++++ app/partials/footer/footer.html | 10 +++++++++- 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/app/js/app.js b/app/js/app.js index 63cf150..d979b99 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -106,6 +106,26 @@ locksmithApp.config([ controller: 'BookmarkShowController', templateUrl: 'partials/bookmarks/show.html' }). + state('favorites', { + abstract: true, + url: '/favorites', + views: { + header: { + templateUrl: 'partials/header/bookmarks.html' + }, + main: { + templateUrl: 'partials/bookmarks/index.html' + }, + footer: { + templateUrl: 'partials/footer/footer.html' + } + } + }). + state('favorites.list', { + url: '', + controller: 'FavoritesIndexController', + templateUrl: 'partials/favorites/list.html' + }). state('accounts', { abstract: true, url: '/accounts', diff --git a/app/js/controllers.js b/app/js/controllers.js index 78f0264..3a61e30 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -142,6 +142,17 @@ locksmithControllers.controller( } ]); +locksmithControllers.controller( + 'FavoritesIndexController', ['$rootScope', '$scope', '$state', 'Bookmark', '$location', 'signin', '$ionicPopup', '$controller', + + function($rootScope, $scope, $state, Bookmark, $location, signin, $ionicPopup, $controller) { + angular.extend(this, $controller('BookmarkIndexController', { + $scope: $scope + })); + } + ]); + + locksmithControllers.controller( 'BookmarkShowController', ['$scope', '$state', 'Bookmark', '$stateParams', function($scope, $state, Bookmark, $stateParams) { @@ -158,6 +169,10 @@ locksmithControllers.controller( $scope.bookmark.$create(); } + if ($scope.bookmark.is_favorite) { + console.log('yep!'); + } + $state.go('bookmarks.list'); }; @@ -171,6 +186,7 @@ locksmithControllers.controller( } ]); + locksmithControllers.controller( 'AccountIndexController', ['$scope', 'Account', '$location', function($scope, Account, $location) { diff --git a/app/partials/bookmarks/show.html b/app/partials/bookmarks/show.html index 8be0089..f239adf 100644 --- a/app/partials/bookmarks/show.html +++ b/app/partials/bookmarks/show.html @@ -34,6 +34,19 @@ ng-model="bookmark.avatar_url" /> + +
+ Favorite + +
@@ -46,4 +59,5 @@ class="button button-block button-assertive" ng-click="delete()" >Delete Bookmark +
diff --git a/app/partials/footer/footer.html b/app/partials/footer/footer.html index 299821a..392d2ab 100644 --- a/app/partials/footer/footer.html +++ b/app/partials/footer/footer.html @@ -1,4 +1,12 @@
+ + + -
\ No newline at end of file + From a67b9eb49c6fa9d22b0933a554f4b13af95e3d7e Mon Sep 17 00:00:00 2001 From: Sander van de Graaf Date: Wed, 2 Aug 2017 11:21:02 +0200 Subject: [PATCH 2/7] added favorites --- app/partials/favorites/list.html | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 app/partials/favorites/list.html diff --git a/app/partials/favorites/list.html b/app/partials/favorites/list.html new file mode 100644 index 0000000..8aadd5c --- /dev/null +++ b/app/partials/favorites/list.html @@ -0,0 +1,31 @@ + + + + + +

{{bookmark.name}}

+

{{bookmark.account_number}}

+ +
+
From 4d2118cbbc73b5bac93a818c7f86fc4f98e312f5 Mon Sep 17 00:00:00 2001 From: Sander van de Graaf Date: Wed, 2 Aug 2017 15:30:17 +0200 Subject: [PATCH 3/7] added favorites --- app/js/app.js | 13 +++++++--- app/js/controllers.js | 41 ++++++++++++++++++++++++------ app/partials/bookmarks/show.html | 5 +++- app/partials/favorites/index.html | 3 +++ app/partials/favorites/list.html | 14 ++-------- app/partials/footer/footer.html | 1 + app/partials/header/favorites.html | 1 + app/partials/settings.html | 15 ++++++++++- 8 files changed, 68 insertions(+), 25 deletions(-) create mode 100644 app/partials/favorites/index.html create mode 100644 app/partials/header/favorites.html diff --git a/app/js/app.js b/app/js/app.js index d979b99..1be6faa 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -44,6 +44,9 @@ locksmithApp.run(function($rootScope, $state, $localStorage) { if (typeof window.settings.bookmarks === 'undefined') { window.settings.bookmarks = []; } + if (typeof window.settings.favorites === 'undefined') { + window.settings.favorites = []; + } $rootScope.jobs = 0; @@ -101,6 +104,11 @@ locksmithApp.config([ controller: 'BookmarkIndexController', templateUrl: 'partials/bookmarks/list.html' }). + state('bookmarks.favorites', { + url: '', + controller: 'FavoritesIndexController', + templateUrl: 'partials/favorites/list.html' + }). state('bookmarks.show', { url: '/:bookmarkId', controller: 'BookmarkShowController', @@ -111,10 +119,10 @@ locksmithApp.config([ url: '/favorites', views: { header: { - templateUrl: 'partials/header/bookmarks.html' + templateUrl: 'partials/header/favorites.html' }, main: { - templateUrl: 'partials/bookmarks/index.html' + templateUrl: 'partials/favorites/index.html' }, footer: { templateUrl: 'partials/footer/footer.html' @@ -188,6 +196,5 @@ locksmithApp.config([ }); $urlRouterProvider.otherwise('/bookmarks'); - } ]); diff --git a/app/js/controllers.js b/app/js/controllers.js index 3a61e30..581685c 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -130,12 +130,25 @@ locksmithControllers.controller( } }); - $scope.bookmarks = Bookmark.query(); - if (typeof $scope.bookmarks.$promise !== 'undefined') { - $scope.bookmarks.$promise.then(function(bookmarks) { - window.settings.bookmarks = bookmarks.bookmarks; - }); - } + Bookmark.query().$promise.then(function(bookmarks) { + // loop through all bookmarks, and check if they are included + // in the favorites. If so, mark them as such + for (i = 0; i < bookmarks.bookmarks.length; i++) { + var bookmark = bookmarks.bookmarks[i]; + bookmarks.bookmarks[i].is_favorite = false; + if (window.settings.favorites.includes(parseInt(bookmark.id))) { + bookmarks.bookmarks[i].is_favorite = true; + } + } + $scope.bookmarks = bookmarks; + + if (typeof $scope.bookmarks.$promise !== 'undefined') { + $scope.bookmarks.$promise.then(function(bookmarks) { + window.settings.bookmarks = bookmarks.bookmarks; + }); + } + }); + $scope.orderProp = 'name'; $('#search').focus(); @@ -149,7 +162,10 @@ locksmithControllers.controller( angular.extend(this, $controller('BookmarkIndexController', { $scope: $scope })); + + } + ]); @@ -158,8 +174,11 @@ locksmithControllers.controller( function($scope, $state, Bookmark, $stateParams) { $scope.bookmarkId = $stateParams.bookmarkId; - $scope.bookmark = Bookmark.query({ + Bookmark.query({ bookmarkId: $scope.bookmarkId + }).$promise.then(function(bookmark) { + bookmark.is_favorite = window.settings.favorites.includes(parseInt(bookmark.id)); + $scope.bookmark = bookmark; }); $scope.save = function() { @@ -170,7 +189,13 @@ locksmithControllers.controller( } if ($scope.bookmark.is_favorite) { - console.log('yep!'); + if (!window.settings.favorites.includes(parseInt($scope.bookmark.id))) { + window.settings.favorites.push(parseInt($scope.bookmarkId)); + } + } else { + window.settings.favorites = window.settings.favorites.filter(function(id) { + return parseInt(id) != parseInt($scope.bookmarkId); + }); } $state.go('bookmarks.list'); diff --git a/app/partials/bookmarks/show.html b/app/partials/bookmarks/show.html index f239adf..151d2d9 100644 --- a/app/partials/bookmarks/show.html +++ b/app/partials/bookmarks/show.html @@ -35,7 +35,10 @@ /> -
+
Favorite
- +
Locksmith
@@ -35,6 +35,19 @@
+
+ Use Favorites + +
+
Date: Wed, 2 Aug 2017 15:41:27 +0200 Subject: [PATCH 4/7] added titles --- app/js/app.js | 2 ++ app/partials/footer/footer.html | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/js/app.js b/app/js/app.js index 1be6faa..464c2c3 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -23,6 +23,7 @@ angular.module('ui.gravatar').config([ ]); locksmithApp.run(function($rootScope, $state, $localStorage) { + console.log('app.run'); $rootScope.$state = $state; window.settings = $rootScope.$settings = $localStorage; @@ -62,6 +63,7 @@ locksmithApp.run(function($rootScope, $state, $localStorage) { locksmithApp.config([ '$stateProvider', '$urlRouterProvider', '$httpProvider', function($stateProvider, $urlRouterProvider, $httpProvider) { + console.log('app.config'); $httpProvider.interceptors.push(function($rootScope) { return { request: function(config) { diff --git a/app/partials/footer/footer.html b/app/partials/footer/footer.html index 3fc6495..ef1615a 100644 --- a/app/partials/footer/footer.html +++ b/app/partials/footer/footer.html @@ -6,14 +6,14 @@ ng-class="{ 'button-positive': $state.includes('favorites') }" - > + > + > + > + >
From 63c1258e58eb72d6219f7f89e60ec2346894ebb9 Mon Sep 17 00:00:00 2001 From: Sander van de Graaf Date: Thu, 3 Aug 2017 08:31:28 +0200 Subject: [PATCH 5/7] Add hide_avatars setting, which will, well, hide avatars --- app/css/app.css | 11 ++++++++++- app/partials/bookmarks/list.html | 8 ++++---- app/partials/settings.html | 22 +++++++++++++++++++++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/app/css/app.css b/app/css/app.css index 0732dbd..02007e2 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -14,6 +14,15 @@ html { text-align: center; } +.list .item.item-button-right { + padding-right: 45px; +} + +.list .item.item-no-avatar { + padding: 10px; + padding-right: 45px; +} + .icon-spin { -webkit-animation: spin 2s infinite linear; -moz-animation: spin 2s infinite linear; @@ -46,4 +55,4 @@ html { to { transform: rotate(360deg); } -} \ No newline at end of file +} diff --git a/app/partials/bookmarks/list.html b/app/partials/bookmarks/list.html index c2e139e..d99f31c 100644 --- a/app/partials/bookmarks/list.html +++ b/app/partials/bookmarks/list.html @@ -10,15 +10,15 @@ />
- - + +

{{bookmark.name}}

{{bookmark.account_number}}/{{bookmark.role_name}}