Skip to content

Commit

Permalink
typing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mashm committed Sep 26, 2024
1 parent 84e5a6f commit 892b69b
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/bridge/BridgeBase/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export class BridgeBase extends LitElement {
@property({ attribute: false, type: String }) validateMessage;
@property({ attribute: false, type: Object }) theComponentStyleTemplate: any = nothing; // Any styling lit-html template that should be added to renderTemplates

@property({ attribute: false, type: Object }) thePConn; // Normalize incoming pConn to a PConnect object
// @ts-ignore
@property({ attribute: false }) thePConn: typeof PConnect; // Normalize incoming pConn to a PConnect object
@property({ attribute: false, type: Object }) children;
@property({ attribute: false, type: Object }) renderTemplates; // Array of lit-html templates to be rendered

Expand Down Expand Up @@ -187,6 +188,7 @@ export class BridgeBase extends LitElement {
} else {
// NOT a PConn -
console.error(`--> ${this.theComponentName} is NOT a PConnect object! Expected for Boilerplate example`);
// @ts-ignore
this.thePConn = null;
}

Expand Down
4 changes: 4 additions & 0 deletions src/components/Attachment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ class Attachment extends BridgeBase {
fileTemp = this.buildFilePropsFromResponse(value.pxResults[0]);

if (fileTemp.responseProps) {
// @ts-ignore - Property 'attachmentsInfo' does not exist on type 'C11nEnv'
if (!this.thePConn.attachmentsInfo) {
// @ts-ignore - Property 'attachmentsInfo' does not exist on type 'C11nEnv'
this.thePConn.attachmentsInfo = {
type: 'File',
attachmentFieldName: this.att_valueRef,
Expand Down Expand Up @@ -363,6 +365,7 @@ class Attachment extends BridgeBase {
const fileIndex = this.arFileList.findIndex(element => element?.id === item?.id);
if (PCore.getPCoreVersion()?.includes('8.7')) {
if (this.value && this.value.pxResults[0]) {
// @ts-ignore - Property 'attachmentsInfo' does not exist on type 'C11nEnv'
this.thePConn.attachmentsInfo = {
type: 'File',
attachmentFieldName: this.att_valueRef,
Expand Down Expand Up @@ -435,6 +438,7 @@ class Attachment extends BridgeBase {
category: this.att_categoryName,
ID: fileRes.ID
};
// @ts-ignore - Property 'attachmentsInfo' does not exist on type 'C11nEnv'
this.thePConn.attachmentsInfo = reqObj;
} else {
reqObj = {
Expand Down
3 changes: 3 additions & 0 deletions src/components/DeferLoad/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class DeferLoad extends BridgeBase {
.getActionsApi()
.showData(this.name, dataContext, dataContextParameters, {
skipSemanticUrl: true,
// @ts-ignore
isDeferLoaded: true
})
.then(data => {
Expand All @@ -138,13 +139,15 @@ class DeferLoad extends BridgeBase {
// Rendering defer loaded tabs in case/ page context
this.thePConn
.getActionsApi()
// @ts-ignore
.loadView(encodeURI(this.loadViewCaseID), this.name, this.getViewOptions())
.then(data => {
this.onResponse(data);
});
} else {
this.thePConn
.getActionsApi()
// @ts-ignore argument null is not assignable to type string
.refreshCaseView(encodeURI(this.loadViewCaseID), this.name, null)
.then(data => {
this.onResponse(data.root);
Expand Down
2 changes: 1 addition & 1 deletion src/components/FlowContainer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class FlowContainer extends BridgeBase {

let loadingInfo: any;
try {
loadingInfo = this.thePConn.getLoadingStatus();
loadingInfo = this.thePConn.getLoadingStatus(''); // 1st arg empty string until typedefs properly allow optional;
} catch (ex) {
console.error(`${this.theComponentName}: loadingInfo catch block`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ModalViewContainer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ModalViewContainer extends BridgeBase {
// routingInfo was added as component prop in populateAdditionalProps
const routingInfo = this.getComponentProp('routingInfo');

const loadingInfo = this.thePConn.getLoadingStatus();
const loadingInfo = this.thePConn.getLoadingStatus(''); // 1st arg empty string until typedefs properly allow optional;
// const configProps = this.thePConn.resolveConfigProps(this.thePConn.getConfigProps());

if (!loadingInfo) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/View/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class View extends BridgeBase {
}
this.title = 'title' in configProps ? configProps.title : '';

const inheritedProps$ = this.thePConn.getInheritedProps();
const inheritedProps$: any = this.thePConn.getInheritedProps(); // try to remove any when getInheritedProps typedefs are fixed

// We need to bind this component's additionalProps (defined on BridgeBase)
// to this implementation's computeAdditionalProps
Expand Down
6 changes: 5 additions & 1 deletion src/components/ViewContainer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ class ViewContainer extends BridgeBase {
*/
prepareDispatchObject(): Object {
const baseContext = this.thePConn.getContextName();
const { acName = 'primary' } = this.thePConn.getContainerName();

let acName = this.thePConn.getContainerName();
if (!acName) {
acName = 'primary';
}

return {
semanticURL: '',
Expand Down
4 changes: 3 additions & 1 deletion src/components/templates/CaseView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class CaseView extends BridgeBase {
localeCategory = 'CaseView';
localeKey = '';
bHasNewAttachments = false;
editAction: editActionType | undefined;

// @ts-ignore
editAction: editActionType;

constructor() {
// Note: BridgeBase constructor has 2 optional args:
Expand Down
2 changes: 2 additions & 0 deletions src/components/templates/DataReference/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,12 @@ class DataReference extends BridgeBase {

const refreshOptions = { autoDetectRefresh: true };
if (this.canBeChangedInReviewMode && this.thePConn.getValue('__currentPageTabViewName')) {
// @ts-ignore - second parameter pageReference for getValue method should be optional
this.thePConn.getActionsApi().refreshCaseView(caseKey, this.thePConn.getValue('__currentPageTabViewName'), null, refreshOptions);
PCore.getDeferLoadManager().refreshActiveComponents(this.thePConn.getContextName());
} else {
const pgRef = this.thePConn.getPageReference().replace('caseInfo.content', '');
// @ts-ignore
this.thePConn.getActionsApi().refreshCaseView(caseKey, this.viewName, pgRef, refreshOptions);
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/templates/ListView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ class ListView extends BridgeBase {
const theConfigProps = this.thePConn?.getConfigProps();
if (theConfigProps) {
this.selectionMode = theConfigProps.selectionMode;
const componentConfig = this.thePConn.getRawMetadata().config;
// @ts-ignore
const componentConfig: any = this.thePConn.getRawMetadata().config; // try to remove any when getInheritedProps typedefs are fixed;
const refList = theConfigProps.referenceList;
const workListData = PCore.getDataApiUtils().getData(refList, this.payload);
workListData.then((workListJSON: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/templates/SimpleTable/SimpleTableManual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class SimpleTableManual extends BridgeBase {
// but getRawMetadata() has each child.config with datasource and value showing their unresolved values (ex: "@P thePropName")
// We need to use the prop name as the "glue" to tie the Angular Material table dataSource, displayColumns and data together.
// So, in the code below, we'll use the unresolved config.value (but replacing the space with an underscore to keep things happy)
const rawMetadata = this.thePConn.getRawMetadata();
const rawMetadata: any = this.thePConn.getRawMetadata(); // try to remove any when getInheritedProps typedefs are fixed;;

// Adapted from Nebula
const {
Expand Down
3 changes: 2 additions & 1 deletion src/components/templates/SimpleTableSelect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class SimpleTableSelect extends BridgeBase {
const pageReference = this.thePConn.getPageReference();
let referenceProp = isMultiSelectMode ? selectionList.substring(1) : pageReference.substring(pageReference.lastIndexOf('.') + 1);
// Replace here to use the context name instead
let contextPageReference = null;
let contextPageReference;
if (this.dataRelationshipContext !== null && selectionMode === 'single') {
referenceProp = this.dataRelationshipContext;
contextPageReference = pageReference.concat('.').concat(referenceProp);
Expand Down Expand Up @@ -183,6 +183,7 @@ class SimpleTableSelect extends BridgeBase {
parameters: this.parameters
};

// @ts-ignore
const filters = this.thePConn.getRawMetadata().config.promotedFilters ?? [];

const isSearchable = filters.length > 0;
Expand Down

0 comments on commit 892b69b

Please sign in to comment.