@@ -36,7 +36,6 @@ export class ApprovalGroupWorkspaceEditorElement extends UmbElementMixin(
3636 private _iconColorAlias ?: string ;
3737
3838 #workspaceContext?: typeof WORKFLOW_APPROVAL_GROUP_WORKSPACE_CONTEXT . TYPE ;
39- #modalContext?: UmbModalManagerContext ;
4039
4140 constructor ( ) {
4241 super ( ) ;
@@ -48,10 +47,6 @@ export class ApprovalGroupWorkspaceEditorElement extends UmbElementMixin(
4847 this . #observeGroup( ) ;
4948 }
5049 ) ;
51-
52- this . consumeContext ( UMB_MODAL_MANAGER_CONTEXT , ( instance ) => {
53- this . #modalContext = instance ;
54- } ) ;
5550 }
5651
5752 #observeGroup( ) {
@@ -68,25 +63,25 @@ export class ApprovalGroupWorkspaceEditorElement extends UmbElementMixin(
6863
6964 // TODO. find a way where we don't have to do this for all workspaces.
7065 #onNameChange( event : UUIInputEvent ) {
71- if ( event instanceof UUIInputEvent ) {
72- const target = event . composedPath ( ) [ 0 ] as UUIInputElement ;
66+ if ( event instanceof UUIInputEvent === false ) return ;
7367
74- if ( typeof target ?. value !== "string" ) return ;
68+ const target = event . composedPath ( ) [ 0 ] as UUIInputElement ;
7569
76- const oldName = this . _group ! . name ;
77- const oldAlias = this . _group ! . alias ;
78- const newName = event . target . value . toString ( ) ;
70+ if ( typeof target ?. value !== "string" ) return ;
7971
80- if ( this . _aliasLocked ) {
81- const expectedOldAlias = generateAlias ( oldName ?? "" ) ;
82- // Only update the alias if the alias matches a generated alias of the old name (otherwise the alias is considered one written by the user.)
83- if ( expectedOldAlias === oldAlias ) {
84- this . #workspaceContext?. setAlias ( generateAlias ( newName ) ) ;
85- }
86- }
72+ const oldName = this . _group ! . name ;
73+ const oldAlias = this . _group ! . alias ;
74+ const newName = event . target . value . toString ( ) ;
8775
88- this . #workspaceContext?. setName ( target . value ) ;
76+ if ( this . _aliasLocked ) {
77+ const expectedOldAlias = generateAlias ( oldName ?? "" ) ;
78+ // Only update the alias if the alias matches a generated alias of the old name (otherwise the alias is considered one written by the user.)
79+ if ( expectedOldAlias === oldAlias ) {
80+ this . #workspaceContext?. setAlias ( generateAlias ( newName ) ) ;
81+ }
8982 }
83+
84+ this . #workspaceContext?. setName ( target . value ) ;
9085 }
9186
9287 // TODO. find a way where we don't have to do this for all workspaces.
@@ -103,20 +98,19 @@ export class ApprovalGroupWorkspaceEditorElement extends UmbElementMixin(
10398 }
10499
105100 async #handleIconClick( ) {
106- if ( ! this . #modalContext) return ;
107-
108- const modalContext = this . #modalContext. open ( this , UMB_ICON_PICKER_MODAL , {
101+ const modalContext = await this . getContext ( UMB_MODAL_MANAGER_CONTEXT ) ;
102+ const modalHandler = modalContext . open ( this , UMB_ICON_PICKER_MODAL , {
109103 value : {
110104 icon : this . _group ! . icon ?? "users" ,
111105 color : this . _iconColorAlias ,
112106 } ,
113107 } ) ;
114108
115- const { icon } = await modalContext . onSubmit ( ) ;
116-
117- if ( icon ) {
118- this . #workspaceContext ?. setIcon ( icon ) ;
119- // TODO => save color
109+ const icon = await modalHandler . onSubmit ( ) . catch ( ( ) => undefined ) ;
110+ if ( icon ?. icon && icon . color ) {
111+ this . #workspaceContext ?. setIcon ( ` ${ icon . icon } color- ${ icon . color } ` ) ;
112+ } else if ( icon ?. icon ) {
113+ this . #workspaceContext ?. setIcon ( icon . icon ) ;
120114 }
121115 }
122116
@@ -125,9 +119,7 @@ export class ApprovalGroupWorkspaceEditorElement extends UmbElementMixin(
125119 }
126120
127121 render ( ) {
128- return html `<umb- wor kspace- edito r
129- alias= "Workflow.Workspace.ApprovalGroup"
130- >
122+ return html `<umb- wor kspace- edito r alias= "Workflow.Workspace.ApprovalGroup" >
131123 <div id= "header" slot = "header" >
132124 <uui- butto n
133125 id= "back-button"
0 commit comments