@messaia/cdk 20.2.2 → 20.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/messaia-cdk.mjs +32 -11
- package/fesm2022/messaia-cdk.mjs.map +1 -1
- package/index.d.ts +10 -5
- package/package.json +1 -1
package/fesm2022/messaia-cdk.mjs
CHANGED
|
@@ -20008,42 +20008,59 @@ class GenericFormBaseComponent extends BaseComponent {
|
|
|
20008
20008
|
* Loads an item by ID.
|
|
20009
20009
|
* This method fetches the item if the component is in edit mode and the service endpoint is defined.
|
|
20010
20010
|
*
|
|
20011
|
-
* @param
|
|
20012
|
-
*
|
|
20011
|
+
* @param successCallback - A function to be called after the item has been successfully loaded.
|
|
20012
|
+
* This function will receive the loaded item as an argument.
|
|
20013
|
+
* @param errorCallback - A function to be called if an error occurs during loading.
|
|
20014
|
+
* This function will receive the error as an argument.
|
|
20015
|
+
* @param headers - Optional HTTP headers to include in the request.
|
|
20013
20016
|
*/
|
|
20014
|
-
loadItem(
|
|
20017
|
+
loadItem(successCallback, errorCallback, headers) {
|
|
20015
20018
|
if (this.isEditMode && this.service?.endpoint) {
|
|
20016
20019
|
/* Set loading state to true to indicate that an item is being loaded */
|
|
20017
20020
|
this.isLoading = true;
|
|
20018
20021
|
/* Trigger change detection to update the view with the loading state */
|
|
20019
20022
|
this.changeDetectorRef.detectChanges();
|
|
20020
20023
|
/* Call the asynchronous method to load the item */
|
|
20021
|
-
this.loadItemAsync().subscribe({
|
|
20024
|
+
this.loadItemAsync(headers).subscribe({
|
|
20022
20025
|
/* Handle the response when the item is successfully loaded */
|
|
20023
20026
|
next: (item) => {
|
|
20024
20027
|
/* Set loading state to false to indicate that loading has completed */
|
|
20025
20028
|
this.isLoading = false;
|
|
20026
|
-
/* Execute the callback if provided
|
|
20027
|
-
if (
|
|
20028
|
-
|
|
20029
|
+
/* Execute the success callback if provided */
|
|
20030
|
+
if (successCallback) {
|
|
20031
|
+
successCallback(item);
|
|
20029
20032
|
}
|
|
20030
20033
|
},
|
|
20031
20034
|
/* Handle any errors that occur during the loading process */
|
|
20032
|
-
error: (error) =>
|
|
20035
|
+
error: (error) => {
|
|
20036
|
+
/* Set loading state to false to indicate that loading has completed with error */
|
|
20037
|
+
this.isLoading = false;
|
|
20038
|
+
/* Parse the error internally */
|
|
20039
|
+
this.parseErrors(error);
|
|
20040
|
+
/* Execute the error callback if provided */
|
|
20041
|
+
if (errorCallback) {
|
|
20042
|
+
errorCallback(error);
|
|
20043
|
+
}
|
|
20044
|
+
}
|
|
20033
20045
|
});
|
|
20034
20046
|
}
|
|
20035
20047
|
}
|
|
20036
20048
|
/**
|
|
20037
20049
|
* Loads an item by ID asynchronously.
|
|
20050
|
+
*
|
|
20051
|
+
* @param headers - Optional HTTP headers to include in the request.
|
|
20038
20052
|
* @returns An Observable of the loaded entity.
|
|
20039
20053
|
*/
|
|
20040
|
-
loadItemAsync() {
|
|
20054
|
+
loadItemAsync(headers) {
|
|
20041
20055
|
if (this.id) {
|
|
20056
|
+
/* Merge provided headers with default 'Disable-Cache' header */
|
|
20057
|
+
const mergedHeaders = Object.assign({ 'Disable-Cache': 'Yes' }, headers || {});
|
|
20058
|
+
/* Perform the GET request to load the entity */
|
|
20042
20059
|
return this.service.get(this.id, Object.assign(this.query || {}, {
|
|
20043
20060
|
includes: this.includes?.length ? this.includes : this.updateIncludes,
|
|
20044
20061
|
projection: this.projection?.join(','),
|
|
20045
20062
|
observe: 'response'
|
|
20046
|
-
}),
|
|
20063
|
+
}), mergedHeaders, true, true).pipe(map((response) => {
|
|
20047
20064
|
/* Read permissions from the http headers */
|
|
20048
20065
|
const permissions = response?.headers?.get('Permissions')?.split(';') ?? [];
|
|
20049
20066
|
return {
|
|
@@ -20850,7 +20867,7 @@ class BaseInterceptor {
|
|
|
20850
20867
|
event => {
|
|
20851
20868
|
if (event instanceof HttpResponse) {
|
|
20852
20869
|
/* Check for specific headers in the response */
|
|
20853
|
-
if (req.headers.get('Show-Message')) {
|
|
20870
|
+
if (req.headers.get('Show-Message')?.trim().toLowerCase() == 'yes') {
|
|
20854
20871
|
/* Show success messages for different types of requests */
|
|
20855
20872
|
if (req.method == 'POST') {
|
|
20856
20873
|
this.snackBar.open($localize `:@@snackbar.send.success:Data sent successfully.`, undefined, {
|
|
@@ -20885,6 +20902,10 @@ class BaseInterceptor {
|
|
|
20885
20902
|
},
|
|
20886
20903
|
/* Handle errors */
|
|
20887
20904
|
error => {
|
|
20905
|
+
/* Check if the 'Show-Message' header is set to 'yes' */
|
|
20906
|
+
if (req.headers.get('Show-Message')?.trim().toLowerCase() != 'yes') {
|
|
20907
|
+
return;
|
|
20908
|
+
}
|
|
20888
20909
|
/* Handle validation errors for status code 400 (Bad Request) */
|
|
20889
20910
|
if (error.status == 400) {
|
|
20890
20911
|
let message = this.parseErrors(error.error);
|