Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Add modal method to dialog service as general modal service #308

Merged
merged 34 commits into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
df5f860
modify modal function in Dialog service and add new features to it
yasharAyari May 30, 2017
f241822
Merge branch '163-general-modal-service' of https://github.com/LiskHQ…
yasharAyari May 30, 2017
8dedd93
create openDialog directive which is a wrapper for Dialog.modal funct…
yasharAyari May 30, 2017
69c446e
Merge branch 'development' into 163-general-modal-service
yasharAyari May 31, 2017
b3b5152
Remove old service and directive of send modal
yasharAyari May 31, 2017
bb377d4
Remove unused service injections
yasharAyari May 31, 2017
4ff65b2
Replace old send modal directive by open modal directive
yasharAyari May 31, 2017
4c0b6e2
Fix reference passing as a attribute to child directive
yasharAyari May 31, 2017
544961a
Add test coverage for openDialog directive and dialog.modal method
yasharAyari May 31, 2017
4b6a031
Adapt code styling with angular recommendation
yasharAyari May 31, 2017
09d628c
Merge branch 'development' into 163-general-modal-service
reyraa Jun 2, 2017
fead4ef
Fix eslint errors in dialog.spec.js
yasharAyari Jun 2, 2017
8e9f7aa
Merge branch '163-general-modal-service' of https://github.com/LiskHQ…
yasharAyari Jun 2, 2017
687ba25
Merge branch 'development' into 163-general-modal-service
reyraa Jun 2, 2017
41f93e6
Merge branch 'development' into 163-general-modal-service
reyraa Jun 2, 2017
cc8063e
Merge branch 'development' into 163-general-modal-service
reyraa Jun 7, 2017
a283d1d
Merge branch 'development' into 163-general-modal-service
reyraa Jun 7, 2017
c4a6099
Fixing eslint issue and removing secondpass modal test since we do no…
reyraa Jun 7, 2017
35af3d3
Merge branch 'development' into 163-general-modal-service
reyraa Jun 7, 2017
c3dcb1e
Renamed and converted directive to component
reyraa Jun 7, 2017
7d2c0eb
Use general modal for setting second passphrase
reyraa Jun 7, 2017
3a79d11
Change the paretn tag to div as is being wrapped into md-modal is bei…
reyraa Jun 7, 2017
b05786b
Merge branch 'development' of https://github.com/LiskHQ/lisk-nano int…
reyraa Jun 7, 2017
d691466
Merge branch '163-general-modal-service' of https://github.com/LiskHQ…
reyraa Jun 7, 2017
8dd9ac1
Remove old dialog directives
reyraa Jun 7, 2017
59dc444
Change the name of the second passphrase component to camelCase
reyraa Jun 7, 2017
a44043c
Use GM to show delegateRegisteration modal
reyraa Jun 7, 2017
b688281
Return mdDialog promise in doalog,modal
reyraa Jun 8, 2017
7722603
Use dialog.modal instead of mdDialog for password dialogs
reyraa Jun 8, 2017
e907a62
Use GM for second passphrase
reyraa Jun 8, 2017
f20ff65
Use GM for geenrating the primary passphrase of new account
reyraa Jun 8, 2017
d0364d8
Adapt unit tests to use GM
reyraa Jun 8, 2017
ee6d991
Use GM for showing delegate registration modal
reyraa Jun 8, 2017
a0a68f0
Merge branch 'development' into 163-general-modal-service
reyraa Jun 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 5 additions & 28 deletions src/components/delegateRegistration/delegateRegistration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import './delegateRegistration.less';
* @class app.delegateRegistration
* @memberOf app
*/
app.directive('delegateRegistration', ($mdDialog, delegateApi, Account, dialog, $rootScope) => {
const DelegateRegistrationLink = function ($scope, $element) {
app.component('delegateRegistration', {
template: require('./delegateRegistration.pug')(),
controller($scope, $mdDialog, delegateApi, Account, dialog, $rootScope) {
function checkPendingRegistration() {
delegateApi.getDelegate({
username: $scope.username,
Expand Down Expand Up @@ -73,31 +74,7 @@ app.directive('delegateRegistration', ($mdDialog, delegateApi, Account, dialog,
*/
$scope.cancel = (form) => {
$scope.reset(form);
$mdDialog.hide();
// $mdDialog.hide();
};

/**
* Shows from dialog.
*
* @todo This should be replaced by a general dialog directive.
*/
$element.bind('click', () => {
$mdDialog.show({
template: require('./delegateRegistration.pug')(),
bindToController: true,
locals: {
form: $scope.form,
cancel: $scope.cancel,
account: Account,
},
controller: () => {},
controllerAs: '$ctrl',
});
});
};

return {
restrict: 'A',
link: DelegateRegistrationLink,
};
},
});
16 changes: 8 additions & 8 deletions src/components/delegateRegistration/delegateRegistration.pug
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
div.dialog-delegate-registration(aria-label='Vote for delegates')
form(name='delegateRegistrationForm', ng-submit='$ctrl.form.onSubmit(delegateRegistrationForm)')
form(name='delegateRegistrationForm', ng-submit='form.onSubmit(delegateRegistrationForm)')
md-toolbar
.md-toolbar-tools
h2 Delegate Registration
span(flex='')
md-button.md-icon-button(ng-click='$ctrl.cancel(delegateRegistrationForm)', aria-label='Close dialog')
md-button.md-icon-button(ng-click='cancel(delegateRegistrationForm)', aria-label='Close dialog')
i.material-icons close
md-dialog-content
.md-dialog-content
div
md-input-container.md-block
label Delegate name
input.username(type='text', name='delegateName', ng-model='$ctrl.form.name', required, ng-disabled='$ctrl.loading', md-autofocus)
input.username(type='text', name='delegateName', ng-model='form.name', required, ng-disabled='loading', md-autofocus)
div(ng-messages='delegateRegistrationForm.name.$error')
div(ng-message='required') Required
md-input-container.md-block(ng-if='!$ctrl.account.get().secondSignature')
div.fee Fee: {{$ctrl.form.fee}} LSK
md-input-container.md-block(ng-if='$ctrl.account.get().secondSignature')
label Second Passphrase
input(type='password', ng-model='$ctrl.form.secondPassphrase', required)
input(type='password', ng-model='form.secondPassphrase', required)
md-input-container.md-block
div.fee Fee: {{$ctrl.form.fee}} LSK
div.fee Fee: {{form.fee}} LSK
md-divider
div(layout='row')
p.info-icon-wrapper
i.material-icons info
p
span Becoming a delegate requires registration. You may choose your own delegate name, which can be used to promote your delegate. Only the top 101 delegates are eligible to forge. All fees are shared equally between the top 101 delegates.
md-divider
p.error(ng-bind='$ctrl.form.error', ng-if='$ctrl.form.error')
p.error(ng-bind='form.error', ng-if='form.error')
md-dialog-actions(layout='row')
md-button.md-secondary(ng-disabled='$ctrl.loading', ng-click='$ctrl.cancel(delegateRegistrationForm)') {{ 'Cancel' }}
md-button.md-secondary(ng-disabled='loading', ng-click='cancel(delegateRegistrationForm)') {{ 'Cancel' }}
span(flex)
md-button.md-raised.md-primary.register-button(ng-disabled='!delegateRegistrationForm.$valid || $ctrl.loading', type='submit') {{ $ctrl.loading ? 'Registering...' : 'Register' }}
md-button.md-raised.md-primary.register-button(ng-disabled='!delegateRegistrationForm.$valid || loading', type='submit') {{ loading ? 'Registering...' : 'Register' }}
6 changes: 3 additions & 3 deletions src/components/header/header.pug
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
md-content.header(layout='row', layout-align='center center', layout-padding)
img.logo(src=require('../../assets/images/LISK-nano.png'))
div(flex)
md-button.md-raised.md-primary.send-button.offline-hide(data-show-send-modal, ng-if='$root.logged' ng-disabled='!$root.peers.online') Send
md-button.md-raised.md-primary.send-button.offline-hide(data-open-dialog='send', ng-if='$root.logged' ng-disabled='!$root.peers.online') Send
md-button.md-raised.md-secondary.logout-button(ng-click='$root.logout()', ng-if='$root.logged') Logout
md-menu.top-menu.offline-hide(ng-if='$root.logged', md-position-mode='target-right target', md-offset='14 0')
md-button.md-icon-button(ng-click='$mdOpenMenu()')
i.material-icons more_vert
md-menu-content(width='2')
md-menu-item(ng-if='$root.logged && !$ctrl.account.get().secondSignature')
md-button.register-second-passphrase(data-set-second-pass)
md-button.register-second-passphrase(data-open-dialog='set-second-pass')
div(layout='row', flex='')
p(flex='') Register second passphrase
md-menu-item(ng-if='$root.logged && !$ctrl.account.get().isDelegate')
md-button.register-as-delegate(data-delegate-registration)
md-button.register-as-delegate(data-open-dialog='delegate-registration')
div(layout='row', flex='')
p(flex='') Register as delegate
md-menu-item
Expand Down
9 changes: 4 additions & 5 deletions src/components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ app.component('login', {
this.$scope.customFullscreen = wantsFullScreen === true;
});

this.$scope.$on('onAfterSignup', (ev, args) => {
if (args.target === 'primary-pass') {
this.passConfirmSubmit(args.passphrase);
}
});
this.$scope.onSave = (primaryPass) => {
this.passConfirmSubmit(primaryPass);
};

this.$scope.$on('onSignupCancel', () => {
this.generatingNewPassphrase = false;
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/login/login.pug
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ md-card
// md-button(ng-disabled='$ctrl.generatingNewPassphrase', ng-click='$ctrl.devTestAccount()') Dev Test Account
md-button.md-primary.new-account-button(ng-disabled='$ctrl.random || $ctrl.generatingNewPassphrase', ng-click='$ctrl.generatePassphrase()') NEW ACCOUNT
md-button.md-raised.md-primary.login-button(md-autofocus, ng-disabled='($ctrl.valid != undefined && $ctrl.valid !== 1) || $root.loggingIn', type='submit') Login
passphrase(ng-if='$ctrl.generatingNewPassphrase', data-on-login='$ctrl.onLogin', data-target='primary-pass', data-ok-button-label='Login')
passphrase(ng-if='$ctrl.generatingNewPassphrase', data-on-save='onSave', data-target='primary-pass', data-ok-button-label='Login')
3 changes: 1 addition & 2 deletions src/components/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ app.component('main', {
*/
controller: class main {
constructor($scope, $rootScope, $timeout, $q, $state, Peers,
dialog, SendModal, Account, AccountApi, Notification) {
dialog, Account, AccountApi, Notification) {
this.$scope = $scope;
this.$rootScope = $rootScope;
this.$timeout = $timeout;
this.$q = $q;
this.peers = Peers;
this.dialog = dialog;
this.transferModal = SendModal;
this.$state = $state;
this.account = Account;
this.accountApi = AccountApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@ import './secondPass.less';
* The directive to show the second passphrase form and register it using AccountApi
*
* @module app
* @submodule setSecondPass
* @submodule SetSecondPassCtrl
*/
app.directive('setSecondPass', (setSecondPass, Account, $rootScope, dialog, AccountApi) => {
/* eslint no-param-reassign: ["error", { "props": false }] */
const SetSecondPassLink = function (scope, element) {
element.bind('click', () => {
setSecondPass.show();
});

app.component('setSecondPass', {
template: require('./secondPass.pug')(),
controller($scope, Account, $rootScope, dialog, AccountApi) {
/**
* We call this after second passphrase is generated.
* Shows an alert with appropriate message in case the request fails.
*
* @param {String} secondSecret - The validated passphrase to register as second secret
*/
scope.passConfirmSubmit = (secondSecret) => {
$scope.passConfirmSubmit = (secondSecret) => {
AccountApi.setSecondSecret(secondSecret, Account.get().publicKey, Account.get().passphrase)
.then(() => {
dialog.successAlert({
Expand All @@ -39,17 +35,9 @@ app.directive('setSecondPass', (setSecondPass, Account, $rootScope, dialog, Acco
});
};

/**
* @todo Why we're listening for onAfterSignup here?
*/
scope.$on('onAfterSignup', (ev, args) => {
if (args.target === 'second-pass') {
scope.passConfirmSubmit(args.passphrase);
}
});
};
return {
restrict: 'A',
link: SetSecondPassLink,
};
$scope.onSave = (secondPass) => {
$scope.passConfirmSubmit(secondPass);
};
},
// controllerAs: 'md',
});
4 changes: 2 additions & 2 deletions src/components/main/secondPass.pug
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
md-dialog.dialog-second(aria-label='Generate a second passphrase for your account')
div.dialog-second(aria-label='Generate a second passphrase for your account')
form
md-toolbar
.md-toolbar-tools
h2 Generate a second passphrase of your account
passphrase(data-on-login='md.onLogin', data-target='second-pass', data-ok-button-label='Register')
passphrase(data-on-save='onSave', data-target='second-pass', data-ok-button-label='Register')
33 changes: 0 additions & 33 deletions src/components/main/setSecondPassService.js

This file was deleted.

17 changes: 17 additions & 0 deletions src/components/openDialog/openDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* a directive to use dialog.modal as a directive
*/
app.directive('openDialog', (dialog) => {
const linkFunc = ($scope, $element) => {
$element.bind('click', () => {
dialog.modal($scope.openDialog, $scope.options);
});
};
return {
scope: {
options: '=',
openDialog: '@',
},
link: linkFunc,
};
});
24 changes: 6 additions & 18 deletions src/components/passphrase/passphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,12 @@ app.directive('passphrase', ($rootScope, $document, Passphrase, dialog, $mdMedia
*/
const generateAndDoubleCheck = (seed) => {
const passphrase = Passphrase.generatePassPhrase(seed);
const label = 'Save';

dialog.modal({
controllerAs: '$ctrl',
controller: /* @ngInject*/ class save {
// eslint-disable-next-line no-shadow
constructor(passphrase, okButtonLabel) {
this.passphrase = passphrase;
this.okButtonLabel = okButtonLabel;
}
},
template: '<save-passphrase ' +
'passphrase="$ctrl.passphrase" ' +
'ok-button-label="$ctrl.okButtonLabel">' +
'</save-passphrase>',
locals: {
passphrase,
okButtonLabel: attrs.okButtonLabel,
},
dialog.modal('save-passphrase', {
passphrase,
label,
'on-save': scope.onSave,
}).then(() => {
$timeout(() => {
$rootScope.$broadcast('onAfterSignup', {
Expand Down Expand Up @@ -86,7 +74,7 @@ app.directive('passphrase', ($rootScope, $document, Passphrase, dialog, $mdMedia
link: PassphraseLink,
restrict: 'E',
scope: {
onLogin: '=',
onSave: '=',
},
template: require('./passphrase.pug')(),
};
Expand Down
4 changes: 3 additions & 1 deletion src/components/passphrase/savePassphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ app.component('savePassphrase', {
template: require('./savePassphrase.pug')(),
bindings: {
passphrase: '<',
okButtonLabel: '<',
label: '<',
onSave: '=',
},
controller: class savePassphrase {
constructor($scope, $rootScope, $mdDialog) {
Expand All @@ -31,6 +32,7 @@ app.component('savePassphrase', {

ok() {
this.$mdDialog.hide();
this.onSave(this.passphrase);
}

back() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/passphrase/savePassphrase.pug
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ form(ng-if='$ctrl.step === 2')
md-dialog-actions(layout='row')
md-button.back-button(ng-click="$ctrl.back()") Back
span(flex)
md-button.md-raised.md-primary.ok-button(ng-click="$ctrl.ok()", ng-disabled='!$ctrl.missing_ok', ng-bind='$ctrl.okButtonLabel')
md-button.md-raised.md-primary.ok-button(ng-click="$ctrl.ok()", ng-disabled='!$ctrl.missing_ok', ng-bind='$ctrl.label')
32 changes: 0 additions & 32 deletions src/components/send/sendModalDirective.js

This file was deleted.

Loading