From 689fe108afe3e34a9277a3a65c475894a8bb2854 Mon Sep 17 00:00:00 2001 From: yashar <darkyashi@gmail.com> Date: Fri, 9 Jun 2017 20:14:21 +0430 Subject: [PATCH 1/4] Remove 'input names' feature from Voting tab --- src/components/delegates/delegates.pug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/delegates/delegates.pug b/src/components/delegates/delegates.pug index 10d4f99b0..e623872fb 100644 --- a/src/components/delegates/delegates.pug +++ b/src/components/delegates/delegates.pug @@ -23,7 +23,7 @@ div.offline-hide i.material-icons.search-append(ng-click='$ctrl.clearSearch()', ng-if='search') close i.material-icons.search-append(ng-hide='search') search span.pull-right.right-action-buttons - md-button(ng-click='$ctrl.usernameListActive = true') + //md-button(ng-click='$ctrl.usernameListActive = true') i.material-icons list span Input Names md-menu.pull-right.right-action-buttons From e262112d6c311d39bcacc29c966c2761c1fd0755 Mon Sep 17 00:00:00 2001 From: yashar <darkyashi@gmail.com> Date: Mon, 12 Jun 2017 19:30:48 +0430 Subject: [PATCH 2/4] Remove 'input names' feature from Voting tab instead of comment it --- src/components/delegates/delegates.pug | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/delegates/delegates.pug b/src/components/delegates/delegates.pug index e623872fb..7adc3487b 100644 --- a/src/components/delegates/delegates.pug +++ b/src/components/delegates/delegates.pug @@ -23,9 +23,6 @@ div.offline-hide i.material-icons.search-append(ng-click='$ctrl.clearSearch()', ng-if='search') close i.material-icons.search-append(ng-hide='search') search span.pull-right.right-action-buttons - //md-button(ng-click='$ctrl.usernameListActive = true') - i.material-icons list - span Input Names md-menu.pull-right.right-action-buttons md-button.pull-right.my-votes-button(ng-click='$mdOpenMenu()', ng-disabled='$ctrl.votedList.length == 0') i.material-icons visibility From 4f9efb775a7b365d0aa73e1aa1c9a5dd372b774e Mon Sep 17 00:00:00 2001 From: yashar <darkyashi@gmail.com> Date: Mon, 12 Jun 2017 19:32:44 +0430 Subject: [PATCH 3/4] Remove 'input names' button functionality from delegates.js file --- src/components/delegates/delegates.js | 84 --------------------------- 1 file changed, 84 deletions(-) diff --git a/src/components/delegates/delegates.js b/src/components/delegates/delegates.js index fac85e8e4..d6563ccac 100644 --- a/src/components/delegates/delegates.js +++ b/src/components/delegates/delegates.js @@ -253,90 +253,6 @@ app.component('delegates', { }, UPDATE_INTERVAL); } - /** - * Needs summary - * - * @method parseVoteListFromInput - */ - parseVoteListFromInput() { - this._parseListFromInput('voteList'); - } - - /** - * Needs summary - * - * @method parseUnvoteListFromInput - */ - parseUnvoteListFromInput() { - this._parseListFromInput('unvoteList'); - } - - /** - * @private - */ - _parseListFromInput(listName) { - const list = this[listName]; - this.invalidUsernames = []; - this.pendingRequests = 0; - this.usernameList = this.usernameInput.trim().split(this.usernameSeparator); - this.usernameList.forEach((username) => { - if ((listName === 'voteList' && !this.votedDict[username.trim()]) || - (listName === 'unvoteList' && this.votedDict[username.trim()])) { - this._setSelected(username.trim(), list); - } - }); - - if (this.pendingRequests === 0) { - this._selectFinish(true, list); - } - } - - /** - * @private - */ - _selectFinish(success, list) { - if (list.length !== 0) { - this.usernameListActive = false; - this.usernameInput = ''; - this.openVoteDialog(); - } else { - this.dialog.errorToast('No delegate usernames could be parsed from the input'); - } - } - - /** - * @private - */ - _setSelected(username, list) { - const delegate = this.delegates.filter(d => d.username === username)[0]; - if (delegate) { - this._selectDelegate(delegate, list); - } else { - this.pendingRequests++; - this.delegateApi.getDelegate(username, - ).then((data) => { - this._selectDelegate(data.delegate, list); - }).catch(() => { - this.invalidUsernames.push(username); - }).finally(() => { - this.pendingRequests--; - if (this.pendingRequests === 0) { - this._selectFinish(this.invalidUsernames.length === 0, list); - } - }); - } - } - // eslint-disable-next-line class-methods-use-this - _selectDelegate(delegate, list) { - // eslint-disable-next-line no-param-reassign - delegate.status = delegate.status || {}; - // eslint-disable-next-line no-param-reassign - delegate.status.selected = true; - if (list.indexOf(delegate) === -1) { - list.push(delegate); - } - } - /** * Uses dialog.modal to show vote list directive. * From 4f5206a5c775f8e4c40884d09f2946a5deca133b Mon Sep 17 00:00:00 2001 From: yashar <darkyashi@gmail.com> Date: Mon, 12 Jun 2017 19:33:54 +0430 Subject: [PATCH 4/4] Remove 'input names' button testing from delegates.spec.js file --- test/components/delegates/delegates.spec.js | 79 --------------------- 1 file changed, 79 deletions(-) diff --git a/test/components/delegates/delegates.spec.js b/test/components/delegates/delegates.spec.js index fdec0cde3..555388731 100644 --- a/test/components/delegates/delegates.spec.js +++ b/test/components/delegates/delegates.spec.js @@ -303,83 +303,4 @@ describe('delegates component controller', () => { $scope.$apply(); }); }); - - describe('parseVoteListFromInput(list)', () => { - let delegateApiMock; - - beforeEach(() => { - delegateApiMock = sinon.mock(controller.delegateApi); - }); - - it('parses this.usernameInput to list of delegates and opens vote dialog if all delegates were immediately resolved', () => { - const spy = sinon.spy(controller, 'openVoteDialog'); - controller.usernameInput = 'genesis_20\ngenesis_42\ngenesis_46\n'; - controller.parseVoteListFromInput(controller.unvoteList); - expect(spy).to.have.been.calledWith(); - }); - - it('parses this.usernameInput to list of delegates and opens vote dialog if all delegates were resolved immediately or from server', () => { - const username = 'not_fetched_yet'; - const deffered = $q.defer(); - delegateApiMock.expects('getDelegate').withArgs(username).returns(deffered.promise); - const spy = sinon.spy(controller, 'openVoteDialog'); - controller.usernameInput = `${username}\ngenesis_42\ngenesis_46`; - - controller.parseVoteListFromInput(controller.unvoteList); - - deffered.resolve({ - success: true, - delegate: { - username, - }, - }); - $scope.$apply(); - expect(spy).to.have.been.calledWith(); - }); - - it('parses this.usernameInput to list of delegates and opens vote dialog if any delegates were resolved', () => { - const username = 'invalid_name'; - const deffered = $q.defer(); - delegateApiMock.expects('getDelegate').withArgs(username).returns(deffered.promise); - const spy = sinon.spy(controller, 'openVoteDialog'); - controller.usernameInput = `${username}\ngenesis_42\ngenesis_46`; - - controller.parseVoteListFromInput(controller.unvoteList); - - deffered.reject({ success: false }); - $scope.$apply(); - expect(spy).to.have.been.calledWith(); - }); - - it('parses this.usernameInput to list of delegates and shows error toast if no delegates were resolved', () => { - const username = 'invalid_name'; - const deffered = $q.defer(); - delegateApiMock.expects('getDelegate').withArgs(username).returns(deffered.promise); - const toastSpy = sinon.spy(controller.dialog, 'errorToast'); - const dialogSpy = sinon.spy(controller, 'openVoteDialog'); - controller.usernameInput = username; - controller.voteList = []; - - controller.parseVoteListFromInput(controller.unvoteList); - - deffered.reject({ success: false }); - $scope.$apply(); - expect(toastSpy).to.have.been.calledWith(); - expect(dialogSpy).to.not.have.been.calledWith(); - }); - }); - - describe('parseUnvoteListFromInput(list)', () => { - it('parses this.usernameInput to list of delegates and opens vote dialog if all delegates were immediately resolved', () => { - const delegate = { - username: 'genesis_20', - status: {}, - }; - const spy = sinon.spy(controller, 'openVoteDialog'); - controller.votedDict[delegate.username] = delegate; - controller.usernameInput = `${delegate.username}\ngenesis_42\ngenesis_46\n`; - controller.parseUnvoteListFromInput(controller.unvoteList); - expect(spy).to.have.been.calledWith(); - }); - }); });