diff --git a/shesha-core/src/Shesha.Framework/EntityReferences/GenericEntityReference.cs b/shesha-core/src/Shesha.Framework/EntityReferences/GenericEntityReference.cs index 3fdcec781..d19b65b4a 100644 --- a/shesha-core/src/Shesha.Framework/EntityReferences/GenericEntityReference.cs +++ b/shesha-core/src/Shesha.Framework/EntityReferences/GenericEntityReference.cs @@ -7,7 +7,7 @@ namespace Shesha.EntityReferences { - public class GenericEntityReference : IGenericEntityReference + public class GenericEntityReference : IEquatable, IGenericEntityReference { private object _entity; @@ -55,5 +55,32 @@ private static GenericEntityReference SetEntity(Entity entity) { return new GenericEntityReference(entity); } + + public override bool Equals(object obj) => this.Equals(obj as GenericEntityReference); + + public bool Equals(GenericEntityReference obj) + { + return Id == obj.Id && _className == obj._className; + } + + public static bool operator ==(GenericEntityReference l, GenericEntityReference r) + { + if (l is null) + { + if (r is null) + return true; + // Only the left side is null. + return false; + } + // Equals handles case of null on right side. + return l.Equals(r); + } + + public static bool operator !=(GenericEntityReference l, GenericEntityReference r) => !(l == r); + + public override int GetHashCode() + { + return Id.IsNullOrEmpty() ? 0 : Id.GetHashCode(); + } } } diff --git a/shesha-core/src/Shesha.Framework/Migrations/PostgreSql/M20230725153499.cs b/shesha-core/src/Shesha.Framework/Migrations/PostgreSql/M20230725153499.cs new file mode 100644 index 000000000..c97e883d8 --- /dev/null +++ b/shesha-core/src/Shesha.Framework/Migrations/PostgreSql/M20230725153499.cs @@ -0,0 +1,31 @@ +using FluentMigrator; +using Shesha.FluentMigrator; + +namespace Shesha.Migrations.PostgreSql +{ + [Migration(20230725153499), PostgreSqlOnly] + public class M20230725153499 : OneWayMigration + { + public override void Up() + { + Execute.Sql( +@"CREATE OR REPLACE FUNCTION public.""log_Frwk_UserLoginAttempts_UpdateLastLoginDate_AI""() + RETURNS trigger + LANGUAGE 'plpgsql' + COST 100 + VOLATILE NOT LEAKPROOF +AS $BODY$ + +BEGIN + IF NEW.""UserId"" IS NOT NULL AND NEW.""ResultLkp"" = 1 THEN + UPDATE ""AbpUsers"" + SET ""LastLoginDate"" = NEW.""CreationTime"" + WHERE ""Id"" = NEW.""UserId""; + END IF; + + RETURN NEW; +END; +$BODY$;"); + } + } +} diff --git a/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/EntityReferenceUserType.cs b/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/EntityReferenceUserType.cs index 19ab73659..49b49c01a 100644 --- a/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/EntityReferenceUserType.cs +++ b/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/EntityReferenceUserType.cs @@ -5,6 +5,7 @@ using Shesha.EntityReferences; using System; using System.Data.Common; +using System.Data.SqlTypes; namespace Shesha.NHibernate.UserTypes { @@ -37,8 +38,10 @@ public object Disassemble(object value, ISessionImplementor session) public new bool Equals(object x, object y) { + if (x == null && y == null) return true; + if (x is GenericEntityReference erx && y is GenericEntityReference ery) - return erx.Id == ery.Id && erx._className == ery._className; + return erx == ery; return false; } diff --git a/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/EntityReferenceWithDisplayUserType.cs b/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/EntityReferenceWithDisplayUserType.cs index 5b3cddbae..f79ce7d84 100644 --- a/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/EntityReferenceWithDisplayUserType.cs +++ b/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/EntityReferenceWithDisplayUserType.cs @@ -37,8 +37,10 @@ public object Disassemble(object value, ISessionImplementor session) public new bool Equals(object x, object y) { + if (x == null && y == null) return true; + if (x is GenericEntityReference erx && y is GenericEntityReference ery) - return erx.Id == ery.Id && erx._className == ery._className; + return erx == ery; return false; } diff --git a/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/JsonUserType.cs b/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/JsonUserType.cs index 4077652c4..6986f1638 100644 --- a/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/JsonUserType.cs +++ b/shesha-core/src/Shesha.NHibernate/NHibernate/UserTypes/JsonUserType.cs @@ -63,7 +63,7 @@ public new bool Equals(object x, object y) if (x == null && y == null) return true; - if (x == null || y == null) + if (x == null && y != null || x != null && y == null) return false; if (x is IJsonEntityProxy xp && y is IJsonEntityProxy yp) diff --git a/shesha-core/src/Shesha.Web.Core/SheshaWebCoreModule.cs b/shesha-core/src/Shesha.Web.Core/SheshaWebCoreModule.cs index 5e4ea31f4..f894432a9 100644 --- a/shesha-core/src/Shesha.Web.Core/SheshaWebCoreModule.cs +++ b/shesha-core/src/Shesha.Web.Core/SheshaWebCoreModule.cs @@ -7,12 +7,9 @@ using Abp.Zero.Configuration; using Boxfusion.Authorization; using Castle.MicroKernel.Registration; -using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Tokens; -using Shesha.Application; using Shesha.Authentication.JwtBearer; using Shesha.Authorization; using Shesha.Bootstrappers; @@ -21,10 +18,7 @@ using Shesha.Languages; using Shesha.NHibernate; using Shesha.Scheduler; -using Shesha.Startup; -using Shesha.Validations; using System; -using System.Reflection; using System.Text; namespace Shesha diff --git a/shesha-core/test/Shesha.Tests/EntityReferenceTest/EntityReference_Tests.cs b/shesha-core/test/Shesha.Tests/EntityReferenceTest/EntityReference_Tests.cs index eba3a9762..5a3e3cc9c 100644 --- a/shesha-core/test/Shesha.Tests/EntityReferenceTest/EntityReference_Tests.cs +++ b/shesha-core/test/Shesha.Tests/EntityReferenceTest/EntityReference_Tests.cs @@ -2,11 +2,14 @@ using Abp.Domain.Repositories; using Abp.Domain.Uow; using Abp.Timing; +using DocumentFormat.OpenXml.Vml.Office; using Shesha.Domain; using Shesha.Domain.ConfigurationItems; using Shesha.DynamicEntities; using Shesha.EntityReferences; using Shesha.Extensions; +using Shesha.NHibernate; +using Shesha.NHibernate.Session; using System; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; @@ -17,7 +20,7 @@ namespace Shesha.Tests.EntityReferenceTest { public class EntityReference_Tests : SheshaNhTestBase - { + { private readonly IUnitOfWorkManager _unitOfWorkManager; private readonly IRepository _personRepository; private readonly IRepository _organisationRepository; @@ -40,12 +43,40 @@ public EntityReference_Tests() _moduleRepo = Resolve>(); } + [Fact] + public async Task TestGnericEntityReference() + { + LoginAsHostAdmin(); + + using (var uow = _unitOfWorkManager.Begin()) + { + var repo = LocalIocManager.Resolve>(); + var items = await repo.GetAllListAsync(); + + var sessionProvider = LocalIocManager.Resolve(); + var session = sessionProvider.Session; + + //GenericEntityReference i = null; + + foreach (var item in items) + { + //var b = i == item.PermissionedEntity1; + //i = item.PermissionedEntity1; + var entry = session?.GetEntry(item, false); + var dirty = session.GetDirtyProperties(item); + } + + await uow.CompleteAsync(); + } + } + [Fact] public async Task CheckUow() { LoginAsHostAdmin(); - using (var uow = _unitOfWorkManager.Begin(new UnitOfWorkOptions { + using (var uow = _unitOfWorkManager.Begin(new UnitOfWorkOptions + { IsTransactional = true, IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) @@ -75,70 +106,70 @@ public async Task CheckUow() } } -/* [Table("Test_EntityRef")] - public class EntityRef : Entity - { - public GenericEntityReference AnyEntity { get; set; } + /* [Table("Test_EntityRef")] + public class EntityRef : Entity + { + public GenericEntityReference AnyEntity { get; set; } - public GenericEntityReference MyEntity { get; set; } + public GenericEntityReference MyEntity { get; set; } - } + } - [Fact] - public async Task CheckUserType() - { - LoginAsHostAdmin(); + [Fact] + public async Task CheckUserType() + { + LoginAsHostAdmin(); - using (var uow = _unitOfWorkManager.Begin()) - { - EntityRef er = _entityRefRepository.GetAll().FirstOrDefault(); + using (var uow = _unitOfWorkManager.Begin()) + { + EntityRef er = _entityRefRepository.GetAll().FirstOrDefault(); - Entity anyEntity = er.AnyEntity; + Entity anyEntity = er.AnyEntity; - if (anyEntity is Person person) - { + if (anyEntity is Person person) + { - } - if (anyEntity is Organisation organisation) - { + } + if (anyEntity is Organisation organisation) + { - } + } - var entity = (Person)er.AnyEntity; + var entity = (Person)er.AnyEntity; - if (anyEntity is Person person2) - { - var name = person2.FullName; - } + if (anyEntity is Person person2) + { + var name = person2.FullName; + } - var org = _organisationRepository.GetAll().FirstOrDefault(); + var org = _organisationRepository.GetAll().FirstOrDefault(); - GenericEntityReference eref = org; - er.AnyEntity = org; - _entityRefRepository.InsertOrUpdate(er); + GenericEntityReference eref = org; + er.AnyEntity = org; + _entityRefRepository.InsertOrUpdate(er); - uow.Complete(); - } - } + uow.Complete(); + } + } - [Fact] - public async Task CheckMuliProp() - { - LoginAsHostAdmin(); + [Fact] + public async Task CheckMuliProp() + { + LoginAsHostAdmin(); - using (var uow = _unitOfWorkManager.Begin()) - { - EntityRef er = _entityRefRepository.GetAll().FirstOrDefault(); + using (var uow = _unitOfWorkManager.Begin()) + { + EntityRef er = _entityRefRepository.GetAll().FirstOrDefault(); - Entity anyEntity = er.AnyEntity; + Entity anyEntity = er.AnyEntity; - er.MyEntity = anyEntity; + er.MyEntity = anyEntity; - _entityRefRepository.InsertOrUpdate(er); + _entityRefRepository.InsertOrUpdate(er); - uow.Complete(); - } - } -*/ + uow.Complete(); + } + } + */ } } \ No newline at end of file diff --git a/shesha-reactjs/src/components/formDesigner/components/subForm/componentsContainerSubForm.tsx b/shesha-reactjs/src/components/formDesigner/components/subForm/componentsContainerSubForm.tsx index 38c02d213..c5dd1acf8 100644 --- a/shesha-reactjs/src/components/formDesigner/components/subForm/componentsContainerSubForm.tsx +++ b/shesha-reactjs/src/components/formDesigner/components/subForm/componentsContainerSubForm.tsx @@ -1,54 +1,61 @@ -import { IComponentsContainerBaseProps } from "interfaces"; -import { useGlobalState, useSubForm } from "providers"; -import React, { Fragment } from "react"; -import { FC, useCallback } from "react"; -import { executeScriptSync } from "utils/publicUtils"; -import DynamicComponent from "../dynamicView/dynamicComponent"; - -export const ComponentsContainerSubForm: FC = props => { - const { containerId, readOnly } = props; - const { getChildComponents } = useSubForm(); - const components = getChildComponents(containerId); - - //alias added for readability and avoiding names clashes - const { value: subFormData } = useSubForm(); - const { globalState } = useGlobalState(); - - const executeExpression = useCallback( - (expression: string) => { - if (!expression) return true; - const evaluated = executeScriptSync(expression, { data: subFormData, globalState }); - return typeof evaluated === 'boolean' ? evaluated : true; - }, - [subFormData, globalState] - ); - - const getReadOnlyState = (isReadOnly: boolean) => (typeof readOnly === 'boolean' ? readOnly : isReadOnly); - - return ( - - {components - ?.filter(({ customVisibility }) => { - return executeExpression(customVisibility); - }) - .map(({ customEnabled, disabled: notabled, ...model }) => { - const disabled = !executeExpression(customEnabled) || notabled; - - return ( - - ); - })} - - ); +import { IComponentsContainerBaseProps } from 'interfaces'; +import { useGlobalState, useSubForm } from 'providers'; +import React from 'react'; +import { FC, useCallback } from 'react'; +import { executeScriptSync } from 'utils/publicUtils'; +import DynamicComponent from '../dynamicView/dynamicComponent'; +import { getAlignmentStyle } from 'components/formDesigner/containers/componentsContainerForm'; +import { ICommonContainerProps } from 'designer-components/container/interfaces'; +import { removeUndefinedProperties } from 'utils/array'; + +interface IComponentsContainerSubFormProps extends IComponentsContainerBaseProps, ICommonContainerProps {} + +export const ComponentsContainerSubForm: FC = (props) => { + const { containerId, readOnly } = props; + const { getChildComponents } = useSubForm(); + const components = getChildComponents(containerId); + + const style = getAlignmentStyle(props); + + //alias added for readability and avoiding names clashes + const { value: subFormData } = useSubForm(); + const { globalState } = useGlobalState(); + + const executeExpression = useCallback( + (expression: string) => { + if (!expression) return true; + const evaluated = executeScriptSync(expression, { data: subFormData, globalState }); + return typeof evaluated === 'boolean' ? evaluated : true; + }, + [subFormData, globalState] + ); + + const getReadOnlyState = (isReadOnly: boolean) => (typeof readOnly === 'boolean' ? readOnly : isReadOnly); + + return ( +
+ {components + ?.filter(({ customVisibility }) => { + return executeExpression(customVisibility); + }) + .map(({ customEnabled, disabled: notabled, ...model }) => { + const disabled = !executeExpression(customEnabled) || notabled; + + return ( + + ); + })} +
+ ); }; -ComponentsContainerSubForm.displayName = "ComponentsContainer(SubForm)"; \ No newline at end of file +ComponentsContainerSubForm.displayName = 'ComponentsContainer(SubForm)'; diff --git a/shesha-reactjs/src/components/formDesigner/components/text/utils.ts b/shesha-reactjs/src/components/formDesigner/components/text/utils.ts index 946ed9001..c22c537ad 100644 --- a/shesha-reactjs/src/components/formDesigner/components/text/utils.ts +++ b/shesha-reactjs/src/components/formDesigner/components/text/utils.ts @@ -38,7 +38,7 @@ export const getContent = (content: string, { dataType = 'string', dateFormat, n }; export const formatDateStringAndPrefix = (content: string, dateFormat: string) => { - const regex = /^\s*([\S\s]+?)\s+(\d{4}-\d{2}-\d{2})/; + const regex = /^\s*([\S\s]+?)\s+(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{1,3})/; const match = content?.match(regex); if (match && match?.length > 2) { diff --git a/shesha-reactjs/src/components/formDesigner/containers/componentsContainerForm.tsx b/shesha-reactjs/src/components/formDesigner/containers/componentsContainerForm.tsx index daa82c70f..3d2a430c4 100644 --- a/shesha-reactjs/src/components/formDesigner/containers/componentsContainerForm.tsx +++ b/shesha-reactjs/src/components/formDesigner/containers/componentsContainerForm.tsx @@ -1,10 +1,7 @@ import React, { CSSProperties, FC, PropsWithChildren, useCallback, useMemo } from 'react'; import ConfigurableFormComponent from '../configurableFormComponent'; import { useForm } from 'providers/form'; -import { - TOOLBOX_COMPONENT_DROPPABLE_KEY, - TOOLBOX_DATA_ITEM_DROPPABLE_KEY, -} from 'providers/form/models'; +import { TOOLBOX_COMPONENT_DROPPABLE_KEY, TOOLBOX_DATA_ITEM_DROPPABLE_KEY } from 'providers/form/models'; import { ItemInterface, ReactSortable } from 'react-sortablejs'; import { joinStringValues } from 'utils'; import DynamicComponent from '../components/dynamicView/dynamicComponent'; @@ -14,7 +11,7 @@ import { useFormData, useGlobalState } from 'providers'; import { executeScriptSync } from 'utils/publicUtils'; import { IComponentsContainerProps } from './componentsContainer'; -export const ComponentsContainerForm: FC = props => { +export const ComponentsContainerForm: FC = (props) => { const { formMode } = useForm(); const { data: formData } = useFormData(); const designer = useFormDesigner(false); @@ -51,7 +48,7 @@ export const ComponentsContainerForm: FC = props => { return useDesigner ? : ; }; -ComponentsContainerForm.displayName = "ComponentsContainer(Form)"; +ComponentsContainerForm.displayName = 'ComponentsContainer(Form)'; type AlignmentProps = Pick< IComponentsContainerProps, @@ -69,7 +66,7 @@ type AlignmentProps = Pick< | 'flexWrap' >; -const getAlignmentStyle = ({ +export const getAlignmentStyle = ({ direction = 'vertical', justifyContent, alignItems, @@ -87,9 +84,7 @@ const getAlignmentStyle = ({ display, }; - const gridTemplateColumns = Array(gridColumnsCount) - .fill('auto') - ?.join(' '); + const gridTemplateColumns = Array(gridColumnsCount).fill('auto')?.join(' '); if (direction === 'horizontal' || display !== 'block') { style['justifyContent'] = justifyContent; @@ -118,7 +113,7 @@ const getAlignmentStyle = ({ return style; }; -const ComponentsContainerDesigner: FC> = props => { +const ComponentsContainerDesigner: FC> = (props) => { const { containerId, children, @@ -132,21 +127,14 @@ const ComponentsContainerDesigner: FC(() => { - return childIds.map(id => ({ - id: id + return childIds.map((id) => ({ + id: id, })); }, [childIds]); @@ -157,15 +145,14 @@ const ComponentsContainerDesigner: FC item.chosen === true); - if (chosen) - return; + const chosen = newState.some((item) => item.chosen === true); + if (chosen) return; // temporary commented out, the behavoiur of the sortablejs differs sometimes const listChanged = true; //!newState.some(item => item.chosen !== null && item.chosen !== undefined); if (listChanged) { - const newDataItemIndex = newState.findIndex(item => item['type'] === TOOLBOX_DATA_ITEM_DROPPABLE_KEY); + const newDataItemIndex = newState.findIndex((item) => item['type'] === TOOLBOX_DATA_ITEM_DROPPABLE_KEY); if (newDataItemIndex > -1) { // dropped data item const draggedItem = newState[newDataItemIndex]; @@ -176,7 +163,7 @@ const ComponentsContainerDesigner: FC item['type'] === TOOLBOX_COMPONENT_DROPPABLE_KEY); + const newComponentIndex = newState.findIndex((item) => item['type'] === TOOLBOX_COMPONENT_DROPPABLE_KEY); if (newComponentIndex > -1) { // add new component const toolboxComponent = newState[newComponentIndex]; @@ -200,7 +187,7 @@ const ComponentsContainerDesigner: FC(item => item.id.toString()); + const newIds = newState.map((item) => item.id.toString()); updateChildComponents({ containerId, componentIds: newIds }); } } @@ -213,7 +200,7 @@ const ComponentsContainerDesigner: FC { + const onDragEnd = (_evt) => { endDragging(); }; @@ -230,7 +217,7 @@ const ComponentsContainerDesigner: FC ( + wrap={(content) => (
{content}
@@ -270,7 +257,7 @@ const ComponentsContainerDesigner: FC> = props => { +const ComponentsContainerLive: FC> = (props) => { const { containerId, children, @@ -305,4 +292,4 @@ const ComponentsContainerLive: FC> {children} ); -}; \ No newline at end of file +}; diff --git a/shesha-reactjs/src/components/notesRenderer/styles/index.less b/shesha-reactjs/src/components/notesRenderer/styles/index.less index e69de29bb..62ad3781a 100644 --- a/shesha-reactjs/src/components/notesRenderer/styles/index.less +++ b/shesha-reactjs/src/components/notesRenderer/styles/index.less @@ -0,0 +1,11 @@ +.sha-notes-renderer::-webkit-scrollbar { + width: 8px; +} + +.sha-notes-renderer::-webkit-scrollbar-thumb { + background-color: gray; +} + +.sha-notes-renderer::-webkit-scrollbar-track { + background-color: lightgrey; +} \ No newline at end of file diff --git a/shesha-reactjs/src/providers/subForm/index.tsx b/shesha-reactjs/src/providers/subForm/index.tsx index 73f29be5a..68fd666be 100644 --- a/shesha-reactjs/src/providers/subForm/index.tsx +++ b/shesha-reactjs/src/providers/subForm/index.tsx @@ -23,7 +23,16 @@ import { EntityAjaxResponse } from 'pages/dynamic/interfaces'; import { UseFormConfigurationArgs } from '../form/api'; import { useConfigurableAction } from '../configurableActionsDispatcher'; import { useConfigurationItemsLoader } from '../configurationItemsLoader'; -import { componentsFlatStructureToTree, componentsTreeToFlatStructure, executeScript, IAnyObject, QueryStringParams, upgradeComponents, useAppConfigurator, useSheshaApplication } from '../..'; +import { + componentsFlatStructureToTree, + componentsTreeToFlatStructure, + executeScript, + IAnyObject, + QueryStringParams, + upgradeComponents, + useAppConfigurator, + useSheshaApplication, +} from '../..'; import * as RestfulShesha from 'utils/fetchers'; import { useModelApiHelper } from 'components/configurableForm/useActionEndpoint'; import { StandardEntityActions } from 'interfaces/metadata'; @@ -34,7 +43,7 @@ export interface SubFormProviderProps extends Omit> = ({ queryParams, onChange, defaultValue, - entityType + entityType, }) => { const [state, dispatch] = useReducer(subFormReducer, SUB_FORM_CONTEXT_INITIAL_STATE); const { publish } = usePubSub(); @@ -124,17 +133,20 @@ const SubFormProvider: FC> = ({ if (!Boolean(internalEntityType)) { if (Boolean(entityType)) { setInternalEntityType(entityType); - } else - if (value && typeof value === 'object' && value['_className']) { - setInternalEntityType(value['_className']); - } + } else if (value && typeof value === 'object' && value['_className']) { + setInternalEntityType(value['_className']); + } } else { if (Boolean(entityType) && internalEntityType !== entityType) { setInternalEntityType(entityType); - } else - if (value && typeof value === 'object' && value['_className'] && internalEntityType !== value['_className']) { - setInternalEntityType(value['_className']); - } + } else if ( + value && + typeof value === 'object' && + value['_className'] && + internalEntityType !== value['_className'] + ) { + setInternalEntityType(value['_className']); + } } }, [entityType, value]); @@ -144,13 +156,13 @@ const SubFormProvider: FC> = ({ return getUrl ? // if getUrl is specified - evaluate value using JS - evaluateUrl(getUrl) + evaluateUrl(getUrl) : internalEntityType - ? // if entityType is specified - get default url for the entity + ? // if entityType is specified - get default url for the entity urlHelper .getDefaultActionUrl({ modelType: internalEntityType, actionName: StandardEntityActions.read }) - .then(endpoint => endpoint.url) - : // return empty string + .then((endpoint) => endpoint.url) + : // return empty string Promise.resolve(''); }; @@ -169,7 +181,7 @@ const SubFormProvider: FC> = ({ useEffect(() => { if (value && formSelectionMode === 'dynamic') { if (value && typeof value === 'object' && value['_className'] && !formConfig?.formId) - getEntityFormId(value['_className'], formType, formid => { + getEntityFormId(value['_className'], formType, (formid) => { setFormConfig({ formId: { name: formid.name, module: formid.module }, lazy: true }); }); } @@ -192,7 +204,7 @@ const SubFormProvider: FC> = ({ // tslint:disable-next-line:function-constructor const func = new Function('data, query, globalState', queryParams); - return args => { + return (args) => { try { const result = func(args?.data, args?.query, args?.globalState); @@ -254,12 +266,12 @@ const SubFormProvider: FC> = ({ } // NOTE: getUrl may be null and a real URL according to the entity type or other params - //if (!getUrl) return; + //if (!getUrl) return; dataRequestAbortController.current = new AbortController(); dispatch(fetchDataRequestAction()); - getReadUrl().then(getUrl => { + getReadUrl().then((getUrl) => { if (!Boolean(getUrl)) { dispatch(fetchDataSuccessAction()); return; @@ -271,7 +283,7 @@ const SubFormProvider: FC> = ({ { base: backendUrl, headers: httpHeaders }, dataRequestAbortController.current.signal ) - .then(dataResponse => { + .then((dataResponse) => { if (dataRequestAbortController.current?.signal?.aborted) return; dataRequestAbortController.current = null; @@ -285,7 +297,7 @@ const SubFormProvider: FC> = ({ dispatch(fetchDataErrorAction({ error: dataResponse.error as GetDataError })); } }) - .catch(e => { + .catch((e) => { dispatch(fetchDataErrorAction({ error: e })); }); }); @@ -297,8 +309,7 @@ const SubFormProvider: FC> = ({ // fetch data on first rendering and on change of some properties useDeepCompareEffect(() => { - if (dataSource === 'api') - fetchData(); + if (dataSource === 'api') fetchData(); }, [dataSource, finalQueryParams]); // todo: memoize final getUrl and add as a dependency const postData = useDebouncedCallback(() => { @@ -309,7 +320,7 @@ const SubFormProvider: FC> = ({ description: 'Please make sure you have specified the POST URL', }); } else { - postHttp(value).then(submittedValue => { + postHttp(value).then((submittedValue) => { onChange(submittedValue?.result); if (onCreated) { const evaluateOnCreated = () => { @@ -337,7 +348,7 @@ const SubFormProvider: FC> = ({ description: 'Please make sure you have specified the PUT URL', }); } else { - putHttp(value).then(submittedValue => { + putHttp(value).then((submittedValue) => { onChange(submittedValue?.result); if (onUpdated) { const evaluateOnUpdated = () => { @@ -365,11 +376,13 @@ const SubFormProvider: FC> = ({ upgradeComponents(designerComponents, payload.formSettings, flatStructure); const tree = componentsFlatStructureToTree(designerComponents, flatStructure); - dispatch(setMarkupWithSettingsAction({ - ...payload, - components: tree, - ...flatStructure - })); + dispatch( + setMarkupWithSettingsAction({ + ...payload, + components: tree, + ...flatStructure, + }) + ); }; //#region Fetch Form @@ -378,7 +391,7 @@ const SubFormProvider: FC> = ({ setFormLoadingState({ isLoading: true, error: null }); getForm({ formId: formConfig.formId, skipCache: false, configurationItemMode: configurationItemMode }) - .then(response => { + .then((response) => { setFormLoadingState({ isLoading: false, error: null }); setMarkup({ @@ -392,7 +405,7 @@ const SubFormProvider: FC> = ({ description: response?.description, }); }) - .catch(e => { + .catch((e) => { setFormLoadingState({ isLoading: false, error: e }); }); } @@ -410,7 +423,7 @@ const SubFormProvider: FC> = ({ const getChildComponents = (componentId: string) => { const childIds = state.componentRelations[componentId]; if (!childIds) return []; - const components = childIds.map(childId => { + const components = childIds.map((childId) => { return state.allComponents[childId]; }); return components; @@ -467,6 +480,8 @@ const SubFormProvider: FC> = ({ return typeof span === 'number' ? { span } : span; }; + console.log('SubFormProvider state?.components: ', state?.components); + return ( - - - - + + + + diff --git a/shesha-starter/backend/src/Module/ShaCompanyName.ShaProjectName.Domain/ShaCompanyName.ShaProjectName.Domain.csproj b/shesha-starter/backend/src/Module/ShaCompanyName.ShaProjectName.Domain/ShaCompanyName.ShaProjectName.Domain.csproj index 21d955476..fb5558e6e 100644 --- a/shesha-starter/backend/src/Module/ShaCompanyName.ShaProjectName.Domain/ShaCompanyName.ShaProjectName.Domain.csproj +++ b/shesha-starter/backend/src/Module/ShaCompanyName.ShaProjectName.Domain/ShaCompanyName.ShaProjectName.Domain.csproj @@ -16,12 +16,12 @@ - - - - - - + + + + + + diff --git a/shesha-starter/backend/src/ShaCompanyName.ShaProjectName.Web.Core/ShaCompanyName.ShaProjectName.Web.Core.csproj b/shesha-starter/backend/src/ShaCompanyName.ShaProjectName.Web.Core/ShaCompanyName.ShaProjectName.Web.Core.csproj index db4c326cf..976d2c878 100644 --- a/shesha-starter/backend/src/ShaCompanyName.ShaProjectName.Web.Core/ShaCompanyName.ShaProjectName.Web.Core.csproj +++ b/shesha-starter/backend/src/ShaCompanyName.ShaProjectName.Web.Core/ShaCompanyName.ShaProjectName.Web.Core.csproj @@ -39,15 +39,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/shesha-starter/backend/src/ShaCompanyName.ShaProjectName.Web.Host/ShaCompanyName.ShaProjectName.Web.Host.csproj b/shesha-starter/backend/src/ShaCompanyName.ShaProjectName.Web.Host/ShaCompanyName.ShaProjectName.Web.Host.csproj index 6955bac7d..fc597a069 100644 --- a/shesha-starter/backend/src/ShaCompanyName.ShaProjectName.Web.Host/ShaCompanyName.ShaProjectName.Web.Host.csproj +++ b/shesha-starter/backend/src/ShaCompanyName.ShaProjectName.Web.Host/ShaCompanyName.ShaProjectName.Web.Host.csproj @@ -73,7 +73,7 @@ - + diff --git a/shesha-starter/backend/test/ShaCompanyName.ShaProjectName.Common.Domain.Tests/ShaCompanyName.ShaProjectName.Common.Domain.Tests.csproj b/shesha-starter/backend/test/ShaCompanyName.ShaProjectName.Common.Domain.Tests/ShaCompanyName.ShaProjectName.Common.Domain.Tests.csproj index 1b646c803..d011093c6 100644 --- a/shesha-starter/backend/test/ShaCompanyName.ShaProjectName.Common.Domain.Tests/ShaCompanyName.ShaProjectName.Common.Domain.Tests.csproj +++ b/shesha-starter/backend/test/ShaCompanyName.ShaProjectName.Common.Domain.Tests/ShaCompanyName.ShaProjectName.Common.Domain.Tests.csproj @@ -12,9 +12,9 @@ - - - + + +