UNPKG

@adaptabletools/adaptable-cjs

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

100 lines (99 loc) 3.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExportReducer = exports.FormatSelect = exports.ExportReady = exports.ReportDelete = exports.ReportEdit = exports.ReportAdd = exports.ReportSelect = exports.FORMAT_SELECT = exports.EXPORT_READY = exports.REPORT_DELETE = exports.REPORT_EDIT = exports.REPORT_ADD = exports.REPORT_SELECT = void 0; const tslib_1 = require("tslib"); const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants"); const AdaptableHelper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/AdaptableHelper")); /** * @ReduxAction A Report has been selected */ exports.REPORT_SELECT = 'REPORT_SELECT'; /** * @ReduxAction A Report has been added */ exports.REPORT_ADD = 'REPORT_ADD'; /** * @ReduxAction A Report has been edited */ exports.REPORT_EDIT = 'REPORT_EDIT'; /** * @ReduxAction A Report has been deleted */ exports.REPORT_DELETE = 'REPORT_DELETE'; /** * @ReduxAction Export Module is ready */ exports.EXPORT_READY = 'EXPORT_READY'; /** * @ReduxAction A report Format has been selected */ exports.FORMAT_SELECT = 'FORMAT_SELECT'; const ReportSelect = (SelectedReport) => ({ type: exports.REPORT_SELECT, SelectedReport, }); exports.ReportSelect = ReportSelect; const ReportAdd = (report) => ({ type: exports.REPORT_ADD, report, }); exports.ReportAdd = ReportAdd; const ReportEdit = (report) => ({ type: exports.REPORT_EDIT, report, }); exports.ReportEdit = ReportEdit; const ReportDelete = (report) => ({ type: exports.REPORT_DELETE, report, }); exports.ReportDelete = ReportDelete; const ExportReady = (exportState) => ({ type: exports.EXPORT_READY, exportState, }); exports.ExportReady = ExportReady; const FormatSelect = (SelectedFormat) => ({ type: exports.FORMAT_SELECT, SelectedFormat, }); exports.FormatSelect = FormatSelect; const initialState = { Reports: GeneralConstants_1.EMPTY_ARRAY, }; const ExportReducer = (state = initialState, action) => { let reports; switch (action.type) { case exports.REPORT_SELECT: return Object.assign({}, state, { CurrentReport: action.SelectedReport, }); case exports.REPORT_ADD: { const actionReport = action.report; AdaptableHelper_1.default.addAdaptableObjectPrimitives(actionReport); reports = [].concat(state.Reports); reports.push(actionReport); return { ...state, Reports: reports }; } case exports.REPORT_EDIT: const actionReport = action.report; return { ...state, Reports: state.Reports.map((abObject) => abObject.Uuid === actionReport.Uuid ? actionReport : abObject), }; case exports.REPORT_DELETE: { const actionReport = action.report; return { ...state, Reports: state.Reports.filter((abObject) => abObject.Uuid !== actionReport.Uuid), }; } case exports.FORMAT_SELECT: return Object.assign({}, state, { CurrentFormat: action.SelectedFormat, }); default: return state; } }; exports.ExportReducer = ExportReducer;