in clns-acuity-vahub/vahub/src/main/webapp/src/app/common/trellising/store/Trellising.ts [1059:1157]
private trellisChangeSettings$(): Observable<Action> {
return this.actions$
.withLatestFrom(this._store.select(getTabId))
.filter(([action, tabId]) => {
return action.type === TRELLIS_PLOT_SETTINGS_CHANGE && NEW_APPROACH_TAB_LIST.contains(tabId);
})
.do(([action, tabId]) => {
this._store.dispatch(this.trellisingActionCreator.makeLoadingAction(true));
this._store.dispatch(action);
})
.withLatestFrom(
this._store.select(getCurrentNewYAxisOption),
this._store.select(getTrellisingRequired)
)
.mergeMap(([[action, tabId], yAxisOption, trellisingRequired]: any) => {
if (trellisingRequired) {
return this.dataService.getTrellisOptions(tabId, fromJS(yAxisOption))
.map((trellisOptions: TrellisOptions<any>[]) => {
return {
action, tabId, yAxisOption,
trellisOptions: trellisOptions.map(option => {
(<any>option).category = 'MANDATORY_TRELLIS';
return option;
})
};
});
} else {
return Observable.of({action, tabId, yAxisOption, trellisOptions: []});
}
})
.withLatestFrom(
this._store.select(getColorByRequired),
this._store.select(getCurrentNewXAxisOption),
this._store.select(getCurrentPlotSettings)
)
.mergeMap(([{action, tabId, yAxisOption, trellisOptions}, colorByRequired, xAxisOption, currentPlotSettings]: any) => {
if (colorByRequired) {
if (currentPlotSettings) {
return this.dataService.getColorByOptions(tabId, yAxisOption, currentPlotSettings)
.map((colorByOptions: TrellisOptions<any>[]) => {
return colorByOptions.map(option => {
(<any>option).category = TrellisCategory.NON_MANDATORY_SERIES;
return option;
});
})
.map((colorByOptions: TrellisOptions<any>[]) => {
this.updateTrellisOptions(colorByOptions.concat(trellisOptions), '');
return {tabId, xAxisOption, yAxisOption, trellisOptions};
});
}
return this.dataService.getColorByOptions(tabId, yAxisOption)
.map((colorByOptions: TrellisOptions<any>[]) => {
return colorByOptions.map(option => {
(<any>option).category = TrellisCategory.NON_MANDATORY_SERIES;
return option;
});
})
.map((colorByOptions: TrellisOptions<any>[]) => {
this.updateTrellisOptions(colorByOptions.concat(trellisOptions), '');
return {tabId, xAxisOption, yAxisOption, trellisOptions};
});
} else {
this.updateTrellisOptions(trellisOptions, '');
return Observable.of({tabId, xAxisOption, yAxisOption, trellisOptions});
}
})
.withLatestFrom(
this._store.select(getCurrentLimit),
this._store.select(getCurrentOffset),
this._store.select(getCurrentNewColorBy),
this._store.select(getCurrentPlotSettings),
this._store.select(getFilterTrellisByOptions)
)
.mergeMap(([{tabId, xAxisOption, yAxisOption, trellisOptions},
limit,
offset,
colorByOptions,
plotSettings,
filterTrellisByOptions
]) => {
const settings = constructDataRequestPayload(
xAxisOption,
yAxisOption,
trellisOptions,
limit,
offset,
colorByOptions,
plotSettings,
filterTrellisByOptions
);
return this.dataService.getPlotData(tabId, yAxisOption, settings)
.map((payload: List<IPlot>) => {
this.trellisingDispatcher.clearSelection();
this.updatePlotOptions(payload, undefined, true);
return this.trellisingActionCreator.makeLoadingAction(false);
});
});
}