Skip to content

Commit

Permalink
feat(assets): add controller stub for the asset issuance form
Browse files Browse the repository at this point in the history
  • Loading branch information
beregovoy68 committed Oct 29, 2016
1 parent 16abbc6 commit 8e6cc03
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = function (grunt) {
'bower_components/ngclipboard/dist/ngclipboard.js',
'bower_components/growl/javascripts/jquery.growl.js',
'bower_components/jquery-validation/dist/jquery.validate.js',
'bower_components/tooltipster/js/jquery.tooltipster.min.js',
'bower_components/waves-angular-validate/src/angular-validate.js',

'src/js/vendor/jquery.modal.js',
Expand Down Expand Up @@ -140,6 +141,9 @@ module.exports = function (grunt) {
'src/js/wallet/wallet.box.component.js',
'src/js/wallet/wallet.controller.js',

'src/js/tokens/tokens.module.js',
'src/js/tokens/token.create.controller.js',

'src/js/history/history.module.js',
'src/js/history/history.controller.js',

Expand Down
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"angular-messages": "^1.5.8",
"angular-validation-match": "^1.9.0",
"angular-material": "^1.1.1",
"waves-angular-validate": "git@github.com:beregovoy68/angular-validate.git#^1.1.2"
"waves-angular-validate": "git@github.com:beregovoy68/angular-validate.git#^1.1.2",
"tooltipster": "^3.3.0"
},
"analytics": false
}
19 changes: 19 additions & 0 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var app = angular.module('app', [
'app.login',
'app.navigation',
'app.wallet',
'app.tokens',
'app.history',
'app.community'
]).config(AngularApplicationConfig).run(AngularApplicationRun);
Expand Down Expand Up @@ -89,6 +90,24 @@ function AngularApplicationRun(rest, coreConstants, notificationService, address
__mockValidateAddress = function (address) {
return addressService.validateDisplayAddress(address);
};

// setting tooltips
/*angular.element('.tooltip').tooltipster();
angular.element('.tooltip-1').tooltipster({
theme: 'tooltipster-theme1',
delay: 1000,
contentAsHTML: true,
debug: true
});
angular.element('.tooltip-2').tooltipster({
theme: 'tooltipster-theme2',
delay: 1000
});
angular.element('.tooltip-3').tooltipster({
theme: 'tooltipster-theme3',
delay: 1000,
contentAsHTML: true
});*/
}

AngularApplicationRun.$inject = ['Restangular', 'constants.core', 'notificationService', 'addressService'];
Expand Down
76 changes: 76 additions & 0 deletions src/js/tokens/token.create.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
(function () {
'use strict';

var ASSET_DESCRIPTION_MAX = 1000;
var ASSET_NAME_MIN = 4;
var ASSET_NAME_MAX = 16;
var TOKEN_DECIMALS_MAX = 8;

angular
.module('app.tokens')
.controller('tokenCreateController', ['$scope', 'constants.ui', 'dialogService', function ($scope, constants, dialogService) {
var transaction;
var ctrl = this;

ctrl.issuanceValidationOptions = {
rules: {
assetName: {
required: true,
minlength: ASSET_NAME_MIN,
maxlength: ASSET_NAME_MAX
},
assetDescription: {
maxlength: ASSET_DESCRIPTION_MAX
},
assetTotalTokens: {
required: true,
min: 0,
max: constants.JAVA_MAX_LONG
},
assetTokenDecimalPlaces: {
required: true,
min: 0,
max: TOKEN_DECIMALS_MAX
}
},
messages: {
assetName: {
required: 'Asset name is required',
minlength: 'Asset name minimum length must be ' + ASSET_NAME_MIN + ' characters',
maxlength: 'Asset name maximum length must be ' + ASSET_NAME_MAX + ' characters'
},
assetDescription: {
maxlength: 'Maximum length of asset description must be less than ' + ASSET_DESCRIPTION_MAX +
' characters'
},
assetTotalTokens: {
required: 'Total amount of issued tokens in required',
min: 'Total issued tokens amount must be greater than or equal to zero',
max: 'Total issued tokens amount must be less than ' + constants.JAVA_MAX_LONG
},
assetTokenDecimalPlaces: {
required: 'Number of token decimal places is required',
min: 'Number of token decimal places must be greater or equal to zero',
max: 'Number of token decimal places must be less than or equal to ' + TOKEN_DECIMALS_MAX
}
}
};
ctrl.confirm = {
pendingIssuance: false
};
ctrl.broadcastIssueTransaction = broadcastIssueTransaction;
ctrl.assetIssueConfirmation = assetIssueConfirmation;

function assetIssueConfirmation(form) {
if (!form.validate())
return;

//to the stuff
dialogService.open('#create-asset-confirmation');
}

function broadcastIssueTransaction() {
console.log('broadcast');
}
}]);
})();
5 changes: 5 additions & 0 deletions src/js/tokens/tokens.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(function() {
'use strict';

angular.module('app.tokens', ['app.shared']);
})();
4 changes: 2 additions & 2 deletions src/js/wallet/wallet.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@
return angular.element('#send-waves-form').scope().sendWavesForm;
}

function submitPayment() {
function submitPayment(paymentForm) {
// here we have a direct markup dependency
var paymentForm = getPaymentForm();
//var paymentForm = getPaymentForm();
wallet.transfer.fee.isValid = angular.isDefined(paymentForm.invalid.wavessendfee) ?
paymentForm.invalid.wavessendfee : true;
if (!paymentForm.validate())
Expand Down
18 changes: 13 additions & 5 deletions src/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ <h2>ACCOUNT INFO BACKUP</h2>
<section id="mBBody" class="fFade" ng-switch on="nav.currentTab">
<!-- WALLET TAB -->
<div id="mBB-wallet" class="mBB-content" ng-switch-when="wallet" ng-controller="walletController as wallet">
<div id="wB-butSend-WAV" waves-dialog ok-button-caption="SUBMIT" cancel-button-visible="false" on-dialog-ok="wallet.submitPayment()">
<div id="wB-butSend-WAV" waves-dialog ok-button-caption="SUBMIT" cancel-button-visible="false" on-dialog-ok="wallet.submitPayment({paymentForm: sendWavesForm})">
<form id="send-waves-form" name="sendWavesForm" class="paymentForm" novalidate ng-validate="wallet.paymentValidationOptions">
<h2>SEND PAYMENT</h2>
<div class="balanceAmt">
Expand Down Expand Up @@ -515,10 +515,10 @@ <h1>DECENTRALIZED VOTING</h1>
<!-- TOKENS TAB -->
<div id="mBB-token" class="mBB-content" ng-switch-when="tokens">

<div>
<div ng-controller="tokenCreateController as ctrl">
<h1>ASSET CREATION</h1>
<br/>
<form name="createAssetForm">
<form id="create-asset-form" name="createAssetForm" novalidate ng-validate="ctrl.issuanceValidationOptions" ng-submit="ctrl.assetIssueConfirmation(createAssetForm)">
<table>
<thead>
<tr>
Expand All @@ -529,7 +529,7 @@ <h1>ASSET CREATION</h1>
<tbody>
<tr>
<td><label for="assetName">Asset's name</label></td>
<td><input id="assetName" name="assetName" type="text" class="wInput form-control"/></td>
<td><input id="assetName" name="assetName" type="text" class="wInput form-control" focus-me="true"/></td>
</tr>
<tr>
<td><label for="assetDescription">Asset's description</label></td>
Expand Down Expand Up @@ -557,8 +557,13 @@ <h1>ASSET CREATION</h1>
<button type="submit">SUBMIT</button>
</div>
</form>
</div>

<div id="create-asset-confirmation" waves-dialog ok-button-caption="CONFIRM" ok-button-enabled="!ctrl.confirm.pendingIssuance" on-dialog-ok="ctrl.broadcastIssueTransaction()">
<p>You are creating asset...
</p>
<p>Please <span class="fontBold"> CONFIRM </span>to execute or <span class="fontBold"> CANCEL </span> to discard.</p>
</div>
</div>
</div>
<!-- / TOKENS TAB -->

Expand Down Expand Up @@ -713,6 +718,9 @@ <h2>LATEST BLOCKS INFORMATION</h2>
<script src="js/wallet/wallet.box.component.js"></script>
<script src="js/wallet/wallet.controller.js"></script>

<script src="js/tokens/tokens.module.js"></script>
<script src="js/tokens/token.create.controller.js"></script>

<script src="js/history/history.module.js"></script>
<script src="js/history/history.controller.js"></script>

Expand Down

0 comments on commit 8e6cc03

Please sign in to comment.