salix/front/core/components/data-viewer/index.js

40 lines
858 B
JavaScript

import ngModule from '../../module';
import './style.scss';
export default class DataViewer {
get computedData() {
return this.data || (this.model && this.model.data);
}
get computedLoading() {
return this.isLoading || (this.model && this.model.isRefreshing);
}
get hasData() {
let data = this.computedData;
return data && data.length;
}
get status() {
if (this.hasData)
return null;
if (this.computedLoading)
return 'loading';
if (this.computedData)
return 'empty';
else
return 'clear';
}
}
ngModule.component('vnDataViewer', {
template: require('./index.html'),
transclude: true,
controller: DataViewer,
bindings: {
model: '<?',
data: '<?',
isLoading: '<?'
}
});