Permalink
Browse files

feat(assets): add controller stub for the asset issuance form

  • Loading branch information...
1 parent 16abbc6 commit 8e6cc031d60b8f97880f18dc07acf4462453b22c @beregovoy68 beregovoy68 committed Oct 29, 2016
Showing with 121 additions and 8 deletions.
  1. +4 −0 Gruntfile.js
  2. +2 −1 bower.json
  3. +19 −0 src/js/app.js
  4. +76 −0 src/js/tokens/token.create.controller.js
  5. +5 −0 src/js/tokens/tokens.module.js
  6. +2 −2 src/js/wallet/wallet.controller.js
  7. +13 −5 src/main.html
View
@@ -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',
@@ -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',
View
@@ -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
}
View
@@ -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);
@@ -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'];
@@ -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');
+ }
+ }]);
+})();
@@ -0,0 +1,5 @@
+(function() {
+ 'use strict';
+
+ angular.module('app.tokens', ['app.shared']);
+})();
@@ -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())
View
@@ -336,7 +336,7 @@ <h2 id="AccHeader">{{accounts.caption}}</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">
@@ -515,10 +515,10 @@ <h2 id="AccHeader">{{accounts.caption}}</h2>
<!-- 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>
@@ -529,7 +529,7 @@ <h2 id="AccHeader">{{accounts.caption}}</h2>
<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>
@@ -557,8 +557,13 @@ <h2 id="AccHeader">{{accounts.caption}}</h2>
<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 -->
@@ -713,6 +718,9 @@ <h2 id="AccHeader">{{accounts.caption}}</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>

0 comments on commit 8e6cc03

Please sign in to comment.