@@ -69,6 +69,9 @@ export class CliActions {
69
69
subscriptions . push (
70
70
commands . registerCommand ( Commands . upgradeAppCatalogApp , CliActions . upgradeAppCatalogApp )
71
71
) ;
72
+ subscriptions . push (
73
+ commands . registerCommand ( Commands . setFormCustomizer , CliActions . setFormCustomizer )
74
+ ) ;
72
75
}
73
76
74
77
/**
@@ -920,4 +923,90 @@ export class CliActions {
920
923
Notifications . error ( `${ fileName } .tour file not found in path ${ path . join ( wsFolder . uri . fsPath , '.tours' ) } . Cannot start Code Tour.` ) ;
921
924
}
922
925
}
926
+
927
+ /**
928
+ * Sets the form customizer for a content type on a list.
929
+ */
930
+ public static async setFormCustomizer ( ) {
931
+ const siteUrl = await window . showInputBox ( {
932
+ prompt : 'Enter the site URL' ,
933
+ ignoreFocusOut : true ,
934
+ validateInput : ( value ) => value ? undefined : 'Site URL is required'
935
+ } ) ;
936
+
937
+ if ( ! siteUrl ) {
938
+ return ;
939
+ }
940
+
941
+ const listTitle = await window . showInputBox ( {
942
+ prompt : 'Enter the list title' ,
943
+ ignoreFocusOut : true ,
944
+ validateInput : ( value ) => value ? undefined : 'List title is required'
945
+ } ) ;
946
+
947
+ if ( ! listTitle ) {
948
+ return ;
949
+ }
950
+
951
+ const contentType = await window . showInputBox ( {
952
+ prompt : 'Enter the Content Type name' ,
953
+ ignoreFocusOut : true ,
954
+ validateInput : ( value ) => value ? undefined : 'Content Type name is required'
955
+ } ) ;
956
+
957
+ if ( ! contentType ) {
958
+ return ;
959
+ }
960
+
961
+ const editFormClientSideComponentId = await window . showInputBox ( {
962
+ prompt : 'Enter the Edit form customizer (leave empty to skip)' ,
963
+ ignoreFocusOut : true
964
+ } ) ;
965
+
966
+ const newFormClientSideComponentId = await window . showInputBox ( {
967
+ prompt : 'Enter the New form customizer (leave empty to skip)' ,
968
+ ignoreFocusOut : true
969
+ } ) ;
970
+
971
+ const displayFormClientSideComponentId = await window . showInputBox ( {
972
+ prompt : 'Enter the View form customizer (leave empty to skip)' ,
973
+ ignoreFocusOut : true
974
+ } ) ;
975
+
976
+ const commandOptions : any = {
977
+ webUrl : siteUrl ,
978
+ listTitle : listTitle ,
979
+ name : contentType
980
+ } ;
981
+
982
+ if ( editFormClientSideComponentId ) {
983
+ commandOptions . EditFormClientSideComponentId = editFormClientSideComponentId ;
984
+ }
985
+
986
+ if ( newFormClientSideComponentId ) {
987
+ commandOptions . newFormCustomizer = newFormClientSideComponentId ;
988
+ }
989
+
990
+ if ( displayFormClientSideComponentId ) {
991
+ commandOptions . DisplayFormClientSideComponentId = displayFormClientSideComponentId ;
992
+ }
993
+
994
+ await window . withProgress ( {
995
+ location : ProgressLocation . Notification ,
996
+ title : 'Setting form customizer...' ,
997
+ cancellable : true
998
+ } , async ( progress : Progress < { message ?: string ; increment ?: number } > ) => {
999
+ try {
1000
+ const result = await CliExecuter . execute ( 'spo contenttype set' , 'json' , commandOptions ) ;
1001
+ if ( result . stderr ) {
1002
+ Notifications . error ( result . stderr ) ;
1003
+ } else {
1004
+ Notifications . info ( 'Form customizer set successfully.' ) ;
1005
+ }
1006
+ } catch ( e : any ) {
1007
+ const message = e ?. error ?. message ;
1008
+ Notifications . error ( message ) ;
1009
+ }
1010
+ } ) ;
1011
+ }
923
1012
}
0 commit comments