Toggle read-only state of screen

I have the following requirements:

  • when a user enters a specific screen, it should be read-only
  • when the user presses a button (“I do want to edit”), the screen becomes writable
  • (preferably, the button would then change to “finish editing” and on click set the screen read-only again)

How would I go about implementing this?

I already explored modeling options, such as

  • using a second screen or a second control grid for editing > becomes a maintenance mess
  • using dependent fields/groups > conflicts with the business rules I already implemented using these mechanisms

As I have not found viable modeling options, I am now looking for coding options to achieve this.

I do know that I can set the whole form engine read-only, but that’s not what I want (I have other screens that should always be writable).

I am grateful for any hints. Thanks.

Hi Alexander,

to make a specific screen read-only I would suggest checking the name of the specific screen that supposes to be a read-only and then customizing the Screen within the Form Model Map by adding new props with a read-only UIState.

const CustomScreenModel = (props:FormModelMap.FormModelComponentProps<FormModel.Screen>): JSX.Element=>{

	const newProps: FormModelMap.FormModelComponentProps<FormModel.Screen>= {
		...props,
		config: {
			...props.config,
			renderOptions: {
				...props.config.renderOptions,
				state: {
					...props.config.renderOptions.state,
					ui: {
						...props.config.renderOptions.state.ui,
						readonly: true
					}
				}
			}
		}

if (props.modelElement.name === "ReadOnlyScreen" ) {
        return (
                <DefaultFormModelMap.Screen.component {...newProps} />  
               )     
}

return <DefaultFormModelMap.Screen.component {...props} />  

}


That will return a read-only screen (for a specific screen name).

maybe a bit a matter of taste, but I would do a customizing based on the
“unconnected” renderer: GetA12 Login

here, you can get the default props and then adjust them conditionally based on the current screen:

https://docs.geta12.com/docs/static/api-docs/79db225a13c286753b9f049a36731c26bf6452b4/modules/view.html#defaultmapstatetoprops-1

https://docs.geta12.com/docs/static/api-docs/79db225a13c286753b9f049a36731c26bf6452b4/modules/view.html#defaultmapdispatchtoprops-1

https://docs.geta12.com/docs/static/api-docs/79db225a13c286753b9f049a36731c26bf6452b4/interfaces/back_end_store.enginestore-1.uistate.html#screenlocation