@@ -40,38 +40,57 @@ export class QuickCreateComponent implements OnInit, OnChanges {
4040
4141 initComponent ( ) {
4242 this . configProps$ = this . pConn$ . resolveConfigProps ( this . pConn$ . getConfigProps ( ) ) as QuickCreateProps ;
43-
4443 this . heading$ = this . configProps$ . heading ;
4544 this . showCaseIcons$ = this . configProps$ . showCaseIcons ;
4645 this . classFilter$ = this . configProps$ . classFilter ;
47-
46+ const cases : any = [ ] ;
47+ const defaultCases : any = [ ] ;
4848 const envInfo = PCore . getEnvironmentInfo ( ) ;
49- if (
50- this . classFilter$ &&
51- envInfo . environmentInfoObject &&
52- envInfo . environmentInfoObject . pyCaseTypeList &&
53- envInfo . environmentInfoObject . pyCaseTypeList . length > 0
54- ) {
55- this . classFilter$ . forEach ( item => {
56- let icon = this . utils . getImageSrc ( 'polaris-solid' , this . utils . getSDKStaticContentUrl ( ) ) ;
57- let label = '' ;
58- ( envInfo . environmentInfoObject as any ) . pyCaseTypeList . forEach ( casetype => {
59- if ( casetype . pyWorkTypeImplementationClassName === item ) {
60- icon = casetype . pxIcon && this . utils . getImageSrc ( casetype ?. pxIcon , this . utils . getSDKStaticContentUrl ( ) ) ;
61- label = casetype . pyWorkTypeName ?? '' ;
62- }
63- } ) ;
64- if ( label !== '' ) {
65- this . cases$ . push ( {
66- label,
49+ if ( envInfo ?. environmentInfoObject ?. pyCaseTypeList ) {
50+ envInfo . environmentInfoObject . pyCaseTypeList . forEach ( ( casetype : any ) => {
51+ if ( casetype . pyWorkTypeName && casetype . pyWorkTypeImplementationClassName ) {
52+ defaultCases . push ( {
53+ classname : casetype . pyWorkTypeImplementationClassName ,
54+ onClick : ( ) => {
55+ this . createCase ( casetype . pyWorkTypeImplementationClassName ) ;
56+ } ,
57+ ...( this . showCaseIcons$ && { icon : this . utils . getImageSrc ( casetype ?. pxIcon , this . utils . getSDKStaticContentUrl ( ) ) } ) ,
58+ label : casetype . pyWorkTypeName
59+ } ) ;
60+ }
61+ } ) ;
62+ } else {
63+ const pConnectInAppContext = PCore . createPConnect ( {
64+ options : { context : PCore . getConstants ( ) . APP . APP }
65+ } ) . getPConnect ( ) ;
66+ const pyPortalInAppContext = pConnectInAppContext . getValue ( 'pyPortal' ) as any ;
67+ pyPortalInAppContext ?. pyCaseTypesAvailableToCreate ?. forEach ( casetype => {
68+ if ( casetype . pyClassName && casetype . pyLabel ) {
69+ defaultCases . push ( {
70+ classname : casetype . pyClassName ,
6771 onClick : ( ) => {
68- this . createCase ( item ) ;
72+ this . createCase ( casetype . pyClassName ) ;
6973 } ,
70- ...( this . showCaseIcons$ && { icon } )
74+ ...( this . showCaseIcons$ && { icon : this . utils . getImageSrc ( casetype ?. pxIcon , this . utils . getSDKStaticContentUrl ( ) ) } ) ,
75+ label : casetype . pyLabel
7176 } ) ;
7277 }
7378 } ) ;
7479 }
80+
81+ /* If classFilter is not empty - filter from the list of defaultCases */
82+ if ( this . classFilter$ ?. length > 0 ) {
83+ this . classFilter$ . forEach ( item => {
84+ defaultCases . forEach ( casetype => {
85+ if ( casetype . classname === item ) {
86+ cases . push ( casetype ) ;
87+ }
88+ } ) ;
89+ } ) ;
90+ this . cases$ = cases ;
91+ } else {
92+ this . cases$ = defaultCases ;
93+ }
7594 }
7695
7796 ngOnInit ( ) {
0 commit comments