covid19-dashboard
Version:
Dashboard App displaying COVID-19 numbers by country
107 lines (89 loc) • 2.55 kB
JavaScript
import ComponentController from '../../../node_modules/neo.mjs/src/controller/Component.mjs';
/**
* @class Covid.view.HelixContainerController
* @extends Neo.controller.Component
*/
class HelixContainerController extends ComponentController {
static getConfig() {return {
/**
* @member {String} className='Covid.view.HelixContainerController'
* @protected
*/
className: 'Covid.view.HelixContainerController',
/**
* @member {Neo.component.Helix|null} helix_=null
* @protected
*/
helix_: null
}}
/**
* Triggered when accessing the helix config
* @param {Neo.component.Helix|null} value
* @protected
*/
beforeGetHelix(value) {
if (!value) {
this._helix = value = this.getReference('helix');
}
return value;
}
/**
* {Object} data
*/
onCollapseButtonClick(data) {
const panel = this.getReference('controls-panel'),
expand = panel.width === 40;
panel.width = expand ? 250 : 40;
data.component.text = expand ? 'X' : '+';
}
/**
* {Object} data
*/
onFlipItemsButtonClick(data) {
this.helix.flipped = !this.helix.flipped;
}
/**
* {Object} data
*/
onFollowSelectionButtonClick(data) {
const button = data.component;
if (button.iconCls === 'fa fa-square') {
this.helix.followSelection = true;
button.iconCls = 'fa fa-check-square';
} else {
this.helix.followSelection = false;
button.iconCls = 'fa fa-square';
}
}
/**
* @param {Object} data
*/
onRangefieldChange(data) {
const name = data.component.name;
if (['deltaY', 'maxOpacity', 'minOpacity'].includes(name)) {
data.value /= 100;
}
this.helix[name] = data.value;
}
/**
* @param {String} id
*/
onRangefieldMounted(id) {
const field = Neo.getComponent(id);
this.helix.on(field.eventName, function(value) {
value = Math.min(Math.max(value, field.minValue), field.maxValue);
field.value = value;
});
}
/**
* @param {Object} data
*/
onSortButtonClick(data) {
this.helix.store.sorters = [{
property : data.component.field,
direction: 'DESC'
}];
}
}
Neo.applyClassConfig(HelixContainerController);
export {HelixContainerController as default};