|
@@ -10,23 +10,23 @@ const optionsToKeep = ['valueOptions', 'stat', 'maxValue', 'maxValue', 'threshol
|
|
|
|
|
|
|
|
export const singleStatBaseOptionsCheck = (
|
|
export const singleStatBaseOptionsCheck = (
|
|
|
options: Partial<SingleStatBaseOptions>,
|
|
options: Partial<SingleStatBaseOptions>,
|
|
|
- prevPluginId?: string,
|
|
|
|
|
- prevOptions?: any
|
|
|
|
|
|
|
+ prevPluginId: string,
|
|
|
|
|
+ prevOptions: any
|
|
|
) => {
|
|
) => {
|
|
|
- if (prevOptions) {
|
|
|
|
|
- for (const otk of optionsToKeep) {
|
|
|
|
|
- if (prevOptions.hasOwnProperty(otk)) {
|
|
|
|
|
- options[otk] = cloneDeep(prevOptions[otk]);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ optionsToKeep.forEach(v => {
|
|
|
|
|
+ if (prevOptions.hasOwnProperty(v)) {
|
|
|
|
|
+ options[v] = cloneDeep(prevOptions.display);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ return options;
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
|
|
+export const singleStatMigrationCheck = (options: Partial<SingleStatBaseOptions>) => {
|
|
|
// 6.1 renamed some stats, This makes sure they are up to date
|
|
// 6.1 renamed some stats, This makes sure they are up to date
|
|
|
// avg -> mean, current -> last, total -> sum
|
|
// avg -> mean, current -> last, total -> sum
|
|
|
const { valueOptions } = options;
|
|
const { valueOptions } = options;
|
|
|
if (valueOptions && valueOptions.stat) {
|
|
if (valueOptions && valueOptions.stat) {
|
|
|
valueOptions.stat = getStatsCalculators([valueOptions.stat]).map(s => s.id)[0];
|
|
valueOptions.stat = getStatsCalculators([valueOptions.stat]).map(s => s.id)[0];
|
|
|
- console.log('CHANGED', valueOptions);
|
|
|
|
|
}
|
|
}
|
|
|
return options;
|
|
return options;
|
|
|
};
|
|
};
|
|
@@ -34,3 +34,4 @@ export const singleStatBaseOptionsCheck = (
|
|
|
reactPanel.setEditor(SingleStatEditor);
|
|
reactPanel.setEditor(SingleStatEditor);
|
|
|
reactPanel.setDefaults(defaults);
|
|
reactPanel.setDefaults(defaults);
|
|
|
reactPanel.setPanelTypeChangedHook(singleStatBaseOptionsCheck);
|
|
reactPanel.setPanelTypeChangedHook(singleStatBaseOptionsCheck);
|
|
|
|
|
+reactPanel.setPanelMigrationHook(singleStatMigrationCheck);
|