Skip to content

Commit 09f1dcc

Browse files
mohas22mohas22
authored andcommitted
fixing few issues in 25
1 parent d6b7a5e commit 09f1dcc

File tree

8 files changed

+106
-100
lines changed

8 files changed

+106
-100
lines changed

packages/angular-sdk-components/src/lib/_components/field/check-box/check-box.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface CheckboxProps extends Omit<PConnFieldProps, 'value'> {
2727
readonlyContextList: any;
2828
referenceList: string;
2929
variant?: string;
30+
renderMode: string;
3031
}
3132

3233
@Component({
@@ -92,7 +93,7 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
9293
// this.updateSelf();
9394
this.checkAndUpdate();
9495

95-
if (this.selectionMode === 'multi' && this.referenceList?.length > 0) {
96+
if (this.selectionMode === 'multi' && this.referenceList?.length > 0 && !this.bReadonly$) {
9697
this.pConn$.setReferenceList(this.selectionList);
9798
updateNewInstructions(this.pConn$, this.selectionList);
9899
}
@@ -157,6 +158,7 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
157158
this.selectionList = this.configProps$.selectionList;
158159
this.selectedvalues = this.configProps$.readonlyContextList;
159160
this.primaryField = this.configProps$.primaryField;
161+
this.bReadonly$ = this.configProps$.renderMode === 'ReadOnly' || this.displayMode$ === 'DISPLAY_ONLY' || this.configProps$.readOnly;
160162

161163
this.datasource = this.configProps$.datasource;
162164
this.selectionKey = this.configProps$.selectionKey;

packages/angular-sdk-components/src/lib/_components/field/phone/phone.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
<ng-template #noDisplayMode>
55
<div *ngIf="bHasForm$; else noEdit">
66
<div #f="ngForm" [formGroup]="formGroup$" *ngIf="bVisible$">
7-
<mat-form-field class="psdk-full-width" subscriptSizing="dynamic" [hintLabel]="helperText">
7+
<mat-form-field class="psdk-full-width" subscriptSizing="dynamic" [hintLabel]="helperText" floatLabel="always">
88
<mat-tel-input
99
[attr.data-test-id]="testId"
1010
[formControl]="fieldControl"
1111
[preferredCountries]="preferredCountries"
1212
[enablePlaceholder]="true"
1313
[enableSearch]="true"
14+
[placeholder]="placeholder"
1415
[required]="bRequired$"
1516
[disabled]="bDisabled$ || bReadonly$"
1617
(change)="fieldOnChange()"

packages/angular-sdk-components/src/lib/_components/field/phone/phone.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class PhoneComponent implements OnInit, OnDestroy {
4040
bHasForm$ = true;
4141
testId: string;
4242
helperText: string;
43+
placeholder: string;
4344

4445
fieldControl = new FormControl('', null);
4546

@@ -115,7 +116,7 @@ export class PhoneComponent implements OnInit, OnDestroy {
115116
this.updatePreferredCountries();
116117
}
117118
this.helperText = this.configProps$.helperText;
118-
119+
this.placeholder = this.configProps$.placeholder || '';
119120
this.actionsApi = this.pConn$.getActionsApi();
120121
this.propName = this.pConn$.getStateProps().value;
121122

packages/angular-sdk-components/src/lib/_components/field/selectable-card/selectable-card.component.ts

Lines changed: 7 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PConnFieldProps } from '../../../_types/PConnProps.interface';
77
import { CommonModule } from '@angular/common';
88
import { deleteInstruction, insertInstruction } from '../../../_helpers/instructions-utils';
99
import { handleEvent } from '../../../_helpers/event-util';
10+
import { Utils } from '../../../_helpers/utils';
1011

1112
interface SelectableCardProps extends PConnFieldProps {
1213
selectionList: any;
@@ -63,7 +64,10 @@ export class SelectableCardComponent implements OnInit, OnDestroy {
6364
actionsApi: Object;
6465
propName: string;
6566

66-
constructor(private angularPConnect: AngularPConnectService) {}
67+
constructor(
68+
private angularPConnect: AngularPConnectService,
69+
private utils: Utils
70+
) {}
6771

6872
ngOnInit(): void {
6973
// First thing in initialization is registering and subscribing to the AngularPConnect service
@@ -184,7 +188,7 @@ export class SelectableCardComponent implements OnInit, OnDestroy {
184188
const cardDataSource = this.readOnly || this.displayMode$ == 'DISPLAY_ONLY' ? this.selectedvalues || [] : this.commonProps?.datasource?.source;
185189

186190
this.contentList = cardDataSource.map(item => {
187-
const resolvedFields = this.resolveReferenceFields(item, this.commonProps.hideFieldLabels, this.commonProps.recordKey, this.pConn$);
191+
const resolvedFields = this.utils.resolveReferenceFields(item, this.commonProps.hideFieldLabels, this.commonProps.recordKey, this.pConn$);
188192
const commonCardProps = {
189193
id: item[this.commonProps.recordKey],
190194
key: item[this.commonProps.recordKey],
@@ -205,7 +209,7 @@ export class SelectableCardComponent implements OnInit, OnDestroy {
205209
maxHeight: '100%',
206210
objectFit: 'contain',
207211
maxWidth: '100%',
208-
height: this.readOnly ? '5rem' : ''
212+
height: this.readOnly && imagePosition !== 'block-start' ? '5rem' : ''
209213
}
210214
}
211215
: undefined;
@@ -248,74 +252,4 @@ export class SelectableCardComponent implements OnInit, OnDestroy {
248252
this.handleChangeMultiMode(event, element);
249253
}
250254
}
251-
252-
prepareComponentInCaseSummary(pConnectMeta, getPConnect) {
253-
const { config, children } = pConnectMeta;
254-
const pConnect = getPConnect();
255-
256-
const caseSummaryComponentObject: any = {};
257-
258-
caseSummaryComponentObject.name = pConnect.resolveConfigProps({ label: config.label }).label;
259-
260-
const { type } = pConnectMeta;
261-
const createdComponent = pConnect.createComponent({
262-
type,
263-
children: children ? [...children] : [],
264-
config: {
265-
...config
266-
}
267-
});
268-
269-
caseSummaryComponentObject.value = createdComponent;
270-
return caseSummaryComponentObject;
271-
}
272-
273-
resolveReferenceFields(
274-
item: {
275-
[key: string]: unknown;
276-
},
277-
hideFieldLabels: boolean,
278-
recordKey: string,
279-
pConnect: typeof PConnect
280-
) {
281-
const presets: {
282-
children?: {
283-
children?: {
284-
config;
285-
type;
286-
};
287-
config?;
288-
};
289-
} = (pConnect.getRawMetadata()?.config as any).presets ?? [];
290-
291-
const presetChildren = presets[0]?.children?.[0]?.children ?? [];
292-
293-
const maxFields = 5;
294-
return presetChildren.slice(0, maxFields).map((preset, index) => {
295-
const fieldMeta = {
296-
meta: {
297-
...preset,
298-
config: {
299-
...preset.config,
300-
displayMode: 'DISPLAY_ONLY'
301-
}
302-
},
303-
useCustomContext: item
304-
};
305-
const configObj = PCore.createPConnect(fieldMeta);
306-
const meta = configObj.getPConnect().getMetadata();
307-
const fieldInfo: {
308-
name?: string;
309-
value?: any;
310-
} = meta ? this.prepareComponentInCaseSummary(meta, configObj.getPConnect) : {};
311-
return hideFieldLabels
312-
? { id: `${item[recordKey]} - ${index}`, value: fieldInfo.value }
313-
: {
314-
id: `${item[recordKey]} - ${index}`,
315-
name: fieldInfo.name,
316-
value: fieldInfo.value,
317-
type: preset.type
318-
};
319-
});
320-
}
321255
}

packages/angular-sdk-components/src/lib/_components/template/case-summary/case-summary.component.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { FormGroup } from '@angular/forms';
33
import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/angular-pconnect';
44
import { ReferenceComponent } from '../../infra/reference/reference.component';
55
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
6+
import { Utils } from '../../../_helpers/utils';
67

78
interface CaseSummaryProps {
89
// If any, enter additional props that only exist on this component
@@ -32,7 +33,10 @@ export class CaseSummaryComponent implements OnInit, OnDestroy, OnChanges {
3233
primaryFields$: any[] = [];
3334
secondaryFields$: any[] = [];
3435

35-
constructor(private angularPConnect: AngularPConnectService) {}
36+
constructor(
37+
private angularPConnect: AngularPConnectService,
38+
private utils: Utils
39+
) {}
3640

3741
ngOnInit(): void {
3842
// First thing in initialization is registering and subscribing to the AngularPConnect service
@@ -100,30 +104,30 @@ export class CaseSummaryComponent implements OnInit, OnDestroy, OnChanges {
100104
});
101105
}
102106

103-
prepareComponentInCaseSummary(pConnectMeta, getPConnect) {
104-
const { config, children } = pConnectMeta;
105-
const pConnect = getPConnect();
107+
// prepareComponentInCaseSummary(pConnectMeta, getPConnect) {
108+
// const { config, children } = pConnectMeta;
109+
// const pConnect = getPConnect();
106110

107-
const caseSummaryComponentObject: any = {};
111+
// const caseSummaryComponentObject: any = {};
108112

109-
const { type } = pConnectMeta;
110-
const createdComponent = pConnect.createComponent({
111-
type,
112-
children: children ? [...children] : [],
113-
config: {
114-
...config
115-
}
116-
});
113+
// const { type } = pConnectMeta;
114+
// const createdComponent = pConnect.createComponent({
115+
// type,
116+
// children: children ? [...children] : [],
117+
// config: {
118+
// ...config
119+
// }
120+
// });
117121

118-
caseSummaryComponentObject.value = createdComponent;
119-
return caseSummaryComponentObject;
120-
}
122+
// caseSummaryComponentObject.value = createdComponent;
123+
// return caseSummaryComponentObject;
124+
// }
121125

122126
prepareCaseSummaryData(summaryFieldChildren) {
123127
const convertChildrenToSummaryData = kid => {
124128
return kid?.map((childItem, index) => {
125129
const childMeta = childItem.getPConnect().meta;
126-
const caseSummaryComponentObject = this.prepareComponentInCaseSummary(childMeta, childItem.getPConnect);
130+
const caseSummaryComponentObject = this.utils.prepareComponentInCaseSummary(childMeta, childItem.getPConnect);
127131
caseSummaryComponentObject.id = index + 1;
128132
return caseSummaryComponentObject;
129133
});

packages/angular-sdk-components/src/lib/_components/template/list-view/list-view.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ export class ListViewComponent implements OnInit, OnDestroy {
155155
query: any = null;
156156
paging: any;
157157
fieldDefs: any;
158-
xRayApis = PCore.getDebugger().getXRayRuntime();
159-
xRayUid = this.xRayApis.startXRay();
160158
checkBoxValue: string;
161159
label?: string = '';
162160

@@ -237,7 +235,6 @@ export class ListViewComponent implements OnInit, OnDestroy {
237235
listContext: this.listContext,
238236
ref: this.ref,
239237
showDynamicFields: this.showDynamicFields,
240-
xRayUid: this.xRayUid,
241238
cosmosTableRef: this.cosmosTableRef,
242239
selectionMode: this.selectionMode
243240
}).then(response => {

packages/angular-sdk-components/src/lib/_components/template/list-view/listViewHelpers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export function init(props) {
1212
ref,
1313
showDynamicFields,
1414
isDataObject,
15-
xRayUid,
1615
cosmosTableRef
1716
} = props;
1817
let { editing, selectionMode } = props;
@@ -67,16 +66,14 @@ export function init(props) {
6766
pConn$,
6867
compositeKeys,
6968
isSearchable,
70-
isCacheable: true,
71-
xRayUid
69+
isCacheable: true
7270
}).then(async context => {
7371
return readContextResponse(context, {
7472
...props,
7573
editing,
7674
selectionCountThreshold,
7775
ref,
7876
selectionMode,
79-
xRayUid,
8077
cosmosTableRef
8178
});
8279
});

packages/angular-sdk-components/src/lib/_helpers/utils.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,4 +455,74 @@ export class Utils {
455455

456456
return currentObj[key] || key;
457457
}
458+
459+
prepareComponentInCaseSummary(pConnectMeta, getPConnect) {
460+
const { config, children } = pConnectMeta;
461+
const pConnect = getPConnect();
462+
463+
const caseSummaryComponentObject: any = {};
464+
465+
caseSummaryComponentObject.name = pConnect.resolveConfigProps({ label: config.label }).label;
466+
467+
const { type } = pConnectMeta;
468+
const createdComponent = pConnect.createComponent({
469+
type,
470+
children: children ? [...children] : [],
471+
config: {
472+
...config
473+
}
474+
});
475+
476+
caseSummaryComponentObject.value = createdComponent;
477+
return caseSummaryComponentObject;
478+
}
479+
480+
resolveReferenceFields(
481+
item: {
482+
[key: string]: unknown;
483+
},
484+
hideFieldLabels: boolean,
485+
recordKey: string,
486+
pConnect: typeof PConnect
487+
) {
488+
const presets: {
489+
children?: {
490+
children?: {
491+
config;
492+
type;
493+
};
494+
config?;
495+
};
496+
} = (pConnect.getRawMetadata()?.config as any).presets ?? [];
497+
498+
const presetChildren = presets[0]?.children?.[0]?.children ?? [];
499+
500+
const maxFields = 5;
501+
return presetChildren.slice(0, maxFields).map((preset, index) => {
502+
const fieldMeta = {
503+
meta: {
504+
...preset,
505+
config: {
506+
...preset.config,
507+
displayMode: 'DISPLAY_ONLY'
508+
}
509+
},
510+
useCustomContext: item
511+
};
512+
const configObj = PCore.createPConnect(fieldMeta);
513+
const meta = configObj.getPConnect().getMetadata();
514+
const fieldInfo: {
515+
name?: string;
516+
value?: any;
517+
} = meta ? this.prepareComponentInCaseSummary(meta, configObj.getPConnect) : {};
518+
return hideFieldLabels
519+
? { id: `${item[recordKey]} - ${index}`, value: fieldInfo.value }
520+
: {
521+
id: `${item[recordKey]} - ${index}`,
522+
name: fieldInfo.name,
523+
value: fieldInfo.value,
524+
type: preset.type
525+
};
526+
});
527+
}
458528
}

0 commit comments

Comments
 (0)