Skip to content

Commit

Permalink
- Transfer : display option for comment only on mobile device
Browse files Browse the repository at this point in the history
- Currency: add "c" and "DU" time period
- Fix #44
  • Loading branch information
blavenie committed Jun 9, 2016
1 parent 32bf075 commit a8aad31
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 25 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
id="fr.duniter.cesium"
version="0.1.13"
version="0.1.14"
android-versionCode="2"
>
<name>Cesium</name>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cesium",
"version": "0.1.13",
"version": "0.1.14",
"description": "A webapp client for Duniter network",
"dependencies": {
"gulp": "^3.9.1",
Expand Down
4 changes: 3 additions & 1 deletion www/i18n/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@
"TIME": "Current time",
"POW_MIN": "Common difficulty",
"RULES_DIVIDER": "Rules",
"C_RULE": "c"
"C_RULE": "c",
"UD_RULE": "Universal dividend (formula)",
"SIG_QTY_RULE": "Required certifications"
}
},
"PEER": {
Expand Down
6 changes: 4 additions & 2 deletions www/i18n/locale-fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"LANGUAGE": "Langue",
"BTN_PICTURE_DELETE": "Supprimer",
"BTN_PICTURE_FAVORISE": "Principale",
"UNIVERSAL_DIVIDEND": "Dividende universel",
"UNIVERSAL_DIVIDEND": "Dividend universel",
"UD": "DU"
},
"SYSTEM": {
Expand Down Expand Up @@ -92,7 +92,9 @@
"TIME": "Heure de la blockchain",
"POW_MIN": "Niveau de difficulté",
"RULES_DIVIDER": "Règles",
"C_RULE": "c"
"C_RULE": "c",
"UD_RULE": "Dividend universel (formule)",
"SIG_QTY_RULE": "Certifications requises"
}
},
"PEER": {
Expand Down
8 changes: 8 additions & 0 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ angular.module('cesium', ['ionic', 'ngCordova', 'ionic-material', 'ngMessages',
};
})

.filter('formatPeriod', function() {
return function(input) {
if (!input) {return null;}
var duration = moment(0).startOf('minute').from(moment(parseInt(input)*1000), true);
return duration.split(" ").slice(-1)[0]; // keep only the last word (e.g. remove "un" "a"...)
};
})

.filter('abbreviate', function() {
return function(input) {
var unit = '', sepChars = ['-', '_', ' '], currency = input || '';
Expand Down
4 changes: 2 additions & 2 deletions www/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ angular.module("cesium.config", [])
"TIMEOUT": 4000,
"DEBUG": false,
"NATIVE_TRANSITION": false,
"VERSION": "0.1.13",
"BUILD_DATE": "2016-06-09T11:59:47.439Z"
"VERSION": "0.1.14",
"BUILD_DATE": "2016-06-09T12:48:28.564Z"
})

;
2 changes: 2 additions & 0 deletions www/js/controllers/currency-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ function CurrencyViewController($scope, $rootScope, $state, BMA, $q, UIUtils, $i
$scope.c = json.c;
$scope.baseUnit = json.currency;
$scope.unit = json.currency;
$scope.dt = json.dt;
$scope.sigQty = json.sigQty;
}),

// Get the current block informations
Expand Down
11 changes: 9 additions & 2 deletions www/js/controllers/transfer-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ function TransferModalController($scope, $rootScope, $ionicModal, $state, BMA, W
$scope.$watch('formData.useRelative', $scope.onUseRelativeChanged, true);
$scope.$watch('walletData.balance', $scope.onUseRelativeChanged, true);

// When changing use comment
$scope.onUseCommentChanged = function() {
if (!$scope.formData.useComment) {
$scope.formData.comment = null; // reset comment only when disable
}
}
$scope.$watch('formData.useComment', $scope.onUseCommentChanged, true);

$scope.openWotLookup = function() {
$scope.lookupModal.show();
};
Expand All @@ -204,8 +212,7 @@ function TransferModalController($scope, $rootScope, $ionicModal, $state, BMA, W
amount = $scope.walletData.currentUD *
amount.replace(new RegExp('[.,]'), '.');
}
var comment = $scope.formData.useComment ? $scope.formData.comment : null;
Wallet.transfer($scope.formData.destPub, amount, comment)
Wallet.transfer($scope.formData.destPub, amount, $scope.formData.comment)
.then(function() {
var callback = $scope.formData.callback;
$scope.formData = {}; // Reset form data
Expand Down
22 changes: 14 additions & 8 deletions www/templates/currency/tabs/view_parameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
<a class="item item-icon-left" ui-sref="app.currency_ud">
<i class="icon ion-load-c"></i>
<span translate>CURRENCY.VIEW.UD</span>
<span class="badge badge-royal">{{UD | formatInteger}} {{unit | abbreviate}}<sub>{{udUnit | abbreviate}}</span>
<span class="badge badge-royal">{{UD | formatInteger}} {{unit | abbreviate}}<sub>{{udUnit | abbreviate}}</sub>&nbsp;/&nbsp;{{dt | formatPeriod}}</span>
</a>

<a class="item item-icon-left" href="#">
<i class="icon ion-arrow-graph-up-right"></i>
<span translate>CURRENCY.VIEW.C_ACTUAL</span>
<span class="badge badge-stable">{{cactual | formatInteger}} %</span>
<span class="badge badge-stable">{{cactual | formatInteger}}%&nbsp;/&nbsp;{{dt | formatPeriod}}</span>
</a>

<div class="item item-toggle dark">
Expand Down Expand Up @@ -79,15 +79,21 @@
<span translate>CURRENCY.VIEW.RULES_DIVIDER</span>
</div>

<a class="item item-icon-left" href="#">
<ion-item class="item item-icon-left">
<i class="icon ion-arrow-graph-up-right"></i>
<span translate>CURRENCY.VIEW.C_RULE</span>
<span class="badge badge-stable">{{c*100 | formatInteger}}%</span>
</a>
<span class="badge badge-stable">{{c*100 | formatInteger}}%&nbsp;/&nbsp;{{dt | formatPeriod}}</span>
</ion-item>

<a class="item item-icon-left" href="#">
<ion-item class="item item-icon-left">
<i class="icon ion-load-c"></i>
<span translate>CURRENCY.VIEW.UD</span>
<span translate>CURRENCY.VIEW.UD_RULE</span>
<span class="item-note">MAX(UD<sub>t-1</sub>, c*M/N)</span>
</a>
</ion-item>

<ion-item class="item-icon-left">
<i class="icon ion-ribbon-b"></i>
<span translate>CURRENCY.VIEW.SIG_QTY_RULE</span>
<span class="badge badge-stable">{{sigQty}}</span>
</ion-item>
</div>
26 changes: 18 additions & 8 deletions www/templates/wallet/transfer_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
ng-class="{'badge-assertive': (convertedBalance <= 0 || (formData.amount && convertedBalance < formData.amount)), 'badge-balanced': (convertedBalance > 0 && (!formData.amount || convertedBalance >= formData.amount)) }">
<ion-spinner icon="android" ng-if="!walletData.pubkey"></ion-spinner>
<span ng-if="walletData.pubkey && !walletData.isMember">
{{walletData.pubkey| formatPubkey}}&nbsp;/&nbsp;
{{walletData.pubkey| formatPubkey}}&nbsp;(&nbsp;
</span>
<span ng-if="walletData.isMember">
{{walletData.uid}}&nbsp;/&nbsp;
{{walletData.uid}}&nbsp;(&nbsp;
</span>
<span ng-if="walletData.pubkey && !formData.useRelative">{{convertedBalance | formatInteger}} {{unit | abbreviate}}</span>
<span ng-if="walletData.pubkey && formData.useRelative">{{convertedBalance | formatDecimal}} {{'COMMON.UD' | translate}}<sub>{{unit | abbreviate}}</sub></span>
&nbsp;)
</span>
</span>

Expand All @@ -42,7 +43,7 @@
<span class="input-label">{{'TRANSFER.AMOUNT' | translate}} ({{'COMMON.UD' | translate}}<sub>{{unit | abbreviate}}</sub>)</span>
<input type="text" name="amount" placeholder="{{'TRANSFER.AMOUNT_HELP' | translate}} ({{'COMMON.UD' | translate}} {{unit | abbreviate}})" ng-model="formData.amount"
required>
<i class="icon ion-android-more-vertical"ng-click="unitPopover.show($event)" >
<i class="gray icon ion-android-more-vertical"ng-click="unitPopover.show($event)" >
</i>
</div>
<div class="form-errors"
Expand All @@ -54,7 +55,7 @@
</div>

<!-- Enable comment ? -->
<div class="item item-content item-toggle dark">
<div class="item item-content item-toggle dark visible-xs visible-sm">
<span class="input-label gray">{{'TRANSFER.BTN_ADD_COMMENT' | translate}}</span>
<label class="toggle toggle-royal">
<input type="checkbox" ng-model="formData.useComment">
Expand All @@ -65,17 +66,26 @@
</div>

<!-- Comment -->
<label class="item item-input item-floating-label"
<label class="item item-input item-floating-label hidden-xs hidden-sm"
ng-class="{'item-input-error': transferForm.$submitted && transferForm.comment.$invalid}">
<span class="input-label">{{'TRANSFER.COMMENT' | translate}}</span>
<textarea placeholder="{{'TRANSFER.COMMENT_HELP' | translate}}"
name="comment"
ng-model="formData.comment"
ng-maxlength="255"
ng-pattern="commentPattern">
</textarea>
</label>
<label class="item item-input item-floating-label visible-xs visible-sm"
ng-if="formData.useComment"
ng-class="{'item-input-error': transferForm.$submitted && transferForm.comment.$invalid}">
<span class="input-label">{{'TRANSFER.COMMENT' | translate}}</span>
<textarea placeholder="{{'TRANSFER.COMMENT_HELP' | translate}}"
name="comment"
ng-model="formData.comment"
ng-maxlength="255"
ng-pattern="commentPattern"
>
</textarea>
ng-pattern="commentPattern">
</textarea>
</label>
<div class="form-errors"
ng-show="transferForm.$submitted && transferForm.comment.$error"
Expand Down

0 comments on commit a8aad31

Please sign in to comment.