-
-
Save NullVoxPopuli/8f906f8f6dfff5803ac96cdeea36979e to your computer and use it in GitHub Desktop.
emberTableDemo
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
import Controller from '@ember/controller'; | |
import { computed } from '@ember/object' | |
function createSymbol() { | |
let chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); | |
let length = 2 + Math.floor(4 * Math.random()); // [2,5] | |
let symbol = ''; | |
while (symbol.length < length) { | |
symbol += chars[Math.floor(chars.length * Math.random())]; | |
} | |
return symbol; | |
} | |
function createPrice() { | |
return 0.5 + 500 * Math.random(); // [0.5,500.5); | |
} | |
function formatPrice(price) { | |
return price.toFixed(2); | |
} | |
function createRow() { | |
return { | |
symbol: createSymbol(), | |
price: formatPrice(createPrice()) | |
}; | |
} | |
function createRows(num) { | |
return Array(num) | |
.fill() | |
.map(createRow); | |
} | |
export default class TableController extends Controller { | |
@computed() | |
get columns(){ | |
return [ | |
{ name: 'Stocks', valuePath: 'symbol', textAlign: 'center' }, | |
{ name: 'Price (USD)', valuePath: 'price', textAlign: 'center' } | |
]; | |
} | |
@computed() | |
get rows(){ | |
return createRows(this.numRows); | |
} | |
numRows= 100; | |
//This is the start of doubt | |
//Octane version by me | |
@action addRows() { | |
this.rows.pushObjects(createRows(parseInt(this.numRows))); | |
} | |
} |
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 Route from '@ember/routing/route'; | |
export default Route.extend({ | |
}); |
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", | |
}, | |
"devDependencies": { | |
"ember-table": "^3.0.1", | |
"sass": "^1.22.7", | |
"tailwindcss": "^1.0.5" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment