diff --git a/src/backend/decorators/property/property-decorator.ts b/src/backend/decorators/property/property-decorator.ts index 858187171..0fc174d20 100644 --- a/src/backend/decorators/property/property-decorator.ts +++ b/src/backend/decorators/property/property-decorator.ts @@ -172,7 +172,7 @@ export class PropertyDecorator { /** * Indicates if given property should be visible * - * @param {'list' | 'edit' | 'show' | 'filter'} where + * @param {'list' | 'edit' | 'new' | 'show' | 'filter'} where */ isVisible(where: PropertyPlace): boolean { if (typeof this.options.isVisible === 'object' && this.options.isVisible !== null) { diff --git a/src/backend/decorators/resource/resource-decorator.spec.ts b/src/backend/decorators/resource/resource-decorator.spec.ts index 15852fcb7..05e7ed8e8 100644 --- a/src/backend/decorators/resource/resource-decorator.spec.ts +++ b/src/backend/decorators/resource/resource-decorator.spec.ts @@ -264,6 +264,7 @@ describe('ResourceDecorator', function () { 'titleProperty', 'resourceActions', 'listProperties', + 'newProperties', 'editProperties', 'showProperties', 'filterProperties', diff --git a/src/backend/decorators/resource/resource-decorator.ts b/src/backend/decorators/resource/resource-decorator.ts index d2e6a9115..95b326f5f 100644 --- a/src/backend/decorators/resource/resource-decorator.ts +++ b/src/backend/decorators/resource/resource-decorator.ts @@ -135,7 +135,7 @@ class ResourceDecorator { * Returns list of all properties which will be visible in given place (where) * * @param {Object} options - * @param {String} options.where one of: 'list', 'show', 'edit', 'filter' + * @param {String} options.where one of: 'list', 'show', 'edit', 'new', 'filter' * @param {String} [options.max] maximum number of properties returned where there are * no overrides in the options * @@ -318,6 +318,9 @@ class ResourceDecorator { editProperties: this.getProperties({ where: 'edit', }).map((property) => property.toJSON('edit')), + newProperties: this.getProperties({ + where: 'new', + }).map((property) => property.toJSON('new')), showProperties: this.getProperties({ where: 'show', }).map((property) => property.toJSON('show')), diff --git a/src/backend/decorators/resource/resource-options.interface.ts b/src/backend/decorators/resource/resource-options.interface.ts index b66e99889..b70ee600e 100644 --- a/src/backend/decorators/resource/resource-options.interface.ts +++ b/src/backend/decorators/resource/resource-options.interface.ts @@ -66,6 +66,10 @@ export interface ResourceOptions { * List of properties which should be visible on edit view */ editProperties?: Array; + /** + * List of properties which should be visible on new view + */ + newProperties?: Array; /** * List of properties which should be visible on the filter */ diff --git a/src/backend/utils/build-feature/build-feature.ts b/src/backend/utils/build-feature/build-feature.ts index 28e705c48..e314db0d5 100644 --- a/src/backend/utils/build-feature/build-feature.ts +++ b/src/backend/utils/build-feature/build-feature.ts @@ -32,7 +32,7 @@ function mergeActionHooks( const basicOptions = ['id', 'href', 'parent', 'sort', 'navigation', 'titleProperty', 'translations'] as const const listOptions = [ - 'listProperties', 'showProperties', 'editProperties', 'filterProperties', + 'listProperties', 'showProperties', 'editProperties', 'newProperties', 'filterProperties', ] as const type BasicOption = typeof basicOptions[number] @@ -54,7 +54,7 @@ const hasMissingKeys: MissingKeys = {} as const * Merges 2 ResourceOptions together. Used by features * * - 'id', 'href', 'parent', 'sort' from `newOptions` override `oldOptions` - * - 'listProperties', 'showProperties', 'editProperties', 'filterProperties' + * - 'listProperties', 'showProperties', 'editProperties', 'newProperties', 'filterProperties' * are joined and made unique * - all 'properties' from `newOptions` override properties from `oldOptions` * - all 'actions' with their parameters from `newOptions` override `oldOptions` diff --git a/src/frontend/components/actions/new.tsx b/src/frontend/components/actions/new.tsx index 75e4ff0d8..6e0910b42 100644 --- a/src/frontend/components/actions/new.tsx +++ b/src/frontend/components/actions/new.tsx @@ -87,7 +87,7 @@ const New: FC = (props) => { record={record as RecordJSON} /> )) - : resource.editProperties.map((property) => ( + : resource.newProperties.map((property) => ( ('ResourceJSON', Object, { showProperties: [], filterProperties: [], editProperties: [], + newProperties: [], }) factory.extend('ResourceJSON', 'ResourceJSON.full', {}, { @@ -44,6 +45,7 @@ factory.extend('ResourceJSON', 'ResourceJSON.full', {}, { listProperties: properties, showProperties: properties, editProperties: properties, + newProperties: properties, filterProperties: properties, } }, diff --git a/src/frontend/interfaces/property-json/property-json.interface.ts b/src/frontend/interfaces/property-json/property-json.interface.ts index e6484ce25..635e3a0dd 100644 --- a/src/frontend/interfaces/property-json/property-json.interface.ts +++ b/src/frontend/interfaces/property-json/property-json.interface.ts @@ -1,6 +1,6 @@ import { PropertyType } from '../../../backend/adapters/property/base-property.js' -export type PropertyPlace = 'show' | 'list' | 'edit' | 'filter'; +export type PropertyPlace = 'show' | 'list' | 'edit' | 'new' | 'filter'; /** * JSON representation of a Property. @@ -108,6 +108,7 @@ export interface PropertyJSON { components?: { show?: string; edit?: string; + new?: string; filter?: string; list?: string; }; diff --git a/src/frontend/interfaces/resource-json.interface.ts b/src/frontend/interfaces/resource-json.interface.ts index a937dddd3..79abeda60 100644 --- a/src/frontend/interfaces/resource-json.interface.ts +++ b/src/frontend/interfaces/resource-json.interface.ts @@ -57,6 +57,10 @@ export interface ResourceJSON { * Properties which should be visible on the edit view */ editProperties: Array; + /** + * Properties which should be visible on the edit new + */ + newProperties: Array; /** * Properties which should be visible on the show view */