From 715656fb4a884b7dcb1196830558a3620c091ef3 Mon Sep 17 00:00:00 2001 From: Mikel Madariaga Date: Thu, 8 Aug 2024 11:33:13 +0200 Subject: [PATCH 1/2] updated hygen templates --- library/hygen/templates/entity/new/Entity.ejs.t | 11 +++++++---- library/hygen/templates/entity/new/Form.ejs.t | 14 ++------------ library/package.json | 2 +- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/library/hygen/templates/entity/new/Entity.ejs.t b/library/hygen/templates/entity/new/Entity.ejs.t index 37dd75a..3ab841f 100644 --- a/library/hygen/templates/entity/new/Entity.ejs.t +++ b/library/hygen/templates/entity/new/Entity.ejs.t @@ -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 = { @@ -19,9 +18,13 @@ const <%= Name %>: EntityInterface = { iden: '<%= Name %>', title: _('<%= Name %>', { count: 2 }), path: '/<%= h.inflection.pluralize(name) %>', - toStr: (row: <%= Name %>PropertyList) => row.id.toStr(), + toStr: (row: <%= Name %>PropertyList) => String(row.id), properties, - selectOptions, + selectOptions: async () => { + const module = await import('./SelectOptions'); + + return module.default; + }, foreignKeyResolver: async () => { const module = await import('./ForeignKeyResolver'); @@ -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'); diff --git a/library/hygen/templates/entity/new/Form.ejs.t b/library/hygen/templates/entity/new/Form.ejs.t index df28f5b..2fd08f4 100644 --- a/library/hygen/templates/entity/new/Form.ejs.t +++ b/library/hygen/templates/entity/new/Form.ejs.t @@ -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 = [ { legend: _('Main'), @@ -27,7 +17,7 @@ const Form = (props: EntityFormProps): JSX.Element => { ]; return ( - + ); }; diff --git a/library/package.json b/library/package.json index a2b3716..98a0b7b 100644 --- a/library/package.json +++ b/library/package.json @@ -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", From 9b1b59543f48e58cf9e35363cfc952d5ed61bc12 Mon Sep 17 00:00:00 2001 From: Mikel Madariaga Date: Thu, 8 Aug 2024 11:33:39 +0200 Subject: [PATCH 2/2] added generator scripts into demo proyect --- demo/bin/generate-cy-subscreen-test | 5 +++++ demo/bin/generate-cy-test | 5 +++++ demo/bin/generate-entity | 4 ++++ 3 files changed, 14 insertions(+) create mode 100755 demo/bin/generate-cy-subscreen-test create mode 100755 demo/bin/generate-cy-test create mode 100755 demo/bin/generate-entity diff --git a/demo/bin/generate-cy-subscreen-test b/demo/bin/generate-cy-subscreen-test new file mode 100755 index 0000000..7f88326 --- /dev/null +++ b/demo/bin/generate-cy-subscreen-test @@ -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 \ No newline at end of file diff --git a/demo/bin/generate-cy-test b/demo/bin/generate-cy-test new file mode 100755 index 0000000..fa79e85 --- /dev/null +++ b/demo/bin/generate-cy-test @@ -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 \ No newline at end of file diff --git a/demo/bin/generate-entity b/demo/bin/generate-entity new file mode 100755 index 0000000..dfa8132 --- /dev/null +++ b/demo/bin/generate-entity @@ -0,0 +1,4 @@ +#!/bin/bash + +# Example bin/generate-entity Administrator +node_modules/hygen/dist/bin.js entity new $1 \ No newline at end of file