Last active
May 7, 2021 17:13
-
-
Save dbachet/62303ed21ededb951155d90ac892c381 to your computer and use it in GitHub Desktop.
New 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 Component from '@glimmer/component'; | |
import { tracked } from '@glimmer/tracking'; | |
export default class extends Component { | |
@tracked _state = false; | |
// get externalState (){ | |
// return this.args.isCheckboxSelected(this.args.checkcboxOwnerId, this.args.selectedCheckboxes) | |
// } | |
get isCheckboxSelected() { | |
// return this.args.checkboxes.find((item) => item.id == this.args.checkbox.checkboxOwnerId); | |
return ''; | |
}; | |
get selectedCheckboxes() { | |
// return this.args.checkboxes.filter((item) => item.state == true); | |
return ''; | |
}; | |
get selectedDetails() { | |
// return this.selectedCheckboxes.map((item) => item.checkboxOwnerId); | |
return ''; | |
}; | |
} |
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 '@glimmer/component'; | |
import { tracked } from '@glimmer/tracking'; | |
import { action } from '@ember/object'; | |
export default class extends Component { | |
get selectedIds(){ | |
console.log('selectedIds : checkboxes =>', this.checkboxes); | |
// return this.checkboxes.map((item) => item.state); | |
return this.checkboxes.filter((item) => item.state == true); | |
// return 'ye' | |
}; | |
constructor() { | |
super(...arguments); | |
this.parentCheckbox = { | |
checkboxOwnerId: 0, | |
name: "Parent checkbox", | |
state: false | |
}; | |
this.checkboxes = [ | |
{ | |
checkboxOwnerId: 1, | |
name: "Child checkbox 1", | |
state: false | |
}, | |
{ | |
checkboxOwnerId: 2, | |
name: "Child checkbox 2", | |
state: false | |
}, | |
{ | |
checkboxOwnerId: 3, | |
name: "Child checkbox 3", | |
state: false | |
} | |
]; | |
console.log('INIT', this.checkboxes); | |
} | |
@tracked parentCheckbox; | |
@tracked checkboxes; | |
@action | |
onClickParentCheckbox(checkboxOwnerId, state){ | |
console.log('Parent : state =>', state); | |
console.log('Parent : checkboxes =>', this.checkboxes); | |
// if(state == true) { | |
// console.log('yolo'); | |
// this.checkboxes.forEach((item) => this.checkboxes[item.key]['state'] = true) | |
// } else { | |
// this.checkboxes.forEach((item) => this.checkboxes[item.key]['state'] = false) | |
// } | |
}; | |
@action | |
onClickChildCheckbox(checkboxOwnerId, state){ | |
console.log('Child : checkboxes before =>', this.checkboxes); | |
console.log('Child : checkboxOwnerId =>', checkboxOwnerId); | |
const checkbox = this.checkboxes.find((item) => item.checkboxOwnerId == checkboxOwnerId) | |
checkbox['state'] = !state; | |
this.checkboxes[] | |
console.log('Child : checkboxes after =>', this.checkboxes.find((item) => item.checkboxOwnerId == checkboxOwnerId)['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 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
{ | |
"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