Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function (state, event, next) {
/** @type {?} */
var matches = actionMatcher(event);
/** @type {?} */
var isInitAction = matches(InitState) || matches(UpdateState);
// const layouts = snq(() => this.options.requirements.layouts.filter(layout => layout instanceof Type), []);
if (isInitAction && !this.initialized) {
var _a = transformRoutes(this.router.config), routes = _a.routes, wrappers = _a.wrappers;
routes = organizeRoutes(routes, wrappers);
state = setValue(state, 'ConfigState', tslib_1.__assign({}, (state.ConfigState && tslib_1.__assign({}, state.ConfigState)), this.options, { routes: routes }));
this.initialized = true;
}
return next(state, event);
};
ConfigPlugin.decorators = [
handle(state, event, next) {
/** @type {?} */
const matches = actionMatcher(event);
/** @type {?} */
const isInitAction = matches(InitState) || matches(UpdateState);
// const layouts = snq(() => this.options.requirements.layouts.filter(layout => layout instanceof Type), []);
if (isInitAction && !this.initialized) {
let { routes, wrappers } = transformRoutes(this.router.config);
routes = organizeRoutes(routes, wrappers);
state = setValue(state, 'ConfigState', Object.assign({}, (state.ConfigState && Object.assign({}, state.ConfigState)), this.options, { routes }));
this.initialized = true;
}
return next(state, event);
}
}
if (type === UpdateFormErrors.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.errors`, {
...event.payload.errors
});
}
if (type === UpdateFormDirty.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.dirty`, event.payload.dirty);
}
if (type === SetFormDirty.type) {
nextState = setValue(nextState, `${event.payload}.dirty`, true);
}
if (type === SetFormPristine.type) {
nextState = setValue(nextState, `${event.payload}.dirty`, false);
}
if (type === SetFormDisabled.type) {
nextState = setValue(nextState, `${event.payload}.disabled`, true);
}
if (type === SetFormEnabled.type) {
nextState = setValue(nextState, `${event.payload}.disabled`, false);
}
return next(nextState, event);
}
handle(state: any, event: any, next: NgxsNextPluginFn) {
const type = getActionTypeFromInstance(event);
let nextState = state;
if (type === UpdateFormValue.type || type === UpdateForm.type) {
const { value } = event.payload;
const payloadValue = Array.isArray(value) ? value.slice() : { ...value };
const path = this.joinPathWithPropertyPath(event);
nextState = setValue(nextState, path, payloadValue);
}
if (type === UpdateFormStatus.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.status`, event.payload.status);
}
if (type === UpdateFormErrors.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.errors`, {
...event.payload.errors
});
}
if (type === UpdateFormDirty.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.dirty`, event.payload.dirty);
}
function (state, event, next) {
/** @type {?} */
var matches = actionMatcher(event);
/** @type {?} */
var isInitAction = matches(InitState) || matches(UpdateState);
if (isInitAction && !this.initialized) {
/** @type {?} */
var transformedRoutes = transformRoutes(this.router.config);
var routes = transformedRoutes.routes;
var wrappers = transformedRoutes.wrappers;
routes = organizeRoutes(routes, wrappers);
/** @type {?} */
var flattedRoutes = flatRoutes(clone(routes));
state = setValue(state, 'ConfigState', tslib_1.__assign({}, (state.ConfigState && tslib_1.__assign({}, state.ConfigState)), this.options, { routes: routes,
flattedRoutes: flattedRoutes }));
this.initialized = true;
}
return next(state, event);
};
ConfigPlugin.decorators = [
handle(state: any, event: any, next: NgxsNextPluginFn) {
const matches = actionMatcher(event);
const isInitAction = matches(InitState) || matches(UpdateState);
if (isInitAction && !this.initialized) {
const transformedRoutes = transformRoutes(this.router.config);
let { routes } = transformedRoutes;
const { wrappers } = transformedRoutes;
routes = organizeRoutes(routes, wrappers);
const flattedRoutes = flatRoutes(clone(routes));
state = setValue(state, 'ConfigState', {
...(state.ConfigState && { ...state.ConfigState }),
...this.options,
routes,
flattedRoutes,
});
this.initialized = true;
}
return next(state, event);
}
}
}
if (type === SetFormDirty.type) {
nextState = setValue(nextState, `${event.payload}.dirty`, true);
}
if (type === SetFormPristine.type) {
nextState = setValue(nextState, `${event.payload}.dirty`, false);
}
if (type === SetFormDisabled.type) {
nextState = setValue(nextState, `${event.payload}.disabled`, true);
}
if (type === SetFormEnabled.type) {
nextState = setValue(nextState, `${event.payload}.disabled`, false);
}
return next(nextState, event);
}
handle(state, event, next) {
/** @type {?} */
const matches = actionMatcher(event);
/** @type {?} */
const isInitAction = matches(InitState) || matches(UpdateState);
if (isInitAction && !this.initialized) {
/** @type {?} */
const transformedRoutes = transformRoutes(this.router.config);
let { routes } = transformedRoutes;
const { wrappers } = transformedRoutes;
routes = organizeRoutes(routes, wrappers);
/** @type {?} */
const flattedRoutes = flatRoutes(clone(routes));
state = setValue(state, 'ConfigState', Object.assign({}, (state.ConfigState && Object.assign({}, state.ConfigState)), this.options, { routes,
flattedRoutes }));
this.initialized = true;
}
return next(state, event);
}
}
let nextState = state;
if (type === UpdateFormValue.type || type === UpdateForm.type) {
const { value } = event.payload;
const payloadValue = Array.isArray(value) ? value.slice() : { ...value };
const path = this.joinPathWithPropertyPath(event);
nextState = setValue(nextState, path, payloadValue);
}
if (type === UpdateFormStatus.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.status`, event.payload.status);
}
if (type === UpdateFormErrors.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.errors`, {
...event.payload.errors
});
}
if (type === UpdateFormDirty.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.dirty`, event.payload.dirty);
}
if (type === SetFormDirty.type) {
nextState = setValue(nextState, `${event.payload}.dirty`, true);
}
if (type === SetFormPristine.type) {
nextState = setValue(nextState, `${event.payload}.dirty`, false);
}
if (type === UpdateFormStatus.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.status`, event.payload.status);
}
if (type === UpdateFormErrors.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.errors`, {
...event.payload.errors
});
}
if (type === UpdateFormDirty.type || type === UpdateForm.type) {
nextState = setValue(nextState, `${event.payload.path}.dirty`, event.payload.dirty);
}
if (type === SetFormDirty.type) {
nextState = setValue(nextState, `${event.payload}.dirty`, true);
}
if (type === SetFormPristine.type) {
nextState = setValue(nextState, `${event.payload}.dirty`, false);
}
if (type === SetFormDisabled.type) {
nextState = setValue(nextState, `${event.payload}.disabled`, true);
}
if (type === SetFormEnabled.type) {
nextState = setValue(nextState, `${event.payload}.disabled`, false);
}
return next(nextState, event);
}