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

feat(new): Add ability to set the newProperties #1721

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/backend/decorators/resource/resource-decorator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ describe('ResourceDecorator', function () {
'titleProperty',
'resourceActions',
'listProperties',
'newProperties',
'editProperties',
'showProperties',
'filterProperties',
Expand Down
3 changes: 3 additions & 0 deletions src/backend/decorators/resource/resource-decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ class ResourceDecorator {
editProperties: this.getProperties({
where: 'edit',
}).map((property) => property.toJSON('edit')),
newProperties: this.getProperties({
where: 'new',
ChristopheCVB marked this conversation as resolved.
Show resolved Hide resolved
}).map((property) => property.toJSON('new')),
showProperties: this.getProperties({
where: 'show',
}).map((property) => property.toJSON('show')),
Expand Down
4 changes: 4 additions & 0 deletions src/backend/decorators/resource/resource-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export interface ResourceOptions {
* List of properties which should be visible on edit view
*/
editProperties?: Array<string>;
/**
* List of properties which should be visible on new view
*/
newProperties?: Array<string>;
/**
* List of properties which should be visible on the filter
*/
Expand Down
4 changes: 2 additions & 2 deletions src/backend/utils/build-feature/build-feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function mergeActionHooks<T>(

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]
Expand All @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/components/actions/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const New: FC<ActionProps> = (props) => {
record={record as RecordJSON}
/>
))
: resource.editProperties.map((property) => (
: resource.newProperties.map((property) => (
ChristopheCVB marked this conversation as resolved.
Show resolved Hide resolved
<BasePropertyComponent
key={property.propertyPath}
where="edit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const resource = {
resourceActions: [],
listProperties: [booleanProperty, stringProperty],
editProperties: [booleanProperty, stringProperty],
newProperties: [booleanProperty, stringProperty],
showProperties: [booleanProperty, stringProperty],
filterProperties: [booleanProperty, stringProperty],
}
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/components/spec/resource-json.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ factory.define<ResourceJSON>('ResourceJSON', Object, {
showProperties: [],
filterProperties: [],
editProperties: [],
newProperties: [],
})

factory.extend('ResourceJSON', 'ResourceJSON.full', {}, {
Expand All @@ -44,6 +45,7 @@ factory.extend('ResourceJSON', 'ResourceJSON.full', {}, {
listProperties: properties,
showProperties: properties,
editProperties: properties,
newProperties: properties,
filterProperties: properties,
}
},
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/interfaces/resource-json.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export interface ResourceJSON {
* Properties which should be visible on the edit view
*/
editProperties: Array<BasePropertyJSON>;
/**
* Properties which should be visible on the edit new
*/
newProperties: Array<BasePropertyJSON>;
/**
* Properties which should be visible on the show view
*/
Expand Down