Last active
August 28, 2020 20:08
-
-
Save HeroicEric/b57805dc3bb5955d49fac961d9c48612 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or 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 hidden or 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('policies', { path: 'policies/:type' }, function() { | |
}); | |
this.route('edit-policy', { path: 'policies/:id' }, function() { | |
this.route('assigned-host-groups'); | |
this.route('protected-android-apps'); | |
this.route('sensor-settings'); | |
}); | |
}); | |
export default Router; |
This file contains hidden or 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 Route.extend({ | |
redirect() { | |
let { id: policyId } = this.modelFor('edit-policy'); | |
this.transitionTo('edit-policy.sensor-settings'); | |
} | |
}); |
This file contains hidden or 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'; | |
import { POLICIES } from './policies'; | |
export default Route.extend({ | |
async model({ id }) { | |
let policy = POLICIES.find(p => p.id === id); | |
return { policy }; | |
} | |
}); |
This file contains hidden or 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 Route.extend({ | |
redirect() { | |
this.transitionTo('policies', 'foo'); | |
} | |
}); |
This file contains hidden or 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 const POLICIES = [ | |
{ id: '1', name: 'Policy 1' }, | |
{ id: '2', name: 'Policy 2' }, | |
{ id: '3', name: 'Policy 3' }, | |
{ id: '4', name: 'Policy 4' }, | |
{ id: '5', name: 'Policy 5' }, | |
{ id: '6', name: 'Policy 6' }, | |
{ id: '7', name: 'Policy 7' }, | |
{ id: '8', name: 'Policy 8' }, | |
{ id: '9', name: 'Policy 9' }, | |
{ id: '10', name: 'Policy 10' }, | |
]; | |
export default Route.extend({ | |
async model() { | |
return { | |
policies: POLICIES | |
}; | |
} | |
}); |
This file contains hidden or 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 Component from '@glimmer/component'; | |
import { inject as service } from '@ember/service'; | |
export default class extends Component { | |
@service router; | |
get isActive() { | |
return this.router.isActive(this.args.route, this.args.model); | |
} | |
} |
This file contains hidden or 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