Last active
July 1, 2021 23:11
-
-
Save junyper/7d810c188a0d8a7ba8e7d92b10552d85 to your computer and use it in GitHub Desktop.
NestedRouteParams
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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
} |
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
import Controller from '@ember/controller'; | |
export default class SearchController extends Controller { | |
reset() { | |
this.query = {}; | |
} | |
get query() { | |
let { q } = this; | |
let query = JSON.stringify({ q }); | |
if (query !== '{}') { | |
return JSON.parse(query); | |
} | |
} | |
set query({ q }) { | |
this.setProperties({ q }); | |
} | |
@action | |
handleFilterByKeyword(q) { | |
if (isBlank(q)) { | |
this.query = {}; | |
} else { | |
this.query = { q }; | |
} | |
} | |
} |
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
import EmberRouter from '@ember/routing/router'; | |
import config from './config/environment'; | |
const Router = EmberRouter.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('search', function () { | |
this.route('modules'); | |
this.route('providers'); | |
}); | |
}); | |
export default Router; |
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
import Route from '@ember/routing/route'; | |
export default class SearchIndexRoute extends { | |
redirect () { | |
this.replaceWith('search.modules'); | |
} | |
} |
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
import Route from '@ember/routing/route'; | |
export default class SearchModulesRoute extends Route { | |
queryParams = { | |
page: { refreshModel: true }, | |
providers: { refreshModel: true, replace: true } | |
}; | |
model() { | |
let { q } = this.modelFor('search'); | |
return { q }; | |
} | |
resetController(controller, isExiting, transition) { | |
let from = transition?.from?.queryParams?.q; | |
let to = transition?.to?.queryParams?.q; | |
if (isExiting || (transition && from !== to)) { | |
controller.reset(); | |
controller.set('q', to); | |
} | |
} | |
setupController(controller, { q }) { | |
controller.set('q', q); | |
} | |
} |
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
import Route from '@ember/routing/route'; | |
export default class SearchProvidersRoute extends Route { | |
queryParams = { | |
page: { refreshModel: true }, | |
}; | |
model() { | |
let { q } = this.modelFor('search'); | |
return { q }; | |
} | |
resetController(controller, isExiting, transition) { | |
let from = transition?.from?.queryParams?.q; | |
let to = transition?.to?.queryParams?.q; | |
if (isExiting || (transition && from !== to)) { | |
controller.reset(); | |
controller.set('q', to); | |
} | |
} | |
setupController(controller, { q }) { | |
controller.set('q', q); | |
} | |
} |
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
import Route from '@ember/routing/route'; | |
export default class SearchRoute extends Route { | |
queryParams = { | |
q: { refreshModel: true, replace: true } | |
}; | |
model({ q }) { | |
return { q }; | |
} | |
resetController(controller, isExiting) { | |
if (isExiting) { | |
controller.reset(); | |
} | |
} | |
setupController(controller, { q }) { | |
controller.set('q', q); | |
} | |
} |
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
{ | |
"version": "0.17.1", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js", | |
"ember": "3.18.1", | |
"ember-template-compiler": "3.18.1", | |
"ember-testing": "3.18.1" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment