@arsedizioni/ars-utils 21.2.223 → 21.2.225

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.
@@ -977,10 +977,10 @@ class ClipperDocumentsUtils {
977
977
  * @param theme - The UI theme to apply. Defaults to the system theme.
978
978
  * @param canUseArchive - When `true`, archive access is enabled inside the viewer.
979
979
  * @param canHandleTooManyResults - When `true`, the component handles oversized result sets.
980
- * @returns The `MatDialogRef` for the opened dialog, or `undefined` when the user is not logged in
981
- * or the document ID is invalid.
980
+ * @param replaceUrl - When provided, after the dialog closes the method calls `window.close()`
981
+ * if the page was opened by another window, or navigates to this URL otherwise.
982
982
  */
983
- static openDocument(injector, documentId, query, queryChunks, selectionMode, selectableModules, theme, canUseArchive, canHandleTooManyResults) {
983
+ static openDocument(injector, documentId, query, queryChunks, selectionMode, selectableModules, theme, canUseArchive, canHandleTooManyResults, replaceUrl) {
984
984
  runInInjectionContext(injector, () => {
985
985
  const dialogService = inject(DialogService);
986
986
  const clipperService = inject(ClipperService);
@@ -993,7 +993,7 @@ class ClipperDocumentsUtils {
993
993
  return;
994
994
  }
995
995
  Promise.resolve().then(function () { return document_component; }).then(({ ClipperDocumentComponent }) => {
996
- dialogService.open(ClipperDocumentComponent, {
996
+ const ref = dialogService.open(ClipperDocumentComponent, {
997
997
  ariaLabel: 'documento',
998
998
  autoFocus: false,
999
999
  restoreFocus: false,
@@ -1013,6 +1013,18 @@ class ClipperDocumentsUtils {
1013
1013
  width: '100%',
1014
1014
  height: '100%'
1015
1015
  });
1016
+ if (replaceUrl && ref) {
1017
+ ref.beforeClosed().subscribe(() => {
1018
+ setTimeout(() => {
1019
+ if (window.opener !== null) {
1020
+ window.close();
1021
+ }
1022
+ else {
1023
+ window.location.replace(replaceUrl);
1024
+ }
1025
+ }, 500);
1026
+ });
1027
+ }
1016
1028
  });
1017
1029
  });
1018
1030
  }