This commit is contained in:
morsh 2017-08-07 18:09:56 +03:00
Родитель 6d223fcce9
Коммит 0d5100932b
7 изменённых файлов: 55 добавлений и 54 удалений

Просмотреть файл

@ -29,18 +29,18 @@ interface IAreaState extends IGenericState {
export default class Area extends GenericComponent<IAreaProps, IAreaState> {
static editor = AreaSettings;
static fromSource(source: string) {
return {
values: source + "-graphData",
lines: source + "-lines",
timeFormat: source + "-timeFormat"
};
}
static defaultProps = {
isStacked: true
};
static fromSource(source: string) {
return {
values: source + '-graphData',
lines: source + '-lines',
timeFormat: source + '-timeFormat'
};
}
dateFormat(time: string): string {
return moment(time).format('MMM-DD');
}

Просмотреть файл

@ -21,8 +21,8 @@ interface IBarProps extends IGenericProps {
};
interface IBarState extends IGenericState {
values: Object[];
bars: Object[];
values: any[];
bars: any[];
}
export default class BarData extends GenericComponent<IBarProps, IBarState> {
@ -35,15 +35,14 @@ export default class BarData extends GenericComponent<IBarProps, IBarState> {
};
}
state = {
values: [],
bars: []
};
constructor(props: any) {
super(props);
this.handleClick = this.handleClick.bind(this);
this.state = {
values: [],
bars: []
};
}
handleClick(data: any, index: number) {

Просмотреть файл

@ -44,31 +44,31 @@ interface IMapDataProps extends IGenericProps {
};
interface IMapDataState extends IGenericState {
markers: Object[];
markers: any[];
locations: any[];
}
export default class MapData extends GenericComponent<IMapDataProps, IMapDataState> {
static fromSource(source: string) {
return {
locations: source
};
}
static defaultProps = {
center: [14.704929, -25.210251],
zoom: 1.4,
maxZoom: 8,
};
state = {
markers: [],
locations: [],
};
static fromSource(source: string) {
return {
locations: source
};
}
constructor(props: IMapDataProps) {
super(props);
this.state = {
markers: [],
locations: [],
};
}
componentWillMount() {

Просмотреть файл

@ -45,13 +45,6 @@ const classNames = {
export default class MenuFilter extends GenericComponent<any, any> {
static fromSource(source: string) {
return {
selectedValue: source + '-selected',
values: source + '-values'
};
}
static defaultProps = {
title: '',
subtitle: 'Select filter',
@ -60,12 +53,12 @@ export default class MenuFilter extends GenericComponent<any, any> {
selectNone: 'Clear filters'
};
state = {
overlay: false,
values: [],
selectedValues: [],
originalSelectedValues: []
};
static fromSource(source: string) {
return {
selectedValue: source + '-selected',
values: source + '-values'
};
}
constructor(props: any) {
super(props);
@ -75,6 +68,13 @@ export default class MenuFilter extends GenericComponent<any, any> {
this.hideOverlay = this.hideOverlay.bind(this);
this.selectAll = this.selectAll.bind(this);
this.selectNone = this.selectNone.bind(this);
this.state = {
overlay: false,
values: [],
selectedValues: [],
originalSelectedValues: []
};
}
toggleOverlay() {

Просмотреть файл

@ -4,6 +4,10 @@ import SelectField from 'react-md/lib/SelectFields';
export default class TextFilter extends GenericComponent<any, any> {
static defaultProps = {
title: 'Select'
};
static fromSource(source: string) {
return {
selectedValue: source + '-selected',
@ -11,10 +15,6 @@ export default class TextFilter extends GenericComponent<any, any> {
};
}
static defaultProps = {
title: 'Select'
};
constructor(props: any) {
super(props);

Просмотреть файл

@ -27,9 +27,9 @@ export default class Timeline extends GenericComponent<ITimelineProps, ITimeline
static editor = settings;
static fromSource(source: string) {
return {
values: source + "-graphData",
lines: source + "-lines",
timeFormat: source + "-timeFormat"
values: source + '-graphData',
lines: source + '-lines',
timeFormat: source + '-timeFormat'
};
}

Просмотреть файл

@ -80,24 +80,26 @@ export function scorecard (
const postfix = args.postfix || null;
let checkValue = (values && values[0] && values[0][countField]) || 0;
let createScoreValue = (value: any, heading: string, color: string, icon: string, subvalue?: any, subheading?: string) => {
let createValue = (value: any, heading: string, color: string, icon: string, subvalue?: any, subheading?: string) => {
let item = {};
let prefix = args && args.prefix || plugin._props.id;
item[prefix + '-value'] = utils.kmNumber(value, postfix);
item[prefix + '-heading'] = heading;
item[prefix + '-color'] = color;
item[prefix + '-icon'] = icon;
item[prefix + '-subvalue'] = subvalue || "";
item[prefix + '-subheading'] = subheading || "";
item[prefix + '-subvalue'] = subvalue || '';
item[prefix + '-subheading'] = subheading || '';
return item;
};
let thresholds = args.thresholds || [ ];
if (!thresholds.length) { thresholds.push({ value: checkValue, heading: '', color: '#000', icon: 'done' }) }
if (!thresholds.length) {
thresholds.push({ value: checkValue, heading: '', color: '#000', icon: 'done' });
}
let firstThreshold = thresholds[0];
if (!values || !values.length) {
return createScoreValue(
return createValue(
firstThreshold.value,
firstThreshold.heading,
firstThreshold.color,
@ -122,7 +124,7 @@ export function scorecard (
let subvalueField = args.subvalueField || null;
let subvalueThresholds = args.subvalueThresholds || [];
if (!subvalueThresholds.length) { subvalueThresholds.push({ subvalue: 0, subheading: '' }) }
if (!subvalueThresholds.length) { subvalueThresholds.push({ subvalue: 0, subheading: '' }); }
checkValue = values[0][subvalueField || countField] || 0;
thresholdIdx = 0;
@ -138,7 +140,7 @@ export function scorecard (
subheading = subvalueThreshold.subheading;
}
return createScoreValue(checkValue, threshold.heading, threshold.color, threshold.icon, subvalue, subheading);
return createValue(checkValue, threshold.heading, threshold.color, threshold.icon, subvalue, subheading);
}
/**
@ -421,7 +423,7 @@ export function bars(
const valueField = args.valueField || 'count';
const barsField = args.barsField || null;
const seriesField = args.seriesField || null;
const valueMaxLength = parseInt(args.valueMaxLength) || 13;
const valueMaxLength = args.valueMaxLength && parseInt(args.valueMaxLength, 10) || 13;
const threshold = args.threshold || 0;
const othersField = args.othersField || 'Others';