Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCW-2785 Add pop up for navigating from empty offer screen #498

Merged
merged 2 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this Pr: this "cancelByMe" feels wrong to me

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