Skip to content

Commit

Permalink
Merge pull request #126 from irontec/CDT-188-update-hygen-templates
Browse files Browse the repository at this point in the history
Fixed hygen templates
  • Loading branch information
mmadariaga authored Aug 8, 2024
2 parents bcb2fe5 + 9b1b595 commit 4f6c0ac
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
5 changes: 5 additions & 0 deletions demo/bin/generate-cy-subscreen-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# Example bin/generate-cy-subscreen-test platform client
node_modules/hygen/dist/bin.js cy subscreen $2 --parent $1 --root demo
node_modules/hygen/dist/bin.js cy fixtures $2 --root demo
5 changes: 5 additions & 0 deletions demo/bin/generate-cy-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# Example bin/generate-cy-test administrator
node_modules/hygen/dist/bin.js cy new $1 --root demo
node_modules/hygen/dist/bin.js cy fixtures $1 --root demo
4 changes: 4 additions & 0 deletions demo/bin/generate-entity
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# Example bin/generate-entity Administrator
node_modules/hygen/dist/bin.js entity new $1
11 changes: 7 additions & 4 deletions library/hygen/templates/entity/new/Entity.ejs.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import EntityInterface from '@irontec-voip/ivoz-ui/entities/EntityInterface';
import _ from '@irontec-voip/ivoz-ui/services/translations/translate';
import defaultEntityBehavior from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
import { EntityValue } from '@irontec-voip/ivoz-ui';
import selectOptions from './SelectOptions';
import { <%= Name %>Properties, <%= Name %>PropertyList } from './<%= Name %>Properties';

const properties: <%= Name %>Properties = {
Expand All @@ -19,9 +18,13 @@ const <%= Name %>: EntityInterface = {
iden: '<%= Name %>',
title: _('<%= Name %>', { count: 2 }),
path: '/<%= h.inflection.pluralize(name) %>',
toStr: (row: <%= Name %>PropertyList<EntityValue>) => row.id.toStr(),
toStr: (row: <%= Name %>PropertyList<EntityValue>) => String(row.id),
properties,
selectOptions,
selectOptions: async () => {
const module = await import('./SelectOptions');

return module.default;
},
foreignKeyResolver: async () => {
const module = await import('./ForeignKeyResolver');

Expand All @@ -30,7 +33,7 @@ const <%= Name %>: EntityInterface = {
foreignKeyGetter: async () => {
const module = await import('./ForeignKeyGetter');

return module.default;
return module.foreignKeyGetter;
},
Form: async () => {
const module = await import('./Form');
Expand Down
14 changes: 2 additions & 12 deletions library/hygen/templates/entity/new/Form.ejs.t
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
---
to: src/entities/<%= Name %>/Form.tsx
---
import useFkChoices from '@irontec-voip/ivoz-ui/entities/data/useFkChoices';
import defaultEntityBehavior, { EntityFormProps, FieldsetGroups } from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
import { EntityFormProps, FieldsetGroups } from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
import _ from '@irontec-voip/ivoz-ui/services/translations/translate';
import { Form as DefaultEntityForm } from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior/Form';
import { foreignKeyGetter } from './ForeignKeyGetter';

const Form = (props: EntityFormProps): JSX.Element => {

const { entityService, row, match } = props;
const fkChoices = useFkChoices({
foreignKeyGetter,
entityService,
row,
match,
});

const groups: Array<FieldsetGroups | false> = [
{
legend: _('Main'),
Expand All @@ -27,7 +17,7 @@ const Form = (props: EntityFormProps): JSX.Element => {
];

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

Expand Down
2 changes: 1 addition & 1 deletion library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@irontec/ivoz-ui",
"version": "1.4.0",
"version": "1.4.1",
"description": "UI library used in ivozprovider",
"license": "GPL-3.0",
"main": "index.js",
Expand Down

0 comments on commit 4f6c0ac

Please sign in to comment.