From 8f895750ca62171c44448801e3d75f537c5eacfb Mon Sep 17 00:00:00 2001 From: Mikel Madariaga Date: Wed, 6 Mar 2024 18:31:14 +0100 Subject: [PATCH] Updated demo portal --- demo/src/entities/Client/Client.tsx | 5 ++++ demo/src/entities/Client/Form.tsx | 19 ++------------ demo/src/entities/Client/View.tsx | 40 +++++++++++++++++++++++++++++ demo/src/entities/Platform/Form.tsx | 13 +--------- demo/src/entities/Platform/View.tsx | 19 ++------------ demo/src/entities/User/Form.tsx | 9 ------- demo/src/i18n.js | 4 +-- demo/src/router/EntityMap.ts | 6 ++--- demo/src/router/addCustomRoutes.ts | 10 ++++++++ 9 files changed, 65 insertions(+), 60 deletions(-) create mode 100644 demo/src/entities/Client/View.tsx diff --git a/demo/src/entities/Client/Client.tsx b/demo/src/entities/Client/Client.tsx index d285eabd..e3a59237 100644 --- a/demo/src/entities/Client/Client.tsx +++ b/demo/src/entities/Client/Client.tsx @@ -159,6 +159,11 @@ const client: EntityInterface = { Form: async () => { const module = await import('./Form'); + return module.default; + }, + View: async () => { + const module = await import('./View'); + return module.default; }, }; diff --git a/demo/src/entities/Client/Form.tsx b/demo/src/entities/Client/Form.tsx index 1226138a..bd67e973 100644 --- a/demo/src/entities/Client/Form.tsx +++ b/demo/src/entities/Client/Form.tsx @@ -1,4 +1,3 @@ -import useFkChoices from '@irontec/ivoz-ui/entities/data/useFkChoices'; import { EntityFormProps, FieldsetGroups, @@ -7,19 +6,12 @@ import { Form as DefaultEntityForm } from '@irontec/ivoz-ui/entities/DefaultEnti import { useFormHandler } from '@irontec/ivoz-ui/entities/DefaultEntityBehavior/Form/useFormHandler'; import _ from '@irontec/ivoz-ui/services/translations/translate'; -import { foreignKeyGetter } from './ForeignKeyGetter'; import useShowRemoteId from './hooks/useShowRemoteId'; const Form = (props: EntityFormProps): JSX.Element => { - const { entityService, row, match, create, filterBy } = props; + const { match, create, filterBy } = props; const formik = useFormHandler(props); - const fkChoices = useFkChoices({ - foreignKeyGetter, - entityService, - row, - match, - }); const showRemoteId = useShowRemoteId({ create, @@ -60,14 +52,7 @@ const Form = (props: EntityFormProps): JSX.Element => { }, ]; - return ( - - ); + return ; }; export default Form; diff --git a/demo/src/entities/Client/View.tsx b/demo/src/entities/Client/View.tsx new file mode 100644 index 00000000..9ac6fa00 --- /dev/null +++ b/demo/src/entities/Client/View.tsx @@ -0,0 +1,40 @@ +import { ViewProps } from '@irontec/ivoz-ui/entities'; +import { FieldsetGroups } from '@irontec/ivoz-ui/entities/DefaultEntityBehavior'; +import DefaultView from '@irontec/ivoz-ui/entities/DefaultEntityBehavior/View'; +import _ from '@irontec/ivoz-ui/services/translations/translate'; + +const View = (props: ViewProps): JSX.Element => { + const groups: Array = [ + { + legend: _('Basic settings'), + fields: [ + 'iden', + 'color', + { + name: 'description', + size: { + md: 12, + lg: 6, + xl: 4, + }, + }, + 'desktopLicences', + 'mobileLicences', + 'language', + 'cardDav', + ], + }, + { + legend: _('SIP settings'), + fields: ['domain', 'transport', 'proxyHost', 'proxyPort'], + }, + { + legend: _('Advanced settings'), + fields: ['sdes', 'authType', 'ldapServer', 'ldapQuery'], + }, + ]; + + return ; +}; + +export default View; diff --git a/demo/src/entities/Platform/Form.tsx b/demo/src/entities/Platform/Form.tsx index 1c5138b8..8ee2bdae 100644 --- a/demo/src/entities/Platform/Form.tsx +++ b/demo/src/entities/Platform/Form.tsx @@ -1,22 +1,11 @@ -import useFkChoices from '@irontec/ivoz-ui/entities/data/useFkChoices'; import { EntityFormProps, FieldsetGroups, - foreignKeyGetter, } from '@irontec/ivoz-ui/entities/DefaultEntityBehavior'; import { Form as DefaultEntityForm } from '@irontec/ivoz-ui/entities/DefaultEntityBehavior/Form'; import _ from '@irontec/ivoz-ui/services/translations/translate'; const Form = (props: EntityFormProps): JSX.Element => { - const { entityService, row, match } = props; - - const fkChoices = useFkChoices({ - foreignKeyGetter, - entityService, - row, - match, - }); - const groups: Array = [ { legend: _('Basic info'), @@ -28,7 +17,7 @@ const Form = (props: EntityFormProps): JSX.Element => { }, ]; - return ; + return ; }; export default Form; diff --git a/demo/src/entities/Platform/View.tsx b/demo/src/entities/Platform/View.tsx index f680484f..b8bdef47 100644 --- a/demo/src/entities/Platform/View.tsx +++ b/demo/src/entities/Platform/View.tsx @@ -1,24 +1,9 @@ import { ViewType } from '@irontec/ivoz-ui/entities'; -import useFkChoices from '@irontec/ivoz-ui/entities/data/useFkChoices'; -import { - FieldsetGroups, - foreignKeyGetter, -} from '@irontec/ivoz-ui/entities/DefaultEntityBehavior'; +import { FieldsetGroups } from '@irontec/ivoz-ui/entities/DefaultEntityBehavior'; import DefaultView from '@irontec/ivoz-ui/entities/DefaultEntityBehavior/View'; -import useCurrentPathMatch from '@irontec/ivoz-ui/hooks/useCurrentPathMatch'; import _ from '@irontec/ivoz-ui/services/translations/translate'; const View: ViewType = (props): JSX.Element => { - const { entityService, row } = props; - - const match = useCurrentPathMatch(); - const fkChoices = useFkChoices({ - foreignKeyGetter, - entityService, - row, - match, - }); - const groups: Array = [ { legend: _('Basic info'), @@ -30,7 +15,7 @@ const View: ViewType = (props): JSX.Element => { }, ]; - return ; + return ; }; export default View; diff --git a/demo/src/entities/User/Form.tsx b/demo/src/entities/User/Form.tsx index 22d8f110..808b03de 100644 --- a/demo/src/entities/User/Form.tsx +++ b/demo/src/entities/User/Form.tsx @@ -1,5 +1,4 @@ import { PropertyList } from '@irontec/ivoz-ui'; -import useFkChoices from '@irontec/ivoz-ui/entities/data/useFkChoices'; import { EntityFormProps, FieldsetGroups, @@ -8,7 +7,6 @@ import { Form as DefaultEntityForm } from '@irontec/ivoz-ui/entities/DefaultEnti import { useFormHandler } from '@irontec/ivoz-ui/entities/DefaultEntityBehavior/Form/useFormHandler'; import _ from '@irontec/ivoz-ui/services/translations/translate'; -import { foreignKeyGetter } from './ForeignKeyGetter'; import useParents from './hook/useParents'; const Form = (props: EntityFormProps): JSX.Element | null => { @@ -18,12 +16,6 @@ const Form = (props: EntityFormProps): JSX.Element | null => { const formik = useFormHandler(props); const values = formik.values; - const fkChoices = useFkChoices({ - foreignKeyGetter, - entityService, - row, - match, - }); if (values.remoteId) { readOnlyProperties.terminal = true; @@ -88,7 +80,6 @@ const Form = (props: EntityFormProps): JSX.Element | null => { diff --git a/demo/src/i18n.js b/demo/src/i18n.js index 9a140f8b..ad544600 100644 --- a/demo/src/i18n.js +++ b/demo/src/i18n.js @@ -26,7 +26,7 @@ i18n resources: { ...translations, }, - detection: { + detection: { convertDetectedLanguage: (lng) => { const availableLangKeys = Object.keys(translations); const currentLangKey = lng.substring(0, 2).toLocaleLowerCase(); @@ -35,7 +35,7 @@ i18n } return lng; - } + }, }, }); diff --git a/demo/src/router/EntityMap.ts b/demo/src/router/EntityMap.ts index be6135b6..802e9b29 100644 --- a/demo/src/router/EntityMap.ts +++ b/demo/src/router/EntityMap.ts @@ -81,12 +81,12 @@ const getEntityMap = (): RouteMap => { { entity: { ...entities.Client, - localPath: '/client_edit_only/2', - title: 'Edit only client 2', + localPath: '/client_view_only/2', + title: 'Read only client 2', acl: { create: false, update: false, - detail: false, + detail: true, read: false, delete: false, }, diff --git a/demo/src/router/addCustomRoutes.ts b/demo/src/router/addCustomRoutes.ts index 677b9c83..03584e41 100644 --- a/demo/src/router/addCustomRoutes.ts +++ b/demo/src/router/addCustomRoutes.ts @@ -45,6 +45,16 @@ const addCustomRoutes = (routes: Array): Array => { path: '/client_edit_only/:id', }); + routes.push({ + component: Detail, + entity: { + ...Client, + localPath: '/client_view_only', + }, + key: 'ReadOnlyClient-view', + path: '/client_view_only/:id', + }); + routes.push({ component: Create, entity: {