-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor all 5 product routes to first stable version
- Loading branch information
1 parent
2e25dd9
commit 80c8f51
Showing
20 changed files
with
259 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
import Controller from '@ember/controller'; | ||
// import { tracked= } from '@glimmer/tracking'; | ||
|
||
export default class ProductsIndexController extends Controller { | ||
// @tracked layout = 'list'; // list, grid | ||
// get products() { | ||
// return this.model.products.sortBy('statusRank', 'name'); | ||
// } | ||
} | ||
export default class ProductsIndexController extends Controller {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Controller from '@ember/controller'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
export default class ProductsMixLoadingController extends Controller { | ||
@tracked title; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import BaseRoute from 'interflux/pods/base/route'; | ||
|
||
export default class ProductsMixLoadingRoute extends BaseRoute {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ProductList @title={{this.title}} @loading={{true}} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Controller from '@ember/controller'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
export default class ProductsMixController extends Controller { | ||
@tracked title; | ||
@tracked products; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import BaseRoute from 'interflux/pods/base/route'; | ||
import { hash } from 'rsvp'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class ProductsMixRoute extends BaseRoute { | ||
beforeModel(transition) { | ||
super.activate(); | ||
|
||
const params = transition.to.params; | ||
const familyId = params.main_family_id; | ||
const useId = params.use_id; | ||
const family = this.store.peekRecord('product-family', familyId); | ||
const use = this.store.peekRecord('use', useId); | ||
|
||
this.controllerFor('products').selectedFamilyId = familyId; | ||
this.controllerFor('products').selectedUseId = useId; | ||
this.controllerFor('products').mainFamiliesSubset = null; | ||
this.controllerFor('products').usesSubset = null; | ||
this.controllerFor('products.mixLoading').title = family | ||
? `${family.get('label')} for ${use.get('name')}` | ||
: 'Loading'; | ||
} | ||
|
||
model(params) { | ||
return hash({ | ||
productUses: this.store.query('product-use', { | ||
filter: { use: params.use_id }, | ||
include: 'product,use' | ||
}) | ||
}); | ||
} | ||
|
||
afterModel(model, transition) { | ||
super.activate(); | ||
|
||
const params = transition.to.params; | ||
const familyId = params.main_family_id; | ||
const useId = params.use_id; | ||
const family = this.store.peekRecord('product-family', familyId); | ||
const use = this.store.peekRecord('use', useId); | ||
const title = `${family.get('label')} for ${use.get('name')}`; | ||
const products = model.productUses | ||
.mapBy('product') | ||
.uniqBy('id') | ||
.filterBy('mainFamily.id', familyId); | ||
|
||
this.controllerFor('products.mix').title = title; | ||
this.controllerFor('products.mix').products = products; | ||
} | ||
|
||
@action | ||
willTransition() { | ||
this.controllerFor('products').selectedFamilyId = null; | ||
this.controllerFor('products').selectedUseId = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<ProductList | ||
@title={{this.title}} | ||
@products={{this.products}} | ||
@groupBy='none' | ||
@searchFor={{this.query}} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.