Skip to content

Commit

Permalink
Updated demo portal
Browse files Browse the repository at this point in the history
  • Loading branch information
mmadariaga committed Mar 6, 2024
1 parent 830b989 commit 8f89575
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 60 deletions.
5 changes: 5 additions & 0 deletions demo/src/entities/Client/Client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
};
Expand Down
19 changes: 2 additions & 17 deletions demo/src/entities/Client/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import useFkChoices from '@irontec/ivoz-ui/entities/data/useFkChoices';
import {
EntityFormProps,
FieldsetGroups,
Expand All @@ -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,
Expand Down Expand Up @@ -60,14 +52,7 @@ const Form = (props: EntityFormProps): JSX.Element => {
},
];

return (
<DefaultEntityForm
{...props}
formik={formik}
fkChoices={fkChoices}
groups={groups}
/>
);
return <DefaultEntityForm {...props} formik={formik} groups={groups} />;
};

export default Form;
40 changes: 40 additions & 0 deletions demo/src/entities/Client/View.tsx
Original file line number Diff line number Diff line change
@@ -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<FieldsetGroups | false> = [
{
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 <DefaultView {...props} groups={groups} />;
};

export default View;
13 changes: 1 addition & 12 deletions demo/src/entities/Platform/Form.tsx
Original file line number Diff line number Diff line change
@@ -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<FieldsetGroups | false> = [
{
legend: _('Basic info'),
Expand All @@ -28,7 +17,7 @@ const Form = (props: EntityFormProps): JSX.Element => {
},
];

return <DefaultEntityForm {...props} fkChoices={fkChoices} groups={groups} />;
return <DefaultEntityForm {...props} groups={groups} />;
};

export default Form;
19 changes: 2 additions & 17 deletions demo/src/entities/Platform/View.tsx
Original file line number Diff line number Diff line change
@@ -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<FieldsetGroups | false> = [
{
legend: _('Basic info'),
Expand All @@ -30,7 +15,7 @@ const View: ViewType = (props): JSX.Element => {
},
];

return <DefaultView {...props} fkChoices={fkChoices} groups={groups} />;
return <DefaultView {...props} groups={groups} />;
};

export default View;
9 changes: 0 additions & 9 deletions demo/src/entities/User/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PropertyList } from '@irontec/ivoz-ui';
import useFkChoices from '@irontec/ivoz-ui/entities/data/useFkChoices';
import {
EntityFormProps,
FieldsetGroups,
Expand All @@ -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 => {
Expand All @@ -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;
Expand Down Expand Up @@ -88,7 +80,6 @@ const Form = (props: EntityFormProps): JSX.Element | null => {
<DefaultEntityForm
{...props}
formik={formik}
fkChoices={fkChoices}
groups={groups}
readOnlyProperties={readOnlyProperties}
/>
Expand Down
4 changes: 2 additions & 2 deletions demo/src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ i18n
resources: {
...translations,
},
detection: {
detection: {
convertDetectedLanguage: (lng) => {
const availableLangKeys = Object.keys(translations);
const currentLangKey = lng.substring(0, 2).toLocaleLowerCase();
Expand All @@ -35,7 +35,7 @@ i18n
}

return lng;
}
},
},
});

Expand Down
6 changes: 3 additions & 3 deletions demo/src/router/EntityMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
10 changes: 10 additions & 0 deletions demo/src/router/addCustomRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ const addCustomRoutes = (routes: Array<RouteSpec>): Array<RouteSpec> => {
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: {
Expand Down

0 comments on commit 8f89575

Please sign in to comment.