From 246d8a1f454bcfd068a397f90907d66d4da37357 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Wed, 8 Feb 2017 11:24:12 +0100 Subject: [PATCH] - Certifications (small device) > unable to show certification tabs - fix #311 - Fix help tip on small device --- www/js/controllers/help-controllers.js | 10 +- www/js/controllers/wallet-controllers.js | 3 +- www/js/controllers/wot-controllers.js | 118 ++++++++++++--------- www/templates/wallet/view_wallet.html | 4 +- www/templates/wot/view_certifications.html | 10 +- 5 files changed, 78 insertions(+), 67 deletions(-) diff --git a/www/js/controllers/help-controllers.js b/www/js/controllers/help-controllers.js index a09e67ca4..1be51cb6e 100644 --- a/www/js/controllers/help-controllers.js +++ b/www/js/controllers/help-controllers.js @@ -157,7 +157,7 @@ function HelpTipController($scope, $rootScope, $state, $window, $ionicSideMenuDe }) // Network tour - .then(function(next){ + /*.then(function(next){ if (!next) return false; return $scope.startNetworkTour(0, true) .then(function(endIndex){ @@ -166,7 +166,7 @@ function HelpTipController($scope, $rootScope, $state, $window, $ionicSideMenuDe csSettings.store(); return $scope.continue; }); - }) + })*/ // Wot tour .then(function(next){ @@ -1007,11 +1007,7 @@ function HelpTipController($scope, $rootScope, $state, $window, $ionicSideMenuDe /* ---------------------------- * Help tour (auto start from home page) * ---------------------------- */ -function HelpTourController($scope, $rootScope, $state, $window, $ionicSideMenuDelegate, $timeout, $q, $anchorScroll, - UIUtils, csConfig, csSettings, csCurrency, Device, csWallet) { - - HelpTipController.call(this, $scope, $rootScope, $state, $window, $ionicSideMenuDelegate, $timeout, $q, $anchorScroll, - UIUtils, csConfig, csSettings, csCurrency, Device, csWallet); +function HelpTourController($scope) { $scope.$on('$ionicView.enter', function(e, state) { $scope.startHelpTour(); diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index c97e64030..32c1542ac 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -523,7 +523,8 @@ function WalletController($scope, $rootScope, $q, $ionicPopup, $timeout, $state, }; $scope.showCertifications = function() { - $state.go(UIUtils.screen.isSmall() ? 'app.wallet_cert.tab_received' : 'app.wallet_cert_lg', { + // Warn: do not use a simple link here (a ng-click is mandatory for help tour) + $state.go(UIUtils.screen.isSmall() ? 'app.wallet_cert.received' : 'app.wallet_cert_lg', { pubkey: $rootScope.walletData.pubkey, uid: $rootScope.walletData.name || $rootScope.walletData.uid }); diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index f232bfb1d..54aac2ee7 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -25,31 +25,39 @@ angular.module('cesium.wot.controllers', ['cesium.services']) }) .state('app.wot_cert', { - url: "/wot/cert", + url: "/wot/cert/:pubkey/:uid", abstract: true, views: { 'menuContent': { templateUrl: "templates/wot/view_certifications.html", - controller: 'WotCertificationsViewCtrl' + controller: 'WotCertificationsTabCtrl' } } }) - .state('app.wot_cert.tab_received', { - url: "/:pubkey/:uid/received", + .state('app.wot_cert.received', { + url: "/received", views: { 'tab-received-cert': { - templateUrl: "templates/wot/tabs/tab_received_certifications.html" + templateUrl: "templates/wot/tabs/tab_received_certifications.html", + controller: 'WotReceivedCertificationsTabCtrl' } + }, + data: { + large: 'app.wot_cert_lg' } }) - .state('app.wot_cert.tab_given', { - url: "/:pubkey/:uid/given", + .state('app.wot_cert.given', { + url: "/given", views: { 'tab-given-cert': { - templateUrl: "templates/wot/tabs/tab_given_certifications.html" + templateUrl: "templates/wot/tabs/tab_given_certifications.html", + controller: 'WotGivenCertificationsTabCtrl' } + }, + data: { + large: 'app.wot_cert_lg' } }) @@ -70,16 +78,17 @@ angular.module('cesium.wot.controllers', ['cesium.services']) views: { 'menuContent': { templateUrl: "templates/wot/view_certifications.html", - controller: 'WotCertificationsViewCtrl' + controller: 'WotCertificationsTabCtrl' } } }) - .state('app.wallet_cert.tab_received', { + .state('app.wallet_cert.received', { url: "/received", views: { 'tab-received-cert': { - templateUrl: "templates/wot/tabs/tab_received_certifications.html" + templateUrl: "templates/wot/tabs/tab_received_certifications.html", + controller: 'WotReceivedCertificationsTabCtrl' } }, data: { @@ -87,11 +96,12 @@ angular.module('cesium.wot.controllers', ['cesium.services']) } }) - .state('app.wallet_cert.tab_given', { + .state('app.wallet_cert.given', { url: "/given", views: { 'tab-given-cert': { - templateUrl: "templates/wot/tabs/tab_given_certifications.html" + templateUrl: "templates/wot/tabs/tab_given_certifications.html", + controller: 'WotGivenCertificationsTabCtrl' } }, data: { @@ -119,6 +129,12 @@ angular.module('cesium.wot.controllers', ['cesium.services']) .controller('WotCertificationsViewCtrl', WotCertificationsViewController) + .controller('WotCertificationsTabCtrl', WotCertificationsTabController) + + .controller('WotReceivedCertificationsTabCtrl', WotReceivedCertificationsTabController) + + .controller('WotGivenCertificationsTabCtrl', WotGivenCertificationsTabController) + ; @@ -462,8 +478,8 @@ function WotIdentityViewController($scope, $state, $timeout, UIUtils, csWot) { }; $scope.showCertifications = function() { - // Warn: do not use a simple link here (a ng-click is need for help tour) - $state.go(UIUtils.screen.isSmall() ? 'app.wot_cert.tab_received' : 'app.wot_cert_lg', { + // Warn: do not use a simple link here (a ng-click is mandatory for help tour) + $state.go(UIUtils.screen.isSmall() ? 'app.wot_cert.received' : 'app.wot_cert_lg', { pubkey: $scope.formData.pubkey, uid: $scope.formData.uid }); @@ -504,9 +520,11 @@ function WotCertificationsViewController($scope, $rootScope, $state, $timeout, $ $scope.loading = true; $scope.formData = {}; - $scope.showCertifications = true; // default value (overwrite when tab switch, on small view) - $scope.showGivenCertifications = false; // default value (overwrite on 'large' view) - $scope.showAvatar = false; // default value (overwrite on 'large' view) + + // Values overwritten in tab controller (for small screen) + $scope.showCertifications = true; + $scope.showGivenCertifications = true; + $scope.showAvatar = true; $scope.$on('$ionicView.enter', function(e, state) { if (state.stateParams && state.stateParams.pubkey && @@ -740,30 +758,6 @@ function WotCertificationsViewController($scope, $rootScope, $state, $timeout, $ $scope.motionGivenCertifications($scope.showCertifications ? 900 : 100); }; - // Show received certifcations - $scope.showCertificationsTab = function() { - $scope.showCertifications = true; - $scope.showGivenCertifications = false; - if (csWallet.isUserPubkey($scope.formData.pubkey)) { - $state.go('app.wallet_cert.tab_received'); - } - else { - $state.go('app.wot_cert.tab_received', {pubkey: $scope.formData.pubkey, uid: $scope.formData.uid}); - } - }; - - // Show given certifcations - $scope.showGivenCertificationsTab = function() { - $scope.showGivenCertifications = true; - $scope.showCertifications = false; - if (csWallet.isUserPubkey($scope.formData.pubkey)) { - $state.go('app.wallet_cert.tab_given'); - } - else { - $state.go('app.wot_cert.tab_given', {pubkey: $scope.formData.pubkey, uid: $scope.formData.uid}); - } - }; - // Show help tip $scope.showHelpTip = function(isWallet) { if (!$scope.isLogin()) return; @@ -800,12 +794,12 @@ function WotCertificationsViewController($scope, $rootScope, $state, $timeout, $ UIUtils.motion.fadeSlideInRight({selector: '.list.certifications .item'}); UIUtils.ink({selector: '.list.certifications .ink'}); }, timeout || 10); - if ($scope.canCertify) { + if ($scope.canCertify || $rootScope.tour) { $scope.showFab('fab-certify'); } } else { - if ($scope.canCertify) { + if ($scope.canCertify || $rootScope.tour) { $scope.hideFab('fab-certify', 0); } } @@ -819,23 +813,45 @@ function WotCertificationsViewController($scope, $rootScope, $state, $timeout, $ UIUtils.motion.fadeSlideInRight({selector: '.list.given-certifications .item'}); UIUtils.ink({selector: '.list.given-certifications .ink'}); }, timeout || 10); - if ($scope.canSelectAndCertify) { + if ($scope.canSelectAndCertify || $rootScope.tour) { $scope.showFab('fab-select-certify'); } } else { - if ($scope.canSelectAndCertify) { + if ($scope.canSelectAndCertify || $rootScope.tour) { $scope.hideFab('fab-select-certify', 0); } } }; - $scope.initLargeView = function() { - $scope.showCertifications = true; - $scope.showGivenCertifications = true; - $scope.showAvatar = true; - }; } +function WotCertificationsTabController($scope, $stateParams) { + + $scope.formData = $scope.formData || {}; + + if ($stateParams.pubkey) { + $scope.formData.pubkey = $stateParams.pubkey; + } + if ($stateParams.uid) { + $scope.formData.uid = $stateParams.uid; + } +} + +function WotReceivedCertificationsTabController($scope, $rootScope, $state, $timeout, $translate, csConfig, csSettings, csWallet, UIUtils, csWot, Modals) { + WotCertificationsViewController.call(this, $scope, $rootScope, $state, $timeout, $translate, csConfig, csSettings, csWallet, UIUtils, csWot, Modals); + + $scope.showCertifications = true; + $scope.showGivenCertifications = false; + $scope.showAvatar = false; +} + +function WotGivenCertificationsTabController($scope, $rootScope, $state, $timeout, $translate, csConfig, csSettings, csWallet, UIUtils, csWot, Modals) { + WotCertificationsViewController.call(this, $scope, $rootScope, $state, $timeout, $translate, csConfig, csSettings, csWallet, UIUtils, csWot, Modals); + + $scope.showCertifications = false; + $scope.showGivenCertifications = true; + $scope.showAvatar = false; +} diff --git a/www/templates/wallet/view_wallet.html b/www/templates/wallet/view_wallet.html index 440cc5181..95f07267d 100644 --- a/www/templates/wallet/view_wallet.html +++ b/www/templates/wallet/view_wallet.html @@ -97,12 +97,10 @@ ng-if="walletData.isMember||walletData.requirements.pendingMembership" ng-click="showCertifications()"> <i class="icon ion-ribbon-b"></i> - <span clas="input-label">{{'ACCOUNT.CERTIFICATION_COUNT'|translate}}</span> - + <span clas="input-label" ng-bind-html="'ACCOUNT.CERTIFICATION_COUNT'|translate"></span> <cs-badge-certification requirements="walletData.requirements" parameters="{sigQty: walletData.parameters.sigQty}"> </cs-badge-certification> - <i class="gray icon ion-ios-arrow-right"></i> </a> diff --git a/www/templates/wot/view_certifications.html b/www/templates/wot/view_certifications.html index b848efc2b..85137aab9 100644 --- a/www/templates/wot/view_certifications.html +++ b/www/templates/wot/view_certifications.html @@ -9,12 +9,12 @@ <ion-tabs class="tabs-positive tabs-icon-top"> <ion-tab title="{{'WOT.CERTIFICATIONS.SUMMARY'|translate}}" icon="ion-ribbon-b" - on-select="showCertificationsTab()"> + ui-sref="app.wot_cert.received({pubkey: formData.pubkey, uid: formData.uid})"> <ion-nav-view name="tab-received-cert"></ion-nav-view> </ion-tab> <ion-tab title="{{'WOT.GIVEN_CERTIFICATIONS.SUMMARY'|translate}}" icon="ion-ribbon-a" - on-select="showGivenCertificationsTab()"> + ui-sref="app.wot_cert.given({pubkey: formData.pubkey, uid: formData.uid})"> <ion-nav-view name="tab-given-cert"></ion-nav-view> </ion-tab> @@ -22,14 +22,14 @@ </ion-content> <!-- fab button --> - <div class="visible-xs visible-sm"> + <div class="visible-xs visible-sm">{{$root.tour}} <button id="fab-certify" class="button button-fab button-fab-bottom-right button-energized-900 spin" ng-click="certify()" - ng-if="formData.hasSelf && canCertify && !alreadyCertified"> + ng-if="(formData.hasSelf && canCertify && !alreadyCertified) || $root.tour"> <i class="icon ion-ribbon-b"></i> </button> <button id="fab-select-certify" class="button button-fab button-fab-bottom-right button-energized-900 spin" - ng-if="canSelectAndCertify" + ng-if="canSelectAndCertify || $root.tour" ng-click="selectAndCertify()"> <i class="icon ion-plus"></i> </button> -- GitLab