Skip to content

Commit 4c7e3a8

Browse files
Merge pull request #240 from crossroads/master
#AprilRelease1
2 parents a0e64d3 + b8b49eb commit 4c7e3a8

22 files changed

+281
-16
lines changed

app/controllers/items/new.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ export default Ember.Controller.extend({
300300
this.send("deleteAutoGeneratedNumber");
301301
this.set("inventoryNumber", "");
302302
}
303+
window.localStorage.setItem("isSelectLocationPreviousRoute", false);
303304
this.send("deleteUnusedImage");
304305
this.set("locationId", "");
305306
this.set("codeId", "");
@@ -357,7 +358,7 @@ export default Ember.Controller.extend({
357358
this.get("messageBox").alert(this.get("i18n").t("offline_error"));
358359
return false;
359360
}
360-
this.set("isSelectLocationPreviousRoute", false);
361+
window.localStorage.setItem("isSelectLocationPreviousRoute", false);
361362
this.set("isSearchCodePreviousRoute", false);
362363
var _this = this, loadingView;
363364
var itemConditions = this.getItemConditions(_this);

app/controllers/select_location.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default searchModule.extend({
99

1010
actions: {
1111
setLocation(location) {
12+
window.localStorage.setItem("isSelectLocationPreviousRoute", true);
1213
this.transitionToRoute("items.new", { queryParams: { locationId: location.get("id") } });
1314
}
1415
}

app/models/address.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Model from 'ember-data/model';
22
import attr from 'ember-data/attr';
33
import { belongsTo } from 'ember-data/relationships';
4+
import Ember from 'ember';
45

56
export default Model.extend({
67
flat: attr('string'),
@@ -11,5 +12,9 @@ export default Model.extend({
1112
district: belongsTo('district', { async: false }),
1213

1314
addressableType: attr('string'),
14-
addressable: belongsTo('addressable', { polymorphic: true, async: false })
15+
addressable: belongsTo('addressable', { polymorphic: true, async: false }),
16+
17+
fullAddress: Ember.computed('flat', 'building', 'street', function() {
18+
return `${this.get('flat')} ${this.get('building')} ${this.get('street')}`;
19+
})
1520
});

app/models/designation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default Model.extend({
1414
detailType: attr('string'),
1515
detailId: attr('number'),
1616
purposeDescription: attr('string'),
17+
gcOrganisationId: attr('number'),
1718

1819
contact: belongsTo('contact', { async: false }),
1920
organisation: belongsTo('organisation', { async: false }),

app/routes/items/new.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ export default AuthorizeRoute.extend({
5252

5353
if(this.get("newItemRequest")) {
5454
this.set("newItemRequest", false);
55-
controller.set('caseNumber', "");
5655
controller.set('quantity', 1);
57-
controller.set('length', null);
58-
controller.set('width', null);
59-
controller.set('height', null);
60-
controller.set('selectedGrade', { name: "B", id: "B" });
61-
controller.set('selectedCondition', { name: "Used", id: "U" });
56+
if(window.localStorage.getItem("isSelectLocationPreviousRoute") === "false") {
57+
controller.set('caseNumber', "");
58+
controller.set('length', null);
59+
controller.set('width', null);
60+
controller.set('height', null);
61+
controller.set('selectedGrade', { name: "B", id: "B" });
62+
controller.set('selectedCondition', { name: "Used", id: "U" });
63+
}
6264
var imageKey = controller.get("imageKeys");
6365
if(imageKey && imageKey.length && window.localStorage.isSelectLocationPreviousRoute === "true") {
6466
var image = this.get("store").peekAll("image").filterBy("cloudinaryId", imageKey).get("firstObject");

app/routes/orders/detail.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ export default getOrderRoute.extend({
4545
},
4646

4747
afterModel(model) {
48+
var organisation;
49+
var organisationId = model.get('gcOrganisationId');
4850
if(model) {
4951
var ordersPackages = this.store.query("orders_package", { search_by_order_id: model.get("id") });
52+
if(organisationId) {
53+
organisation = this.store.findRecord('gcOrganisation', organisationId);
54+
this.store.pushPayload(organisation);
55+
}
5056
this.store.pushPayload(ordersPackages);
5157
}
5258
},

app/routes/orders/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
import AuthorizeRoute from './../authorize';
2+
import AjaxPromise from 'stock/utils/ajax-promise';
23

3-
export default AuthorizeRoute.extend();
4+
export default AuthorizeRoute.extend({
5+
model() {
6+
return new AjaxPromise("/auth/current_user_profile", "GET", this.session.get("authToken"))
7+
.then(data => {
8+
this.store.pushPayload(data);
9+
});
10+
}
11+
});

app/templates/orders/detail.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
Organisation:
5757
</div>
5858
<div class="small-8 columns">
59-
{{apply-line-break (if model.isGoodCityOrder model.organisation.nameEn model.organisation.name)}}
59+
{{apply-line-break (if model.isGoodCityOrder model.gcOrganisation.nameEn model.organisation.name)}}
6060
</div>
6161
</div>
6262

config/coverage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
coverageFolder: 'coverage',
33
excludes: [
4-
'*/routes/**/*', '*/**/router.js', "public/*/**/*"
4+
'*/routes/**/*', '*/**/router.js', "public/*/**/*", '*/serializers/**/*'
55
]
66
}

tests/acceptance/add-item-to-order-test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ import { module, test } from 'qunit';
33
import startApp from '../helpers/start-app';
44
import FactoryGuy from 'ember-data-factory-guy';
55
import '../factories/designation';
6+
import '../factories/location';
67
import { mockFindAll } from 'ember-data-factory-guy';
78

8-
var App, designation, item, item1, orders_package, orders_package1;
9+
var App, designation, item, item1, orders_package, orders_package1, location1;
910

1011
module('Acceptance: Add item to order', {
1112
beforeEach: function(){
1213
App = startApp({}, 2);
1314
designation = FactoryGuy.make("designation");
15+
location1 = FactoryGuy.make("location");
16+
mockFindAll('location').returns({json: {locations: [location1.toJSON({includeId: true})]}});
1417
var data = {"user_profile": {"id": 2, "first_name": "David", "last_name": "Dara51", "mobile": "61111111", "permission_id": 4}, "permissions": [{"id": 4, "name": "Supervisor"}]};
1518

1619
$.mockjax({url:"/api/v1/auth/current_user_profil*",
@@ -20,7 +23,11 @@ module('Acceptance: Add item to order', {
2023
orders_package = FactoryGuy.make("orders_package", { state: "designated", quantity: 6, item: item, designation: designation });
2124
orders_package1 = FactoryGuy.make("orders_package", { state: "dispatched", quantity: 4, item: item1, designation: designation });
2225

23-
visit("/orders/");
26+
visit("/");
27+
28+
andThen(function() {
29+
visit("/orders/");
30+
});
2431

2532
fillIn('#searchText', designation.get("code"));
2633
andThen(function(){

0 commit comments

Comments
 (0)