Last active
April 7, 2020 11:48
-
-
Save 2hu12/d84f8bc6dc415ea5b0bea1b45a26c8df to your computer and use it in GitHub Desktop.
radio input multi 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 Ember from 'ember'; | |
import { computed } from '@ember/object'; | |
import { set } from '@ember/object'; | |
export default Ember.Component.extend({ | |
valueForAll: '', | |
// isAllSelected: computed('items.[]', { | |
isAllSelected: computed('items.@each.selceted', { | |
get() { | |
return this.get('items').every(item => item.selceted) | |
}, | |
set(_, isAllSelected) { | |
this.get('items').forEach(item => set(item, 'selceted', isAllSelected)) | |
return isAllSelected | |
} | |
}), | |
ll: computed('items.[]', function() { | |
return this.get('items.length') + 1 | |
}), | |
actions: { | |
onSelectSingleOption() {}, | |
onSelectAllOption() {}, | |
addOne() { | |
this.items.pushObject({ name: `No. ${this.items.length}` }) | |
}, | |
replaceOne() { | |
this.items.replace(1, 1, [{ name: 'set-bar-2-replaced' }]) | |
} | |
} | |
}); |
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.Component.extend ({ | |
actions: { | |
//toggling the text | |
toggleBody: function (event) { | |
console.log('post action:', event); | |
this.toggleProperty('isShowing'); | |
} | |
} | |
}); |
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'; | |
import { get } from '@ember/object'; | |
let list = [{ | |
name: 'set-bar-1', | |
value: 1 | |
}, { | |
name: 'set-bar-2', | |
value: 2 | |
}] | |
let defaultBar = 1 | |
let ST_ALL = 'ALL' | |
let ST_VOID = 'VOID' | |
let ST_Y = true | |
let ST_N = false | |
// let { lastObject: mmax } = [] | |
console.log(get([1,2], 'lastObject')) | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
foo: '<button>click</button>', | |
bar: defaultBar, | |
qux: { a: 1, b: 2 }, | |
bl: '', | |
list, | |
actions: { | |
change(v) { | |
this.set('bl', JSON.parse(v)) | |
}, | |
keyPress(event) { | |
// console.log(event.keyCode, event, code) | |
console.log(event) | |
} | |
} | |
}); |
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'; | |
/** | |
Helper, which compares two values strictly. Returns `true` if the values are the same, `false` | |
otherwise. | |
@param value1 {Any} the first value | |
@param value2 {Any} the second value | |
@return `true` if the values are equal, `false` otherwise. | |
*/ | |
export function eq([value1, value2] /* , hash*/) { | |
// console.log(value1, value2) | |
return value1 === value2; | |
} | |
export default helper(eq); |
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.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment