@esfaenza/extensions 15.2.50 → 15.2.52
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/esm2020/lib/services/extensions.embedding.service.mjs +53 -12
- package/fesm2015/esfaenza-extensions.mjs +56 -14
- package/fesm2015/esfaenza-extensions.mjs.map +1 -1
- package/fesm2020/esfaenza-extensions.mjs +52 -11
- package/fesm2020/esfaenza-extensions.mjs.map +1 -1
- package/lib/services/extensions.embedding.service.d.ts +5 -0
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { InjectionToken, Injectable, Optional, Inject, Pipe, NgModule, Injector
|
|
|
3
3
|
import * as i1 from '@esfaenza/localizations';
|
|
4
4
|
import { LocalizationModule } from '@esfaenza/localizations';
|
|
5
5
|
import { first, filter, take, map } from 'rxjs/operators';
|
|
6
|
-
import { of, Subject } from 'rxjs';
|
|
6
|
+
import { of, Subject, filter as filter$1 } from 'rxjs';
|
|
7
7
|
import { ToastrService } from 'ngx-toastr';
|
|
8
8
|
import swal from 'sweetalert2';
|
|
9
9
|
import * as i2 from '@angular/router';
|
|
@@ -1061,6 +1061,9 @@ class AppEmbeddingExtensions {
|
|
|
1061
1061
|
this.EmbeddingLevel = 0;
|
|
1062
1062
|
this.MessageObserver = new Subject();
|
|
1063
1063
|
this._reloadAllowed = true;
|
|
1064
|
+
this.pushedHistories = [];
|
|
1065
|
+
this.MessageBarrierDebouncMs = 250;
|
|
1066
|
+
this.OnMessageCallBarrier = {};
|
|
1064
1067
|
this.MainWindow = window;
|
|
1065
1068
|
while (this.MainWindow.parent != this.MainWindow) {
|
|
1066
1069
|
this.MainWindow = this.MainWindow.parent;
|
|
@@ -1074,6 +1077,21 @@ class AppEmbeddingExtensions {
|
|
|
1074
1077
|
this.configureEmbeddability();
|
|
1075
1078
|
if (this.Embedded)
|
|
1076
1079
|
this.msgService.configureEmbeddability(this.MainWindow, this.MessageObserver);
|
|
1080
|
+
this.MessageObserver.pipe(filter$1(ev => ev.event == "menu-navigation")).subscribe(event => {
|
|
1081
|
+
// Mi interessa solo roba relativa all'embedding
|
|
1082
|
+
if (!event.data.routerLink.startsWith("embed"))
|
|
1083
|
+
return;
|
|
1084
|
+
// emb/crm/parties/parties_search?blabla --> parties/parties_search
|
|
1085
|
+
let normalizedRequestedRoute = event.data.routerLink.split("?")[0].split("/").slice(2).join("/");
|
|
1086
|
+
///pages_ext/parties/parties_search?blabla --> parties/parties_search
|
|
1087
|
+
let normalizedFirstRoute = this.pushedHistories.length > 0 ? this.pushedHistories[0].from.split("?")[0].split("/").slice(2).join("/") : "";
|
|
1088
|
+
// La route su cui sto navigando ora è uguale alla route in cui l'embedding è iniziato.
|
|
1089
|
+
// Significa che devo simulare dei back fino a che non sono arrivato all'inizio
|
|
1090
|
+
if (normalizedRequestedRoute == normalizedFirstRoute) {
|
|
1091
|
+
this.router.navigate(["pages/" + event.data.routerLink, { wakeup: 1 }], { queryParams: event.data.queryParams, onSameUrlNavigation: "reload" });
|
|
1092
|
+
this.pushedHistories = [];
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1077
1095
|
}
|
|
1078
1096
|
waitForMyConfigAndForceEmbeddedModule() {
|
|
1079
1097
|
// Aspetto di ricevere il myconfig e setto con lui l'embeddedmodule. Questo viene eseguito solo se this.location.path() per qualche motivo non contiene il module
|
|
@@ -1089,11 +1107,22 @@ class AppEmbeddingExtensions {
|
|
|
1089
1107
|
this._reloadAllowed = true;
|
|
1090
1108
|
return ret;
|
|
1091
1109
|
}
|
|
1110
|
+
messageHash(event) {
|
|
1111
|
+
return `${JSON.parse(JSON.stringify(event?.data))}`;
|
|
1112
|
+
}
|
|
1092
1113
|
configureEmbeddability() {
|
|
1093
1114
|
window.onmessage = (event) => {
|
|
1094
1115
|
// Ignoro i miei messaggi dato che mi interessano solo quelli degli altri iframe
|
|
1095
1116
|
if (event.source == window && event?.data?.type != "modal-open")
|
|
1096
1117
|
return;
|
|
1118
|
+
// Posso gestire lo stesso identico messaggio solo 1 volta ogni MessageBarrierDebouncMs
|
|
1119
|
+
let messageHash = this.messageHash(event);
|
|
1120
|
+
if (this.OnMessageCallBarrier[messageHash])
|
|
1121
|
+
return;
|
|
1122
|
+
else {
|
|
1123
|
+
this.OnMessageCallBarrier[messageHash] = true;
|
|
1124
|
+
setTimeout(() => delete this.OnMessageCallBarrier[messageHash], this.MessageBarrierDebouncMs);
|
|
1125
|
+
}
|
|
1097
1126
|
this.MessageObserver.next({ event: "window-message", data: event?.data });
|
|
1098
1127
|
if (event?.data?.type == "alert") {
|
|
1099
1128
|
console.log(`Window message - alert -> Level: ${event?.data?.level}, Message: ${event?.data?.msg}`);
|
|
@@ -1141,6 +1170,7 @@ class AppEmbeddingExtensions {
|
|
|
1141
1170
|
console.log(`Window message - navigate -> ${event?.data?.url}`);
|
|
1142
1171
|
var newTab = event?.data?.newTab;
|
|
1143
1172
|
var replaceState = event?.data?.replaceState;
|
|
1173
|
+
var current = event?.data?.current;
|
|
1144
1174
|
// Controllo se il router sta seguendo la chiamata attuale. Escludo i query params che sono gli unici che possono essere seccati dai replaceState
|
|
1145
1175
|
// e che potrebbero fare del casino
|
|
1146
1176
|
if (!window.location.href.includes(this.router.url.split("?")[0])) {
|
|
@@ -1150,17 +1180,16 @@ class AppEmbeddingExtensions {
|
|
|
1150
1180
|
let newRelativeUrl = this.router.createUrlTree([event?.data?.url]);
|
|
1151
1181
|
let baseUrl = window.location.href.replace(this.router.url.replace("?ignoreStorage=true", ''), '');
|
|
1152
1182
|
let newUrl = baseUrl + decodeURIComponent(newRelativeUrl.toString());
|
|
1153
|
-
if (replaceState)
|
|
1183
|
+
if (replaceState) {
|
|
1184
|
+
this.pushedHistories.push({ _pushed: true, url: newUrl, from: current });
|
|
1154
1185
|
history.pushState({ _pushed: true }, "", newUrl);
|
|
1186
|
+
}
|
|
1155
1187
|
else if (newTab)
|
|
1156
1188
|
window.open(newUrl, '_blank');
|
|
1157
1189
|
}
|
|
1158
1190
|
else if (event?.data?.type == "navigate-back") {
|
|
1159
1191
|
console.log(`Window message - navigate-back -> ${event?.data?.url}`);
|
|
1160
|
-
|
|
1161
|
-
this._reloadAllowed = false;
|
|
1162
|
-
history.back();
|
|
1163
|
-
}
|
|
1192
|
+
this.onNavigateBack();
|
|
1164
1193
|
}
|
|
1165
1194
|
else if (event?.data?.type == "redirect") {
|
|
1166
1195
|
console.log(`Window message - redirect -> ${event?.data?.url}`);
|
|
@@ -1176,7 +1205,8 @@ class AppEmbeddingExtensions {
|
|
|
1176
1205
|
const wrapperPaddingLeft = parseInt(wrapperStyles.getPropertyValue("padding-left"));
|
|
1177
1206
|
const wrapperPaddingRight = parseInt(wrapperStyles.getPropertyValue("padding-right"));
|
|
1178
1207
|
console.log(`Window message - Modal Open -> Backdrop Height: ${event?.data?.backdropHeight}`);
|
|
1179
|
-
var
|
|
1208
|
+
var bottomLeftover = 7; // Valore fisso... robina che rimane di sotto per un motivo o quell'altro
|
|
1209
|
+
var topHeight = 86; // valore fisso, distanza fra il top e l'inizio dell'iframe, non sarà mai diverso
|
|
1180
1210
|
var rightSpace = wrapperPaddingRight; // valore fisso, distanza fra la fine dell'iframe e il lato sinistro dello schermo, non sarà mai diverso
|
|
1181
1211
|
var leftSpace = this.sidebarWidth + wrapperPaddingLeft;
|
|
1182
1212
|
let commonStyles = "position: absolute; z-index: 9999; background-color: #000; opacity: 0.5; ";
|
|
@@ -1193,13 +1223,14 @@ class AppEmbeddingExtensions {
|
|
|
1193
1223
|
right.className = "embedded-modal-right";
|
|
1194
1224
|
right.style.cssText = commonStyles + `height: calc(100% - ${topHeight}px); top: ${topHeight}px; right: 0; width: ${rightSpace}px;`;
|
|
1195
1225
|
right.id = "right";
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1226
|
+
const bottom = document.createElement("div");
|
|
1227
|
+
bottom.className = "embedded-modal-bottom";
|
|
1228
|
+
bottom.style.cssText = commonStyles + `height: ${bottomLeftover}px; bottom: 0; width: calc(100% - ${leftSpace + rightSpace}px); left: ${leftSpace}px`;
|
|
1229
|
+
bottom.id = "bottom";
|
|
1200
1230
|
document.body.appendChild(top);
|
|
1201
1231
|
document.body.appendChild(left);
|
|
1202
1232
|
document.body.appendChild(right);
|
|
1233
|
+
document.body.appendChild(bottom);
|
|
1203
1234
|
}
|
|
1204
1235
|
else if (event?.data?.type == "modal-close") {
|
|
1205
1236
|
console.log(`Window message - Modal Close`);
|
|
@@ -1208,17 +1239,27 @@ class AppEmbeddingExtensions {
|
|
|
1208
1239
|
const top = document.getElementById("top");
|
|
1209
1240
|
const left = document.getElementById("left");
|
|
1210
1241
|
const right = document.getElementById("right");
|
|
1242
|
+
const bottom = document.getElementById("bottom");
|
|
1211
1243
|
if (top)
|
|
1212
1244
|
document.body.removeChild(top);
|
|
1213
1245
|
if (left)
|
|
1214
1246
|
document.body.removeChild(left);
|
|
1215
1247
|
if (right)
|
|
1216
1248
|
document.body.removeChild(right);
|
|
1249
|
+
if (bottom)
|
|
1250
|
+
document.body.removeChild(bottom);
|
|
1217
1251
|
}
|
|
1218
1252
|
};
|
|
1219
1253
|
if (this.Embedded)
|
|
1220
1254
|
document.body.style.setProperty("overflow-y", "auto", "important");
|
|
1221
1255
|
}
|
|
1256
|
+
onNavigateBack() {
|
|
1257
|
+
if (history?.state?._pushed) {
|
|
1258
|
+
this._reloadAllowed = false;
|
|
1259
|
+
this.pushedHistories.pop();
|
|
1260
|
+
history.back();
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1222
1263
|
replaceState(basePath, url) {
|
|
1223
1264
|
// Esempio basePath: pages
|
|
1224
1265
|
// Esempio url: parties/leads_search
|