Close popout instead of navigating, style fixes

This commit is contained in:
Thomas Rittson 2021-01-15 15:58:38 +10:00
parent bef1008b9d
commit 092110fd5f
4 changed files with 21 additions and 16 deletions

View File

@ -274,9 +274,8 @@
<a class="box-content-row box-content-row-flex text-default" href="#" appStopClick appBlurClick <a class="box-content-row box-content-row-flex text-default" href="#" appStopClick appBlurClick
(click)="attachments()" *ngIf="editMode && showAttachments && !cloneMode"> (click)="attachments()" *ngIf="editMode && showAttachments && !cloneMode">
<div class="row-main">{{'attachments' | i18n}}</div> <div class="row-main">{{'attachments' | i18n}}</div>
<i class="fa fa-chevron-right row-sub-icon" aria-hidden="true" <i class="fa fa-external-link fa-lg fa-fw" aria-hidden="true" *ngIf="openAttachmentsInPopup"></i>
*ngIf="!openAttachmentsInPopup()"></i> <i class="fa fa-chevron-right row-sub-icon" aria-hidden="true" *ngIf="!openAttachmentsInPopup"></i>
<i class="fa fa-external-link fa-lg fa-fw" aria-hidden="true" *ngIf="openAttachmentsInPopup()"></i>
</a> </a>
<a class="box-content-row box-content-row-flex text-default" href="#" appStopClick appBlurClick <a class="box-content-row box-content-row-flex text-default" href="#" appStopClick appBlurClick
(click)="editCollections()" *ngIf="editMode && cipher.organizationId && !cloneMode"> (click)="editCollections()" *ngIf="editMode && cipher.organizationId && !cloneMode">

View File

@ -31,6 +31,7 @@ import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/componen
export class AddEditComponent extends BaseAddEditComponent { export class AddEditComponent extends BaseAddEditComponent {
currentUris: string[]; currentUris: string[];
showAttachments = true; showAttachments = true;
openAttachmentsInPopup: boolean;
constructor(cipherService: CipherService, folderService: FolderService, constructor(cipherService: CipherService, folderService: FolderService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService, i18nService: I18nService, platformUtilsService: PlatformUtilsService,
@ -83,6 +84,8 @@ export class AddEditComponent extends BaseAddEditComponent {
if (queryParamsSub != null) { if (queryParamsSub != null) {
queryParamsSub.unsubscribe(); queryParamsSub.unsubscribe();
} }
this.openAttachmentsInPopup = this.popupUtilsService.inPopup(window);
}); });
if (!this.editMode) { if (!this.editMode) {
@ -118,9 +121,9 @@ export class AddEditComponent extends BaseAddEditComponent {
attachments() { attachments() {
super.attachments(); super.attachments();
if (this.openAttachmentsInPopup()) { if (this.openAttachmentsInPopup) {
let destinationUrl = this.router.createUrlTree(['/attachments'], { queryParams: { cipherId: this.cipher.id } }).toString(); const destinationUrl = this.router.createUrlTree(['/attachments'], { queryParams: { cipherId: this.cipher.id } }).toString();
let currentBaseUrl = window.location.href.replace(this.router.url, ''); const currentBaseUrl = window.location.href.replace(this.router.url, '');
this.popupUtilsService.popOut(window, currentBaseUrl + destinationUrl); this.popupUtilsService.popOut(window, currentBaseUrl + destinationUrl);
} else { } else {
this.router.navigate(['/attachments'], { queryParams: { cipherId: this.cipher.id } }); 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 return (!this.editMode || this.cloneMode) && this.ownershipOptions
&& (this.ownershipOptions.length > 1 || !this.allowPersonal); && (this.ownershipOptions.length > 1 || !this.allowPersonal);
} }
openAttachmentsInPopup(): boolean {
return this.popupUtilsService.inPopup(window);
}
} }

View File

@ -1,7 +1,10 @@
<form #form (ngSubmit)="submit()" [appApiAction]="formPromise"> <form #form (ngSubmit)="submit()" [appApiAction]="formPromise">
<header> <header>
<div class="left"> <div class="left">
<button type="button" appBlurClick (click)="back()"> <button type="button" appBlurClick (click)="close()" *ngIf="openedAttachmentsInPopup">
{{'close' | i18n}}
</button>
<button type="button" appBlurClick (click)="back()" *ngIf="!openedAttachmentsInPopup">
<span class="header-icon"><i class="fa fa-chevron-left" aria-hidden="true"></i></span> <span class="header-icon"><i class="fa fa-chevron-left" aria-hidden="true"></i></span>
<span>{{'back' | i18n}}</span> <span>{{'back' | i18n}}</span>
</button> </button>

View File

@ -15,6 +15,8 @@ import { AttachmentsComponent as BaseAttachmentsComponent } from 'jslib/angular/
templateUrl: 'attachments.component.html', templateUrl: 'attachments.component.html',
}) })
export class AttachmentsComponent extends BaseAttachmentsComponent { export class AttachmentsComponent extends BaseAttachmentsComponent {
openedAttachmentsInPopup: boolean;
constructor(cipherService: CipherService, i18nService: I18nService, constructor(cipherService: CipherService, i18nService: I18nService,
cryptoService: CryptoService, userService: UserService, cryptoService: CryptoService, userService: UserService,
platformUtilsService: PlatformUtilsService, private location: Location, platformUtilsService: PlatformUtilsService, private location: Location,
@ -30,13 +32,15 @@ export class AttachmentsComponent extends BaseAttachmentsComponent {
queryParamsSub.unsubscribe(); queryParamsSub.unsubscribe();
} }
}); });
this.openedAttachmentsInPopup = history.length === 1;
} }
back() { back() {
if (document.referrer === "") { this.location.back();
this.router.navigate(['/edit-cipher'], { queryParams: { cipherId: this.cipher.id } }); }
} else {
this.location.back(); close() {
} window.close();
} }
} }