Skip to content

Commit 4cf2cb2

Browse files
Merge pull request #592 from crossroads/master
Release#2 Jan2020
2 parents 488eca7 + 80fb382 commit 4cf2cb2

34 files changed

+513
-225
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
aliases:
44
- defaults: &defaults
55
docker:
6-
- image: circleci/node:boron
6+
- image: circleci/node:8.15
77
working_directory: ~/code
88
- &restore-repo-cache
99
key: v1-stock-goodcity-{{ .Environment.CIRCLE_SHA1 }}
@@ -74,7 +74,7 @@ jobs:
7474
test_cases:
7575
<<: *defaults
7676
docker:
77-
- image: circleci/node:6-browsers
77+
- image: circleci/node:8.15-browsers
7878
environment:
7979
JOBS: 1
8080
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# compiled output
44
/dist
55
/tmp
6+
/documentation
67

78
.vscode
89
.idea

Gemfile.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ GEM
7171
faraday_middleware (0.13.1)
7272
faraday (>= 0.7.4, < 1.0)
7373
fastimage (2.1.7)
74-
fastlane (2.139.0)
74+
fastlane (2.140.0)
7575
CFPropertyList (>= 2.3, < 4.0.0)
7676
addressable (>= 2.3, < 3.0.0)
7777
babosa (>= 1.0.2, < 2.0.0)
@@ -119,10 +119,12 @@ GEM
119119
representable (~> 3.0)
120120
retriable (>= 2.0, < 4.0)
121121
signet (~> 0.12)
122-
google-cloud-core (1.4.1)
122+
google-cloud-core (1.5.0)
123123
google-cloud-env (~> 1.0)
124+
google-cloud-errors (~> 1.0)
124125
google-cloud-env (1.3.0)
125126
faraday (~> 0.11)
127+
google-cloud-errors (1.0.0)
126128
google-cloud-storage (1.25.1)
127129
addressable (~> 2.5)
128130
digest-crc (~> 0.4)

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ Make use of the many generators for code, try `ember help generate` for more det
5050

5151
Specify what it takes to deploy your app.
5252

53+
### Documentation
54+
55+
Re-usable mixins/components/services of the project have been documented with JSDoc comments.
56+
Documentation can be generated using the following commands :
57+
58+
```bash
59+
$> yarn document # generates a 'documentation' folder
60+
$> open documentation/index.html # view the documentation in your browser
61+
```
62+
5363
## Further Reading / Useful Links
5464

5565
* [ember.js](http://emberjs.com/)

app/components/goodcity/orders-package-block.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,22 @@ const CANCELLED = {};
2929
/**
3030
* UI Component representing an orders_package
3131
*
32-
* --------------------------------------------------------
33-
* | op_state | order_code order_state | < |
34-
* | | | < |
35-
* | qty | organisation | < |
36-
* --------------------------------------------------------
32+
* --------------------------------------------------------
33+
* | op_state | order_code order_state | < |
34+
* | | | < |
35+
* | qty | organisation | < |
36+
* --------------------------------------------------------
3737
*
38-
* It provides a drawer from the right side which is populated
39-
* with the actions provided by the backend
38+
* @module Components/goodcity/orders-package-block
39+
* @augments ember/Component
40+
* @param {Model} orderPkg the orders_package to display
41+
* @description
42+
* <br> It provides a drawer from the right side which is populated
43+
* <br> with the actions provided by the backend
44+
* <br>
45+
* <br> Clicking on an action will run it on the API side
4046
*
41-
* Clicking on an action will run it on the API side
42-
*
43-
* @property {Model} orderPkg the orders_package to display
44-
*
45-
* Usage:
47+
* @example
4648
* {{goodcity/orders-package-block orderPkg=orderPkg }}
4749
*/
4850
export default Ember.Component.extend(AsyncMixin, {
@@ -73,6 +75,7 @@ export default Ember.Component.extend(AsyncMixin, {
7375
*
7476
* CANCELLED is returned if the user closes the UI
7577
*
78+
* @private
7679
* @returns {Promise<String>}
7780
*/
7881
async selectOrder() {
@@ -88,6 +91,7 @@ export default Ember.Component.extend(AsyncMixin, {
8891
*
8992
* CANCELLED is returned if the user closes the UI
9093
*
94+
* @private
9195
* @returns {Promise<String>}
9296
*/
9397
async selectLocation() {
@@ -101,6 +105,7 @@ export default Ember.Component.extend(AsyncMixin, {
101105
*
102106
* CANCELLED is returned if the user closes the UI
103107
*
108+
* @private
104109
* @returns {Promise<number>}
105110
*/
106111
selectQuantity() {
@@ -132,6 +137,11 @@ export default Ember.Component.extend(AsyncMixin, {
132137
* to successfully
133138
*
134139
* CANCELLED if the user did not provide the
140+
*
141+
* @private
142+
* @memberof OrdersPackageBlock
143+
* @param {string} actionName the action being run
144+
* @returns the options to send to the api
135145
*/
136146
async fulfillParams(actionName) {
137147
const paramNames = _.get(ACTIONS_SETTINGS, `${actionName}.params`, []);
@@ -164,6 +174,10 @@ export default Ember.Component.extend(AsyncMixin, {
164174
/**
165175
* Runs the desired action
166176
*
177+
* @memberof OrdersPackageBlock
178+
* @private
179+
* @param {string} actionName the action to run
180+
* @returns {Promise<Package>} the updated package
167181
*/
168182
async runAction(actionName) {
169183
const params = await this.fulfillParams(actionName);

app/components/let-alias.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import Ember from "ember";
22

33
/**
4-
* Small helper component allowing to rename variables within the .hbs file
5-
*
6-
* Usage:
4+
* @module Components/let-alias
5+
* @description Small helper component allowing to rename variables within the .hbs file
6+
* @example
77
*
88
* {{#let-alias model.someReallyLongPropertyName as |short| }}
99
* <div> This is {{short}} </div>

app/components/toggle-switch.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import _ from "lodash";
44
/**
55
* Fancy toggle-switch component, wraps a checkbox internally
66
*
7+
* @module Components/toggle-switch
8+
* @augments ember/Component
79
* @property {boolean} value a property the component will bind to
810
* @property {function} [afterChange] a callback triggered after value changes
911
* <br> We typically listen to data change with Ember observers in the
@@ -12,6 +14,18 @@ import _ from "lodash";
1214
* <br> This callback can be used to react to changes that exclusively belong
1315
* <br> to the checkbox
1416
*
17+
* @example
18+
*
19+
* {{toggle-switch
20+
* disabled=(unless allowPublish true)
21+
* on-icon='eye'
22+
* off-icon='eye-slash'
23+
* on-text=(t 'item_filters.published')
24+
* off-text=(t 'item_filters.private')
25+
* value=model.allowWebPublish
26+
* after-change=(action 'persistModel')
27+
* }}
28+
*
1529
*/
1630
export default Ember.Component.extend({
1731
attributeBindings: ["value"],
Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import Ember from 'ember';
2-
import RSVP from 'rsvp';
3-
import _ from 'lodash';
1+
import Ember from "ember";
2+
import RSVP from "rsvp";
3+
import _ from "lodash";
44

55
/**
6-
* Generic controller base. Should hopefully help avoid re-writing code in the future
7-
* Has:
8-
* - Message box
9-
* - Loading spinner
10-
* - CRUD methods for controlling records
11-
*
6+
* @module Controllers/GoodcityController
7+
* @augments ember/Controller
8+
* @description Generic controller base. Should hopefully help avoid re-writing code in the future
9+
* <br> Has:
10+
* <br> - Message box
11+
* <br> - Loading spinner
12+
* <br> - CRUD methods for controlling records
1213
*/
1314
export default Ember.Controller.extend({
14-
1515
// ---- Services
1616

1717
messageBox: Ember.inject.service(),
@@ -23,15 +23,25 @@ export default Ember.Controller.extend({
2323

2424
// ---- Generic Helpers
2525

26+
/**
27+
* @instance
28+
* @description displays the loading spinner on the screen
29+
*/
2630
showLoadingSpinner() {
2731
if (Ember.testing) {
2832
return;
2933
}
3034
if (!this.loadingView) {
31-
this.loadingView = Ember.getOwner(this).lookup('component:loading').append();
35+
this.loadingView = Ember.getOwner(this)
36+
.lookup("component:loading")
37+
.append();
3238
}
3339
},
3440

41+
/**
42+
* @instance
43+
* @description hides the loading spinner off the screen
44+
*/
3545
hideLoadingSpinner() {
3646
if (Ember.testing) {
3747
return;
@@ -43,38 +53,45 @@ export default Ember.Controller.extend({
4353
},
4454

4555
showError(message, cb) {
46-
this.get("messageBox").alert(message || this.get("i18n").t("unexpected_error"), cb);
56+
this.get("messageBox").alert(
57+
message || this.get("i18n").t("unexpected_error"),
58+
cb
59+
);
4760
},
4861

4962
onError(response = {}) {
50-
const errors = _.map(response.errors, (err) => _.isString(err) ? err : err.detail);
63+
const errors = _.map(response.errors, err =>
64+
_.isString(err) ? err : err.detail
65+
);
5166
this.showError(errors[0]);
5267
},
5368

5469
// ---- CRUD
5570

5671
createRecord(modelName, payload) {
57-
const newRecord = this.get('store').createRecord(modelName, payload);
72+
const newRecord = this.get("store").createRecord(modelName, payload);
5873
this.showLoadingSpinner();
59-
return newRecord.save()
74+
return newRecord
75+
.save()
6076
.catch(r => {
6177
this.onError(r);
6278
})
63-
.then(() => this.hideLoadingSpinner());
79+
.then(() => this.hideLoadingSpinner());
6480
},
6581

6682
updateRecord(record, updates = {}, opts = {}) {
6783
_.each(updates, (v, k) => record.set(k, v));
6884
this.showLoadingSpinner();
69-
return record.save()
85+
return record
86+
.save()
7087
.then(() => {
71-
_.get(opts, 'onSuccess', _.noop)();
88+
_.get(opts, "onSuccess", _.noop)();
7289
})
7390
.catch(e => {
7491
if (!opts.noRollback) {
7592
record.rollbackAttributes();
7693
}
77-
_.get(opts, 'onFailure', _.noop)(e);
94+
_.get(opts, "onFailure", _.noop)(e);
7895
this.onError(e);
7996
})
8097
.finally(() => this.hideLoadingSpinner());
@@ -90,5 +107,4 @@ export default Ember.Controller.extend({
90107
back() {
91108
history.back();
92109
}
93-
94110
});

app/controllers/items/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import config from "../../config/environment";
22
import _ from "lodash";
33
import SearchMixin from "stock/mixins/search_resource";
44

5+
/**
6+
* @module Controllers/items/ItemsSearchController
7+
* @augments ember/Controller
8+
*/
59
export default Ember.Controller.extend(SearchMixin, {
610
queryParams: ["searchInput", "itemSetId"],
711
itemSetId: null,
@@ -13,11 +17,11 @@ export default Ember.Controller.extend(SearchMixin, {
1317
},
1418

1519
/**
16-
* @type {Boolean}, expected in SearchMixin
20+
* @property {Boolean} SearchMixin configuration
1721
**/
1822
autoLoad: true,
1923
/**
20-
* @type {Number}, perPage in response
24+
* @property {Number} SearchMixin configuration, perPage in response
2125
**/
2226
perPage: 25,
2327

@@ -49,6 +53,12 @@ export default Ember.Controller.extend(SearchMixin, {
4953
}),
5054

5155
actions: {
56+
/**
57+
* Load the next page of the list
58+
*
59+
* @param {number} pageNo the page to load
60+
* @returns {Promise<Model[]>}
61+
*/
5262
loadMoreItems(pageNo) {
5363
const params = this.trimQuery(
5464
_.merge(

0 commit comments

Comments
 (0)