Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,23 @@ export async function getSdkComponentMap(inLocalComponentMap = {}) {
let idNextCheck;
if (!SdkComponentMap && !SdkComponentMapCreateInProgress) {
SdkComponentMapCreateInProgress = true;
createSdkComponentMap(inLocalComponentMap).then(theComponentMap => {
// debugger;
// Key initialization of SdkComponentMap
SdkComponentMap = theComponentMap;
SdkComponentMapCreateInProgress = false;

console.log(`getSdkComponentMap: created SdkComponentMap singleton`);
// Create and dispatch the SdkConfigAccessReady event
// Not used anyplace yet but putting it in place in case we need it.
const event = new CustomEvent('SdkComponentMapReady', {});
document.dispatchEvent(event);
return resolve(SdkComponentMap /* .sdkComponentMap */);
});
createSdkComponentMap(inLocalComponentMap)
.then(theComponentMap => {
// debugger;
// Key initialization of SdkComponentMap
SdkComponentMap = theComponentMap;
SdkComponentMapCreateInProgress = false;

console.log(`getSdkComponentMap: created SdkComponentMap singleton`);
// Create and dispatch the SdkConfigAccessReady event
// Not used anyplace yet but putting it in place in case we need it.
const event = new CustomEvent('SdkComponentMapReady', {});
document.dispatchEvent(event);
return resolve(SdkComponentMap /* .sdkComponentMap */);
})
.catch(e => {
console.error(e);
});
} else {
const fnCheckForConfig = () => {
if (SdkComponentMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,80 +80,84 @@ export default function Operator(props: OperatorProps) {
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
const localeCategory = 'Operator';

operatorPreviewPromise.then((res: any) => {
const fillerString = '---';
let fields: any = [];
if (res.data && res.data.pyOperatorInfo && res.data.pyOperatorInfo.pyUserName) {
fields = [
{
id: 'pyPosition',
name: localizedVal('Position', localeCategory),
value: res.data.pyOperatorInfo.pyPosition ? res.data.pyOperatorInfo.pyPosition : fillerString
},
{
id: 'pyOrganization',
name: localizedVal('Organization', localeCategory),
value: res.data.pyOperatorInfo.pyOrganization ? res.data.pyOperatorInfo.pyOrganization : fillerString
},
{
id: 'ReportToUserName',
name: localizedVal('Reports to', localeCategory),
value: res.data.pyOperatorInfo.pyReportToUserName ? res.data.pyOperatorInfo.pyReportToUserName : fillerString
},
{
id: 'pyTelephone',
name: localizedVal('Telephone', localeCategory),
value: res.data.pyOperatorInfo.pyTelephone ? (
<a href={`tel:${res.data.pyOperatorInfo.pyTelephone}`}>{res.data.pyOperatorInfo.pyTelephone}</a>
) : (
fillerString
)
},
{
id: 'pyEmailAddress',
name: localizedVal('Email address', localeCategory),
value: res.data.pyOperatorInfo.pyEmailAddress ? (
<a href={`mailto:${res.data.pyOperatorInfo.pyEmailAddress}`}>{res.data.pyOperatorInfo.pyEmailAddress}</a>
) : (
fillerString
)
}
];
} else {
console.log(
`Operator: PCore.getUserApi().getOperatorDetails(${caseOpId}); returned empty res.data.pyOperatorInfo.pyUserName - adding default`
);
fields = [
{
id: 'pyPosition',
name: localizedVal('Position', localeCategory),
value: fillerString
},
{
id: 'pyOrganization',
name: localizedVal('Organization', localeCategory),
value: fillerString
},
{
id: 'ReportToUserName',
name: localizedVal('Reports to', localeCategory),
value: fillerString
},
{
id: 'pyTelephone',
name: localizedVal('Telephone', localeCategory),
value: fillerString
},
{
id: 'pyEmailAddress',
name: localizedVal('Email address', localeCategory),
value: fillerString
}
];
}
// Whatever the fields are, update the component's popoverFields
setPopoverFields(fields);
});
operatorPreviewPromise
.then((res: any) => {
const fillerString = '---';
let fields: any = [];
if (res.data && res.data.pyOperatorInfo && res.data.pyOperatorInfo.pyUserName) {
fields = [
{
id: 'pyPosition',
name: localizedVal('Position', localeCategory),
value: res.data.pyOperatorInfo.pyPosition ? res.data.pyOperatorInfo.pyPosition : fillerString
},
{
id: 'pyOrganization',
name: localizedVal('Organization', localeCategory),
value: res.data.pyOperatorInfo.pyOrganization ? res.data.pyOperatorInfo.pyOrganization : fillerString
},
{
id: 'ReportToUserName',
name: localizedVal('Reports to', localeCategory),
value: res.data.pyOperatorInfo.pyReportToUserName ? res.data.pyOperatorInfo.pyReportToUserName : fillerString
},
{
id: 'pyTelephone',
name: localizedVal('Telephone', localeCategory),
value: res.data.pyOperatorInfo.pyTelephone ? (
<a href={`tel:${res.data.pyOperatorInfo.pyTelephone}`}>{res.data.pyOperatorInfo.pyTelephone}</a>
) : (
fillerString
)
},
{
id: 'pyEmailAddress',
name: localizedVal('Email address', localeCategory),
value: res.data.pyOperatorInfo.pyEmailAddress ? (
<a href={`mailto:${res.data.pyOperatorInfo.pyEmailAddress}`}>{res.data.pyOperatorInfo.pyEmailAddress}</a>
) : (
fillerString
)
}
];
} else {
console.log(
`Operator: PCore.getUserApi().getOperatorDetails(${caseOpId}); returned empty res.data.pyOperatorInfo.pyUserName - adding default`
);
fields = [
{
id: 'pyPosition',
name: localizedVal('Position', localeCategory),
value: fillerString
},
{
id: 'pyOrganization',
name: localizedVal('Organization', localeCategory),
value: fillerString
},
{
id: 'ReportToUserName',
name: localizedVal('Reports to', localeCategory),
value: fillerString
},
{
id: 'pyTelephone',
name: localizedVal('Telephone', localeCategory),
value: fillerString
},
{
id: 'pyEmailAddress',
name: localizedVal('Email address', localeCategory),
value: fillerString
}
];
}
// Whatever the fields are, update the component's popoverFields
setPopoverFields(fields);
})
.catch(e => {
console.error(e);
});

setPopoverAnchorEl(event.currentTarget);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,13 @@ export default function AutoComplete(props: AutoCompleteProps) {

useEffect(() => {
if (!displayMode && listType !== 'associated') {
getDataPage(datasource, parameters, context).then((results: any) => {
setOptions(buildOptionsFromResults(results));
});
getDataPage(datasource, parameters, context)
.then((results: any) => {
setOptions(buildOptionsFromResults(results));
})
.catch(e => {
console.error(e);
});
}
}, []);

Expand Down Expand Up @@ -309,9 +313,13 @@ export default function AutoComplete(props: AutoCompleteProps) {
const changePromise = (actionsApi as any).triggerFieldChange(propName, val);
if (onRecordChange) {
if (changePromise && changePromise.then) {
changePromise.then(() => {
onRecordChange({ ...event, id: val });
});
changePromise
.then(() => {
onRecordChange({ ...event, id: val });
})
.catch(e => {
console.error(e);
});
} else {
onRecordChange({ ...event, id: val });
}
Expand Down Expand Up @@ -359,9 +367,13 @@ export default function AutoComplete(props: AutoCompleteProps) {
// Re-fetches the options list (equivalent to initializeList in constellation-frontend)
const refreshOptionsList = () => {
if (!displayMode && listType !== 'associated') {
getDataPage(datasource, parameters, context).then((results: any) => {
setOptions(buildOptionsFromResults(results));
});
getDataPage(datasource, parameters, context)
.then((results: any) => {
setOptions(buildOptionsFromResults(results));
})
.catch(e => {
console.error(e);
});
}
};

Expand Down Expand Up @@ -409,22 +421,26 @@ export default function AutoComplete(props: AutoCompleteProps) {

if (selectKey && listType !== 'associated' && datasource) {
// Re-fetch data to find the newly created record and set all mapped properties
getDataPage(datasource, parameters, context).then((results: any) => {
setOptions(buildOptionsFromResults(results));

// Find the newly created record by ID or caseId and set all properties
const displayColumn = getDisplayFieldsMetaData(columns);
const newRecord = results?.find((el: any) => el.ID === data.ID || (el[displayColumn.key] || el.pyGUID) === selectKey);
if (newRecord) {
setValuesToAdditionalFields(newRecord);
} else {
// Fallback: just set the key value
handleEvent(actionsApi, 'changeNblur', propName, selectKey);
}
if (onRecordChange) {
onRecordChange({ id: selectKey });
}
});
getDataPage(datasource, parameters, context)
.then((results: any) => {
setOptions(buildOptionsFromResults(results));

// Find the newly created record by ID or caseId and set all properties
const displayColumn = getDisplayFieldsMetaData(columns);
const newRecord = results?.find((el: any) => el.ID === data.ID || (el[displayColumn.key] || el.pyGUID) === selectKey);
if (newRecord) {
setValuesToAdditionalFields(newRecord);
} else {
// Fallback: just set the key value
handleEvent(actionsApi, 'changeNblur', propName, selectKey);
}
if (onRecordChange) {
onRecordChange({ id: selectKey });
}
})
.catch(e => {
console.error(e);
});
}
PCore.getPubSubUtils().unsubscribe(eventType, contextClass);
}
Expand All @@ -440,11 +456,15 @@ export default function AutoComplete(props: AutoCompleteProps) {
startingFields: {}
});

Promise.resolve(triggerCreate).then(() => {
PCore.getPubSubUtils().subscribe(eventType, createNewCallback, contextClass);
// Re-initialize the list (equivalent to initializeList() in constellation-frontend)
refreshOptionsList();
});
Promise.resolve(triggerCreate)
.then(() => {
PCore.getPubSubUtils().subscribe(eventType, createNewCallback, contextClass);
// Re-initialize the list (equivalent to initializeList() in constellation-frontend)
refreshOptionsList();
})
.catch(e => {
console.error(e);
});
};

const showCreateButton = props.allowCreatingRecords === true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,27 @@ export default function Dropdown(props: DropdownProps) {

useEffect(() => {
if (listType !== 'associated' && typeof datasource === 'string') {
getDataPage(datasource, parameters, context).then((results: any) => {
const optionsData: any[] = [];
const displayColumn = getDisplayFieldsMetaData(columns);
results?.forEach(element => {
const val = element[displayColumn.primary]?.toString();
const obj = {
key: element[displayColumn.key] || element.pyGUID,
value: val
};
optionsData.push(obj);
getDataPage(datasource, parameters, context)
.then((results: any) => {
const optionsData: any[] = [];
const displayColumn = getDisplayFieldsMetaData(columns);
results?.forEach(element => {
const val = element[displayColumn.primary]?.toString();
const obj = {
key: element[displayColumn.key] || element.pyGUID,
value: val
};
optionsData.push(obj);
});
optionsData.unshift({
key: placeholder,
value: thePConn.getLocalizedValue(placeholder, '', '')
});
setOptions(optionsData);
})
.catch(e => {
console.error(e);
});
optionsData.unshift({
key: placeholder,
value: thePConn.getLocalizedValue(placeholder, '', '')
});
setOptions(optionsData);
});
}
}, [memoizedParameters]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ export default function Multiselect(props) {
if (!isGroupData) {
getCaseListBasedOnParamsDebounced.current(inputValue ?? '', '', [...selectedItems], [...itemsTree]);
}
})
.catch(e => {
console.error(e);
});
}
}, [dataConfig, listType, dataConfig.columns, inputValue, dataConfig.groupColumnsConfig, showSecondaryInSearchOnly]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,13 @@ export default function ObjectReference(props: ObjectReferenceProps) {
.then((response: any) => {
PCore.getContainerUtils().updateParentLastUpdateTime(pConn.getContextName(), (response.data as any).data.caseInfo.lastUpdateTime);
PCore.getContainerUtils().updateRelatedContextEtag(pConn.getContextName(), response.headers.etag);
})
.catch(e => {
console.error(e);
});
})
.catch(e => {
console.error(e);
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ const UserReference = (props: UserReferenceProps) => {
// if same user ref field is referred in view as editable & readonly formatted text
// referenced users won't be available, so get user details from dx api
const { getOperatorDetails } = PCore.getUserApi();
getOperatorDetails(userId).then((res: any) => {
if (res.data && res.data.pyOperatorInfo && res.data.pyOperatorInfo.pyUserName) {
setUserName(res.data.pyOperatorInfo.pyUserName);
}
});
getOperatorDetails(userId)
.then((res: any) => {
if (res.data && res.data.pyOperatorInfo && res.data.pyOperatorInfo.pyUserName) {
setUserName(res.data.pyOperatorInfo.pyUserName);
}
})
.catch(e => {
console.error(e);
});
}
} else if (displayAs === DROPDOWN_LIST) {
const queryPayload = {
Expand Down
Loading
Loading