Last active
May 25, 2022 20:59
-
-
Save rossjha/1ceb8b796dec7790c073a0d1a94b391e to your computer and use it in GitHub Desktop.
native select
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'; | |
import { get, set } from '@ember/object' | |
export default Controller.extend({ | |
// Properties | |
options: [{ | |
id: '1', | |
name: 'One', | |
params: { | |
state: 'Completed' | |
} | |
}, { | |
id: '2', | |
name: 'Two', | |
params: { | |
state: 'Deleted' | |
} | |
}, { | |
id: '3', | |
name: 'Three', | |
params: { | |
state: 'Pending' | |
} | |
}], | |
state: null, | |
queryParams: ['state'], | |
// Lifecycle hooks | |
init() { | |
this._super(...arguments); | |
set(this, 'currentOption', get(this, 'options')[1]); | |
}, | |
// Functions | |
actions: { | |
selectOption(optionId) { | |
const selectedOption = get(this, 'options').find((option) => option.id === optionId); | |
set(this, 'state', selectedOption.params.state) | |
} | |
} | |
}); |
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 { helper } from '@ember/component/helper'; | |
export default helper(function eq([param1, param2]) { | |
return param1 === param2; | |
}); |
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": "2.18.2", | |
"ember-template-compiler": "2.18.2", | |
"ember-testing": "2.18.2" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0", | |
"ember-data": "2.18.5" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment