UNPKG

appxigon-react

Version:

Appxigon implementation on React JS

69 lines (60 loc) 2.08 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.default = AXGView; var _actionTypes = require('../action-types'); var _actionTypes2 = _interopRequireDefault(_actionTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var initialState = { viewId: 'default', // not used ? locale: 'en', loading: false, modalDisplay: false, modalTitle: '', modalViewSchema: null }; function AXGView() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; var action = arguments[1]; switch (action.type) { case _actionTypes2.default.SET_VIEWID: var viewId = action.options.viewId; // TODO: get reliable current viewId // if (state.current != viewId) { // window.appxigon.history.push(`/${viewId}`) // } window.appxigon.history.push('/' + viewId); return _extends({}, state, { current: viewId }); case _actionTypes2.default.SET_LOADING: return _extends({}, state, { loading: action.options.loading }); case _actionTypes2.default.SET_MODAL_VIEW_SCHEMA: return _extends({}, state, { modalDisplay: true, modalViewSchema: action.options.schema }); case _actionTypes2.default.SET_MODAL_TITLE: return _extends({}, state, { modalTitle: action.title }); case _actionTypes2.default.SET_MODAL_STYLE: return _extends({}, state, { modalStyle: action.style }); case _actionTypes2.default.SET_LOCALE: return _extends({}, state, { locale: action.locale }); case _actionTypes2.default.CLOSE_MODAL: return _extends({}, state, { modalDisplay: false }); default: return state; } }