Skip to content

Commit c907f18

Browse files
Merge pull request #267 from crossroads/master
#JuneRelease3
2 parents 69bd90c + df98289 commit c907f18

File tree

13 files changed

+161
-27
lines changed

13 files changed

+161
-27
lines changed

app/controllers/orders/detail.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ export default Ember.Controller.extend({
7373

7474
updateOrder(order, actionName) {
7575
switch(actionName) {
76+
case "finish_processing":
77+
this.send("promptFinishModal", order, actionName);
78+
break;
7679
case "messagePopUp":
7780
this.send("changeOrderState", order, "cancel");
7881
break;
@@ -102,6 +105,16 @@ export default Ember.Controller.extend({
102105
}
103106
},
104107

108+
promptFinishModal(order, actionName) {
109+
var _this = this;
110+
var ordersPackagesState = order.get("ordersPackages").getEach("state");
111+
if(ordersPackagesState.indexOf("cancelled") >= 0) {
112+
_this.genericAlertPopUp("order_details.finish_process_warning", function() {});
113+
} else {
114+
_this.send("changeOrderState", order, actionName);
115+
}
116+
},
117+
105118
dispatchLaterModel(order, actionName) {
106119
var _this = this;
107120
if(!order.get('allDesignatedOrdersPackages')) {

app/locales/en/translations.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ I18nTranslationsEn =
6262
"add_item_to_order": "Add an item to this order"
6363
"resubmit_order_warning": "Resubmitting an Order will set order state to submitted. Are you sure you want to resubmit the order?"
6464
"reopen_undispatch_warning": "You can only reopen an order after un-dispatching all dispatched items."
65-
"dispatch_later_undispatch_warning": "You need to un-dispatch all dispatched the items first."
65+
"dispatch_later_undispatch_warning": "You need to un-dispatch all the dispatched items first."
6666
"dispatch_later_warning": "Dispatching later will change order state to awaiting dispatch state. Are you sure you want to dispatch later?"
6767
"reopen_warning": "Reopening this order will set order state to dispatching. Are you sure you want to reopen the order?"
6868
"restart_undispatch_warning": "You can only restart processing an order after un-dispatching all dispatched items."
@@ -72,6 +72,7 @@ I18nTranslationsEn =
7272
"first_item_dispatch_warning": "You are dispatching first Item in the Order. This will also change state of the Order to dispatching."
7373
"close_order_popup": "All items in this order are dispatched. Would you like to close the Order? You will not be able to modify the order after closing it."
7474
"cancel_item_designate_warning": "This will also change state of the Order to processing from cancelled. Are you sure you want to designate?"
75+
"finish_process_warning": "Designate all the items before finishing process."
7576

7677
"order":
7778
"submitted": "Submitted"

app/locales/zh-tw/translations.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ I18nTranslationsEn =
6161
"add_item_to_order": "Add an item to this order"
6262
"resubmit_order_warning": "Resubmitting an Order will set order state to submitted. Are you sure you want to resubmit the order?"
6363
"reopen_undispatch_warning": "You can only reopen an order after un-dispatching all dispatched items."
64-
"dispatch_later_undispatch_warning": "You need to un-dispatch all dispatched the items first."
64+
"dispatch_later_undispatch_warning": "You need to un-dispatch all the dispatched items first."
6565
"dispatch_later_warning": "Dispatching later will change order state to awaiting dispatch state. Are you sure you want to dispatch later?"
6666
"reopen_warning": "Reopening this order will set order state to dispatching. Are you sure you want to reopen the order?"
6767
"restart_undispatch_warning": "You can only restart processing an order after un-dispatching all dispatched items."
@@ -71,6 +71,7 @@ I18nTranslationsEn =
7171
"first_item_dispatch_warning": "You are dispatching first Item in the Order. This will also change state of the Order to dispatching."
7272
"close_order_popup": "All items in this order are dispatched. Would you like to close the Order? You will not be able to modify the order after closing it."
7373
"cancel_item_designate_warning": "This will also change state of the Order to processing from cancelled. Are you sure you want to designate?"
74+
"finish_process_warning": "Designate all the items before finishing process."
7475

7576
"order":
7677
"submitted": "Submitted"

app/models/designation.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export default Model.extend({
1010
state: attr('string'),
1111
createdAt: attr('date'),
1212
recentlyUsedAt: attr('date'),
13+
submittedAt: attr('date'),
14+
submittedById: attr('number'),
1315
processedAt: attr('date'),
1416
processedById: attr('number'),
1517
cancelledAt: attr('date'),
@@ -36,6 +38,7 @@ export default Model.extend({
3638
ordersPackages: hasMany('ordersPackages', { async: false }),
3739
orderTransport: belongsTo('orderTransport', { async: false }),
3840
ordersPurposes: hasMany('ordersPurpose', { async: false }),
41+
submittedBy: belongsTo('user', { async: false }),
3942

4043
isLocalOrder: Ember.computed.equal('detailType', 'LocalOrder'),
4144
isGoodCityOrder: Ember.computed.equal('detailType', 'GoodCity'),

app/routes/orders/detail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export default getOrderRoute.extend({
4646

4747
afterModel(model) {
4848
var organisation;
49-
var organisationId = model.get('gcOrganisationId');
5049
if(model) {
50+
var organisationId = model.get('gcOrganisationId');
5151
var ordersPackages = this.store.query("orders_package", { search_by_order_id: model.get("id") });
5252
if(organisationId) {
5353
organisation = this.store.findRecord('gcOrganisation', organisationId);

app/styles/templates/orders/_detail.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@
184184
}
185185
}
186186

187+
.contact_details {
188+
margin-top: 1rem !important;
189+
}
190+
187191
.main_details {
188192
margin: -1rem 0.3rem;
189193
font-size: 0.8rem;

app/templates/orders/_order_status_bar.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<div class="small-6 medium-6 large-6 columns">
3333
<button {{action 'updateOrder' model 'finish_processing'}} class="button expand">{{t "order.finish_process"}}</button>
3434
</div>
35-
<div class="{{if model.ordersPackagesCount 'small-6 medium-6 large-6' 'small-12 medium-12 large-12'}} columns">
35+
<div class="small-6 medium-6 large-6 columns">
3636
<button {{action 'updateOrder' model 'cancel'}} disabled={{if model.allDesignatedOrdersPackages false 'disabled'}} class="button expand">{{t "order.cancel_order"}}</button>
3737
</div>
3838
{{else if (is-equal model.capitalizedState "Awaiting_dispatch")}}

app/templates/orders/contact.hbs

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,72 @@
1313
</nav>
1414

1515
<section class="main-section order_page">
16-
17-
<div class="row ">
18-
<div class="small-12 columns main_details">
19-
<div class="row">
20-
<div class="small-5 columns">
21-
Name:
22-
</div>
23-
<div class="small-7 columns">
24-
{{contact.fullName}}
16+
{{#if model.isGoodCityOrder}}
17+
<div class="row ">
18+
<div class="small-12 columns main_details contact_details">
19+
<div class="row">
20+
<div class="small-5 columns">
21+
Name:
22+
</div>
23+
<div class="small-7 columns name">
24+
{{model.submittedBy.fullName}}
25+
</div>
2526
</div>
26-
</div>
2727

28-
{{#if contact.phoneNumber}}
2928
<div class="row">
3029
<div class="small-5 columns">
3130
Phone Number:
3231
</div>
33-
<div class="small-7 columns">
34-
{{contact.phoneNumber}}
32+
<div class="small-7 columns mobile">
33+
{{model.submittedBy.mobile}}
3534
</div>
3635
</div>
37-
{{/if}}
3836

39-
{{#if contact.mobilePhoneNumber}}
4037
<div class="row">
4138
<div class="small-5 columns">
42-
Mobile Number:
39+
Email:
40+
</div>
41+
<div class="small-7 columns email">
42+
{{model.submittedBy.email}}
43+
</div>
44+
</div>
45+
</div>
46+
</div>
47+
{{else}}
48+
<div class="row ">
49+
<div class="small-12 columns main_details">
50+
<div class="row">
51+
<div class="small-5 columns">
52+
Name:
4353
</div>
4454
<div class="small-7 columns">
45-
{{contact.mobilePhoneNumber}}
55+
{{contact.fullName}}
4656
</div>
4757
</div>
48-
{{/if}}
58+
59+
{{#if contact.phoneNumber}}
60+
<div class="row">
61+
<div class="small-5 columns">
62+
Phone Number:
63+
</div>
64+
<div class="small-7 columns">
65+
{{contact.phoneNumber}}
66+
</div>
67+
</div>
68+
{{/if}}
69+
70+
{{#if contact.mobilePhoneNumber}}
71+
<div class="row">
72+
<div class="small-5 columns">
73+
Mobile Number:
74+
</div>
75+
<div class="small-7 columns">
76+
{{contact.mobilePhoneNumber}}
77+
</div>
78+
</div>
79+
{{/if}}
80+
</div>
4981
</div>
50-
</div>
82+
{{/if}}
5183

5284
</section>

app/templates/orders/detail.hbs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<div class="small-4 columns">
4646
Organisation:
4747
</div>
48-
<div class="small-8 columns">
48+
<div class="small-8 columns organisation_name">
4949
{{apply-line-break (if model.isGoodCityOrder model.gcOrganisation.nameEn model.organisation.name)}}
5050
</div>
5151
</div>
@@ -56,7 +56,11 @@
5656
Contact:
5757
</div>
5858
<div class="small-7 columns">
59-
{{model.contact.fullName}}
59+
{{#if model.isGoodCityOrder}}
60+
{{model.submittedBy.fullName}}
61+
{{else}}
62+
{{model.contact.fullName}}
63+
{{/if}}
6064
</div>
6165
<div class="small-1 columns icons">
6266
<i class="fa fa-angle-right arrow-icon" aria-hidden="true"></i>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import Ember from 'ember';
2+
import { module, test } from 'qunit';
3+
import startApp from '../helpers/start-app';
4+
import '../factories/orders_package';
5+
import '../factories/designation';
6+
import '../factories/item';
7+
import '../factories/gc_organisation';
8+
import '../factories/user';
9+
import '../factories/location';
10+
import '../factories/organisations_user';
11+
import FactoryGuy from 'ember-data-factory-guy';
12+
import { mockFindAll } from 'ember-data-factory-guy';
13+
14+
var App, designation, item1, orders_package1, gc_organisation, user, organisation_user;
15+
16+
module('Acceptance: Order Detail', {
17+
beforeEach: function() {
18+
App = startApp({}, 2);
19+
user = FactoryGuy.make("user", { mobile: "123456", email: "abc@xyz" });
20+
var location = FactoryGuy.make("location");
21+
gc_organisation = FactoryGuy.make("gc_organisation");
22+
organisation_user = FactoryGuy.make("organisationsUser", { gcOrganisation: gc_organisation, user: user });
23+
designation = FactoryGuy.make("designation", { state: "submitted", detailType: "GoodCity", gcOrganisation: gc_organisation, submittedBy: user });
24+
item1 = FactoryGuy.make("item", { state: "submitted", quantity: 0 , designation: designation});
25+
orders_package1 = FactoryGuy.make("orders_package", { state: "dispatched", quantity: 1, item: item1, designation: designation });
26+
var data = {"user_profile": [{"id": 2,"first_name": "David", "last_name": "Dara51", "mobile": "61111111", "user_role_ids": [1]}], "users": [{"id": 2,"first_name": "David", "last_name": "Dara51", "mobile": "61111111"}], "roles": [{"id": 4, "name": "Supervisor"}], "user_roles": [{"id": 1, "user_id": 2, "role_id": 4}]};
27+
28+
$.mockjax({url:"/api/v1/auth/current_user_profil*",
29+
responseText: data });
30+
$.mockjax({url: "/api/v1/designations/*", type: 'GET', status: 200,responseText: {
31+
designations: [designation.toJSON({includeId: true})],
32+
orders_packages: [orders_package1.toJSON({includeId: true})]
33+
}});
34+
35+
visit("/");
36+
37+
andThen(function() {
38+
visit("/orders/");
39+
});
40+
41+
andThen(function(){
42+
visit("/orders/" + designation.id);
43+
});
44+
45+
mockFindAll('location').returns({json: {locations: [location.toJSON({includeId: true})]}});
46+
mockFindAll('designation').returns({ json: {designations: [designation.toJSON({includeId: true})], items: [item1.toJSON({includeId: true})], orders_packages: [orders_package1.toJSON({includeId: true})], meta: {search: designation.get('code').toString()}}});
47+
mockFindAll('orders_package').returns({ json: {orders_packages: [orders_package1.toJSON({includeId: true})]}});
48+
},
49+
afterEach: function() {
50+
Ember.run(App, 'destroy');
51+
}
52+
});
53+
54+
test("Organisation Detail for Order detail page", function(assert) {
55+
assert.expect(2);
56+
assert.equal(currentPath(), "orders.detail");
57+
assert.equal($('.organisation_name').text().trim(), gc_organisation.get("nameEn"));
58+
});
59+
60+
test("Contact Details for Order detail page", function(assert) {
61+
assert.expect(6);
62+
63+
assert.equal(currentPath(), "orders.detail");
64+
assert.equal($(".main_details div:eq(5)").text().trim(), user.get("fullName"));
65+
click($('.icons:eq(0)'));
66+
67+
andThen(function() {
68+
assert.equal(currentPath(), "orders.contact");
69+
assert.equal($('.name').text().trim(), user.get("fullName"));
70+
assert.equal($('.mobile').text().trim(), user.get("mobile"));
71+
assert.equal($('.email').text().trim(), user.get("email"));
72+
});
73+
});
74+

0 commit comments

Comments
 (0)