Skip to content

Commit e15698e

Browse files
author
matograine
committed
create modal controller for certification checklist
1 parent 8be3dab commit e15698e

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

www/js/controllers/wot-controllers.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ angular.module('cesium.wot.controllers', ['cesium.services'])
157157

158158
.controller('WotCertificationsViewCtrl', WotCertificationsViewController)
159159

160+
.controller('WotCertificationChecklistCtrl', WotCertificationChecklistController)
161+
160162
.controller('WotSelectPubkeyIdentityModalCtrl', WotSelectPubkeyIdentityModalController)
161163

162164
;
@@ -1429,6 +1431,77 @@ function WotCertificationsViewController($scope, $rootScope, $controller, csSett
14291431
};
14301432
}
14311433

1434+
/**
1435+
* Certification checklist controller
1436+
* @param $controller
1437+
*/
1438+
function WotCertificationChecklistController($scope, $controller, parameters){
1439+
1440+
// allow to display license
1441+
$controller('CurrencyViewCtrl', {$scope: $scope});
1442+
1443+
let answers_are_right = parameters.answers_are_right;
1444+
$scope.identity = parameters.identity;
1445+
1446+
$scope.prepare_cert_checklist = function() {
1447+
const original_cert_checklist = [
1448+
{
1449+
question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.WELL_KNOWN',
1450+
expected_answer: true,
1451+
answer: false
1452+
},
1453+
{
1454+
question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.REVOCATION',
1455+
expected_answer: true,
1456+
answer: false
1457+
},
1458+
{
1459+
question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.CONTACT',
1460+
expected_answer: true,
1461+
answer: false
1462+
},
1463+
{
1464+
question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.DOUBLE_IDENTITY',
1465+
expected_answer: false,
1466+
answer: false
1467+
},
1468+
{
1469+
question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.MASTER_ACCOUNT',
1470+
expected_answer: true,
1471+
answer: false
1472+
},
1473+
{
1474+
question: 'ACCOUNT.CERTIFICATION_MODAL.QUESTIONS.LICENSE',
1475+
expected_answer: true,
1476+
answer: false
1477+
},
1478+
];
1479+
1480+
// Fisher-Yates shuffle
1481+
function shuffle(array) {
1482+
for (let i = array.length - 1; i > 0; i--) {
1483+
let j = Math.floor(Math.random() * (i + 1)); // random index from 0 to i
1484+
let t = array[i]; array[i] = array[j]; array[j] = t
1485+
}
1486+
return array;
1487+
}
1488+
1489+
return shuffle(original_cert_checklist);
1490+
}
1491+
$scope.cert_checklist = $scope.prepare_cert_checklist();
1492+
1493+
$scope.verifyAnswers = function() {
1494+
$scope.cert_checklist.map( question => {
1495+
if (question.answer !== question.expected_answer) {
1496+
// TODO message should be changed.
1497+
answers_are_right.reject();
1498+
}
1499+
});
1500+
answers_are_right.resolve(true);
1501+
1502+
$scope.closeModal();
1503+
}
1504+
}
14321505

14331506
/**
14341507
* Select identities from a pubkey (useful when many self on the same pubkey)

www/js/services/modal-services.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ angular.module('cesium.modal.services', ['cesium.utils.services'])
232232
parameters);
233233
}
234234

235+
function showCertificationCheckList(parameters) {
236+
return ModalUtils.show('templates/wot/modal_certification_checklist.html','WotCertificationChecklistCtrl', parameters);
237+
}
238+
235239
function showSelectPubkeyIdentity(parameters) {
236240
return ModalUtils.show('templates/wot/modal_select_pubkey_identity.html', 'WotSelectPubkeyIdentityModalCtrl',
237241
parameters);
@@ -294,6 +298,7 @@ angular.module('cesium.modal.services', ['cesium.utils.services'])
294298
showHelp: showHelp,
295299
showAccountSecurity: showAccountSecurity,
296300
showLicense: showLicense,
301+
showCertificationCheckList: showCertificationCheckList,
297302
showSelectPubkeyIdentity: showSelectPubkeyIdentity,
298303
showSelectWallet: showSelectWallet,
299304
showPassword: showPassword

0 commit comments

Comments
 (0)