diff --git a/src/popup/vault/add-edit.component.html b/src/popup/vault/add-edit.component.html index 8ee8bff2fe..eba3c193cc 100644 --- a/src/popup/vault/add-edit.component.html +++ b/src/popup/vault/add-edit.component.html @@ -274,9 +274,8 @@ {{'attachments' | i18n}} - - + + diff --git a/src/popup/vault/add-edit.component.ts b/src/popup/vault/add-edit.component.ts index d5de243200..655728736e 100644 --- a/src/popup/vault/add-edit.component.ts +++ b/src/popup/vault/add-edit.component.ts @@ -31,6 +31,7 @@ import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/componen export class AddEditComponent extends BaseAddEditComponent { currentUris: string[]; showAttachments = true; + openAttachmentsInPopup: boolean; constructor(cipherService: CipherService, folderService: FolderService, i18nService: I18nService, platformUtilsService: PlatformUtilsService, @@ -83,6 +84,8 @@ export class AddEditComponent extends BaseAddEditComponent { if (queryParamsSub != null) { queryParamsSub.unsubscribe(); } + + this.openAttachmentsInPopup = this.popupUtilsService.inPopup(window); }); if (!this.editMode) { @@ -118,9 +121,9 @@ export class AddEditComponent extends BaseAddEditComponent { attachments() { super.attachments(); - if (this.openAttachmentsInPopup()) { - let destinationUrl = this.router.createUrlTree(['/attachments'], { queryParams: { cipherId: this.cipher.id } }).toString(); - let currentBaseUrl = window.location.href.replace(this.router.url, ''); + if (this.openAttachmentsInPopup) { + const destinationUrl = this.router.createUrlTree(['/attachments'], { queryParams: { cipherId: this.cipher.id } }).toString(); + const currentBaseUrl = window.location.href.replace(this.router.url, ''); this.popupUtilsService.popOut(window, currentBaseUrl + destinationUrl); } else { this.router.navigate(['/attachments'], { queryParams: { cipherId: this.cipher.id } }); @@ -170,8 +173,4 @@ export class AddEditComponent extends BaseAddEditComponent { return (!this.editMode || this.cloneMode) && this.ownershipOptions && (this.ownershipOptions.length > 1 || !this.allowPersonal); } - - openAttachmentsInPopup(): boolean { - return this.popupUtilsService.inPopup(window); - } } diff --git a/src/popup/vault/attachments.component.html b/src/popup/vault/attachments.component.html index 7c6ec237fe..44c776b9ef 100644 --- a/src/popup/vault/attachments.component.html +++ b/src/popup/vault/attachments.component.html @@ -1,7 +1,10 @@ - + + {{'close' | i18n}} + + {{'back' | i18n}} diff --git a/src/popup/vault/attachments.component.ts b/src/popup/vault/attachments.component.ts index b2a1afab06..fe4714132e 100644 --- a/src/popup/vault/attachments.component.ts +++ b/src/popup/vault/attachments.component.ts @@ -15,6 +15,8 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib/angular/ templateUrl: 'attachments.component.html', }) export class AttachmentsComponent extends BaseAttachmentsComponent { + openedAttachmentsInPopup: boolean; + constructor(cipherService: CipherService, i18nService: I18nService, cryptoService: CryptoService, userService: UserService, platformUtilsService: PlatformUtilsService, private location: Location, @@ -30,13 +32,15 @@ export class AttachmentsComponent extends BaseAttachmentsComponent { queryParamsSub.unsubscribe(); } }); + + this.openedAttachmentsInPopup = history.length === 1; } back() { - if (document.referrer === "") { - this.router.navigate(['/edit-cipher'], { queryParams: { cipherId: this.cipher.id } }); - } else { - this.location.back(); - } + this.location.back(); + } + + close() { + window.close(); } }