From 5fe6299dc1e7251691d15dc100679f7cd78ed78a Mon Sep 17 00:00:00 2001 From: AbulAsar Sayyad Date: Wed, 27 Jan 2021 19:47:52 +0530 Subject: [PATCH 01/37] added inventory popup for received item --- app/components/receive-menu.js | 27 +++++++++++++++++++++++ app/locales/en/translations.coffee | 2 ++ app/locales/zh-tw/translations.coffee | 3 ++- app/templates/components/receive_menu.hbs | 13 +++++++---- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/app/components/receive-menu.js b/app/components/receive-menu.js index 15c96d95f..6e2750994 100644 --- a/app/components/receive-menu.js +++ b/app/components/receive-menu.js @@ -15,6 +15,14 @@ export default Ember.Component.extend(AsyncTasksMixin, { isReceived: Ember.computed.equal("package.state", "received"), isMissing: Ember.computed.equal("package.state", "missing"), + isReceivedWithoutInventory: Ember.computed( + "package", + "isReceived", + function() { + return this.get("isReceived") && !this.get("package.inventoryNumber"); + } + ), + allowLabelPrint: Ember.computed( "isReceived", "package.inventoryNumber", @@ -157,6 +165,25 @@ export default Ember.Component.extend(AsyncTasksMixin, { } }, + inventorizeReceivedItem() { + this.get("messageBox").confirm( + this.get("i18n").t("receive.inventorize_warning"), + () => this.send("assingInventoryNumber") + ); + }, + + async assingInventoryNumber() { + const pkg = this.get("package"); + this.runTask(async () => { + const inventoryNumber = await this.get( + "packageService" + ).generateInventoryNumber(); + pkg.set("inventoryNumber", inventoryNumber.inventory_number); + pkg.set("state", "received"); + await pkg.save(); + }, ERROR_STRATEGIES.MODAL); + }, + applyReceiving(event, allow_event = true) { if (!this.get("isFirstReceivingPackage") && allow_event) { return this.send(event); diff --git a/app/locales/en/translations.coffee b/app/locales/en/translations.coffee index 3411052d5..dd70dac9b 100644 --- a/app/locales/en/translations.coffee +++ b/app/locales/en/translations.coffee @@ -353,6 +353,8 @@ I18nTranslationsEn = "not_now": "Not Now" "begin_receiving": "Begin Receiving" + "inventorize_warning": "Are you sure you want to inventorize?" + "finished": "title": "Finished" "received": "Received" diff --git a/app/locales/zh-tw/translations.coffee b/app/locales/zh-tw/translations.coffee index 807a92f15..2a373fdf9 100644 --- a/app/locales/zh-tw/translations.coffee +++ b/app/locales/zh-tw/translations.coffee @@ -349,7 +349,8 @@ I18nTranslationsZhTw = "header": "開始接收捐贈項目" "cant_modify_note": "提示:一旦捐贈項目狀態改成「正在接收」,將無法還原,捐贈人士亦無法更改物資資料。" "not_now": "現在無法進行" - "begin_receiving": "開始接收" + "begin_receiving": "開始接收", + "inventorize_warning": "Are you sure you want to inventorize?" "finished": diff --git a/app/templates/components/receive_menu.hbs b/app/templates/components/receive_menu.hbs index eeff520c5..711e2a63f 100644 --- a/app/templates/components/receive_menu.hbs +++ b/app/templates/components/receive_menu.hbs @@ -42,11 +42,16 @@ {{t "receive.label"}} + {{else if isReceivedWithoutInventory}} +
+ + {{t "receive.inventory"}} +
{{else}} -
- - {{t "receive.inventory"}} -
+
+ + {{t "receive.inventory"}} +
{{/if}}
- {{offer-filter-checkbox name="showPriority"}} + {{offer-filter-checkbox name="priorityOffers"}} +
+
+
+
+ {{offer-filter-checkbox name="publishedOffers"}}

diff --git a/tests/acceptance/search-test.js b/tests/acceptance/search-test.js index 533389f66..d13f1d6ec 100644 --- a/tests/acceptance/search-test.js +++ b/tests/acceptance/search-test.js @@ -173,7 +173,7 @@ test("Checking multiple states checkboxes in State filter page applies number of assert.equal(currentURL(), "/offers_filters?applyStateFilter=true"); click("#submitted"); noOfSelectedStates += 1; - click("#showPriority"); + click("#priorityOffers"); noOfSelectedStates += 1; }); From 1173236705252687988772a97c87dc372bd0d4f6 Mon Sep 17 00:00:00 2001 From: shreyas098 Date: Wed, 3 Feb 2021 11:33:25 +0530 Subject: [PATCH 05/37] Refactor filter services --- app/services/filter-service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/filter-service.js b/app/services/filter-service.js index d0d2ebc40..73d38850e 100644 --- a/app/services/filter-service.js +++ b/app/services/filter-service.js @@ -51,7 +51,7 @@ export default Ember.Service.extend(Ember.Evented, { isPublished() { const filters = this.get("offerStateFilters"); - return filters && filters.indexOf(STATE_FILTERS.PUBLISHED) >= 0; + return _.includes(filters, STATE_FILTERS.PUBLISHED); }, clearOfferStateFilters() { From caac32db384aca89e93101b71f15c571fb38959f Mon Sep 17 00:00:00 2001 From: Patrick R Date: Thu, 11 Feb 2021 12:44:47 +0800 Subject: [PATCH 06/37] UPDATE: fastlane + shared.goodcity --- Gemfile.lock | 28 +++++++++++++++------------- yarn.lock | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 17444cba3..bbc259680 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,17 +17,17 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.1.0) - aws-partitions (1.417.0) - aws-sdk-core (3.111.2) + aws-partitions (1.426.0) + aws-sdk-core (3.112.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.41.0) - aws-sdk-core (~> 3, >= 3.109.0) + aws-sdk-kms (1.42.0) + aws-sdk-core (~> 3, >= 3.112.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.87.0) - aws-sdk-core (~> 3, >= 3.109.0) + aws-sdk-s3 (1.88.0) + aws-sdk-core (~> 3, >= 3.112.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) aws-sigv4 (1.2.2) @@ -88,7 +88,7 @@ GEM dotenv (2.7.6) emoji_regex (3.2.1) escape (0.0.4) - excon (0.78.1) + excon (0.79.0) faraday (1.3.0) faraday-net_http (~> 1.0) multipart-post (>= 1.2, < 3) @@ -99,8 +99,8 @@ GEM faraday-net_http (1.0.1) faraday_middleware (1.0.0) faraday (~> 1.0) - fastimage (2.2.1) - fastlane (2.172.0) + fastimage (2.2.2) + fastlane (2.174.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.3, < 3.0.0) artifactory (~> 3.0) @@ -148,7 +148,7 @@ GEM representable (~> 3.0) retriable (>= 2.0, < 4.0) signet (~> 0.12) - google-apis-core (0.2.0) + google-apis-core (0.2.1) addressable (~> 2.5, >= 2.5.1) googleauth (~> 0.14) httpclient (>= 2.8.1, < 3.0) @@ -157,9 +157,10 @@ GEM retriable (>= 2.0, < 4.0) rexml signet (~> 0.14) + webrick google-apis-iamcredentials_v1 (0.1.0) google-apis-core (~> 0.1) - google-apis-storage_v1 (0.1.0) + google-apis-storage_v1 (0.2.0) google-apis-core (~> 0.1) google-cloud-core (1.5.0) google-cloud-env (~> 1.0) @@ -175,7 +176,7 @@ GEM google-cloud-core (~> 1.2) googleauth (~> 0.9) mini_mime (~> 1.0) - googleauth (0.14.0) + googleauth (0.15.1) faraday (>= 0.17.3, < 2.0) jwt (>= 1.4, < 3.0) memoist (~> 0.16) @@ -223,7 +224,7 @@ GEM ruby2_keywords (0.0.4) rubyzip (2.3.0) security (0.1.3) - signet (0.14.0) + signet (0.14.1) addressable (~> 2.3) faraday (>= 0.17.3, < 2.0) jwt (>= 1.5, < 3.0) @@ -250,6 +251,7 @@ GEM unf_ext unf_ext (0.0.7.7) unicode-display_width (1.7.0) + webrick (1.7.0) word_wrap (1.0.0) xcodeproj (1.19.0) CFPropertyList (>= 2.3.3, < 4.0) diff --git a/yarn.lock b/yarn.lock index 6e0b071e1..02451a6f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13259,7 +13259,7 @@ sha@~2.0.1: "shared-goodcity@git://github.com/crossroads/shared.goodcity.git#master": version "0.0.0" - resolved "git://github.com/crossroads/shared.goodcity.git#a676df6f453bb8f390d8f90037c614c6d5bd45c5" + resolved "git://github.com/crossroads/shared.goodcity.git#65ab6a9e1cd8ef7ae233f2565ca442e0981e3044" dependencies: cryptiles "^4.1.2" ember-cli-babel "^5.1.6" From c095aa15b5438d5d092f0a17d74fdfc650e25ba5 Mon Sep 17 00:00:00 2001 From: shreyas098 Date: Thu, 11 Feb 2021 15:36:33 +0530 Subject: [PATCH 07/37] Changed the icon of published offers filter --- app/helpers/state-filter-icon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/state-filter-icon.js b/app/helpers/state-filter-icon.js index 35d8e4afc..83bc7d5b8 100644 --- a/app/helpers/state-filter-icon.js +++ b/app/helpers/state-filter-icon.js @@ -24,7 +24,7 @@ const STATE_ICONS = { [CANCELLED]: "thumbs-down", [INACTIVE]: "bed", [PRIORITY]: "warning", - [PUBLISHED]: "bed" + [PUBLISHED]: "eye" }; export default Ember.Helper.helper(function(state) { From b2cd5ba4892b112898df1d830bf1dfa5224dd5dc Mon Sep 17 00:00:00 2001 From: bharat619 Date: Mon, 15 Feb 2021 10:14:59 +0530 Subject: [PATCH 08/37] Update shared hash --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 02451a6f7..3f9d55aa0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13259,7 +13259,7 @@ sha@~2.0.1: "shared-goodcity@git://github.com/crossroads/shared.goodcity.git#master": version "0.0.0" - resolved "git://github.com/crossroads/shared.goodcity.git#65ab6a9e1cd8ef7ae233f2565ca442e0981e3044" + resolved "git://github.com/crossroads/shared.goodcity.git#bbf74d6c8ba19e671625dfb3d894be448d5801ed" dependencies: cryptiles "^4.1.2" ember-cli-babel "^5.1.6" From 26cabf71009c11bf41c45e1c18d58fc5bd819675 Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Wed, 17 Feb 2021 18:33:37 +0530 Subject: [PATCH 09/37] added overlay for adding canned response --- app/components/add-edit-message-overlay.js | 22 +++++++++ app/components/canned-messages-overlay.js | 4 ++ app/components/let-alias.js | 20 ++++++++ app/components/pro-forma-message-overlay.js | 46 ++++++++++++++++++ app/routes/review_item.js | 20 +++++--- app/services/message-service.js | 2 + .../components/_canned-messages-overlay.scss | 30 ++++++++++++ app/templates/_global_components.hbs | 9 ++++ .../components/add-edit-message-overlay.hbs | 38 +++++++++++++++ .../components/canned-messages-overlay.hbs | 3 +- app/templates/components/let-alias.hbs | 1 + .../components/pro-forma-message-overlay.hbs | 47 +++++++++++++++++++ 12 files changed, 234 insertions(+), 8 deletions(-) create mode 100644 app/components/add-edit-message-overlay.js create mode 100644 app/components/let-alias.js create mode 100644 app/components/pro-forma-message-overlay.js create mode 100644 app/templates/_global_components.hbs create mode 100644 app/templates/components/add-edit-message-overlay.hbs create mode 100644 app/templates/components/let-alias.hbs create mode 100644 app/templates/components/pro-forma-message-overlay.hbs diff --git a/app/components/add-edit-message-overlay.js b/app/components/add-edit-message-overlay.js new file mode 100644 index 000000000..3ffefc82c --- /dev/null +++ b/app/components/add-edit-message-overlay.js @@ -0,0 +1,22 @@ +import Ember from "ember"; +import _ from "lodash"; + +export default Ember.Component.extend({ + messageService: Ember.inject.service(), + store: Ember.inject.service(), + + actions: { + createCannedMessage() { + const response = this.get("store").createRecord("canned-response", { + name: this.get("label"), + nameEn: this.get("label"), + content: this.get("message"), + contentEn: this.get("label") + }); + response.save().then(() => { + console.log("saved"); + this.set("messageService.isAddMessageVisible", false); + }); + } + } +}); diff --git a/app/components/canned-messages-overlay.js b/app/components/canned-messages-overlay.js index 304d58c8e..f9dae5654 100644 --- a/app/components/canned-messages-overlay.js +++ b/app/components/canned-messages-overlay.js @@ -24,6 +24,10 @@ export default Ember.Component.extend({ return this.get("store").query("canned_response", params); }, + openProFormaOverlay() { + this.set("messageService.isProFormaMessageVisible", true); + }, + setCannedResponse(text) { if (!text) return; const onSelect = this.getWithDefault("onSelect", _.noop); diff --git a/app/components/let-alias.js b/app/components/let-alias.js new file mode 100644 index 000000000..56268b039 --- /dev/null +++ b/app/components/let-alias.js @@ -0,0 +1,20 @@ +import Ember from "ember"; + +/** + * @module Components/let-alias + * @description Small helper component allowing to rename variables within the .hbs file + * @example + * + * {{#let-alias model.someReallyLongPropertyName as |short| }} + *
This is {{short}}
+ *
I can use {{short}} many times {{short}}
+ *
because it's very {{short}}
this.set("displayResults", true), 500); + }, + + hasSearchText: Ember.computed("searchText", function() { + return this.get("searchText") && this.get("searchText").trim().length; + }), + + actions: { + loadMoreCannedMessages() { + const params = { searchText: this.get("searchText") }; + return this.get("store").query("canned_response", params); + }, + + addMessage() { + this.set("messageService.isAddMessageVisible", true); + }, + + setCannedResponse(text) { + if (!text) return; + const onSelect = this.getWithDefault("onSelect", _.noop); + onSelect(text); + this.set("open", false); + }, + + clearSearch() { + this.set("searchText", ""); + }, + + cancel() { + this.set("open", false); + } + } +}); diff --git a/app/routes/review_item.js b/app/routes/review_item.js index 837f42929..c76a117eb 100644 --- a/app/routes/review_item.js +++ b/app/routes/review_item.js @@ -1,26 +1,32 @@ -import AuthorizeRoute from './authorize'; +import AuthorizeRoute from "./authorize"; export default AuthorizeRoute.extend({ - editItemRequest: "", - beforeModel(){ + beforeModel() { var previousRoutes = this.router.router.currentHandlerInfos; var previousRoute = previousRoutes && previousRoutes.pop(); - if(previousRoute){ - var editItemRequest = ["review_offer.items", "review_offer.receive"].indexOf(previousRoute.name) >= 0; + if (previousRoute) { + var editItemRequest = + ["review_offer.items", "review_offer.receive"].indexOf( + previousRoute.name + ) >= 0; this.set("editItemRequest", editItemRequest); } }, model(params) { - return this.store.findRecord('item', params.item_id); + return this.store.findRecord("item", params.item_id); }, setupController(controller, model) { this._super(controller, model); + this.set( + "existingPackageType", + model.get("packageType") && model.get("packageType").id + ); - if((this.get("editItemRequest"))){ + if (this.get("editItemRequest")) { var itemDetails = { donorConditionId: model.get("donorConditionId"), donorDescription: model.get("donorDescription") diff --git a/app/services/message-service.js b/app/services/message-service.js index 40c13ab3f..0fe247e08 100644 --- a/app/services/message-service.js +++ b/app/services/message-service.js @@ -9,6 +9,8 @@ export default ApiBaseService.extend({ init() { this._super(...arguments); this.set("isCannedMessagesVisible", false); + this.set("isProFormaMessageVisible", false); + this.set("isAddMessageVisible", false); }, toggle() { diff --git a/app/styles/templates/components/_canned-messages-overlay.scss b/app/styles/templates/components/_canned-messages-overlay.scss index b6b0f68a8..c84e22380 100644 --- a/app/styles/templates/components/_canned-messages-overlay.scss +++ b/app/styles/templates/components/_canned-messages-overlay.scss @@ -16,6 +16,19 @@ margin-left: 0%; } + .tabs { + width: 50%; + padding-left: 15%; + margin-left: -10%; + float: left; + padding-top: 2%; + padding-bottom: 2%; + cursor: pointer; + } + + .selected { + border-bottom: 2px solid #ddd; + } .search-field { flex: 0.8; } @@ -43,6 +56,23 @@ flex-direction: column; margin-top: 1.5rem; + .light-button { + border: 1px solid #fff; + max-width: 16rem; + height: 2rem; + line-height: 2rem; + text-align: center; + cursor: pointer; + color: #fff; + background: #002352; + font-size: 120%; + padding-bottom: 8%; + padding-top: 1%; + padding-left: 7%; + padding-right: 7%; + position: absolute; + } + li { margin-bottom: clamp(1rem, 5vw, 4rem); diff --git a/app/templates/_global_components.hbs b/app/templates/_global_components.hbs new file mode 100644 index 000000000..8b2309fe2 --- /dev/null +++ b/app/templates/_global_components.hbs @@ -0,0 +1,9 @@ +{{#let-alias messageService as |s|}} + {{pro-forma-message-overlay + open=s.isProFormaMessageVisible + }} + + {{add-edit-message-overlay + open=s.isAddMessageVisible + }} +{{/let-alias}} \ No newline at end of file diff --git a/app/templates/components/add-edit-message-overlay.hbs b/app/templates/components/add-edit-message-overlay.hbs new file mode 100644 index 000000000..5f7577b33 --- /dev/null +++ b/app/templates/components/add-edit-message-overlay.hbs @@ -0,0 +1,38 @@ +
+ {{#popup-overlay open=open}} + +
+ +
+ + Label + + + {{textarea type='textarea' value=label}} + +
+ + +
+ + Label + + + {{textarea type='textarea' value=message}} + +
+ + + +
+ + + {{/popup-overlay}} +
\ No newline at end of file diff --git a/app/templates/components/canned-messages-overlay.hbs b/app/templates/components/canned-messages-overlay.hbs index 80758df66..4501e85b5 100644 --- a/app/templates/components/canned-messages-overlay.hbs +++ b/app/templates/components/canned-messages-overlay.hbs @@ -19,9 +19,10 @@
-
+
{{t 'canned_response.title'}}
+ {{#if displayResults}} {{#infinite-list height="82vh" loadMore=(action "loadMoreCannedMessages") as |cannedMessages| }}
    diff --git a/app/templates/components/let-alias.hbs b/app/templates/components/let-alias.hbs new file mode 100644 index 000000000..907aade9e --- /dev/null +++ b/app/templates/components/let-alias.hbs @@ -0,0 +1 @@ +{{yield value}} \ No newline at end of file diff --git a/app/templates/components/pro-forma-message-overlay.hbs b/app/templates/components/pro-forma-message-overlay.hbs new file mode 100644 index 000000000..2d730150d --- /dev/null +++ b/app/templates/components/pro-forma-message-overlay.hbs @@ -0,0 +1,47 @@ +
    + {{#popup-overlay open=open}} +
    +
    + + {{t 'cancel'}} +
    +
    + Message Admin +
    +
    +
    +
    + Canned Message +
    +
    + System Message +
    +
    + +
    + + {{#if displayResults}} + {{#infinite-list height="82vh" loadMore=(action "loadMoreCannedMessages") as |cannedMessages| }} +
      + {{#each cannedMessages as |cannedMessage|}} +
    • +
      +
      + {{canned-content cannedMessage=cannedMessage}} +
      +
      + EN + + 中文 + +
      +
      +
    • + {{/each}} +
    + {{/infinite-list}} + {{/if}} +
    + {{/popup-overlay}} +
    \ No newline at end of file From c9da81699122c657c2f0468bd518127ff649b7f6 Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Thu, 18 Feb 2021 11:26:53 +0530 Subject: [PATCH 10/37] improved header of overlay pages and added tabs for canned and system messages --- app/components/add-edit-message-overlay.js | 4 ++ app/components/pro-forma-message-overlay.js | 20 ++++++ .../components/add-edit-message-overlay.hbs | 5 +- .../components/pro-forma-message-overlay.hbs | 66 ++++++++++--------- 4 files changed, 64 insertions(+), 31 deletions(-) diff --git a/app/components/add-edit-message-overlay.js b/app/components/add-edit-message-overlay.js index 3ffefc82c..a6a917ad5 100644 --- a/app/components/add-edit-message-overlay.js +++ b/app/components/add-edit-message-overlay.js @@ -17,6 +17,10 @@ export default Ember.Component.extend({ console.log("saved"); this.set("messageService.isAddMessageVisible", false); }); + }, + + closeOverlay() { + this.set("messageService.isAddMessageVisible", false); } } }); diff --git a/app/components/pro-forma-message-overlay.js b/app/components/pro-forma-message-overlay.js index e67a0294b..5be51e17c 100644 --- a/app/components/pro-forma-message-overlay.js +++ b/app/components/pro-forma-message-overlay.js @@ -5,6 +5,13 @@ export default Ember.Component.extend({ messageService: Ember.inject.service(), displayResults: true, store: Ember.inject.service(), + + init() { + this._super(...arguments); + this.set("selected", "canned"); + this.set("isSelected", true); + }, + onSearchTextChange: Ember.observer("searchText", function() { Ember.run.debounce(this, this.reloadResults, 500); }), @@ -28,6 +35,19 @@ export default Ember.Component.extend({ this.set("messageService.isAddMessageVisible", true); }, + closeOverlay() { + this.set("messageService.isProFormaMessageVisible", false); + }, + + selectTab(selectedTab = "canned") { + this.set("selected", selectedTab); + if (selectedTab == "canned") { + this.set("isSelected", true); + } else { + this.set("isSelected", false); + } + }, + setCannedResponse(text) { if (!text) return; const onSelect = this.getWithDefault("onSelect", _.noop); diff --git a/app/templates/components/add-edit-message-overlay.hbs b/app/templates/components/add-edit-message-overlay.hbs index 5f7577b33..4e0ee7dc4 100644 --- a/app/templates/components/add-edit-message-overlay.hbs +++ b/app/templates/components/add-edit-message-overlay.hbs @@ -2,7 +2,10 @@ {{#popup-overlay open=open}}
    -
    +
    Canned Message
    -
    +
    System Message
    - - {{#if displayResults}} - {{#infinite-list height="82vh" loadMore=(action "loadMoreCannedMessages") as |cannedMessages| }} -
      - {{#each cannedMessages as |cannedMessage|}} -
    • -
      -
      - {{canned-content cannedMessage=cannedMessage}} -
      -
      - EN - - 中文 - -
      + {{#if (is-equal selected 'canned') }} + + {{#if displayResults}} + {{#infinite-list height="82vh" loadMore=(action "loadMoreCannedMessages") as |cannedMessages| }} +
        + {{#each cannedMessages as |cannedMessage|}} +
      • +
        +
        + {{canned-content cannedMessage=cannedMessage}}
        -
      • - {{/each}} -
      - {{/infinite-list}} - {{/if}} +
      + EN + + 中文 + +
      +
      +
    • + {{/each}} +
    + {{/infinite-list}} + {{/if}} + {{else}} + System messages + {{/if}}
    {{/popup-overlay}}
    \ No newline at end of file From f9747c90fa0b05cead0a810c94e5331a18d88f6d Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Fri, 19 Feb 2021 13:48:57 +0530 Subject: [PATCH 11/37] added edit and delete feature for canned messages --- app/components/add-edit-message-overlay.js | 46 ++++++++++++++----- app/components/pro-forma-message-overlay.js | 18 ++++---- app/services/message-service.js | 1 + .../components/_canned-messages-overlay.scss | 8 ++-- app/templates/_global_components.hbs | 1 + .../components/add-edit-message-overlay.hbs | 14 ++++-- .../components/pro-forma-message-overlay.hbs | 19 ++++---- 7 files changed, 68 insertions(+), 39 deletions(-) diff --git a/app/components/add-edit-message-overlay.js b/app/components/add-edit-message-overlay.js index a6a917ad5..ffa9fbef5 100644 --- a/app/components/add-edit-message-overlay.js +++ b/app/components/add-edit-message-overlay.js @@ -1,26 +1,50 @@ import Ember from "ember"; import _ from "lodash"; +import AsyncTasksMixin, { ERROR_STRATEGIES } from "../mixins/async_tasks"; -export default Ember.Component.extend({ +export default Ember.Component.extend(AsyncTasksMixin, { messageService: Ember.inject.service(), store: Ember.inject.service(), + async didReceiveAttrs() { + const editMessageId = this.get("messageService.editMessage"); + const store = this.get("store"); + let message; + if (editMessageId) { + message = store.peekRecord("canned_response", editMessageId); + } else { + message = store.createRecord("canned-response"); + } + this.set("message", message); + }, + actions: { createCannedMessage() { - const response = this.get("store").createRecord("canned-response", { - name: this.get("label"), - nameEn: this.get("label"), - content: this.get("message"), - contentEn: this.get("label") - }); - response.save().then(() => { - console.log("saved"); - this.set("messageService.isAddMessageVisible", false); - }); + this.runTask( + this.get("message") + .save() + .then(() => this.set("messageService.isAddMessageVisible", false)) + ); }, closeOverlay() { this.set("messageService.isAddMessageVisible", false); + this.set("messageService.editMessage", ""); + }, + + deleteMessage() { + const store = this.get("store"); + const message = store.peekRecord( + "canned_response", + this.get("message").id + ); + this.runTask( + message.destroyRecord().then(() => { + store.unloadRecord(message); + this.set("messageService.isAddMessageVisible", false); + }), + ERROR_STRATEGIES + ); } } }); diff --git a/app/components/pro-forma-message-overlay.js b/app/components/pro-forma-message-overlay.js index 5be51e17c..06178fad4 100644 --- a/app/components/pro-forma-message-overlay.js +++ b/app/components/pro-forma-message-overlay.js @@ -27,7 +27,11 @@ export default Ember.Component.extend({ actions: { loadMoreCannedMessages() { - const params = { searchText: this.get("searchText") }; + const params = { + searchText: this.get("searchText"), + is_canned: false, + is_system: false + }; return this.get("store").query("canned_response", params); }, @@ -48,15 +52,9 @@ export default Ember.Component.extend({ } }, - setCannedResponse(text) { - if (!text) return; - const onSelect = this.getWithDefault("onSelect", _.noop); - onSelect(text); - this.set("open", false); - }, - - clearSearch() { - this.set("searchText", ""); + editMessage(message) { + this.set("messageService.editMessage", message.id); + this.send("addMessage"); }, cancel() { diff --git a/app/services/message-service.js b/app/services/message-service.js index 0fe247e08..0ba153428 100644 --- a/app/services/message-service.js +++ b/app/services/message-service.js @@ -11,6 +11,7 @@ export default ApiBaseService.extend({ this.set("isCannedMessagesVisible", false); this.set("isProFormaMessageVisible", false); this.set("isAddMessageVisible", false); + this.set("editMessage", ""); }, toggle() { diff --git a/app/styles/templates/components/_canned-messages-overlay.scss b/app/styles/templates/components/_canned-messages-overlay.scss index c84e22380..273fe2b5f 100644 --- a/app/styles/templates/components/_canned-messages-overlay.scss +++ b/app/styles/templates/components/_canned-messages-overlay.scss @@ -66,11 +66,13 @@ color: #fff; background: #002352; font-size: 120%; - padding-bottom: 8%; - padding-top: 1%; + padding-bottom: 7.5%; + padding-top: 0.5%; padding-left: 7%; padding-right: 7%; - position: absolute; + position: relative; + margin-right: 5%; + float: right; } diff --git a/app/templates/_global_components.hbs b/app/templates/_global_components.hbs index 8b2309fe2..bc54c8e9e 100644 --- a/app/templates/_global_components.hbs +++ b/app/templates/_global_components.hbs @@ -5,5 +5,6 @@ {{add-edit-message-overlay open=s.isAddMessageVisible + cannedMessageId=s.cannedMessageId }} {{/let-alias}} \ No newline at end of file diff --git a/app/templates/components/add-edit-message-overlay.hbs b/app/templates/components/add-edit-message-overlay.hbs index 4e0ee7dc4..b6912f6eb 100644 --- a/app/templates/components/add-edit-message-overlay.hbs +++ b/app/templates/components/add-edit-message-overlay.hbs @@ -12,13 +12,17 @@
    - -
    + {{#if message.id}} +
    + +
    + {{/if}} +
    Label - {{textarea type='textarea' value=label}} + {{textarea type='textarea' value=message.nameEn}}
    @@ -28,11 +32,11 @@ Label - {{textarea type='textarea' value=message}} + {{textarea type='textarea' value=message.contentEn}}
    - +
    diff --git a/app/templates/components/pro-forma-message-overlay.hbs b/app/templates/components/pro-forma-message-overlay.hbs index 20315638e..a435bf3ab 100644 --- a/app/templates/components/pro-forma-message-overlay.hbs +++ b/app/templates/components/pro-forma-message-overlay.hbs @@ -22,23 +22,22 @@
    {{#if (is-equal selected 'canned') }} - +
    + +
    {{#if displayResults}} {{#infinite-list height="82vh" loadMore=(action "loadMoreCannedMessages") as |cannedMessages| }}
      {{#each cannedMessages as |cannedMessage|}} -
    • +
    • {{canned-content cannedMessage=cannedMessage}} -
      -
      - EN - - 中文 - -
      +
      +
      + EN + 中文 +
    {{/each}} From 9d1d678d9f478d047201a2433c0cfcbb88e11e5a Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Mon, 22 Feb 2021 20:49:46 +0530 Subject: [PATCH 12/37] added language specific edit --- app/components/add-edit-message-overlay.js | 13 +++++-- app/components/pro-forma-message-overlay.js | 12 +++--- app/models/canned_response.js | 1 + app/services/message-service.js | 5 ++- .../components/_canned-messages-overlay.scss | 8 ++++ .../components/add-edit-message-overlay.hbs | 37 +++++++++++++------ .../components/pro-forma-message-overlay.hbs | 22 ++++++++++- 7 files changed, 74 insertions(+), 24 deletions(-) diff --git a/app/components/add-edit-message-overlay.js b/app/components/add-edit-message-overlay.js index ffa9fbef5..6bc83a701 100644 --- a/app/components/add-edit-message-overlay.js +++ b/app/components/add-edit-message-overlay.js @@ -7,15 +7,19 @@ export default Ember.Component.extend(AsyncTasksMixin, { store: Ember.inject.service(), async didReceiveAttrs() { - const editMessageId = this.get("messageService.editMessage"); + const editMessage = this.get("messageService.editMessage"); const store = this.get("store"); let message; - if (editMessageId) { - message = store.peekRecord("canned_response", editMessageId); + if (editMessage.messageId) { + message = store.peekRecord("canned_response", editMessage.messageId); } else { message = store.createRecord("canned-response"); } this.set("message", message); + this.set( + "language", + this.get("messageService.editMessage.language") == "en" + ); }, actions: { @@ -29,7 +33,8 @@ export default Ember.Component.extend(AsyncTasksMixin, { closeOverlay() { this.set("messageService.isAddMessageVisible", false); - this.set("messageService.editMessage", ""); + this.set("messageService.editMessage.language", "en"); + this.set("messageService.editMessage.messageId", ""); }, deleteMessage() { diff --git a/app/components/pro-forma-message-overlay.js b/app/components/pro-forma-message-overlay.js index 06178fad4..f6ed54c19 100644 --- a/app/components/pro-forma-message-overlay.js +++ b/app/components/pro-forma-message-overlay.js @@ -28,10 +28,11 @@ export default Ember.Component.extend({ actions: { loadMoreCannedMessages() { const params = { - searchText: this.get("searchText"), - is_canned: false, - is_system: false + searchText: this.get("searchText") }; + if (this.get("selected") == "system") { + params.type = "system"; + } return this.get("store").query("canned_response", params); }, @@ -52,8 +53,9 @@ export default Ember.Component.extend({ } }, - editMessage(message) { - this.set("messageService.editMessage", message.id); + editMessage(message, lang) { + this.set("messageService.editMessage.messageId", message.id); + this.set("messageService.editMessage.language", lang); this.send("addMessage"); }, diff --git a/app/models/canned_response.js b/app/models/canned_response.js index cb32207a2..554720ee5 100644 --- a/app/models/canned_response.js +++ b/app/models/canned_response.js @@ -4,6 +4,7 @@ import attr from "ember-data/attr"; export default Model.extend({ name: attr("string"), nameEn: attr("string"), + nameZhTw: attr("string"), content: attr("string"), contentEn: attr("string"), contentZhTw: attr("string") diff --git a/app/services/message-service.js b/app/services/message-service.js index 0ba153428..ceb29978a 100644 --- a/app/services/message-service.js +++ b/app/services/message-service.js @@ -5,13 +5,16 @@ import ApiBaseService from "./api-base-service"; export default ApiBaseService.extend({ store: Ember.inject.service(), + editMessage: { + language: "en", + messageId: "" + }, init() { this._super(...arguments); this.set("isCannedMessagesVisible", false); this.set("isProFormaMessageVisible", false); this.set("isAddMessageVisible", false); - this.set("editMessage", ""); }, toggle() { diff --git a/app/styles/templates/components/_canned-messages-overlay.scss b/app/styles/templates/components/_canned-messages-overlay.scss index 273fe2b5f..1176cb9fb 100644 --- a/app/styles/templates/components/_canned-messages-overlay.scss +++ b/app/styles/templates/components/_canned-messages-overlay.scss @@ -56,6 +56,14 @@ flex-direction: column; margin-top: 1.5rem; + .message-textarea { + background: #1A3A64; + border: 1px solid #002352; + color: #8496AE; + width: 98%; + font-size: 100%; + } + .light-button { border: 1px solid #fff; max-width: 16rem; diff --git a/app/templates/components/add-edit-message-overlay.hbs b/app/templates/components/add-edit-message-overlay.hbs index b6912f6eb..cc95d14c5 100644 --- a/app/templates/components/add-edit-message-overlay.hbs +++ b/app/templates/components/add-edit-message-overlay.hbs @@ -17,26 +17,39 @@
    {{/if}} -
    - - Label +
    + + Label* +
    + EN | 中文 +
    - - {{textarea type='textarea' value=message.nameEn}} + + {{#if language}} + {{textarea type='textarea' value=message.nameEn classNames="message-textarea" rows="5"}} + {{else}} + {{textarea type='textarea' value=message.nameZhTw classNames="message-textarea" rows="5"}} + {{/if}}
    - -
    - - Label +
    + + Message* +
    + EN | 中文 +
    - - {{textarea type='textarea' value=message.contentEn}} + + {{#if language}} + {{textarea type='textarea' value=message.contentEn classNames="message-textarea" rows="10"}} + {{else}} + {{textarea type='textarea' value=message.contentZhTw classNames="message-textarea" rows="10"}} + {{/if}}
    - +
    diff --git a/app/templates/components/pro-forma-message-overlay.hbs b/app/templates/components/pro-forma-message-overlay.hbs index a435bf3ab..b23b2fbb3 100644 --- a/app/templates/components/pro-forma-message-overlay.hbs +++ b/app/templates/components/pro-forma-message-overlay.hbs @@ -25,6 +25,26 @@
    + {{#if displayResults}} + {{#infinite-list height="82vh" loadMore=(action "loadMoreCannedMessages") as |cannedMessages| }} +
      + {{#each cannedMessages as |cannedMessage|}} +
    • +
      +
      + {{canned-content cannedMessage=cannedMessage}} +
      +
      + EN + 中文 +
      +
      +
    • + {{/each}} +
    + {{/infinite-list}} + {{/if}} + {{else}} {{#if displayResults}} {{#infinite-list height="82vh" loadMore=(action "loadMoreCannedMessages") as |cannedMessages| }}
      @@ -44,8 +64,6 @@
    {{/infinite-list}} {{/if}} - {{else}} - System messages {{/if}}
    {{/popup-overlay}} From 934e9c2743a5a498447dc9c5e1f32bb2275c77a8 Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Tue, 23 Feb 2021 13:44:11 +0530 Subject: [PATCH 13/37] moved language switching logic on add-edit message page --- app/components/add-edit-message-overlay.js | 9 ++-- .../components/_canned-messages-overlay.scss | 54 ++++++++++++++++--- .../components/add-edit-message-overlay.hbs | 16 +++--- .../components/pro-forma-message-overlay.hbs | 14 +++-- 4 files changed, 65 insertions(+), 28 deletions(-) diff --git a/app/components/add-edit-message-overlay.js b/app/components/add-edit-message-overlay.js index 6bc83a701..e488c262b 100644 --- a/app/components/add-edit-message-overlay.js +++ b/app/components/add-edit-message-overlay.js @@ -16,10 +16,7 @@ export default Ember.Component.extend(AsyncTasksMixin, { message = store.createRecord("canned-response"); } this.set("message", message); - this.set( - "language", - this.get("messageService.editMessage.language") == "en" - ); + this.set("isEnglish", true); }, actions: { @@ -37,6 +34,10 @@ export default Ember.Component.extend(AsyncTasksMixin, { this.set("messageService.editMessage.messageId", ""); }, + setLanguage(lang = "en") { + this.set("isEnglish", lang == "en"); + }, + deleteMessage() { const store = this.get("store"); const message = store.peekRecord( diff --git a/app/styles/templates/components/_canned-messages-overlay.scss b/app/styles/templates/components/_canned-messages-overlay.scss index 1176cb9fb..bc1e2b6eb 100644 --- a/app/styles/templates/components/_canned-messages-overlay.scss +++ b/app/styles/templates/components/_canned-messages-overlay.scss @@ -56,6 +56,10 @@ flex-direction: column; margin-top: 1.5rem; + i.edit-pointer { + font-size: 200%; + } + .message-textarea { background: #1A3A64; border: 1px solid #002352; @@ -64,23 +68,57 @@ font-size: 100%; } + .edit-message { + display: flex; + + + .disabled { + color: #bab3b3; + cursor: default; + } + } + + .create-btn{ + width: 50%; + margin-left: 30%; + } + + span.label { + flex: 1; + text-align: center; + } + + span.content { + flex: 5; + } + .light-button { border: 1px solid #fff; max-width: 16rem; height: 2rem; - line-height: 2rem; text-align: center; cursor: pointer; color: #fff; background: #002352; - font-size: 120%; - padding-bottom: 7.5%; - padding-top: 0.5%; - padding-left: 7%; - padding-right: 7%; - position: relative; - margin-right: 5%; float: right; + font-size: 100%; + padding-bottom: 2.5%; + padding-top: 1%; + padding-left: 5%; + padding-right: 5%; + margin-right: 25%; + + + @media #{$small-only} { + line-height: 2rem; + font-size: 120%; + padding-bottom: 7.5%; + padding-top: 0.5%; + padding-left: 7%; + padding-right: 7%; + position: relative; + margin-right: 5%; + } } diff --git a/app/templates/components/add-edit-message-overlay.hbs b/app/templates/components/add-edit-message-overlay.hbs index cc95d14c5..2a62873d4 100644 --- a/app/templates/components/add-edit-message-overlay.hbs +++ b/app/templates/components/add-edit-message-overlay.hbs @@ -8,7 +8,7 @@
-

Edit Message

+

{{if message.id "Edit" "Create"}} Message

@@ -17,15 +17,15 @@
{{/if}} -
+
Label*
- EN | 中文 + EN | 中文
- {{#if language}} + {{#if isEnglish}} {{textarea type='textarea' value=message.nameEn classNames="message-textarea" rows="5"}} {{else}} {{textarea type='textarea' value=message.nameZhTw classNames="message-textarea" rows="5"}} @@ -33,15 +33,15 @@
-
+
Message*
- EN | 中文 + EN | 中文
- {{#if language}} + {{#if isEnglish}} {{textarea type='textarea' value=message.contentEn classNames="message-textarea" rows="10"}} {{else}} {{textarea type='textarea' value=message.contentZhTw classNames="message-textarea" rows="10"}} @@ -49,7 +49,7 @@
- +
diff --git a/app/templates/components/pro-forma-message-overlay.hbs b/app/templates/components/pro-forma-message-overlay.hbs index b23b2fbb3..0e721e1e3 100644 --- a/app/templates/components/pro-forma-message-overlay.hbs +++ b/app/templates/components/pro-forma-message-overlay.hbs @@ -34,11 +34,10 @@
{{canned-content cannedMessage=cannedMessage}}
-
- EN - 中文 -
+
+
+
{{/each}} @@ -54,11 +53,10 @@
{{canned-content cannedMessage=cannedMessage}}
-
- EN - 中文 -
+
+
+
{{/each}} From 0e99371d1df1144dffe5ac6817b35e3e81eeee43 Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Wed, 24 Feb 2021 09:58:12 +0530 Subject: [PATCH 14/37] added validation for label and content --- app/components/add-edit-message-overlay.js | 8 ++++++++ app/locales/en/translations.coffee | 3 ++- app/locales/zh-tw/translations.coffee | 2 ++ .../templates/components/_canned-messages-overlay.scss | 9 +++++++++ app/templates/components/add-edit-message-overlay.hbs | 8 +++++++- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/components/add-edit-message-overlay.js b/app/components/add-edit-message-overlay.js index e488c262b..744a6add8 100644 --- a/app/components/add-edit-message-overlay.js +++ b/app/components/add-edit-message-overlay.js @@ -19,6 +19,14 @@ export default Ember.Component.extend(AsyncTasksMixin, { this.set("isEnglish", true); }, + disableCreateEdit: Ember.computed( + "message.nameEn", + "message.contentEn", + function() { + return !(this.get("message.nameEn") && this.get("message.contentEn")); + } + ), + actions: { createCannedMessage() { this.runTask( diff --git a/app/locales/en/translations.coffee b/app/locales/en/translations.coffee index dd70dac9b..39967fae7 100644 --- a/app/locales/en/translations.coffee +++ b/app/locales/en/translations.coffee @@ -473,5 +473,6 @@ I18nTranslationsEn = "canned_response": "title": "Manage pro-forma messages" - + "en_content": "English content cannot be blank" + "en_label": "English label be blank" `export default I18nTranslationsEn` diff --git a/app/locales/zh-tw/translations.coffee b/app/locales/zh-tw/translations.coffee index 2a373fdf9..938180311 100644 --- a/app/locales/zh-tw/translations.coffee +++ b/app/locales/zh-tw/translations.coffee @@ -471,5 +471,7 @@ I18nTranslationsZhTw = "canned_response": "title": "Manage pro-forma messages" + "en_content": "English content cannot be blank" + "en_label": "English label be blank" `export default I18nTranslationsZhTw` diff --git a/app/styles/templates/components/_canned-messages-overlay.scss b/app/styles/templates/components/_canned-messages-overlay.scss index bc1e2b6eb..388b45154 100644 --- a/app/styles/templates/components/_canned-messages-overlay.scss +++ b/app/styles/templates/components/_canned-messages-overlay.scss @@ -76,6 +76,15 @@ color: #bab3b3; cursor: default; } + + .input-error { + background: #f46769; + color: #fff; + padding: .2rem; + width: 98%; + margin-top: -5%; + margin-bottom: 5%; + } } .create-btn{ diff --git a/app/templates/components/add-edit-message-overlay.hbs b/app/templates/components/add-edit-message-overlay.hbs index 2a62873d4..99b52cb84 100644 --- a/app/templates/components/add-edit-message-overlay.hbs +++ b/app/templates/components/add-edit-message-overlay.hbs @@ -30,6 +30,9 @@ {{else}} {{textarea type='textarea' value=message.nameZhTw classNames="message-textarea" rows="5"}} {{/if}} + {{#unless message.nameEn}} +
{{t 'canned_response.en_label'}}
+ {{/unless}} @@ -46,10 +49,13 @@ {{else}} {{textarea type='textarea' value=message.contentZhTw classNames="message-textarea" rows="10"}} {{/if}} + {{#unless message.contentEn}} +
{{t 'canned_response.en_content'}}
+ {{/unless}} - + From f0b004b74574445dd72516f72484e96f505a3ce7 Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Wed, 24 Feb 2021 14:51:09 +0530 Subject: [PATCH 15/37] GCW-35111-fixed image height --- app/styles/templates/_dashboard.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/styles/templates/_dashboard.scss b/app/styles/templates/_dashboard.scss index 98c6952b5..9523cdf61 100644 --- a/app/styles/templates/_dashboard.scss +++ b/app/styles/templates/_dashboard.scss @@ -78,7 +78,7 @@ justify-content: center; img { - height: -webkit-fill-available; + height: 89px; @media #{$small-only} { margin-left: -5%; From 6db4d1df2901915db5b53213d193c280b469f9bf Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Thu, 25 Feb 2021 16:57:55 +0530 Subject: [PATCH 16/37] removed tabs in prof-forma overlay --- app/components/pro-forma-message-overlay.js | 13 ---- .../components/pro-forma-message-overlay.hbs | 69 ++++++------------- 2 files changed, 20 insertions(+), 62 deletions(-) diff --git a/app/components/pro-forma-message-overlay.js b/app/components/pro-forma-message-overlay.js index f6ed54c19..0755d2385 100644 --- a/app/components/pro-forma-message-overlay.js +++ b/app/components/pro-forma-message-overlay.js @@ -8,7 +8,6 @@ export default Ember.Component.extend({ init() { this._super(...arguments); - this.set("selected", "canned"); this.set("isSelected", true); }, @@ -30,9 +29,6 @@ export default Ember.Component.extend({ const params = { searchText: this.get("searchText") }; - if (this.get("selected") == "system") { - params.type = "system"; - } return this.get("store").query("canned_response", params); }, @@ -44,15 +40,6 @@ export default Ember.Component.extend({ this.set("messageService.isProFormaMessageVisible", false); }, - selectTab(selectedTab = "canned") { - this.set("selected", selectedTab); - if (selectedTab == "canned") { - this.set("isSelected", true); - } else { - this.set("isSelected", false); - } - }, - editMessage(message, lang) { this.set("messageService.editMessage.messageId", message.id); this.set("messageService.editMessage.language", lang); diff --git a/app/templates/components/pro-forma-message-overlay.hbs b/app/templates/components/pro-forma-message-overlay.hbs index 0e721e1e3..fdfb4922b 100644 --- a/app/templates/components/pro-forma-message-overlay.hbs +++ b/app/templates/components/pro-forma-message-overlay.hbs @@ -11,58 +11,29 @@

Message Admin

-
-
- Canned Message -
-
- System Message -
-
- +
- {{#if (is-equal selected 'canned') }} -
- -
- {{#if displayResults}} - {{#infinite-list height="82vh" loadMore=(action "loadMoreCannedMessages") as |cannedMessages| }} -
    - {{#each cannedMessages as |cannedMessage|}} -
  • -
    -
    - {{canned-content cannedMessage=cannedMessage}} -
    -
    - -
    +
    + +
    + {{#if displayResults}} + {{#infinite-list height="82vh" loadMore=(action "loadMoreCannedMessages") as |cannedMessages| }} +
      + {{#each cannedMessages as |cannedMessage|}} +
    • +
      +
      + {{canned-content cannedMessage=cannedMessage}}
      -
    • - {{/each}} -
    - {{/infinite-list}} - {{/if}} - {{else}} - {{#if displayResults}} - {{#infinite-list height="82vh" loadMore=(action "loadMoreCannedMessages") as |cannedMessages| }} -
      - {{#each cannedMessages as |cannedMessage|}} -
    • -
      -
      - {{canned-content cannedMessage=cannedMessage}} -
      -
      - -
      +
      +
      -
    • - {{/each}} -
    - {{/infinite-list}} - {{/if}} - {{/if}} +
    +
  • + {{/each}} +
+ {{/infinite-list}} + {{/if}}
{{/popup-overlay}} \ No newline at end of file From 08e0165fc72cebf331cb51f9fc25d4b89a684258 Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Fri, 26 Feb 2021 14:16:10 +0530 Subject: [PATCH 17/37] fixed: PR comment --- app/components/add-edit-message-overlay.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/components/add-edit-message-overlay.js b/app/components/add-edit-message-overlay.js index 744a6add8..4cc3754f3 100644 --- a/app/components/add-edit-message-overlay.js +++ b/app/components/add-edit-message-overlay.js @@ -9,12 +9,9 @@ export default Ember.Component.extend(AsyncTasksMixin, { async didReceiveAttrs() { const editMessage = this.get("messageService.editMessage"); const store = this.get("store"); - let message; - if (editMessage.messageId) { - message = store.peekRecord("canned_response", editMessage.messageId); - } else { - message = store.createRecord("canned-response"); - } + const message = + store.peekRecord("canned_response", editMessage.messageId) || + store.createRecord("canned-response"); this.set("message", message); this.set("isEnglish", true); }, From 8b0eb757c7ff154e1c7379d85fcca5f9c905bf6d Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Mon, 1 Mar 2021 14:21:54 +0530 Subject: [PATCH 18/37] refresh list on add overlay close --- app/components/canned-messages-overlay.js | 9 +++++++++ app/components/pro-forma-message-overlay.js | 9 +++++++++ app/templates/components/add-edit-message-overlay.hbs | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/components/canned-messages-overlay.js b/app/components/canned-messages-overlay.js index f9dae5654..bf0ac95d4 100644 --- a/app/components/canned-messages-overlay.js +++ b/app/components/canned-messages-overlay.js @@ -18,6 +18,15 @@ export default Ember.Component.extend({ return this.get("searchText") && this.get("searchText").trim().length; }), + refreshDisplayResult: Ember.observer( + "messageService.isAddMessageVisible", + function() { + if (!this.get("messageService.isAddMessageVisible")) { + this.reloadResults(); + } + } + ), + actions: { loadMoreCannedMessages() { const params = { searchText: this.get("searchText") }; diff --git a/app/components/pro-forma-message-overlay.js b/app/components/pro-forma-message-overlay.js index 0755d2385..7a7052ecf 100644 --- a/app/components/pro-forma-message-overlay.js +++ b/app/components/pro-forma-message-overlay.js @@ -15,6 +15,15 @@ export default Ember.Component.extend({ Ember.run.debounce(this, this.reloadResults, 500); }), + refreshDisplayResult: Ember.observer( + "messageService.isAddMessageVisible", + function() { + if (!this.get("messageService.isAddMessageVisible")) { + this.reloadResults(); + } + } + ), + reloadResults() { this.set("displayResults", false); Ember.run.debounce(this, () => this.set("displayResults", true), 500); diff --git a/app/templates/components/add-edit-message-overlay.hbs b/app/templates/components/add-edit-message-overlay.hbs index 99b52cb84..1b358e3b5 100644 --- a/app/templates/components/add-edit-message-overlay.hbs +++ b/app/templates/components/add-edit-message-overlay.hbs @@ -55,7 +55,7 @@ - + From ad3404975c130d072d302d15687fb1f77bfe91e2 Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Mon, 1 Mar 2021 18:01:25 +0530 Subject: [PATCH 19/37] update locales and bumped latest shared version --- app/controllers/application.js | 59 +++++++++++++++++++ app/locales/en/translations.coffee | 3 + app/locales/zh-tw/translations.coffee | 3 + .../components/add-edit-message-overlay.hbs | 6 +- yarn.lock | 33 ++++++++--- 5 files changed, 92 insertions(+), 12 deletions(-) create mode 100644 app/controllers/application.js diff --git a/app/controllers/application.js b/app/controllers/application.js new file mode 100644 index 000000000..3a58115ec --- /dev/null +++ b/app/controllers/application.js @@ -0,0 +1,59 @@ +import config from "../config/environment"; + +export default Ember.Controller.extend({ + cordova: Ember.inject.service(), + subscriptions: Ember.inject.controller(), + messageService: Ember.inject.service(), + isMobileApp: config.cordova.enabled, + config, + + app_id: config.APP.ANDROID_APP_ID, + ios_app_id: config.APP.IOS_APP_ID, + appTitle: config.APP.TITLE, + bannerImage: config.APP.BANNER_IMAGE, + + initSubscriptions: Ember.on("init", function() { + if (this.session.get("isLoggedIn")) { + this.send("setSubscriptions"); + } + }), + + supportGCLink: Ember.computed("session.language", function() { + return this.get("session.language") === "zh-tw" + ? "https://www.crossroads.org.hk/zh-hant/home/donate-funds/" + : "https://www.crossroads.org.hk/home/donate-funds/"; + }), + + appVersion: Ember.computed(function() { + return config.cordova.enabled ? config.APP.VERSION : null; + }), + + actions: { + logMeOut() { + this.session.clear(); // this should be first since it updates isLoggedIn status + this.get("subscriptions").send("unwire"); + this.get("subscriptions").send("unloadNotifications"); + this.store.unloadAll(); + var _this = this; + config.APP.PRELOAD_TYPES.forEach(function(type) { + _this.store.findAll(type); + }); + this.transitionToRoute("login"); + }, + + logMeIn() { + this.send("setSubscriptions"); + }, + + setSubscriptions() { + this.get("subscriptions").send("wire"); + }, + + rateApp() { + if (this.get("cordova").isIOS()) { + this.set("app_id", this.get("ios_app_id")); + } + LaunchReview.launch(this.get("app_id")); + } + } +}); diff --git a/app/locales/en/translations.coffee b/app/locales/en/translations.coffee index 39967fae7..b60efdc8d 100644 --- a/app/locales/en/translations.coffee +++ b/app/locales/en/translations.coffee @@ -475,4 +475,7 @@ I18nTranslationsEn = "title": "Manage pro-forma messages" "en_content": "English content cannot be blank" "en_label": "English label be blank" + "delete_message": "Delete Message" + "label": "Label" + "message": "Message" `export default I18nTranslationsEn` diff --git a/app/locales/zh-tw/translations.coffee b/app/locales/zh-tw/translations.coffee index 938180311..17bd39206 100644 --- a/app/locales/zh-tw/translations.coffee +++ b/app/locales/zh-tw/translations.coffee @@ -473,5 +473,8 @@ I18nTranslationsZhTw = "title": "Manage pro-forma messages" "en_content": "English content cannot be blank" "en_label": "English label be blank" + "delete_message": "Delete Message" + "label": "Label" + "message": "Message" `export default I18nTranslationsZhTw` diff --git a/app/templates/components/add-edit-message-overlay.hbs b/app/templates/components/add-edit-message-overlay.hbs index 1b358e3b5..fcd5c7bda 100644 --- a/app/templates/components/add-edit-message-overlay.hbs +++ b/app/templates/components/add-edit-message-overlay.hbs @@ -14,12 +14,12 @@
{{#if message.id}}
- +
{{/if}}
- Label* + {{t 'canned_response.label'}}*
EN | 中文
@@ -38,7 +38,7 @@
- Message* + {{t 'canned_response.message'}}*
EN | 中文
diff --git a/yarn.lock b/yarn.lock index 3f9d55aa0..7625ef940 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7795,11 +7795,16 @@ got@^8.0.1: url-parse-lax "^3.0.0" url-to-options "^1.0.1" -graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.4, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0: +graceful-fs@^4.1.11, graceful-fs@^4.1.3, graceful-fs@^4.1.9, graceful-fs@^4.2.0: version "4.2.4" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== +graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6: + version "4.2.6" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee" + integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ== + graceful-fs@~4.1.2, graceful-fs@~4.1.6, graceful-fs@~4.1.9: version "4.1.15" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" @@ -8572,7 +8577,7 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" -is-core-module@^2.1.0: +is-core-module@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ== @@ -9827,11 +9832,16 @@ lodash@^3.10.0, lodash@^3.10.1, lodash@^3.3.1, lodash@^3.5.0, lodash@^3.9.3: resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y= -lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.5.1, lodash@^4.6.1, lodash@~4.17.10: +lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.5.1, lodash@^4.6.1, lodash@~4.17.10: version "4.17.20" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== +lodash@^4.17.14: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + lodash@~2.4.1: version "2.4.2" resolved "https://registry.yarnpkg.com/lodash/-/lodash-2.4.2.tgz#fadd834b9683073da179b3eae6d9c0d15053f73e" @@ -12836,11 +12846,11 @@ resolve@^0.6.3: integrity sha1-3ZV5gufnNt699TtYpN2RdUV13UY= resolve@^1.1.2, resolve@^1.1.6, resolve@^1.10.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c" - integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg== + version "1.20.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" + integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== dependencies: - is-core-module "^2.1.0" + is-core-module "^2.2.0" path-parse "^1.0.6" resolve@^1.1.3, resolve@^1.1.4, resolve@^1.11.1, resolve@^1.13.1, resolve@^1.17.0, resolve@^1.3.0, resolve@^1.3.2, resolve@^1.3.3, resolve@^1.4.0, resolve@^1.5.0, resolve@^1.8.1: @@ -13259,7 +13269,7 @@ sha@~2.0.1: "shared-goodcity@git://github.com/crossroads/shared.goodcity.git#master": version "0.0.0" - resolved "git://github.com/crossroads/shared.goodcity.git#bbf74d6c8ba19e671625dfb3d894be448d5801ed" + resolved "git://github.com/crossroads/shared.goodcity.git#006c006783ac6a87ff2d26bcf4df3a81482f1508" dependencies: cryptiles "^4.1.2" ember-cli-babel "^5.1.6" @@ -15340,7 +15350,12 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@^4.0.2, xtend@~4.0.1: resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== -y18n@^3.2.0, y18n@^3.2.1: +y18n@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.2.tgz#85c901bd6470ce71fc4bb723ad209b70f7f28696" + integrity sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ== + +y18n@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" integrity sha1-bRX7qITAhnnA136I53WegR4H+kE= From 5dcac79371f004c743f49277b8719ddd66ff5fc3 Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Mon, 1 Mar 2021 19:31:28 +0530 Subject: [PATCH 20/37] fixed failed test cases --- tests/acceptance/selecting-package-type-test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/acceptance/selecting-package-type-test.js b/tests/acceptance/selecting-package-type-test.js index b8ccd6894..a2817626f 100644 --- a/tests/acceptance/selecting-package-type-test.js +++ b/tests/acceptance/selecting-package-type-test.js @@ -40,6 +40,15 @@ module("Reviewer: Select package type", { } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); + $.mockjax({ url: "/api/v1/package_types", type: "GET", From 3626e0ad92915abf98b7a3e7191d66f45678d1f8 Mon Sep 17 00:00:00 2001 From: abulsayyad123 Date: Mon, 1 Mar 2021 19:40:39 +0530 Subject: [PATCH 21/37] added canned_response mock in all test cases --- tests/acceptance/accept-test.js | 8 + tests/acceptance/app-menu-test.js | 8 + tests/acceptance/authorization-test.js | 8 + tests/acceptance/closed-offers-test.js | 60 +++-- .../acceptance/complete_review_offer_test.js | 9 + tests/acceptance/index-test.js | 8 + tests/acceptance/login-test.js | 8 + tests/acceptance/logistic-tab-test.js | 8 + tests/acceptance/my-notifications-test.js | 8 + tests/acceptance/not-found-test.js | 63 +++-- .../receive-tab-close-options-test.js | 125 ++++++--- tests/acceptance/receive_package_test.js | 8 + tests/acceptance/received-test.js | 126 ++++++--- tests/acceptance/reject-test.js | 9 + tests/acceptance/review-item-test.js | 8 + .../acceptance/reviewer-item-messages-test.js | 9 + .../reviewer-item-status-message-test.js | 140 +++++++--- .../reviewer-offer-messages-test.js | 9 + .../reviewer-offer-status-messages-test.js | 249 +++++++++++++----- tests/acceptance/reviewer-reject-item-test.js | 100 ++++--- tests/acceptance/scheduled-test.js | 170 ++++++++---- tests/acceptance/search-test.js | 9 + 22 files changed, 849 insertions(+), 301 deletions(-) diff --git a/tests/acceptance/accept-test.js b/tests/acceptance/accept-test.js index 32ccb9a39..f28137c0e 100644 --- a/tests/acceptance/accept-test.js +++ b/tests/acceptance/accept-test.js @@ -43,6 +43,14 @@ module("Reviewer: Accept Item Tab", { roles: [role.toJSON({ includeId: true })] } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); $.mockjax({ url: "/api/v1/donor_condition*", diff --git a/tests/acceptance/app-menu-test.js b/tests/acceptance/app-menu-test.js index bb7c5cdee..8e4d26261 100644 --- a/tests/acceptance/app-menu-test.js +++ b/tests/acceptance/app-menu-test.js @@ -37,6 +37,14 @@ module("App Menu", { responseText: { roles: [role.toJSON({ includeId: true })] } + }), + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } }) ); diff --git a/tests/acceptance/authorization-test.js b/tests/acceptance/authorization-test.js index 967b3f78f..7b7ed99b5 100644 --- a/tests/acceptance/authorization-test.js +++ b/tests/acceptance/authorization-test.js @@ -18,6 +18,14 @@ module("Authorization", { roles: [role.toJSON({ includeId: true })] } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); }, afterEach: function() { Ember.run(App, "destroy"); diff --git a/tests/acceptance/closed-offers-test.js b/tests/acceptance/closed-offers-test.js index 7c750aa4c..89513b6f6 100644 --- a/tests/acceptance/closed-offers-test.js +++ b/tests/acceptance/closed-offers-test.js @@ -1,29 +1,43 @@ -import Ember from 'ember'; -import { module, test } from 'qunit'; -import startApp from '../helpers/start-app'; -import '../factories/offer'; -import '../factories/item'; -import FactoryGuy from 'ember-data-factory-guy'; -import '../factories/role'; -import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper'; +import Ember from "ember"; +import { module, test } from "qunit"; +import startApp from "../helpers/start-app"; +import "../factories/offer"; +import "../factories/item"; +import FactoryGuy from "ember-data-factory-guy"; +import "../factories/role"; +import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; var App, offer, item, role; -module('Closed Offer', { +module("Closed Offer", { beforeEach: function() { App = startApp({}, 2); TestHelper.setup(); offer = FactoryGuy.make("offer", { state: "closed" }); item = FactoryGuy.make("item", { state: "rejected", offer: offer }); role = FactoryGuy.make("role"); - $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: { - roles: [role.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/role*", + type: "GET", + status: 200, + responseText: { + roles: [role.toJSON({ includeId: true })] + } + }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] } }); }, afterEach: function() { - Em.run(function() { TestHelper.teardown(); }); - Ember.run(App, 'destroy'); + Em.run(function() { + TestHelper.teardown(); + }); + Ember.run(App, "destroy"); } }); @@ -31,7 +45,7 @@ test("display closed offer with rejected items", function(assert) { assert.expect(2); visit("/offers/" + offer.id + "/review_offer/items"); - andThen(function(){ + andThen(function() { assert.equal(currentURL(), "/offers/" + offer.id + "/review_offer/items"); assert.equal(find(".reject_badge").length, 1); }); @@ -41,10 +55,20 @@ test("display logistics tab of closed offer", function(assert) { assert.expect(2); visit("/offers/" + offer.id + "/review_offer/logistics"); - andThen(function(){ - assert.equal(currentURL(), "/offers/" + offer.id + "/review_offer/logistics"); + andThen(function() { + assert.equal( + currentURL(), + "/offers/" + offer.id + "/review_offer/logistics" + ); - var logistics_text = $.trim($('.noTransportItems').text().replace(/\s+/g, " ")); - assert.equal(logistics_text, "No items to transport. This offer is closed now."); + var logistics_text = $.trim( + $(".noTransportItems") + .text() + .replace(/\s+/g, " ") + ); + assert.equal( + logistics_text, + "No items to transport. This offer is closed now." + ); }); }); diff --git a/tests/acceptance/complete_review_offer_test.js b/tests/acceptance/complete_review_offer_test.js index 2b5aa5c51..669a4a435 100644 --- a/tests/acceptance/complete_review_offer_test.js +++ b/tests/acceptance/complete_review_offer_test.js @@ -33,6 +33,15 @@ module("In Review Offers", { } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); + $.mockjax({ url: "/api/v1/canned_respons*", type: "GET", diff --git a/tests/acceptance/index-test.js b/tests/acceptance/index-test.js index 4ff42eb6e..e1daae83f 100644 --- a/tests/acceptance/index-test.js +++ b/tests/acceptance/index-test.js @@ -29,6 +29,14 @@ module("Home Page", { roles: [role.toJSON({ includeId: true })] } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); item = FactoryGuy.make("item", { state: "submitted", offer: offer1 }); message2 = FactoryGuy.make("message", { diff --git a/tests/acceptance/login-test.js b/tests/acceptance/login-test.js index 414cb81fa..0d3981f1f 100644 --- a/tests/acceptance/login-test.js +++ b/tests/acceptance/login-test.js @@ -22,6 +22,14 @@ module("Acceptance: Login", { roles: [role.toJSON({ includeId: true })] } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); reviewer1 = FactoryGuy.make("user", { isReviwer: true }); offer1 = FactoryGuy.make("offer", { state: "receiving" }); offer2 = FactoryGuy.make("offer", { state: "submitted" }); diff --git a/tests/acceptance/logistic-tab-test.js b/tests/acceptance/logistic-tab-test.js index c75498181..6d34d5686 100644 --- a/tests/acceptance/logistic-tab-test.js +++ b/tests/acceptance/logistic-tab-test.js @@ -47,6 +47,14 @@ module("Review Offer Logistics", { roles: [role.toJSON({ includeId: true })] } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); reviewer = FactoryGuy.make("user"); offer = FactoryGuy.make("offer", { diff --git a/tests/acceptance/my-notifications-test.js b/tests/acceptance/my-notifications-test.js index f63ba8a34..06ab288d6 100644 --- a/tests/acceptance/my-notifications-test.js +++ b/tests/acceptance/my-notifications-test.js @@ -91,6 +91,14 @@ module("Reviewer: Notifications", { roles: [role.toJSON({ includeId: true })] } }), + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }), $.mockjax({ url: "/api/v1/message*", type: "GET", diff --git a/tests/acceptance/not-found-test.js b/tests/acceptance/not-found-test.js index d37e7c5ae..0902ac0f2 100644 --- a/tests/acceptance/not-found-test.js +++ b/tests/acceptance/not-found-test.js @@ -1,29 +1,42 @@ -import Ember from 'ember'; -import { module, test } from 'qunit'; -import '../factories/offer'; -import startApp from '../helpers/start-app'; -import testSkip from '../helpers/test-skip'; -import FactoryGuy from 'ember-data-factory-guy'; -import '../factories/role'; +import Ember from "ember"; +import { module, test } from "qunit"; +import "../factories/offer"; +import startApp from "../helpers/start-app"; +import testSkip from "../helpers/test-skip"; +import FactoryGuy from "ember-data-factory-guy"; +import "../factories/role"; var App, offer, t, role; -module('Display not found error', { +module("Display not found error", { beforeEach: function() { App = startApp(); Ember.run.later = () => true; offer = FactoryGuy.make("offer"); - var i18n = App.__container__.lookup('service:i18n'); + var i18n = App.__container__.lookup("service:i18n"); t = i18n.t.bind(i18n); role = FactoryGuy.make("role"); - $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: { - roles: [role.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/role*", + type: "GET", + status: 200, + responseText: { + roles: [role.toJSON({ includeId: true })] + } + }); + + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] } }); App.__container__.lookup("service:logger").error = () => {}; }, afterEach: function() { - Ember.run(App, 'destroy'); + Ember.run(App, "destroy"); } }); @@ -32,33 +45,39 @@ module('Display not found error', { testSkip("Display error popup for invalid offer", function(assert) { assert.expect(1); - $('.reveal-modal').remove(); + $(".reveal-modal").remove(); visit("/offers/invalid/review_offer/items"); - andThen(function(){ + andThen(function() { assert.equal(Ember.$("#messageBoxText").text(), t("404_error").toString()); - Ember.$('#errorModal').foundation('reveal', 'close'); + Ember.$("#errorModal").foundation("reveal", "close"); }); }); testSkip("Display error popup for invalid item", function(assert) { assert.expect(1); - $('.reveal-modal').remove(); + $(".reveal-modal").remove(); visit("/offers/" + offer.id + "/review_item/invalid/accept"); - $.mockjax({url:"/api/v1/items/*",status:404}); + $.mockjax({ url: "/api/v1/items/*", status: 404 }); - andThen(function(){ + andThen(function() { assert.equal(Ember.$("#messageBoxText").text(), t("404_error").toString()); - Ember.$('#errorModal').foundation('reveal', 'close'); + Ember.$("#errorModal").foundation("reveal", "close"); }); }); test("Display not-found page for invalid url", function(assert) { assert.expect(2); - $('.reveal-modal').remove(); + $(".reveal-modal").remove(); visit("/invalid_url"); - andThen(function(){ + andThen(function() { assert.equal(currentURL(), "/invalid_url"); - assert.notEqual(Ember.$(".xy-center").text().indexOf(t("not_found")), -1, "not found message found"); + assert.notEqual( + Ember.$(".xy-center") + .text() + .indexOf(t("not_found")), + -1, + "not found message found" + ); }); }); diff --git a/tests/acceptance/receive-tab-close-options-test.js b/tests/acceptance/receive-tab-close-options-test.js index 3ed2ba985..a0ae16623 100644 --- a/tests/acceptance/receive-tab-close-options-test.js +++ b/tests/acceptance/receive-tab-close-options-test.js @@ -1,81 +1,126 @@ -import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import '../factories/orders_package'; -import '../factories/packages_location'; -import { module, test } from 'qunit'; -import '../factories/offer'; -import FactoryGuy from 'ember-data-factory-guy'; -import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper'; -import '../factories/role'; +import Ember from "ember"; +import startApp from "../helpers/start-app"; +import "../factories/orders_package"; +import "../factories/packages_location"; +import { module, test } from "qunit"; +import "../factories/offer"; +import FactoryGuy from "ember-data-factory-guy"; +import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; +import "../factories/role"; var App, ofr1, item, pkg1, pkg2, pkg3, order_pkg, packages_location, role; -module('Received Tab close options', { +module("Received Tab close options", { beforeEach: function() { App = startApp({}, 2); TestHelper.setup(); - item = FactoryGuy.make("item", {state: "accepted"}); + item = FactoryGuy.make("item", { state: "accepted" }); ofr1 = FactoryGuy.make("offer", { state: "received", items: [item] }); packages_location = FactoryGuy.make("packages_location"); role = FactoryGuy.make("role"); - $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: { - roles: [role.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/role*", + type: "GET", + status: 200, + responseText: { + roles: [role.toJSON({ includeId: true })] } }); - order_pkg = FactoryGuy.make("orders_package", { id: 500, state: "designated", quantity: 6}); - pkg1 = FactoryGuy.make("package", { offerId: parseInt(ofr1.id), state: "expecting", item: item}); - pkg2 = FactoryGuy.make("package", { offerId: parseInt(ofr1.id), state: "expecting", item: item}); - pkg3 = FactoryGuy.make("package", { offerId: parseInt(ofr1.id), state: "expecting", item: item}); - + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); + order_pkg = FactoryGuy.make("orders_package", { + id: 500, + state: "designated", + quantity: 6 + }); + pkg1 = FactoryGuy.make("package", { + offerId: parseInt(ofr1.id), + state: "expecting", + item: item + }); + pkg2 = FactoryGuy.make("package", { + offerId: parseInt(ofr1.id), + state: "expecting", + item: item + }); + pkg3 = FactoryGuy.make("package", { + offerId: parseInt(ofr1.id), + state: "expecting", + item: item + }); }, afterEach: function() { - Em.run(function() { TestHelper.teardown(); }); - Ember.run(App, 'destroy'); + Em.run(function() { + TestHelper.teardown(); + }); + Ember.run(App, "destroy"); } }); test("Clicking on receive item options closes other receive-options if already open", function(assert) { assert.expect(2); - visit("/offers/"+ofr1.id+"/review_offer/receive"); - $.mockjax({url: '/api/v1/packages_location*', type: 'GET', status: 200,responseText: { - packages_locations: [packages_location.toJSON({includeId: true})] + visit("/offers/" + ofr1.id + "/review_offer/receive"); + $.mockjax({ + url: "/api/v1/packages_location*", + type: "GET", + status: 200, + responseText: { + packages_locations: [packages_location.toJSON({ includeId: true })] } }); - $.mockjax({url: '/api/v1/orders_package*', type: 'GET', status: 200,responseText: { - orders_packages: [order_pkg.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/orders_package*", + type: "GET", + status: 200, + responseText: { + orders_packages: [order_pkg.toJSON({ includeId: true })] } }); - andThen(function(){ + andThen(function() { //clicking on item options of first package - Ember.$('.options-link-open.' + pkg1.id).click(); - assert.equal($('.receive-options').not('.hidden').length, 1); + Ember.$(".options-link-open." + pkg1.id).click(); + assert.equal($(".receive-options").not(".hidden").length, 1); //clicking on item optins of second package - Ember.$('.options-link-open.' + pkg2.id).click(); + Ember.$(".options-link-open." + pkg2.id).click(); //checking if item option is closed for first package - assert.equal($('.receive-options .hidden').length, 0); + assert.equal($(".receive-options .hidden").length, 0); }); }); test("Clicking on other item detail closes item options", function(assert) { assert.expect(2); - visit("/offers/"+ofr1.id+"/review_offer/receive"); - $.mockjax({url: '/api/v1/packages_location*', type: 'GET', status: 200,responseText: { - packages_locations: [packages_location.toJSON({includeId: true})] + visit("/offers/" + ofr1.id + "/review_offer/receive"); + $.mockjax({ + url: "/api/v1/packages_location*", + type: "GET", + status: 200, + responseText: { + packages_locations: [packages_location.toJSON({ includeId: true })] } }); - $.mockjax({url: '/api/v1/orders_package*', type: 'GET', status: 200,responseText: { - orders_packages: [order_pkg.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/orders_package*", + type: "GET", + status: 200, + responseText: { + orders_packages: [order_pkg.toJSON({ includeId: true })] } }); - andThen(function(){ + andThen(function() { //clicking on item options of first package - Ember.$('.options-link-open.' + pkg1.id).click(); - assert.equal($('.receive-options').not('.hidden').length, 1); + Ember.$(".options-link-open." + pkg1.id).click(); + assert.equal($(".receive-options").not(".hidden").length, 1); //clicking on item status of second package - Ember.$('.package-expecting:first div div').click(); + Ember.$(".package-expecting:first div div").click(); //checking if item option is closed for first package - assert.equal(Ember.$('.receive-options').not('.hidden').length, 0); + assert.equal(Ember.$(".receive-options").not(".hidden").length, 0); }); }); diff --git a/tests/acceptance/receive_package_test.js b/tests/acceptance/receive_package_test.js index cea379c3d..439243655 100644 --- a/tests/acceptance/receive_package_test.js +++ b/tests/acceptance/receive_package_test.js @@ -51,6 +51,14 @@ module("Receive package", { roles: [role.toJSON({ includeId: true })] } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); $.mockjax({ url: "/api/v1/offer*", diff --git a/tests/acceptance/received-test.js b/tests/acceptance/received-test.js index 1f4a6ac37..b669f1b19 100644 --- a/tests/acceptance/received-test.js +++ b/tests/acceptance/received-test.js @@ -1,60 +1,120 @@ -import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import '../factories/orders_package'; -import '../factories/packages_location'; -import { module, test } from 'qunit'; -import '../factories/offer'; -import '../factories/role'; -import FactoryGuy from 'ember-data-factory-guy'; -import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper'; +import Ember from "ember"; +import startApp from "../helpers/start-app"; +import "../factories/orders_package"; +import "../factories/packages_location"; +import { module, test } from "qunit"; +import "../factories/offer"; +import "../factories/role"; +import FactoryGuy from "ember-data-factory-guy"; +import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; -var App, offer1, item1, package1, package2, package3, orders_pkg1, packages_location, role; +var App, + offer1, + item1, + package1, + package2, + package3, + orders_pkg1, + packages_location, + role; -module('Received Offers', { +module("Received Offers", { beforeEach: function() { App = startApp({}, 2); TestHelper.setup(); role = FactoryGuy.make("role"); - $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: { - roles: [role.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/role*", + type: "GET", + status: 200, + responseText: { + roles: [role.toJSON({ includeId: true })] } }); - item1 = FactoryGuy.make("item", {state: "accepted"}); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); + item1 = FactoryGuy.make("item", { state: "accepted" }); offer1 = FactoryGuy.make("offer", { state: "received", items: [item1] }); packages_location = FactoryGuy.make("packages_location"); - orders_pkg1 = FactoryGuy.make("orders_package", { id: 500, state: "designated", quantity: 6}); - package1 = FactoryGuy.make("package", { offerId: parseInt(offer1.id), state: "received", item: item1}); - package2 = FactoryGuy.make("package", { offerId: parseInt(offer1.id), state: "expecting", item: item1}); - package3 = FactoryGuy.make("package", { offerId: parseInt(offer1.id), state: "missing", item: item1}); - + orders_pkg1 = FactoryGuy.make("orders_package", { + id: 500, + state: "designated", + quantity: 6 + }); + package1 = FactoryGuy.make("package", { + offerId: parseInt(offer1.id), + state: "received", + item: item1 + }); + package2 = FactoryGuy.make("package", { + offerId: parseInt(offer1.id), + state: "expecting", + item: item1 + }); + package3 = FactoryGuy.make("package", { + offerId: parseInt(offer1.id), + state: "missing", + item: item1 + }); }, afterEach: function() { - Em.run(function() { TestHelper.teardown(); }); - Ember.run(App, 'destroy'); + Em.run(function() { + TestHelper.teardown(); + }); + Ember.run(App, "destroy"); } }); test("expecting, received and missing count", function(assert) { assert.expect(3); - visit("/offers/"+offer1.id+"/review_offer/receive"); - $.mockjax({url: '/api/v1/packages_location*', type: 'GET', status: 200,responseText: { - packages_locations: [packages_location.toJSON({includeId: true})] + visit("/offers/" + offer1.id + "/review_offer/receive"); + $.mockjax({ + url: "/api/v1/packages_location*", + type: "GET", + status: 200, + responseText: { + packages_locations: [packages_location.toJSON({ includeId: true })] } }); - $.mockjax({url: '/api/v1/orders_package*', type: 'GET', status: 200,responseText: { - orders_packages: [orders_pkg1.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/orders_package*", + type: "GET", + status: 200, + responseText: { + orders_packages: [orders_pkg1.toJSON({ includeId: true })] } }); - andThen(function(){ + andThen(function() { //expecting - var href = "/offers/"+offer1.id+"/review_offer/receive"; - assert.equal($('a[href="'+href+'"]:last').text().trim(), "Expecting(1)"); + var href = "/offers/" + offer1.id + "/review_offer/receive"; + assert.equal( + $('a[href="' + href + '"]:last') + .text() + .trim(), + "Expecting(1)" + ); //received - var href1 = href +"?state=received"; - assert.equal($('a[href="'+href1+'"]:last').text().trim(), "Received(1)"); + var href1 = href + "?state=received"; + assert.equal( + $('a[href="' + href1 + '"]:last') + .text() + .trim(), + "Received(1)" + ); //missing - href1 = href +"?state=missing"; - assert.equal($('a[href="'+href1+'"]').text().trim(), "Missing(1)"); + href1 = href + "?state=missing"; + assert.equal( + $('a[href="' + href1 + '"]') + .text() + .trim(), + "Missing(1)" + ); }); }); diff --git a/tests/acceptance/reject-test.js b/tests/acceptance/reject-test.js index 708cd78c8..7316326b8 100644 --- a/tests/acceptance/reject-test.js +++ b/tests/acceptance/reject-test.js @@ -41,6 +41,15 @@ module("Reviewer: Reject Item Tab", { } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); + offer = FactoryGuy.make("offer", { state: "under_review" }); diff --git a/tests/acceptance/review-item-test.js b/tests/acceptance/review-item-test.js index 173aaf4c5..3bc1d04f0 100644 --- a/tests/acceptance/review-item-test.js +++ b/tests/acceptance/review-item-test.js @@ -49,6 +49,14 @@ module("Display review Item", { roles: [role.toJSON({ includeId: true })] } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); $.mockjax({ url: "/api/v1/packages_location*", type: "GET", diff --git a/tests/acceptance/reviewer-item-messages-test.js b/tests/acceptance/reviewer-item-messages-test.js index 06b284204..3d351385f 100644 --- a/tests/acceptance/reviewer-item-messages-test.js +++ b/tests/acceptance/reviewer-item-messages-test.js @@ -23,6 +23,15 @@ module("Reviewer: Display Item Messages", { roles: [role.toJSON({ includeId: true })] } }); + + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); offer = { id: "300", state: "under_review" }; item = { id: "110", state: "submitted", offer_id: offer.id }; message1 = { diff --git a/tests/acceptance/reviewer-item-status-message-test.js b/tests/acceptance/reviewer-item-status-message-test.js index d4f5a4568..7ca962ac5 100644 --- a/tests/acceptance/reviewer-item-status-message-test.js +++ b/tests/acceptance/reviewer-item-status-message-test.js @@ -1,92 +1,146 @@ -import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import FactoryGuy from 'ember-data-factory-guy'; -import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper'; -import { module, test } from 'qunit'; -import '../factories/offer'; -import '../factories/item'; -import '../factories/role'; - -var App, offer1, offer2, item2, item1, item3, item4, - offer3, item5, role; - -module('Reviewer: Display Item Status', { +import Ember from "ember"; +import startApp from "../helpers/start-app"; +import FactoryGuy from "ember-data-factory-guy"; +import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; +import { module, test } from "qunit"; +import "../factories/offer"; +import "../factories/item"; +import "../factories/role"; + +var App, offer1, offer2, item2, item1, item3, item4, offer3, item5, role; + +module("Reviewer: Display Item Status", { beforeEach: function() { App = startApp({}, 2); TestHelper.setup(); role = FactoryGuy.make("role"); - $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: { - roles: [role.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/role*", + type: "GET", + status: 200, + responseText: { + roles: [role.toJSON({ includeId: true })] } }); - offer1 = FactoryGuy.make("offer", {state:"submitted"}); - item1 = FactoryGuy.make("item", {offer: offer1, state:"submitted"}); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); + + offer1 = FactoryGuy.make("offer", { state: "submitted" }); + item1 = FactoryGuy.make("item", { offer: offer1, state: "submitted" }); - offer2 = FactoryGuy.make("offer", {state:"under_review"}); - item2 = FactoryGuy.make("item", {offer: offer2, state:"submitted"}); - item3 = FactoryGuy.make("item", {offer: offer2, state:"accepted"}); - item4 = FactoryGuy.make("item", {offer: offer2, state:"rejected"}); + offer2 = FactoryGuy.make("offer", { state: "under_review" }); + item2 = FactoryGuy.make("item", { offer: offer2, state: "submitted" }); + item3 = FactoryGuy.make("item", { offer: offer2, state: "accepted" }); + item4 = FactoryGuy.make("item", { offer: offer2, state: "rejected" }); - offer3 = FactoryGuy.make("offer", {state:"cancelled"}); - item5 = FactoryGuy.make("item", {offer: offer3, state:"accepted"}); + offer3 = FactoryGuy.make("offer", { state: "cancelled" }); + item5 = FactoryGuy.make("item", { offer: offer3, state: "accepted" }); }, afterEach: function() { - Em.run(function() { TestHelper.teardown(); }); - Ember.run(App, 'destroy'); + Em.run(function() { + TestHelper.teardown(); + }); + Ember.run(App, "destroy"); } }); test("Display item status for submitted item", function(assert) { assert.expect(2); - visit('/offers/' + offer1.id + "/review_item/"+ item1.id +"/accept"); + visit("/offers/" + offer1.id + "/review_item/" + item1.id + "/accept"); andThen(function() { - assert.equal(currentURL(), '/offers/' + offer1.id + "/review_item/"+ item1.id +"/accept"); - assert.equal($.trim(find('.status-message').text()), "This item is awaiting review."); + assert.equal( + currentURL(), + "/offers/" + offer1.id + "/review_item/" + item1.id + "/accept" + ); + assert.equal( + $.trim(find(".status-message").text()), + "This item is awaiting review." + ); }); }); test("Display item status for under review item", function(assert) { assert.expect(2); - visit('/offers/' + offer2.id + "/review_item/"+ item2.id +"/accept"); + visit("/offers/" + offer2.id + "/review_item/" + item2.id + "/accept"); andThen(function() { - assert.equal(currentURL(), '/offers/' + offer2.id + "/review_item/"+ item2.id +"/accept"); - assert.equal($.trim(find('.status-message').text()), "This item is being reviewed."); + assert.equal( + currentURL(), + "/offers/" + offer2.id + "/review_item/" + item2.id + "/accept" + ); + assert.equal( + $.trim(find(".status-message").text()), + "This item is being reviewed." + ); }); }); test("Display item status for accepted item", function(assert) { assert.expect(2); - visit('/offers/' + offer2.id + "/review_item/"+ item3.id +"/accept"); + visit("/offers/" + offer2.id + "/review_item/" + item3.id + "/accept"); andThen(function() { - assert.equal(currentURL(), '/offers/' + offer2.id + "/review_item/"+ item3.id +"/accept"); - assert.equal($.trim(find('.status-message').text()), "This item has been accepted."); + assert.equal( + currentURL(), + "/offers/" + offer2.id + "/review_item/" + item3.id + "/accept" + ); + assert.equal( + $.trim(find(".status-message").text()), + "This item has been accepted." + ); }); }); test("Display offer status for reviewed offer", function(assert) { assert.expect(2); - visit('/offers/' + offer2.id + "/review_item/"+ item4.id +"/reject"); + visit("/offers/" + offer2.id + "/review_item/" + item4.id + "/reject"); andThen(function() { - assert.equal(currentURL(), '/offers/' + offer2.id + "/review_item/"+ item4.id +"/reject"); - assert.equal($.trim(find('.status-message').text()), "This item has been rejected."); + assert.equal( + currentURL(), + "/offers/" + offer2.id + "/review_item/" + item4.id + "/reject" + ); + assert.equal( + $.trim(find(".status-message").text()), + "This item has been rejected." + ); }); }); test("Display offer status for reviewed offer", function(assert) { assert.expect(2); - visit('/offers/' + offer3.id + "/review_item/"+ item5.id +"/accept"); + visit("/offers/" + offer3.id + "/review_item/" + item5.id + "/accept"); andThen(function() { - assert.equal(currentURL(), '/offers/' + offer3.id + "/review_item/"+ item5.id +"/accept"); - - var donor_name = offer3.get("createdBy.firstName") + " " + offer3.get("createdBy.lastName"); - - assert.equal($('.status-message').text().trim().indexOf("The offer this item belongs to has been cancelled by " + donor_name + " on") >= 0, true); + assert.equal( + currentURL(), + "/offers/" + offer3.id + "/review_item/" + item5.id + "/accept" + ); + + var donor_name = + offer3.get("createdBy.firstName") + + " " + + offer3.get("createdBy.lastName"); + + assert.equal( + $(".status-message") + .text() + .trim() + .indexOf( + "The offer this item belongs to has been cancelled by " + + donor_name + + " on" + ) >= 0, + true + ); }); }); diff --git a/tests/acceptance/reviewer-offer-messages-test.js b/tests/acceptance/reviewer-offer-messages-test.js index 8e9f08bc1..c0fe69d9d 100644 --- a/tests/acceptance/reviewer-offer-messages-test.js +++ b/tests/acceptance/reviewer-offer-messages-test.js @@ -34,6 +34,15 @@ module("Reviewer: Display Offer Messages", { roles: [role.toJSON({ includeId: true })] } }); + + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); user1 = FactoryGuy.make("user"); user2 = FactoryGuy.make("user_with_image"); offer = { id: 33, state: "under_review" }; diff --git a/tests/acceptance/reviewer-offer-status-messages-test.js b/tests/acceptance/reviewer-offer-status-messages-test.js index c7ddc7a80..8379cfce2 100644 --- a/tests/acceptance/reviewer-offer-status-messages-test.js +++ b/tests/acceptance/reviewer-offer-status-messages-test.js @@ -1,100 +1,165 @@ -import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import FactoryGuy from 'ember-data-factory-guy'; -import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper'; -import { module, test } from 'qunit'; -import '../factories/user'; -import '../factories/offer'; -import '../factories/item'; -import '../factories/schedule'; -import '../factories/gogovan_order'; -import '../factories/delivery'; -import '../factories/role'; - -var App, offer1, offer2, reviewer, reviewerName, - offer7, offer3, offer4, delivery1, delivery2, offer5, delivery3, offer6, - offer8, item8, offer9, item9, offer10, schedule, ggv_order11, delivery11, - offer11, offer12, role; - -module('Reviewer: Display Offer Status', { +import Ember from "ember"; +import startApp from "../helpers/start-app"; +import FactoryGuy from "ember-data-factory-guy"; +import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; +import { module, test } from "qunit"; +import "../factories/user"; +import "../factories/offer"; +import "../factories/item"; +import "../factories/schedule"; +import "../factories/gogovan_order"; +import "../factories/delivery"; +import "../factories/role"; + +var App, + offer1, + offer2, + reviewer, + reviewerName, + offer7, + offer3, + offer4, + delivery1, + delivery2, + offer5, + delivery3, + offer6, + offer8, + item8, + offer9, + item9, + offer10, + schedule, + ggv_order11, + delivery11, + offer11, + offer12, + role; + +module("Reviewer: Display Offer Status", { beforeEach: function() { App = startApp({}, 2); TestHelper.setup(); role = FactoryGuy.make("role"); - $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: { - roles: [role.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/role*", + type: "GET", + status: 200, + responseText: { + roles: [role.toJSON({ includeId: true })] + } + }); + + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] } }); reviewer = FactoryGuy.make("user"); - offer1 = FactoryGuy.make("offer_with_items", {state:"submitted"}); + offer1 = FactoryGuy.make("offer_with_items", { state: "submitted" }); - offer2 = FactoryGuy.make("offer_with_items", {state:"under_review", reviewedBy: reviewer}); + offer2 = FactoryGuy.make("offer_with_items", { + state: "under_review", + reviewedBy: reviewer + }); reviewerName = reviewer.get("firstName") + " " + reviewer.get("lastName"); - offer3 = FactoryGuy.make("offer_with_items", {state:"reviewed"}); + offer3 = FactoryGuy.make("offer_with_items", { state: "reviewed" }); - schedule = FactoryGuy.make('schedule', {scheduledAt: '12/01/2014'}); - delivery1 = FactoryGuy.make('delivery', {deliveryType: "Alternate", schedule: schedule}); - offer4 = FactoryGuy.make("offer_with_items", {state:"scheduled", delivery: delivery1}); + schedule = FactoryGuy.make("schedule", { scheduledAt: "12/01/2014" }); + delivery1 = FactoryGuy.make("delivery", { + deliveryType: "Alternate", + schedule: schedule + }); + offer4 = FactoryGuy.make("offer_with_items", { + state: "scheduled", + delivery: delivery1 + }); - delivery2 = FactoryGuy.make('delivery', {deliveryType: "Gogovan", schedule: schedule}); - offer5 = FactoryGuy.make("offer_with_items", {state:"scheduled", delivery: delivery2}); + delivery2 = FactoryGuy.make("delivery", { + deliveryType: "Gogovan", + schedule: schedule + }); + offer5 = FactoryGuy.make("offer_with_items", { + state: "scheduled", + delivery: delivery2 + }); - delivery3 = FactoryGuy.make('delivery', {deliveryType: "Drop Off", schedule: schedule}); - offer6 = FactoryGuy.make("offer_with_items", {state:"scheduled", delivery: delivery3}); + delivery3 = FactoryGuy.make("delivery", { + deliveryType: "Drop Off", + schedule: schedule + }); + offer6 = FactoryGuy.make("offer_with_items", { + state: "scheduled", + delivery: delivery3 + }); - offer7 = FactoryGuy.make("offer_with_items", { state:"closed", reviewedBy: reviewer }); + offer7 = FactoryGuy.make("offer_with_items", { + state: "closed", + reviewedBy: reviewer + }); - offer8 = FactoryGuy.make("offer", { state:"under_review" }); + offer8 = FactoryGuy.make("offer", { state: "under_review" }); item8 = FactoryGuy.make("item", { state: "rejected", offer: offer8 }); - offer9 = FactoryGuy.make("offer", { state:"under_review" }); + offer9 = FactoryGuy.make("offer", { state: "under_review" }); item9 = FactoryGuy.make("item", { state: "accepted", offer: offer9 }); - offer10 = FactoryGuy.make("offer_with_items", { state:"received" }); + offer10 = FactoryGuy.make("offer_with_items", { state: "received" }); ggv_order11 = FactoryGuy.make("gogovan_active_order"); - delivery11 = FactoryGuy.make("delivery", { deliveryType: "Gogovan", gogovanOrder: ggv_order11 }); - offer11 = FactoryGuy.make("offer_with_items", {state:"scheduled", delivery: delivery11}); - offer12 = FactoryGuy.make("offer_with_items", {state:"cancelled"}); + delivery11 = FactoryGuy.make("delivery", { + deliveryType: "Gogovan", + gogovanOrder: ggv_order11 + }); + offer11 = FactoryGuy.make("offer_with_items", { + state: "scheduled", + delivery: delivery11 + }); + offer12 = FactoryGuy.make("offer_with_items", { state: "cancelled" }); }, afterEach: function() { - Em.run(function() { TestHelper.teardown(); }); - Ember.run(App, 'destroy'); + Em.run(function() { + TestHelper.teardown(); + }); + Ember.run(App, "destroy"); } }); test("Display offer status for submitted offer", function(assert) { assert.expect(2); - visit('/offers/' + offer1.id + "/review_offer/items"); + visit("/offers/" + offer1.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer1.id + "/review_offer/items"); - assert.equal($.trim(find('.status-message').text()), "Start Review"); + assert.equal($.trim(find(".status-message").text()), "Start Review"); }); }); // display initial char with message test("Display offer status for offer under review", function(assert) { assert.expect(3); - visit('/offers/' + offer2.id + "/review_offer/items"); + visit("/offers/" + offer2.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer2.id + "/review_offer/items"); // message detail - var status = $.trim(find('.status-message').text()); - assert.equal(status.indexOf("Started by "+ reviewerName) >= 0, true); - assert.equal(status.indexOf(reviewer.get('nameInitial')) >= 0, true); + var status = $.trim(find(".status-message").text()); + assert.equal(status.indexOf("Started by " + reviewerName) >= 0, true); + assert.equal(status.indexOf(reviewer.get("nameInitial")) >= 0, true); }); }); test("Display offer status for reviewed offer", function(assert) { assert.expect(1); - visit('/offers/' + offer3.id + "/review_offer/items"); + visit("/offers/" + offer3.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer3.id + "/review_offer/items"); @@ -106,48 +171,73 @@ test("Display offer status for reviewed offer", function(assert) { test("Display offer status for scheduled offer: Collection", function(assert) { assert.expect(2); - visit('/offers/' + offer4.id + "/review_offer/items"); + visit("/offers/" + offer4.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer4.id + "/review_offer/items"); - assert.equal($.trim(find('.status-message').text().replace(/\s{2,}/g, ' ')), "Collection Mon 1st Dec Afternoon"); + assert.equal( + $.trim( + find(".status-message") + .text() + .replace(/\s{2,}/g, " ") + ), + "Collection Mon 1st Dec Afternoon" + ); }); }); test("Display offer status for scheduled offer: Gogovan pending", function(assert) { assert.expect(2); - visit('/offers/' + offer5.id + "/review_offer/items"); + visit("/offers/" + offer5.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer5.id + "/review_offer/items"); - assert.equal($.trim(find('.status-message').text().replace(/\s{2,}/g, ' ')), "Van ordered Afternoon, 2pm-4pm Mon 1st Dec"); + assert.equal( + $.trim( + find(".status-message") + .text() + .replace(/\s{2,}/g, " ") + ), + "Van ordered Afternoon, 2pm-4pm Mon 1st Dec" + ); }); }); test("Display offer status for scheduled offer: Gogovan active", function(assert) { assert.expect(2); - visit('/offers/' + offer11.id + "/review_offer/items"); + visit("/offers/" + offer11.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer11.id + "/review_offer/items"); - var status = $.trim(find('.status-message').text().replace(/\s{2,}/g, ' ')); + var status = $.trim( + find(".status-message") + .text() + .replace(/\s{2,}/g, " ") + ); assert.equal(status.indexOf("Van confirmed Afternoon, 2pm-4pm") >= 0, true); }); }); test("Display offer status for scheduled offer: Drop Off", function(assert) { assert.expect(2); - visit('/offers/' + offer6.id + "/review_offer/items"); + visit("/offers/" + offer6.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer6.id + "/review_offer/items"); - assert.equal($.trim(find('.status-message').text().replace(/\s{2,}/g, ' ')), "Drop-off Mon 1st Dec Afternoon"); + assert.equal( + $.trim( + find(".status-message") + .text() + .replace(/\s{2,}/g, " ") + ), + "Drop-off Mon 1st Dec Afternoon" + ); }); }); test("Display offer status for closed offer", function(assert) { assert.expect(1); - visit('/offers/' + offer7.id + "/review_offer/items"); + visit("/offers/" + offer7.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer7.id + "/review_offer/items"); @@ -157,42 +247,69 @@ test("Display offer status for closed offer", function(assert) { test("Display offer status for all rejected items", function(assert) { assert.expect(2); - visit('/offers/' + offer8.id + "/review_offer/items"); + visit("/offers/" + offer8.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer8.id + "/review_offer/items"); - assert.equal($.trim(find('.status-message').text()).indexOf("No items needed") >= 0, true); + assert.equal( + $.trim(find(".status-message").text()).indexOf("No items needed") >= 0, + true + ); }); }); test("Display offer status for all reviewed items", function(assert) { assert.expect(2); - visit('/offers/' + offer9.id + "/review_offer/items"); + visit("/offers/" + offer9.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer9.id + "/review_offer/items"); - assert.equal(find('.status-message').text().replace(/ /g,' ').indexOf("All items reviewed") >= 0, true); + assert.equal( + find(".status-message") + .text() + .replace(/ /g, " ") + .indexOf("All items reviewed") >= 0, + true + ); }); }); test("Display offer status for received offer-items", function(assert) { assert.expect(2); - visit('/offers/' + offer10.id + "/review_offer/items"); + visit("/offers/" + offer10.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer10.id + "/review_offer/items"); - var donor_name = offer10.get("createdBy.firstName") + " " + offer10.get("createdBy.lastName"); - assert.equal($('.status-message').text().trim().indexOf("Goods donated by " + donor_name + " received") >= 0, true); + var donor_name = + offer10.get("createdBy.firstName") + + " " + + offer10.get("createdBy.lastName"); + assert.equal( + $(".status-message") + .text() + .trim() + .indexOf("Goods donated by " + donor_name + " received") >= 0, + true + ); }); }); test("Display offer status for cancelled offer", function(assert) { assert.expect(2); - visit('/offers/' + offer12.id + "/review_offer/items"); + visit("/offers/" + offer12.id + "/review_offer/items"); andThen(function() { assert.equal(currentURL(), "/offers/" + offer12.id + "/review_offer/items"); - var donor_name = offer12.get("closedBy.firstName") + " " + offer12.get("closedBy.lastName"); - assert.equal($('.status-message').text().trim().indexOf("Cancelled by " + donor_name) >= 0, true); + var donor_name = + offer12.get("closedBy.firstName") + + " " + + offer12.get("closedBy.lastName"); + assert.equal( + $(".status-message") + .text() + .trim() + .indexOf("Cancelled by " + donor_name) >= 0, + true + ); }); }); diff --git a/tests/acceptance/reviewer-reject-item-test.js b/tests/acceptance/reviewer-reject-item-test.js index f4d99bbcd..44a053043 100644 --- a/tests/acceptance/reviewer-reject-item-test.js +++ b/tests/acceptance/reviewer-reject-item-test.js @@ -1,33 +1,48 @@ -import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import FactoryGuy from 'ember-data-factory-guy'; -import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper'; -import testSkip from '../helpers/test-skip'; -import { module, test } from 'qunit'; -import '../factories/offer'; -import '../factories/role'; +import Ember from "ember"; +import startApp from "../helpers/start-app"; +import FactoryGuy from "ember-data-factory-guy"; +import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; +import testSkip from "../helpers/test-skip"; +import { module, test } from "qunit"; +import "../factories/offer"; +import "../factories/role"; var App, offer, item1, item2, role; -module('Reviewer: Rejct Item Tab', { +module("Reviewer: Rejct Item Tab", { beforeEach: function() { App = startApp({}, 2); TestHelper.setup(); role = FactoryGuy.make("role"); - $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: { - roles: [role.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/role*", + type: "GET", + status: 200, + responseText: { + roles: [role.toJSON({ includeId: true })] } }); - offer = FactoryGuy.make("offer", { state:"under_review"}); - item1 = FactoryGuy.make("item_with_type", { offer: offer}); - item2 = FactoryGuy.make("item", { offer: offer}); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); + + offer = FactoryGuy.make("offer", { state: "under_review" }); + item1 = FactoryGuy.make("item_with_type", { offer: offer }); + item2 = FactoryGuy.make("item", { offer: offer }); }, afterEach: function() { - Em.run(function() { TestHelper.teardown(); }); - Ember.run(App, 'destroy'); + Em.run(function() { + TestHelper.teardown(); + }); + Ember.run(App, "destroy"); } }); @@ -35,9 +50,12 @@ test("visit rejected item without item_type", function(assert) { assert.expect(3); visit("/offers/" + offer.id + "/review_item/" + item2.id + "/reject"); andThen(function() { - assert.equal(currentURL(), "/offers/" + offer.id + "/review_item/" + item2.id + "/reject"); - assert.equal($('.item_lable_input input').val(), ""); - assert.equal($('p.no-items').text(), "Please choose Item Type first!"); + assert.equal( + currentURL(), + "/offers/" + offer.id + "/review_item/" + item2.id + "/reject" + ); + assert.equal($(".item_lable_input input").val(), ""); + assert.equal($("p.no-items").text(), "Please choose Item Type first!"); }); }); @@ -45,12 +63,21 @@ testSkip("visit rejected item with item_type", function(assert) { assert.expect(4); visit("/offers/" + offer.id + "/review_item/" + item1.id + "/reject"); andThen(function() { - assert.equal(currentURL(), "/offers/" + offer.id + "/review_item/" + item1.id + "/reject"); - assert.equal($('.item_lable_input input').val(), item1.get('packageType.name')); + assert.equal( + currentURL(), + "/offers/" + offer.id + "/review_item/" + item1.id + "/reject" + ); + assert.equal( + $(".item_lable_input input").val(), + item1.get("packageType.name") + ); assert.equal($(".reject-offer ul li").length, 4); //placeholder message in recjectio comments textarea - assert.equal($('textarea').attr('placeholder'), "Message to donor about the rejection of this item"); + assert.equal( + $("textarea").attr("placeholder"), + "Message to donor about the rejection of this item" + ); }); }); @@ -58,9 +85,12 @@ test("validate at least one option selected", function(assert) { assert.expect(2); visit("/offers/" + offer.id + "/review_item/" + item1.id + "/reject"); andThen(function() { - assert.equal(currentURL(), "/offers/" + offer.id + "/review_item/" + item1.id + "/reject"); - click('.rejectOffer'); - andThen(function(){ + assert.equal( + currentURL(), + "/offers/" + offer.id + "/review_item/" + item1.id + "/reject" + ); + click(".rejectOffer"); + andThen(function() { assert.equal($.trim($(".error-box").text()), "Please choose a reason."); }); }); @@ -70,16 +100,22 @@ testSkip("display message for quality option", function(assert) { assert.expect(3); visit("/offers/" + offer.id + "/review_item/" + item1.id + "/reject"); andThen(function() { - assert.equal(currentURL(), "/offers/" + offer.id + "/review_item/" + item1.id + "/reject"); - click($('input[type=radio]:eq(0)')); - andThen(function(){ + assert.equal( + currentURL(), + "/offers/" + offer.id + "/review_item/" + item1.id + "/reject" + ); + click($("input[type=radio]:eq(0)")); + andThen(function() { // set textarea conent on click of radio option - assert.equal($('textarea').val(), "Unfortunately we cannot receive this item. Some categories of items are very difficult for us to distribute unless they are in excellent condition."); + assert.equal( + $("textarea").val(), + "Unfortunately we cannot receive this item. Some categories of items are very difficult for us to distribute unless they are in excellent condition." + ); // clear message conent on click of x-icon - click($('.remove-text')); - andThen(function(){ - assert.equal($('textarea').val(), ""); + click($(".remove-text")); + andThen(function() { + assert.equal($("textarea").val(), ""); }); }); }); diff --git a/tests/acceptance/scheduled-test.js b/tests/acceptance/scheduled-test.js index 04b5a47d6..f25294e2e 100644 --- a/tests/acceptance/scheduled-test.js +++ b/tests/acceptance/scheduled-test.js @@ -1,49 +1,91 @@ -import Ember from 'ember'; -import startApp from '../helpers/start-app'; -import FactoryGuy from 'ember-data-factory-guy'; -import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper'; -import testSkip from '../helpers/test-skip'; -import { module } from 'qunit'; -import '../factories/user'; -import '../factories/offer'; -import '../factories/item'; -import '../factories/schedule'; -import '../factories/gogovan_order'; -import '../factories/delivery'; -import '../factories/role'; - -var App, offer1, delivery1, offer2, delivery2, offer3, - delivery3, schedule4, offer4, delivery4, ggv_order, role; - -module('Scheduled Offers', { +import Ember from "ember"; +import startApp from "../helpers/start-app"; +import FactoryGuy from "ember-data-factory-guy"; +import TestHelper from "ember-data-factory-guy/factory-guy-test-helper"; +import testSkip from "../helpers/test-skip"; +import { module } from "qunit"; +import "../factories/user"; +import "../factories/offer"; +import "../factories/item"; +import "../factories/schedule"; +import "../factories/gogovan_order"; +import "../factories/delivery"; +import "../factories/role"; + +var App, + offer1, + delivery1, + offer2, + delivery2, + offer3, + delivery3, + schedule4, + offer4, + delivery4, + ggv_order, + role; + +module("Scheduled Offers", { beforeEach: function() { App = startApp({}, 2); TestHelper.setup(); role = FactoryGuy.make("role"); - $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: { - roles: [role.toJSON({includeId: true})] + $.mockjax({ + url: "/api/v1/role*", + type: "GET", + status: 200, + responseText: { + roles: [role.toJSON({ includeId: true })] } }); - delivery1 = FactoryGuy.make('delivery', {deliveryType: "Gogovan"}); - offer1 = FactoryGuy.make("offer_with_items", { state: "scheduled", delivery: delivery1 }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); - ggv_order = FactoryGuy.make("gogovan_order", {status: "pending"}); - schedule4 = FactoryGuy.make('schedule', { - scheduledAt: (new Date(new Date().setDate(new Date().getDate()+30)))}); - delivery4 = FactoryGuy.make('delivery', {deliveryType: "Gogovan", schedule: schedule4, gogovanOrder: ggv_order }); - offer4 = FactoryGuy.make("offer_with_items", { state: "scheduled", delivery: delivery4 }); + delivery1 = FactoryGuy.make("delivery", { deliveryType: "Gogovan" }); + offer1 = FactoryGuy.make("offer_with_items", { + state: "scheduled", + delivery: delivery1 + }); - delivery2 = FactoryGuy.make('delivery', {deliveryType: "Alternate"}); - offer2 = FactoryGuy.make("offer_with_items", { state: "scheduled", delivery: delivery2 }); + ggv_order = FactoryGuy.make("gogovan_order", { status: "pending" }); + schedule4 = FactoryGuy.make("schedule", { + scheduledAt: new Date(new Date().setDate(new Date().getDate() + 30)) + }); + delivery4 = FactoryGuy.make("delivery", { + deliveryType: "Gogovan", + schedule: schedule4, + gogovanOrder: ggv_order + }); + offer4 = FactoryGuy.make("offer_with_items", { + state: "scheduled", + delivery: delivery4 + }); - delivery3 = FactoryGuy.make('delivery', {deliveryType: "Drop Off"}); - offer3 = FactoryGuy.make("offer_with_items", { state: "scheduled", delivery: delivery3 }); + delivery2 = FactoryGuy.make("delivery", { deliveryType: "Alternate" }); + offer2 = FactoryGuy.make("offer_with_items", { + state: "scheduled", + delivery: delivery2 + }); + + delivery3 = FactoryGuy.make("delivery", { deliveryType: "Drop Off" }); + offer3 = FactoryGuy.make("offer_with_items", { + state: "scheduled", + delivery: delivery3 + }); }, afterEach: function() { - Em.run(function() { TestHelper.teardown(); }); - Ember.run(App, 'destroy'); + Em.run(function() { + TestHelper.teardown(); + }); + Ember.run(App, "destroy"); } }); @@ -51,12 +93,24 @@ testSkip("viewing collection schedule", function(assert) { assert.expect(5); visit("/offers/scheduled"); - andThen(function(){ + andThen(function() { assert.equal(currentURL(), "/offers/scheduled/collection"); assert.equal(find("ul.list li").length, 1); assert.equal(find("ul.list img").length, 1); - assert.equal($('.time_indicator').text().indexOf('Collection') > 0, true); - assert.equal($.trim(find('.dynamic_filter select option').first().text()), "All offers (1)"); + assert.equal( + $(".time_indicator") + .text() + .indexOf("Collection") > 0, + true + ); + assert.equal( + $.trim( + find(".dynamic_filter select option") + .first() + .text() + ), + "All offers (1)" + ); }); }); @@ -64,11 +118,16 @@ testSkip("viewing gogovan delivery schedule", function(assert) { assert.expect(4); visit("/offers/scheduled/gogovan"); - andThen(function(){ + andThen(function() { assert.equal(currentURL(), "/offers/scheduled/gogovan"); assert.equal(find("ul.list li").length, 2); assert.equal(find("ul.list img").length, 2); - assert.equal($('.time_indicator').text().indexOf('Van ordered') > 0, true); + assert.equal( + $(".time_indicator") + .text() + .indexOf("Van ordered") > 0, + true + ); }); }); @@ -76,17 +135,29 @@ testSkip("filtering gogovan delivery schedule", function(assert) { assert.expect(5); visit("/offers/scheduled/gogovan"); - andThen(function(){ + andThen(function() { assert.equal(currentURL(), "/offers/scheduled/gogovan"); - var option = find('.dynamic_filter select option:contains("After next week (1)")').val(); - $('.dynamic_filter select').val(option).change(); - - andThen(function(){ - assert.equal($.trim(find('.dynamic_filter select :selected').text()), "After next week (1)"); + var option = find( + '.dynamic_filter select option:contains("After next week (1)")' + ).val(); + $(".dynamic_filter select") + .val(option) + .change(); + + andThen(function() { + assert.equal( + $.trim(find(".dynamic_filter select :selected").text()), + "After next week (1)" + ); assert.equal(find("ul.list li").length, 1); assert.equal(find("ul.list img").length, 1); - assert.equal($('.time_indicator').text().indexOf('Van ordered') > 0, true); + assert.equal( + $(".time_indicator") + .text() + .indexOf("Van ordered") > 0, + true + ); }); }); }); @@ -95,10 +166,15 @@ testSkip("viewing other delivery schedule", function(assert) { assert.expect(4); visit("/offers/scheduled/other_delivery"); - andThen(function(){ + andThen(function() { assert.equal(currentURL(), "/offers/scheduled/other_delivery"); assert.equal(find("ul.list li").length, 1); assert.equal(find("ul.list img").length, 1); - assert.equal($('.time_indicator').text().indexOf('Drop-off') > 0, true); + assert.equal( + $(".time_indicator") + .text() + .indexOf("Drop-off") > 0, + true + ); }); }); diff --git a/tests/acceptance/search-test.js b/tests/acceptance/search-test.js index 533389f66..71f469807 100644 --- a/tests/acceptance/search-test.js +++ b/tests/acceptance/search-test.js @@ -31,6 +31,15 @@ module("Search Offers", { } }); + $.mockjax({ + url: "/api/v1/canned*", + type: "GET", + status: 200, + responseText: { + canned_responses: [] + } + }); + user = FactoryGuy.make("user", { firstName: "Johnny", mobile: "99999999" }); offer = FactoryGuy.make("offer_with_items", { state: "scheduled", From 0c5bcfb064bd3f79fd15b7b5d2a49fb6ed203c0b Mon Sep 17 00:00:00 2001 From: shreyas098 Date: Mon, 1 Mar 2021 21:01:47 +0530 Subject: [PATCH 22/37] GCw-3487-Offer_id missing in params for item notification --- app/controllers/my_notifications.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/my_notifications.js b/app/controllers/my_notifications.js index aa5646bb8..806d73eb0 100644 --- a/app/controllers/my_notifications.js +++ b/app/controllers/my_notifications.js @@ -235,6 +235,9 @@ export default Ember.Controller.extend({ const messageId = notification.get("id"); var message = this.store.peekRecord("message", messageId); var route = this.get("messagesUtil").getRoute(message); + if (message.get("messageableType") === "Item") { + route[1] = message.get("item.offer.id"); + } this.transitionToRoute.apply(this, route); } }, From 9ee642562662037a24996b00babf9c0d43652cc8 Mon Sep 17 00:00:00 2001 From: bharat619 Date: Tue, 2 Mar 2021 10:22:05 +0530 Subject: [PATCH 23/37] Use phonegap-plugin-push 2.3.0 --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 84ebbd45a..4e5a06a6e 100755 --- a/Rakefile +++ b/Rakefile @@ -103,7 +103,7 @@ namespace :cordova do if platform == 'android' sh %{ cordova plugin add phonegap-plugin-push@2.1.2 } else - sh %{ cordova plugin add phonegap-plugin-push@1.9.2 --variable SENDER_ID="XXXXXXX" } + sh %{ cordova plugin add phonegap-plugin-push@2.3.0 --variable SENDER_ID="XXXXXXX" } end build = (environment == "staging" && platform == 'android') ? "debug" : "release" extra_params = (platform === "android") ? '' : ios_build_config From 418156efbf31dce051945d1a3b021f1cb1e65208 Mon Sep 17 00:00:00 2001 From: bharat619 Date: Tue, 2 Mar 2021 11:02:35 +0530 Subject: [PATCH 24/37] Circle-Ci changes for testing purpose --- .circleci/config.yml | 53 ++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 39 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 202708315..e66e69562 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -76,43 +76,6 @@ jobs: - run: yarn run bower install - save-cache: *save-bower-cache - tests: - <<: *defaults - docker: - - image: circleci/node:10-browsers - steps: - - restore-cache: *restore-repo-cache - - restore-cache: *restore-yarn-cache - - restore-cache: *restore-bower-cache - - run: - name: Start Ember test server - command: yarn run ember server --port 4201 - background: true - - run: - name: Wait for Ember test server to start - command: dockerize -wait tcp://localhost:4201 -timeout 1m - - run: - name: Run Ember tests - command: yarn test:ci - # command: COVERAGE=true yarn test:ci - # - persist_to_workspace: - # root: . - # paths: - # - coverage*/lcov.info - - upload-coverage: - <<: *defaults - steps: - - restore-cache: *restore-repo-cache - - restore-cache: *restore-yarn-cache - - restore-cache: *restore-bower-cache - - attach_workspace: - at: ~/code - - run: - name: Upload coverage results to Code Climate - command: | - yarn run codeclimate-test-reporter < coverage*/lcov.info - www_build: <<: *defaults steps: @@ -126,6 +89,9 @@ jobs: master) ENVIRONMENT=staging ;; + GCW-3202-ios-push-notifications) + ENVIRONMENT=staging + ;; preview) ENVIRONMENT=preview ;; @@ -215,6 +181,9 @@ jobs: master) ENVIRONMENT=staging ;; + GCW-3202-ios-push-notifications) + ENVIRONMENT=staging + ;; preview) ENVIRONMENT=preview ;; @@ -330,6 +299,12 @@ jobs: echo 'export CERTIFICATE=GoodCity_2020_Development.p12' >> $BASH_ENV echo 'export PROVISIONING_PROFILE=GoodcityAdminStaging.mobileprovision' >> $BASH_ENV ;; + GCW-3202-ios-push-notifications) + echo 'export ENVIRONMENT=staging' >> $BASH_ENV + echo 'export CERTIFICATE=GoodCity_2020_Development.p12' >> $BASH_ENV + echo 'export PROVISIONING_PROFILE=GoodCityStockStaging.mobileprovision' >> $BASH_ENV + echo 'export SCANDIT_LICENSE_KEY=$SCANDIT_LICENSE_KEY_IOS_STAGING' >> $BASH_ENV + ;; live) echo 'export ENVIRONMENT=production' >> $BASH_ENV echo 'export CERTIFICATE=Goodcity_2020.p12' >> $BASH_ENV @@ -437,7 +412,7 @@ workflows: - package_dependencies filters: branches: - only: /^(master|live)$/ + only: /^(master|live|GCW-3202-ios-push-notifications)$/ - android_build_and_deploy: requires: - ember_cordova_build @@ -449,4 +424,4 @@ workflows: - tests filters: branches: - only: /^(master|live)$/ + only: /^(master|live|GCW-3202-ios-push-notifications)$/ From 1ed8ca830b81e1f5c2bdd2fa5518ff34ef9a9644 Mon Sep 17 00:00:00 2001 From: bharat619 Date: Tue, 2 Mar 2021 11:10:39 +0530 Subject: [PATCH 25/37] Circle-Ci changes for testing purpose --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e66e69562..4ad261da8 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -395,7 +395,6 @@ workflows: # only: /^(master|live)$/ - www_build: requires: - - tests - package_dependencies filters: branches: @@ -408,7 +407,6 @@ workflows: only: /^(master|live|preview)$/ - ember_cordova_build: requires: - - tests - package_dependencies filters: branches: @@ -421,7 +419,6 @@ workflows: only: /^(master|live)$/ - ios_build_and_deploy: requires: - - tests filters: branches: only: /^(master|live|GCW-3202-ios-push-notifications)$/ From 79c024528370dd4d43e9bb00969795ca86735734 Mon Sep 17 00:00:00 2001 From: Patrick R Date: Tue, 2 Mar 2021 14:12:45 +0800 Subject: [PATCH 26/37] FIX: Shared chat displays are broken when there is no donor --- app/controllers/message_base_controller.js | 15 +++++++-------- app/controllers/my_notifications.js | 5 +++-- app/controllers/review_offer/share/index.js | 1 - app/models/message.js | 4 ++++ package.json | 3 ++- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/controllers/message_base_controller.js b/app/controllers/message_base_controller.js index bfc6a550d..2e2ae162d 100644 --- a/app/controllers/message_base_controller.js +++ b/app/controllers/message_base_controller.js @@ -59,14 +59,13 @@ export default Ember.Controller.extend({ this.get("recipientId") || (this.get("isPrivate") ? null : this.get("offer.createdById")); - if (recipientId) { - messages = messages.filter(m => { - return ( - m.get("recipientId") === recipientId || - m.get("senderId") === recipientId - ); - }); - } + messages = messages.filter(m => { + return ( + recipientId && + (m.get("recipientId") === recipientId || + m.get("senderId") === recipientId) + ); + }); return messages.filter(m => { return Boolean(m.get("isPrivate")) === this.get("isPrivate"); diff --git a/app/controllers/my_notifications.js b/app/controllers/my_notifications.js index aa5646bb8..1def55f2c 100644 --- a/app/controllers/my_notifications.js +++ b/app/controllers/my_notifications.js @@ -183,8 +183,9 @@ export default Ember.Controller.extend({ const donorId = message.get("offer.createdById"); return ( - message.get("senderId") !== donorId && - message.get("recipientId") !== donorId + !donorId || + (message.get("senderId") !== donorId && + message.get("recipientId") !== donorId) ); }, diff --git a/app/controllers/review_offer/share/index.js b/app/controllers/review_offer/share/index.js index 0d9163222..33e8ae01f 100644 --- a/app/controllers/review_offer/share/index.js +++ b/app/controllers/review_offer/share/index.js @@ -23,7 +23,6 @@ export default Ember.Controller.extend(AsyncTasksMixin, { "allMessages.length", "allMessages.@each.{senderId,recipientId}", function() { - const donorId = this.get("offer.createdById"); return this.get("allMessages") .filterBy("offerId", this.get("offer.id")) .filter(m => diff --git a/app/models/message.js b/app/models/message.js index 262a07704..11b7b94ce 100644 --- a/app/models/message.js +++ b/app/models/message.js @@ -69,6 +69,10 @@ export default DS.Model.extend({ const donorId = this.get("offer.createdById"); + if (!donorId) { + return !this.get("isPrivate"); + } + // It's a chat with an external user (a charity) if: // - It's public // - It does not involve the donor diff --git a/package.json b/package.json index 012de71b2..55a5b939a 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ }, "scripts": { "start": "EMBER_CLI_CORDOVA=0 ENVIRONMENT=development ember serve --port 4201 --live-reload-port 35730", + "start:staging": "EMBER_CLI_CORDOVA=0 ENVIRONMENT=staging ember serve --port 4201 --live-reload-port 35730", "test": "EMBER_CLI_CORDOVA=0 ENVIRONMENT=test ember test --server --test-port 7358", "test:ci": "EMBER_CLI_CORDOVA=0 ENVIRONMENT=test ember-pretty-test", "build:web:development": "EMBER_CLI_CORDOVA=0 ENVIRONMENT=development ember build", @@ -64,7 +65,7 @@ "ember-cli-inject-live-reload": "^1.7.0", "ember-cli-qunit": "^2.2.4", "ember-cli-release": "^1.0.0-beta.2", - "ember-cli-sass": "^7.1.2", + "ember-cli-sass": "^5.6.0", "ember-cli-sri": "^2.1.1", "ember-cli-uglify": "^2.1.0", "ember-data": "~2.11.0", From fda46edf3b30412995796d0133d368dc78396794 Mon Sep 17 00:00:00 2001 From: Patrick R Date: Tue, 2 Mar 2021 14:14:26 +0800 Subject: [PATCH 27/37] FIX: restore package.json dependency version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 55a5b939a..6d9a2f297 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "ember-cli-inject-live-reload": "^1.7.0", "ember-cli-qunit": "^2.2.4", "ember-cli-release": "^1.0.0-beta.2", - "ember-cli-sass": "^5.6.0", + "ember-cli-sass": "^7.1.2", "ember-cli-sri": "^2.1.1", "ember-cli-uglify": "^2.1.0", "ember-data": "~2.11.0", From add13a596340cd4da179d0b4a1e4ae9ecc8e81ff Mon Sep 17 00:00:00 2001 From: bharat619 Date: Tue, 2 Mar 2021 11:52:27 +0530 Subject: [PATCH 28/37] updating fastlane --- Gemfile.lock | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bbc259680..bcb2eefb7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,7 +17,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.1.0) - aws-partitions (1.426.0) + aws-partitions (1.430.0) aws-sdk-core (3.112.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) @@ -26,7 +26,7 @@ GEM aws-sdk-kms (1.42.0) aws-sdk-core (~> 3, >= 3.112.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.88.0) + aws-sdk-s3 (1.89.0) aws-sdk-core (~> 3, >= 3.112.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) @@ -86,7 +86,7 @@ GEM domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) dotenv (2.7.6) - emoji_regex (3.2.1) + emoji_regex (3.2.2) escape (0.0.4) excon (0.79.0) faraday (1.3.0) @@ -99,8 +99,8 @@ GEM faraday-net_http (1.0.1) faraday_middleware (1.0.0) faraday (~> 1.0) - fastimage (2.2.2) - fastlane (2.174.0) + fastimage (2.2.3) + fastlane (2.176.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.3, < 3.0.0) artifactory (~> 3.0) @@ -124,6 +124,7 @@ GEM jwt (>= 2.1.0, < 3) mini_magick (>= 4.9.4, < 5.0.0) multipart-post (~> 2.0.0) + naturally (~> 2.2) plist (>= 3.1.0, < 4.0.0) rubyzip (>= 2.0.0, < 3.0.0) security (= 0.1.3) From 2616b029849c844857f0c375c78651cfb38e2ef2 Mon Sep 17 00:00:00 2001 From: bharat619 Date: Tue, 2 Mar 2021 12:10:33 +0530 Subject: [PATCH 29/37] Circle-Ci changes for testing purpose --- .circleci/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ad261da8..cde3c7ff3 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -302,8 +302,7 @@ jobs: GCW-3202-ios-push-notifications) echo 'export ENVIRONMENT=staging' >> $BASH_ENV echo 'export CERTIFICATE=GoodCity_2020_Development.p12' >> $BASH_ENV - echo 'export PROVISIONING_PROFILE=GoodCityStockStaging.mobileprovision' >> $BASH_ENV - echo 'export SCANDIT_LICENSE_KEY=$SCANDIT_LICENSE_KEY_IOS_STAGING' >> $BASH_ENV + echo 'export PROVISIONING_PROFILE=GoodcityAdminStaging.mobileprovision' >> $BASH_ENV ;; live) echo 'export ENVIRONMENT=production' >> $BASH_ENV From c23c57a4f18e719cddab1f5a21777bd9a1708a9d Mon Sep 17 00:00:00 2001 From: Patrick R Date: Tue, 2 Mar 2021 14:46:18 +0800 Subject: [PATCH 30/37] FIX: broken specs --- .../acceptance/reviewer-item-messages-test.js | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/reviewer-item-messages-test.js b/tests/acceptance/reviewer-item-messages-test.js index 3d351385f..5cddb2de7 100644 --- a/tests/acceptance/reviewer-item-messages-test.js +++ b/tests/acceptance/reviewer-item-messages-test.js @@ -8,7 +8,7 @@ import "../factories/offer"; import "../factories/item"; import "../factories/role"; -var App, offer, item, message1, message2, message3, role; +var App, offer, item, message1, message2, message3, role, donor; module("Reviewer: Display Item Messages", { beforeEach: function() { @@ -32,20 +32,26 @@ module("Reviewer: Display Item Messages", { canned_responses: [] } }); - offer = { id: "300", state: "under_review" }; + + donor = { id: "1000", first_name: "jane", last_name: "doe" }; + offer = { id: "300", state: "under_review", created_by_id: 1000 }; item = { id: "110", state: "submitted", offer_id: offer.id }; message1 = { id: "44", offer_id: offer.id, item_id: item.id, - created_at: new Date("2015/1/1").toString() + created_at: new Date("2015/1/1").toString(), + is_private: false, + sender_id: donor.id }; message2 = { id: "45", offer_id: offer.id, item_id: item.id, body: "Message from Donor", - created_at: new Date("2015/1/2").toString() + created_at: new Date("2015/1/2").toString(), + is_private: false, + sender_id: donor.id }; message3 = { id: "46", @@ -60,7 +66,8 @@ module("Reviewer: Display Item Messages", { type: "GET", status: 200, responseText: { - messages: [message1, message2, message3] + messages: [message1, message2, message3], + users: [donor] } }); @@ -71,7 +78,8 @@ module("Reviewer: Display Item Messages", { responseText: { items: [item], offers: [offer], - messages: [message1, message2, message3] + messages: [message1, message2, message3], + users: [donor] } }); From 3e5a85f2814a4eb2099a66eb1816efe44b7457b3 Mon Sep 17 00:00:00 2001 From: Patrick R Date: Tue, 2 Mar 2021 15:13:15 +0800 Subject: [PATCH 31/37] FIX: broken specs --- .../reviewer-offer-messages-test.js | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/tests/acceptance/reviewer-offer-messages-test.js b/tests/acceptance/reviewer-offer-messages-test.js index c0fe69d9d..06615d005 100644 --- a/tests/acceptance/reviewer-offer-messages-test.js +++ b/tests/acceptance/reviewer-offer-messages-test.js @@ -18,7 +18,7 @@ var App, message5, user1, user2, - offer1, + offer2, role; module("Reviewer: Display Offer Messages", { @@ -45,29 +45,30 @@ module("Reviewer: Display Offer Messages", { }); user1 = FactoryGuy.make("user"); user2 = FactoryGuy.make("user_with_image"); - offer = { id: 33, state: "under_review" }; - offer1 = { id: 34, createdBy: user1, state: "under_review" }; + offer = { id: 33, created_by_id: user1.get("id"), state: "under_review" }; + offer2 = { id: 34, created_by_id: user2.get("id"), state: "under_review" }; message4 = { id: 81, - offer_id: offer1.id, - sender: user2.get("id"), - item_id: null, - body: "Message from donor1", - created_at: new Date("2015/1/1").toString() - }; - message5 = { - id: 82, - offer_id: offer1.id, + offer_id: offer.id, sender_id: user1.get("id"), item_id: null, - body: "Message from donor2", - created_at: new Date("2015/1/2").toString() + body: "Message from donor 1", + created_at: new Date("2015/1/1").toString() }; message1 = { id: 83, + offer_id: offer2.id, + item: null, + created_at: new Date("2015/1/3").toString(), + sender_id: user2.get("id") + }; + message2 = { + id: 85, offer_id: offer.id, item: null, - created_at: new Date("2015/1/3").toString() + body: "Message from Donor", + created_at: new Date("2015/1/4").toString(), + sender_id: user1.get("id") }; message3 = { id: 84, @@ -76,22 +77,19 @@ module("Reviewer: Display Offer Messages", { body: "Message from Supervisor", is_private: true }; - message2 = { - id: 85, - offer_id: offer.id, - item: null, - body: "Message from Donor", - created_at: new Date("2015/1/4").toString() - }; - let messages = [message1, message2, message3, message4, message5]; - let offers = [offer, offer1]; + let messages = [message1, message2, message3, message4]; + let offers = [offer, offer2]; + let users = [ + user1.toJSON({ includeId: true }), + user2.toJSON({ includeId: true }) + ]; $.mockjax({ url: "/api/v1/message*", type: "GET", status: 200, - responseText: { messages } + responseText: { messages, users, offers } }); $.mockjax({ @@ -107,7 +105,7 @@ module("Reviewer: Display Offer Messages", { url: "/api/v1/offer*", type: "GET", status: 200, - responseText: { offers, messages } + responseText: { offers, messages, users } }); }, @@ -192,7 +190,7 @@ test("offer-messages from staff should add unread bubble in supervisor message t testSkip("offer-message with image", function(assert) { assert.expect(1); - visit("/offers/" + offer1.id + "/donor_messages"); + visit("/offers/" + offer2.id + "/donor_messages"); andThen(function() { var src = $(".received_message#" + message4.id + " img").attr("src"); assert.equal(src.indexOf("cloudinary") > 0, true); From fe248841d89f123e4ddcc29c5d037321ceeb7a8f Mon Sep 17 00:00:00 2001 From: bharat619 Date: Tue, 2 Mar 2021 13:04:46 +0530 Subject: [PATCH 32/37] Revert circleci changes --- .circleci/config.yml | 55 +++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cde3c7ff3..202708315 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -76,6 +76,43 @@ jobs: - run: yarn run bower install - save-cache: *save-bower-cache + tests: + <<: *defaults + docker: + - image: circleci/node:10-browsers + steps: + - restore-cache: *restore-repo-cache + - restore-cache: *restore-yarn-cache + - restore-cache: *restore-bower-cache + - run: + name: Start Ember test server + command: yarn run ember server --port 4201 + background: true + - run: + name: Wait for Ember test server to start + command: dockerize -wait tcp://localhost:4201 -timeout 1m + - run: + name: Run Ember tests + command: yarn test:ci + # command: COVERAGE=true yarn test:ci + # - persist_to_workspace: + # root: . + # paths: + # - coverage*/lcov.info + + upload-coverage: + <<: *defaults + steps: + - restore-cache: *restore-repo-cache + - restore-cache: *restore-yarn-cache + - restore-cache: *restore-bower-cache + - attach_workspace: + at: ~/code + - run: + name: Upload coverage results to Code Climate + command: | + yarn run codeclimate-test-reporter < coverage*/lcov.info + www_build: <<: *defaults steps: @@ -89,9 +126,6 @@ jobs: master) ENVIRONMENT=staging ;; - GCW-3202-ios-push-notifications) - ENVIRONMENT=staging - ;; preview) ENVIRONMENT=preview ;; @@ -181,9 +215,6 @@ jobs: master) ENVIRONMENT=staging ;; - GCW-3202-ios-push-notifications) - ENVIRONMENT=staging - ;; preview) ENVIRONMENT=preview ;; @@ -299,11 +330,6 @@ jobs: echo 'export CERTIFICATE=GoodCity_2020_Development.p12' >> $BASH_ENV echo 'export PROVISIONING_PROFILE=GoodcityAdminStaging.mobileprovision' >> $BASH_ENV ;; - GCW-3202-ios-push-notifications) - echo 'export ENVIRONMENT=staging' >> $BASH_ENV - echo 'export CERTIFICATE=GoodCity_2020_Development.p12' >> $BASH_ENV - echo 'export PROVISIONING_PROFILE=GoodcityAdminStaging.mobileprovision' >> $BASH_ENV - ;; live) echo 'export ENVIRONMENT=production' >> $BASH_ENV echo 'export CERTIFICATE=Goodcity_2020.p12' >> $BASH_ENV @@ -394,6 +420,7 @@ workflows: # only: /^(master|live)$/ - www_build: requires: + - tests - package_dependencies filters: branches: @@ -406,10 +433,11 @@ workflows: only: /^(master|live|preview)$/ - ember_cordova_build: requires: + - tests - package_dependencies filters: branches: - only: /^(master|live|GCW-3202-ios-push-notifications)$/ + only: /^(master|live)$/ - android_build_and_deploy: requires: - ember_cordova_build @@ -418,6 +446,7 @@ workflows: only: /^(master|live)$/ - ios_build_and_deploy: requires: + - tests filters: branches: - only: /^(master|live|GCW-3202-ios-push-notifications)$/ + only: /^(master|live)$/ From 5c85e27da7d0308f449c986d4a543c74008baa64 Mon Sep 17 00:00:00 2001 From: bharat619 Date: Thu, 4 Mar 2021 10:34:07 +0530 Subject: [PATCH 33/37] :art: Adds popup for offer deletion on clicking back button from empty offer --- app/controllers/review_offer.js | 40 +++++++++++++++++++++------ app/locales/en/translations.coffee | 2 ++ app/locales/zh-tw/translations.coffee | 1 + app/templates/review_offer.hbs | 3 +- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/app/controllers/review_offer.js b/app/controllers/review_offer.js index 5cace66ef..e6ec32d0f 100644 --- a/app/controllers/review_offer.js +++ b/app/controllers/review_offer.js @@ -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"); @@ -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")); diff --git a/app/locales/en/translations.coffee b/app/locales/en/translations.coffee index aec54e05d..81ce409e2 100644 --- a/app/locales/en/translations.coffee +++ b/app/locales/en/translations.coffee @@ -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" @@ -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." diff --git a/app/locales/zh-tw/translations.coffee b/app/locales/zh-tw/translations.coffee index 87105fe24..9df74c124 100644 --- a/app/locales/zh-tw/translations.coffee +++ b/app/locales/zh-tw/translations.coffee @@ -250,6 +250,7 @@ I18nTranslationsZhTw = "close_offer_summary": "這項捐贈項目將列為完成。" "add_note": "按下以增加/修改記事板" "tap_to_save": "按下以儲存" + "empty_offer_message": "這個捐贈沒有任何相關物資。你是否需要刪除" "donor": "offer_id": "捐贈項目號碼" diff --git a/app/templates/review_offer.hbs b/app/templates/review_offer.hbs index 31328034d..79d5c3008 100644 --- a/app/templates/review_offer.hbs +++ b/app/templates/review_offer.hbs @@ -1,6 +1,7 @@