Skip to content

Commit

Permalink
Merge pull request #121 from Ahmad-AbuOsbeh/cost-to-redeem-fix
Browse files Browse the repository at this point in the history
allow  zero cost  to redeem per item
  • Loading branch information
charkhaw authored Aug 30, 2023
2 parents 4daa373 + 0a9eeae commit f90b8c7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions control/content/controllers/content.reward.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@
if(!ContentReward.item.title || ContentReward.item.title.length == 0) {
ContentReward.validations.title = true;
}
if ((!ContentReward.item.pointsToRedeem || ContentReward.item.pointsToRedeem.length == 0) &&
if (((!ContentReward.item.pointsToRedeem && ContentReward.item.pointsToRedeem !== 0) || ContentReward.item.pointsToRedeem.length == 0) &&
(!ContentReward.item.pointsPerItem || ContentReward.item.pointsPerItem.length == 0) ){
ContentReward.validations.points = true;
}
if (!ContentReward.validations.title && !ContentReward.validations.points){
// "Hack" for overcoming pointsToRedeem validation if the item can only be bought but not redeemed
if(ContentReward.item.pointsPerItem && ContentReward.item.pointsPerItem.length > 0
&&
(!ContentReward.item.pointsToRedeem || ContentReward.item.pointsToRedeem.length === 0 || ContentReward.item.pointsToRedeem === '38762499627')) {
((!ContentReward.item.pointsToRedeem && ContentReward.item.pointsToRedeem !== 0) || ContentReward.item.pointsToRedeem.length === 0 || ContentReward.item.pointsToRedeem === '38762499627')) {
ContentReward.item.pointsToRedeem = '38762499627'
}
ContentReward.addReward(JSON.parse(angular.toJson(ContentReward.item)));
Expand Down Expand Up @@ -253,7 +253,7 @@
/*validate the required fields whether its there or not */
ContentReward.isValidReward = function (reward) {
if (reward)
return (reward.title && reward.pointsToRedeem);
return (reward.title && (reward.pointsToRedeem || reward.pointsToRedeem === 0));
};

/*This method is used to get the rewards details*/
Expand Down
4 changes: 2 additions & 2 deletions control/content/templates/reward.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1>Item Details</h1>
<span class="tip btn-info-icon btn-primary"><span class="cp-tooltip">If this field is blank, then “Points per Item” cannot be blank. If this field has a value greater than zero, then this item will show up as a reward to redeem on the Loyalty feature’s main screen</span>
</div>
<div class="main col-md-9 pull-right">
<input ng-if="ContentReward.item.pointsToRedeem != '38762499627'" type="number" class="form-control" ng-model = "ContentReward.item.pointsToRedeem">
<input ng-if="ContentReward.item.pointsToRedeem != '38762499627'" type="number" min="0" class="form-control" ng-model = "ContentReward.item.pointsToRedeem">
<input ng-if="ContentReward.loading && ContentReward.item.pointsToRedeem == '38762499627'" type="number" class="form-control" >
</div>
</div>
Expand Down Expand Up @@ -73,7 +73,7 @@ <h1>Item Details</h1>
<div class="main col-md-9 pull-right" style="margin-right: 1px; margin-top: 5px;">
<div class="col-md-6 pull-right padding-right-zero padding-left-ten">
<a class="btn btn-success pull-right btn-save"
ng-disabled="ContentReward.loading || ContentReward.item.listImage == ''|| ContentReward.item.pointsPerItem=='' || ContentReward.item.pointsToRedeem=='' || ContentReward.item.title == ''"
ng-disabled="ContentReward.loading || ContentReward.item.listImage == ''|| ContentReward.item.pointsPerItem=='' || ((ContentReward.item.pointsToRedeem=='' || !ContentReward.item.pointsToRedeem) && ContentReward.item.pointsToRedeem !== 0) || ContentReward.item.title == ''"
ng-click="ContentReward.addingReward()">
Save
</a>
Expand Down
2 changes: 1 addition & 1 deletion widget/controllers/widget.item.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
if (item && item.description) {
WidgetItem.reward.description = item.description;
}
if (item && item.pointsToRedeem) {
if (item && (item.pointsToRedeem || item.pointsToRedeem === 0)) {
WidgetItem.reward.pointsToRedeem = item.pointsToRedeem;
}
});
Expand Down
2 changes: 1 addition & 1 deletion widget/controllers/widget.redeem.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
if (item && item.description) {
WidgetRedeem.reward.description = item.description;
}
if (item && item.pointsToRedeem) {
if (item && (item.pointsToRedeem || item.pointsToRedeem === 0)) {
WidgetRedeem.reward.pointsToRedeem = item.pointsToRedeem;
}
});
Expand Down
2 changes: 1 addition & 1 deletion widget/controllers/widget.success.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
if (item && item.description) {
WidgetSuccess.reward.description = item.description;
}
if (item && item.pointsToRedeem) {
if (item && (item.pointsToRedeem || item.pointsToRedeem === 0)) {
WidgetSuccess.reward.pointsToRedeem = item.pointsToRedeem;
}
});
Expand Down
2 changes: 1 addition & 1 deletion widget/templates/Item_Details.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div>
<p class="redeem-title">{{WidgetItem.reward.title}}</p>

<label class="redeem-points" ng-if="WidgetItem.reward.pointsToRedeem">
<label class="redeem-points" ng-if="WidgetItem.reward.pointsToRedeem || WidgetItem.reward.pointsToRedeem === 0">
{{WidgetItem.reward.pointsToRedeem}} {{WidgetItem.strings["general.points"]}}</label>
<label class="redeem-points" ng-if="WidgetItem.reward.earnPoint">
{{WidgetItem.reward.earnPoint}} {{WidgetItem.strings["general.points"]}}</label>
Expand Down

0 comments on commit f90b8c7

Please sign in to comment.