Skip to content

Commit

Permalink
Fixed error details two column (#223)
Browse files Browse the repository at this point in the history
* Fixed error details two column

---------

Co-authored-by: mohas22 <[email protected]>
  • Loading branch information
samhere06 and mohas22 authored Nov 5, 2024
1 parent 3419eca commit bf8e432
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class DetailsFields extends LitElement {

getFieldsHtml(arFields): any {
const arFHtml: any[] = [];

for (const field of arFields) {
if (field?.type === 'reference') {
arFHtml.push(html`
Expand Down
2 changes: 1 addition & 1 deletion src/components/templates/MultiReferenceReadonly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class MultiReferenceReadonly extends BridgeBase {
getMultiReferenceHtml(): any {
const configObj = this.pConn.getReferencedView();
configObj.config.label = this.label;
this.pConn = this.pConn.getReferencedViewPConnect(true).getPConnect();
// this.pConn = this.pConn.getReferencedViewPConnect(true).getPConnect();
return html`<simple-table-manual .pConn=${this.pConn}></simple-table-manual>`;
}

Expand Down
9 changes: 6 additions & 3 deletions src/components/templates/SimpleTable/SimpleTableManual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import '../PromotedFilters';
import { Utils } from '../../../helpers/utils';
import { buildFieldsForTable } from './helpers';
import { FieldGroupUtils } from '../../../helpers/field-group-utils';
import { getDataPage } from '../../../helpers/data_page';

// import the component's styles as HTML with <style>
import { simpleTableManualStyles } from './simple-table-manual-styles';
Expand Down Expand Up @@ -255,11 +256,13 @@ class SimpleTableManual extends BridgeBase {
const context = this.thePConn.getContextName();
// if dataPageName property value exists then make a datapage fetch call and get the list of data.
if (dataPageName) {
PCore.getDataApiUtils()
.getData(dataPageName, parameters, context)
getDataPage(dataPageName, parameters, context)
.then(response => {
const data = this.formatRowsData(response.data.data);
const data = this.formatRowsData(response);
this.rowData = data;
})
.catch(e => {
console.log(e);
});
} else {
// The referenceList prop has the JSON data for each row to be displayed
Expand Down
25 changes: 2 additions & 23 deletions src/components/templates/details/Details/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../../../Region';
import { detailsStyles } from './details-styles';

import '../../../designSystemExtension/DetailsFields';
import { getDetailsFieldArray } from '../../../../helpers/details-utils';

interface DetailsProps {
// If any, enter additional props that only exist on this component
Expand Down Expand Up @@ -66,29 +67,7 @@ class Details extends DetailsTemplateBase {
this.arFields = [];
const pKid = kid.getPConnect();
const fields = pKid.getChildren();
fields?.forEach(field => {
const thePConn = field.getPConnect();
const theCompType = thePConn.getComponentName().toLowerCase();
if (theCompType === 'reference') {
const configObj = thePConn.getReferencedView();
configObj.config.readOnly = true;
configObj.config.displayMode = 'DISPLAY_ONLY';
const propToUse = { ...thePConn.getInheritedProps() };
configObj.config.label = propToUse?.label;
const loadedPConn = thePConn.getReferencedViewPConnect(true).getPConnect();
const data = {
type: theCompType,
pConn: loadedPConn
};
this.arFields.push(data);
} else {
const data = {
type: theCompType,
config: thePConn.getConfigProps()
};
this.arFields.push(data);
}
});
this.arFields = getDetailsFieldArray(fields);
}

this.requestUpdate();
Expand Down
7 changes: 4 additions & 3 deletions src/components/templates/details/DetailsTwoColumn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../../../Region';
import { detailsTwoColumnStyles } from './details-two-column-styles';

import '../../../designSystemExtension/DetailsFields';
import { getDetailsFieldArray } from '../../../../helpers/details-utils';

@customElement('details-two-column-component')
class DetailsTwoColumn extends DetailsTemplateBase {
Expand Down Expand Up @@ -56,11 +57,11 @@ class DetailsTwoColumn extends DetailsTemplateBase {

for (const kid of this.children) {
const pKid = kid.getPConnect();
const pKidData = pKid.resolveConfigProps(pKid.getRawMetadata());
const fields = pKid.getChildren();
if (this.children.indexOf(kid) == 0) {
this.arFields = pKidData.children;
this.arFields = getDetailsFieldArray(fields);
} else {
this.arFields2 = pKidData.children;
this.arFields2 = getDetailsFieldArray(fields);
}
}

Expand Down
27 changes: 27 additions & 0 deletions src/helpers/details-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export function getDetailsFieldArray(arFields) {
const fields: any[] = [];
arFields?.forEach(field => {
const thePConn = field.getPConnect();
const theCompType = thePConn.getComponentName().toLowerCase();
if (theCompType === 'reference') {
const configObj = thePConn.getReferencedView();
configObj.config.readOnly = true;
configObj.config.displayMode = 'DISPLAY_ONLY';
const propToUse = { ...thePConn.getInheritedProps() };
configObj.config.label = propToUse?.label;
const loadedPConn = thePConn.getReferencedViewPConnect(true).getPConnect();
const data = {
type: theCompType,
pConn: loadedPConn
};
fields.push(data);
} else {
const data = {
type: theCompType,
config: thePConn.getConfigProps()
};
fields.push(data);
}
});
return fields;
}

0 comments on commit bf8e432

Please sign in to comment.