Last active
July 18, 2018 21:34
-
-
Save Frozenfire92/58e6b06cb4afb6278cbde6fec93094b0 to your computer and use it in GitHub Desktop.
TestBug
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 Component from '@ember/component'; | |
import { observer, get, set, getWithDefault } from '@ember/object'; | |
import { later } from '@ember/runloop'; | |
export default Component.extend({ | |
// Required: | |
// value - the currently selected option | |
// options - the available options, | |
// ['Canada', 'USA', 'Mexico'] | |
// [{value: 'word-cloud', label: 'Word Cloud'}] | |
// Optional: | |
// disabled - boolean | |
// required - boolean | |
// multiple - boolean | |
// name - string | |
tagName: 'select', | |
attributeBindings: [ | |
'disabled', | |
'required', | |
'multiple', | |
'name' | |
], | |
didReceiveAttrs() { | |
set(this, 'noDefault', (get(this, 'value') && !get(this, 'keys')) ? false : true); | |
}, | |
didInsertElement() { | |
this.$().val(get(this, 'value') || ''); | |
}, | |
didRender() { | |
this.$().val(get(this, 'value')); | |
if (get(this, 'isUserRoles') && get(this, 'value') === '') { | |
set(this, 'value', get(this, 'originalRole')); | |
} | |
}, | |
willDestroyElement() { | |
if (get(this, 'isUserRoles')) { | |
set(this, 'value', ''); | |
} | |
}, | |
// For when value changes | |
valueWatcher: observer('value', function() { | |
let propValue = get(this, 'value'); | |
let elValue = this.$().val(); | |
if (elValue !== propValue) { | |
this.$().val(propValue); | |
} | |
}), | |
// For when element changes | |
change() { | |
let oldValue = get(this, 'value'); | |
let newValue = this.$().val(); | |
if (oldValue !== newValue) { | |
set(this, 'value', newValue); | |
if (get(this, 'changeAction')) { | |
later(()=>get(this, 'changeAction')(), getWithDefault(this, 'changeDelay', 0)); | |
} | |
} | |
} | |
}); |
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 Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
dropdownOptions: ['thing', 'thing2'], | |
selectedOption: 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
{ | |
"version": "0.15.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "release", | |
"ember-template-compiler": "release", | |
"ember-testing": "release" | |
}, | |
"addons": { | |
"ember-data": "3.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment