Skip to content

Commit

Permalink
Merge pull request #48 from ahmadfh/master
Browse files Browse the repository at this point in the history
Now currency section is dynamic
  • Loading branch information
mkuhnsbuildfire authored Jun 1, 2017
2 parents 46bf41a + 7683673 commit 5362267
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
27 changes: 23 additions & 4 deletions control/settings/controllers/settings.home.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
symbol:"ZAR"
}];


SettingsHome.newCurrency = [];

var _data = {
"settings":{
currency:""
Expand All @@ -67,10 +70,19 @@
if(err)
console.error('Error while getting data', err);
else {
SettingsHome.data = data.data;
$scope.$apply();
updateMasterItem(SettingsHome.data);
if (tmrDelay)clearTimeout(tmrDelay);
buildfire.datastore.get(TAG_NAMES.NEW_CURRENCY,function(err,currencyData){
if(err)
console.error('Error while getting data', err);
else {
if(currencyData.data && currencyData.data.length > 0)
SettingsHome.newCurrency = currencyData.data;

SettingsHome.data = data.data;
$scope.$apply();
updateMasterItem(SettingsHome.data);
if (tmrDelay)clearTimeout(tmrDelay);
}
});
}
});
};
Expand Down Expand Up @@ -115,6 +127,13 @@
return SettingsHome.data;
}, SettingsHome.saveDataWithDelay, true);

SettingsHome.addNewCurrency = function () {
SettingsHome.newCurrency.push(SettingsHome.newSymbol);
SettingsHome.changeCurrency(SettingsHome.newSymbol);
SettingsHome.newSymbol = {};
SettingsHome.saveData(SettingsHome.newCurrency,TAG_NAMES.NEW_CURRENCY);
};

init();


Expand Down
3 changes: 2 additions & 1 deletion control/settings/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
(function (angular) {
angular.module('loyaltyPluginSettings')
.constant('TAG_NAMES', {
LOYALTY_INFO: 'loyaltyInfo'
LOYALTY_INFO: 'loyaltyInfo',
NEW_CURRENCY: 'newCurrency'
});
})(window.angular);
15 changes: 15 additions & 0 deletions control/settings/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
<li ng-repeat="currency in SettingsHome.currency">
<a tabindex="-1" class="transition-third" ng-click="SettingsHome.changeCurrency(currency)"><span ng-bind-html="SettingsHome.convertHtml(currency.symbol)"></span>&nbsp;&nbsp;&nbsp;&nbsp;{{currency.name}}</a>
</li>
<li ng-repeat="currency in SettingsHome.newCurrency">
<a tabindex="-1" class="transition-third" ng-click="SettingsHome.changeCurrency(currency)"><span ng-bind-html="SettingsHome.convertHtml(currency.symbol)"></span>&nbsp;&nbsp;&nbsp;&nbsp;{{currency.name}}</a>
</li>
<li onclick="event.stopPropagation();">
<div class="input-group">
<input type="text" ng-model="SettingsHome.newSymbol.symbol" class="form-control" placeholder="Sybmol" />
<span class = "input-group-addon">-</span>
<input type="text" ng-model="SettingsHome.newSymbol.name" class="form-control" placeholder="Name" />
<span class="input-group-btn">
<button class="btn btn-primary" ng-click="SettingsHome.addNewCurrency()" type="button">
Add
</button>
</span>
</div>
</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit 5362267

Please sign in to comment.