Last active
December 14, 2019 18:20
-
-
Save cah-danmonroe/aab786f62b838562163c11f8bee3a578 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 Ember from 'ember'; | |
import {computed, get, set} from '@ember/object'; | |
export default Ember.Component.extend({ | |
columns: null, | |
editingRowId: null, | |
editingCellValue: null, | |
init () { | |
this._super(...arguments); | |
this.columns = [ | |
{ | |
name: 'Foo Bars Table', | |
valuePath: 'bars' | |
} | |
]; | |
}, | |
rows: computed('foos.@each.{bars}', function() { | |
console.log('+++++ rows update'); | |
return get(this, 'foos').toArray(); | |
}), | |
actions: { | |
clickCell(cellValue, rowValue, rowMeta) { | |
if (get(rowMeta, 'isEditing') === true) { | |
return; | |
} | |
set(this, 'editingRowId', get(rowValue, 'id')); | |
set(this, 'editingCellValue', cellValue); | |
get(this, 'bumpInstructions')(); | |
}, | |
blurBars(editedCellValue, rowValue) { | |
set(this, 'editingRowId', null); | |
get(this, 'onRowChange')(rowValue, editedCellValue); | |
get(this, 'bumpInstructions')(); | |
} | |
} | |
}); |
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, get, set} from '@ember/object'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
showTable: false, | |
instructionsCounter: 0, | |
rows: [ | |
{ id: 1, bars: 'bar 1'}, | |
{ id: 2, bars: 'bar 2'}, | |
{ id: 3, bars: 'bar 3'} | |
], | |
actions: { | |
toggleTable() { | |
this.toggleProperty('showTable'); | |
this.incrementProperty('instructionsCounter'); | |
}, | |
rowChange(rowValue, editedValue) { | |
set(rowValue, 'bars', editedValue); | |
}, | |
bumpInstructions() { | |
this.incrementProperty('instructionsCounter'); | |
} | |
}, | |
instructions: computed('instructionsCounter', function() { | |
switch(get(this, 'instructionsCounter')) { | |
case 0: | |
return "Click Toggle Table to show component with ember table. Open the developer tools so you can follow console output."; | |
case 1: | |
return "Click on one of the rows and edit the value"; | |
case 2: | |
case 3: | |
return "Change the value and then click HERE"; | |
case 4: | |
return "Now the value is changed. Click Toggle Table to close the component."; | |
case 5: | |
return "Click Toggle Table again."; | |
case 6: | |
return "Again, click on one of the rows and edit the value"; | |
case 7: | |
case 8: | |
return "Change value and click HERE to finally see the error in the console."; | |
default: | |
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 Ember from 'ember'; | |
export function eq(params/*, hash*/) { | |
return params[0] === params[1]; | |
} | |
export default Ember.Helper.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.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": "3.0.0", | |
"ember-template-compiler": "3.0.0", | |
"ember-testing": "3.0.0" | |
}, | |
"addons": { | |
"ember-data": "3.2.0", | |
"ember-table": "2.0.0-beta.4", | |
"ember-paper": "1.0.0-beta.5" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment