Last active
October 14, 2016 02:26
-
-
Save stavarotti/b72f9c2c7836ca32a545cf166c84505e to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or 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({ | |
model: [], | |
hasData: Ember.computed('model', { | |
get() { | |
let model = this.get('model'); | |
return !Ember.isEmpty(model) && | |
!(Ember.get(model, 'message') === 'no_data'); | |
} | |
}), | |
tableHeadRows: Ember.computed('model', { | |
get() { | |
if (this.get('hasData')) { | |
return this.get('model').headerRow; | |
} else { | |
return []; | |
} | |
} | |
}), | |
tableBodyRows: Ember.computed('model', { | |
get() { | |
if (this.get('hasData')) { | |
return this.get('model').bodyRows; | |
} else { | |
return []; | |
} | |
} | |
}), | |
init() { | |
this._super(...arguments); | |
Ember.Logger.debug('standard-table init...'); | |
}, | |
didUpdateAttrs(){ | |
this._super(...arguments); | |
Ember.Logger.debug('standard-table didUpdateAttrs...'); | |
}, | |
didReceiveAttrs(){ | |
this._super(...arguments); | |
Ember.Logger.debug('standard-table didReceiveAttrs...'); | |
}, | |
willUpdate(){ | |
this._super(...arguments); | |
Ember.Logger.debug('standard-table willUpdate...'); | |
}, | |
willRender(){ | |
this._super(...arguments); | |
Ember.Logger.debug('standard-table willRender...'); | |
}, | |
didUpdate(){ | |
this._super(...arguments); | |
Ember.Logger.debug('standard-table didUpdate...'); | |
}, | |
didRender(){ | |
this._super(...arguments); | |
Ember.Logger.debug('standard-table didRender...', ...arguments); | |
Ember.Logger.debug('---------------------------', ...arguments); | |
} | |
}); |
This file contains hidden or 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'; | |
function getData () { | |
let time = (new Date()).getTime(); | |
return { | |
headerRow: [[ | |
{value: 'Header 1 - '}, | |
{value: 'Header 2'} | |
]], | |
bodyRows: [[ | |
{value: 'Cell 1 - ' + time}, | |
{value: 'Cell 2 - ' + time} | |
]] | |
}; | |
} | |
export default Ember.Controller.extend({ | |
isLoading: false, | |
model: {}, | |
actions: { | |
refreshData() { | |
this.set('isLoading', true); | |
Ember.run.later(this, function () { | |
this.set('model', getData()); | |
this.set('isLoading', false); | |
}, 1000); | |
} | |
} | |
}); |
This file contains hidden or 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.10.5", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.8.0", | |
"ember-data": "2.8.0", | |
"ember-template-compiler": "2.8.0", | |
"ember-testing": "2.8.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment