Skip to content

Commit 55509e9

Browse files
authored
Merge pull request #955 from crossroads/master
[Release] Stock v0.20.8
2 parents 85ce23f + 331db07 commit 55509e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+496
-150
lines changed

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ GEM
1414
json (>= 1.5.1)
1515
atomos (0.1.3)
1616
aws-eventstream (1.1.0)
17-
aws-partitions (1.393.0)
18-
aws-sdk-core (3.109.2)
17+
aws-partitions (1.397.0)
18+
aws-sdk-core (3.109.3)
1919
aws-eventstream (~> 1, >= 1.0.2)
2020
aws-partitions (~> 1, >= 1.239.0)
2121
aws-sigv4 (~> 1.1)
2222
jmespath (~> 1.0)
2323
aws-sdk-kms (1.39.0)
2424
aws-sdk-core (~> 3, >= 3.109.0)
2525
aws-sigv4 (~> 1.1)
26-
aws-sdk-s3 (1.84.1)
26+
aws-sdk-s3 (1.85.0)
2727
aws-sdk-core (~> 3, >= 3.109.0)
2828
aws-sdk-kms (~> 1)
2929
aws-sigv4 (~> 1.1)
@@ -93,7 +93,7 @@ GEM
9393
faraday_middleware (1.0.0)
9494
faraday (~> 1.0)
9595
fastimage (2.2.0)
96-
fastlane (2.167.0)
96+
fastlane (2.168.0)
9797
CFPropertyList (>= 2.3, < 4.0.0)
9898
addressable (>= 2.3, < 3.0.0)
9999
aws-sdk-s3 (~> 1.0)

app/components/contained-package.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Ember from "ember";
2-
import ItemActionMixin from "stock/mixins/item_actions";
32

4-
export default Ember.Component.extend(ItemActionMixin, {
3+
export default Ember.Component.extend({
54
packageService: Ember.inject.service(),
65
store: Ember.inject.service(),
76

app/components/date-picker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export default Ember.TextField.extend({
4343

4444
Ember.run.scheduleOnce("afterRender", this, function() {
4545
Ember.$(this.element).pickadate({
46-
selectMonths: !!enablePastDate,
47-
selectYears: !!enablePastDate,
46+
selectMonths: true,
47+
selectYears: true,
4848
formatSubmit: "ddd mmm d",
4949
monthsFull: moment.months(),
5050
monthsShort: moment.monthsShort(),

app/components/focus-textfield.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Ember from "ember";
2+
import { callbackObserver } from "../utils/ember";
23

34
export default Ember.TextField.extend({
45
tagName: "input",
@@ -7,19 +8,33 @@ export default Ember.TextField.extend({
78
cordova: Ember.inject.service(),
89
store: Ember.inject.service(),
910
hasRecentDesignations: true,
11+
autofocus: true,
12+
autofocusOnEmptyValue: true,
1013

11-
triggerAutofocus: Ember.observer("value", function() {
12-
if (this.get("value").length === 0) {
13-
this.$().focus();
14+
valueAutofocusListener: Ember.observer("value", function() {
15+
if (
16+
this.get("autofocus") &&
17+
this.get("autofocusOnEmptyValue") &&
18+
this.get("value").length === 0
19+
) {
20+
this.applyFocus();
1421
}
1522
}),
1623

24+
autofocusSettingListener: callbackObserver("autofocus", [
25+
[true, "applyFocus"]
26+
]),
27+
1728
hasFixedInputHeader: Ember.computed(function() {
1829
return (
1930
this.get("cordova").isIOS() && Ember.$(".fixed_search_header").length > 0
2031
);
2132
}),
2233

34+
applyFocus() {
35+
this.$().trigger("focus");
36+
},
37+
2338
scrollToStart() {
2439
Ember.$(".fixed_search_header").addClass("absolute");
2540
Ember.$(".footer").addClass("absolute_footer");
@@ -38,7 +53,9 @@ export default Ember.TextField.extend({
3853

3954
didInsertElement() {
4055
document.body.scrollTop = document.documentElement.scrollTop = 0;
41-
this.$().focus();
56+
if (this.get("autofocus")) {
57+
this.applyFocus();
58+
}
4259
if (this.get("hasFixedInputHeader")) {
4360
this.element.addEventListener("touchstart", this.scrollToStart);
4461
}

app/components/goodcity/code-search-overlay.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Ember from "ember";
22
import _ from "lodash";
33
import SearchMixin from "stock/mixins/search_resource";
4+
import AsyncMixin, { ASYNC_BEHAVIOURS } from "stock/mixins/async";
45

56
/**
67
* An overlay that pops up from the bottom of the screen, allowing the user
@@ -11,8 +12,9 @@ import SearchMixin from "stock/mixins/search_resource";
1112
* @property {boolean} open whether the popup is visible or not
1213
* @property {function} onSelect callback triggered when an order is selected
1314
*/
14-
export default Ember.Component.extend(SearchMixin, {
15+
export default Ember.Component.extend(SearchMixin, AsyncMixin, {
1516
store: Ember.inject.service(),
17+
packageTypeService: Ember.inject.service(),
1618
filter: "",
1719
searchText: "",
1820
fetchMoreResult: true,
@@ -22,6 +24,12 @@ export default Ember.Component.extend(SearchMixin, {
2224
this._super("code-search-overlay");
2325
},
2426

27+
async didRender() {
28+
await this.runTask(() => {
29+
return this.get("packageTypeService").preload();
30+
}, ASYNC_BEHAVIOURS.SILENT_DEPENDENCY);
31+
},
32+
2533
allPackageTypes: Ember.computed("open", "subsetPackageTypes", function() {
2634
if (this.get("subsetPackageTypes")) {
2735
return this.get("subsetPackageTypes");

app/components/goodcity/item-search-overlay.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import _ from "lodash";
33
import config from "stock/config/environment";
44
import SearchMixin from "stock/mixins/search_resource";
55
import AsyncMixin from "stock/mixins/async";
6+
import { chain } from "../../utils/async";
7+
import { callbackObserver } from "../../utils/ember";
68

79
export default Ember.Component.extend(SearchMixin, AsyncMixin, {
810
searchText: "",
@@ -12,13 +14,27 @@ export default Ember.Component.extend(SearchMixin, AsyncMixin, {
1214
perPage: 10,
1315
isMobileApp: config.cordova.enabled,
1416
packageService: Ember.inject.service(),
17+
cordova: Ember.inject.service(),
1518
messageBox: Ember.inject.service(),
1619
i18n: Ember.inject.service(),
20+
requireFocus: false,
21+
22+
inputmode: Ember.computed("searchMode", function() {
23+
if (this.get("searchMode") === "numeric") {
24+
return "numeric";
25+
}
26+
return "text";
27+
}),
1728

1829
hasSearchText: Ember.computed("searchText", function() {
1930
return !!this.get("searchText");
2031
}),
2132

33+
openStateListener: callbackObserver("open", [
34+
[true, "onOpen"],
35+
[false, "onClose"]
36+
]),
37+
2238
closeOverlay() {
2339
this.setProperties({
2440
searchText: "",
@@ -38,6 +54,20 @@ export default Ember.Component.extend(SearchMixin, AsyncMixin, {
3854
return _.flatten([states]).join(",");
3955
},
4056

57+
async onOpen() {
58+
const platform = this.get("cordova");
59+
const scrollFix = platform.isIOS() || platform.isIOSBrowser();
60+
61+
await chain.stagerred([
62+
() => this.set("requireFocus", true),
63+
() => scrollFix && window.scrollTo(0, 0)
64+
]);
65+
},
66+
67+
onClose() {
68+
this.set("requireFocus", false);
69+
},
70+
4171
actions: {
4272
cancel() {
4373
this.closeOverlay();

app/components/goodcity/offers-search-overlay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default Ember.Component.extend(SearchMixin, {
3838
companies: true,
3939
slug: "search",
4040
is_desc: true,
41-
sort_column: "reviewed_at"
41+
sort_column: "received_at"
4242
},
4343
this.get("offer_state"),
4444
this.getSearchQuery(),
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import Ember from "ember";
2+
import _ from "lodash";
3+
const { getOwner } = Ember;
4+
5+
import AsyncMixin, { ERROR_STRATEGIES } from "stock/mixins/async";
6+
import ItemActions from "stock/mixins/item_actions";
7+
8+
export default Ember.Component.extend(AsyncMixin, ItemActions, {
9+
packageService: Ember.inject.service(),
10+
locationService: Ember.inject.service(),
11+
12+
isValidQuantity: Ember.computed(
13+
"maxRemovableQuantity",
14+
"removableQuantity",
15+
function() {
16+
let value = +this.get("removableQuantity");
17+
return value > 0 && value <= +this.get("maxRemovableQuantity");
18+
}
19+
),
20+
21+
actions: {
22+
async beginUnpack(container, item, quantity) {
23+
this.set("openRemoveItemOverlay", false);
24+
25+
const selectedLocation = await this.get(
26+
"locationService"
27+
).userPickLocation();
28+
29+
if (!selectedLocation) {
30+
return;
31+
} else {
32+
this.set("removableQuantity", quantity);
33+
this.set("maxRemovableQuantity", quantity);
34+
35+
this.set("location", selectedLocation);
36+
this.set("openRemoveItemOverlay", true);
37+
}
38+
},
39+
40+
async performUnpack() {
41+
await this.runTask(() => {
42+
return this.unpack(
43+
this.get("container"),
44+
this.get("item"),
45+
this.get("location.id"),
46+
this.get("removableQuantity"),
47+
this.get("onUnpackCallback")
48+
);
49+
}, ERROR_STRATEGIES.MODAL);
50+
51+
this.set("openRemoveItemOverlay", false);
52+
},
53+
54+
cancelAction() {
55+
this.set("openRemoveItemOverlay", false);
56+
}
57+
}
58+
});

app/components/message-box.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export default Ember.Component.extend({
1111
displayCloseLink: false,
1212
isVisible: false,
1313

14+
init() {
15+
this._super(...arguments);
16+
this.get("router").addObserver("currentRouteName", () => this.close());
17+
},
18+
1419
close() {
1520
if (this.get("isVisible")) {
1621
this.set("isVisible", false);

app/controllers/items/detail.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ export default GoodcityController.extend(
606606
per_page: 10
607607
})
608608
.then(data => {
609-
this.get("store").pushPayload(data);
610-
return data;
609+
this.set("containerQuantity", data.containerQuantity);
610+
return data.containedPackages;
611611
});
612612
},
613613

0 commit comments

Comments
 (0)