Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed hygen templates #126

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading