Skip to content

Commit

Permalink
Merge pull request #498 from crossroads/GCW-2785-admin-offer-creation
Browse files Browse the repository at this point in the history
GCW-2785 Add pop up for navigating from empty offer screen
  • Loading branch information
bharat619 authored Mar 4, 2021
2 parents 8363e1b + 1892744 commit b313600
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
40 changes: 31 additions & 9 deletions app/controllers/review_offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ export default Ember.Controller.extend(AsyncTasksMixin, {
}
}),

deleteOffer(offer, path = this.get("backLinkPath")) {
this.set("cancelByMe", true);
this.runTask(offer.destroyRecord())
.then(() => this.transitionToRoute(path))
.catch(error => {
offer.rollbackAttributes();
throw error;
})
.finally(() => this.set("cancelByMe", false));
},

actions: {
toggleOfferOptions() {
this.toggleProperty("displayOfferOptions");
Expand Down Expand Up @@ -133,25 +144,36 @@ export default Ember.Controller.extend(AsyncTasksMixin, {

deleteOffer() {
this.send("toggleOfferOptions");
var offer = this.get("model");
const offer = this.get("model");
this.get("messageBox").custom(
this.get("i18n").t("delete_confirm"),
this.get("i18n").t("review_offer.options.yes"),
() => {
this.set("cancelByMe", true);
this.runTask(offer.destroyRecord())
.then(() => this.transitionToRoute(this.get("backLinkPath")))
.catch(error => {
offer.rollbackAttributes();
throw error;
})
.finally(() => this.set("cancelByMe", false));
this.deleteOffer(offer);
},
this.get("i18n").t("review_item.not_now"),
null
);
},

transitionTo(path) {
const offer = this.get("model");
const items = offer.get("items");
if (!items.length) {
this.get("messageBox").custom(
this.get("i18n").t("review_offer.empty_offer_message"),
this.get("i18n").t("review_offer.options.yes"),
() => {
this.deleteOffer(offer, path);
},
this.get("i18n").t("review_item.not_now"),
null
);
} else {
this.transitionToRoute(path);
}
},

reopenOffer() {
this.runTask(async () => {
await this.get("offerService").reopenOffer(this.get("model"));
Expand Down
2 changes: 2 additions & 0 deletions app/locales/en/translations.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ I18nTranslationsEn =
"close_offer_summary": "This will close the offer."
"add_note": "Tap to add/edit sticky note"
"tap_to_save": "tap to save"
"empty_offer_message": "This offer is empty. Do you want to delete it?"

"donor":
"offer_id": "Offer ID"
Expand Down Expand Up @@ -320,6 +321,7 @@ I18nTranslationsEn =
"assign": "Assign"
"select_package_image": "Choose the favourite image for this package:"


"reject":
"select_type": "Please choose Item Type first!"
"option_error": "Please choose a reason."
Expand Down
1 change: 1 addition & 0 deletions app/locales/zh-tw/translations.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ I18nTranslationsZhTw =
"close_offer_summary": "這項捐贈項目將列為完成。"
"add_note": "按下以增加/修改記事板"
"tap_to_save": "按下以儲存"
"empty_offer_message": "這個捐贈沒有任何相關物資。你是否需要刪除"

"donor":
"offer_id": "捐贈項目號碼"
Expand Down
2 changes: 1 addition & 1 deletion app/templates/review_offer.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<nav class="tab-bar offer_details_title non-draft">
<section class="left-small">
{{#link-to backLinkPath classNames="back"}}{{t "back"}}{{/link-to}}
<div class="back" {{action 'transitionTo' backLinkPath}}>{{t "back"}}</div>
</section>

<section class="middle tab-bar-section">
Expand Down

0 comments on commit b313600

Please sign in to comment.