1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

fixing share modal

This commit is contained in:
Patrik J. Braun 2018-05-22 20:58:12 -04:00
parent 7bd7928664
commit c08a2b35ba
2 changed files with 104 additions and 105 deletions

View File

@ -1,19 +1,13 @@
<button id="shareButton" class="nav-link btn btn-default btn-link" <button id="shareButton" class="nav-link btn btn-default btn-link"
type="button" [disabled]="!enabled" (click)="showModal()"> type="button" [disabled]="!enabled" (click)="openModal(shareModal)">
<span class="oi oi-share"></span> <span class="oi oi-share"></span>
<ng-container i18n>Share</ng-container> <ng-container i18n>Share</ng-container>
</button> </button>
<ng-template #shareModal>
<!-- sharing Modal--> <!-- sharing Modal-->
<div bsModal #shareModal="bs-modal"
class="modal fade" id="shareModal"
tabindex="-1" role="dialog" aria-labelledby="shareModalLabel"
[config]="{ backdrop: false }"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="shareModalLabel" i18n>Share</h5> <h5 class="modal-title" i18n>Share</h5>
<button type="button" class="close" (click)="hideModal()" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" (click)="hideModal()" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
@ -106,6 +100,4 @@
</div> </div>
</div> </div>
</div> </div>
</div> </ng-template>
</div>
</div>

View File

@ -1,14 +1,15 @@
import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {Component, OnDestroy, OnInit, TemplateRef} from '@angular/core';
import {Utils} from '../../../../common/Utils'; import {Utils} from '../../../../common/Utils';
import {ShareService} from '../share.service'; import {ShareService} from '../share.service';
import {GalleryService} from '../gallery.service'; import {GalleryService} from '../gallery.service';
import {ContentWrapper} from '../../../../common/entities/ConentWrapper'; import {ContentWrapper} from '../../../../common/entities/ConentWrapper';
import {SharingDTO} from '../../../../common/entities/SharingDTO'; import {SharingDTO} from '../../../../common/entities/SharingDTO';
import {ModalDirective} from 'ngx-bootstrap/modal';
import {Config} from '../../../../common/config/public/Config'; import {Config} from '../../../../common/config/public/Config';
import {NotificationService} from '../../model/notification.service'; import {NotificationService} from '../../model/notification.service';
import {DirectoryDTO} from '../../../../common/entities/DirectoryDTO'; import {DirectoryDTO} from '../../../../common/entities/DirectoryDTO';
import {I18n} from '@ngx-translate/i18n-polyfill'; import {I18n} from '@ngx-translate/i18n-polyfill';
import {BsModalService} from 'ngx-bootstrap/modal';
import {BsModalRef} from 'ngx-bootstrap/modal/bs-modal-ref.service';
@Component({ @Component({
@ -17,7 +18,6 @@ import {I18n} from '@ngx-translate/i18n-polyfill';
styleUrls: ['./share.gallery.component.css'], styleUrls: ['./share.gallery.component.css'],
}) })
export class GalleryShareComponent implements OnInit, OnDestroy { export class GalleryShareComponent implements OnInit, OnDestroy {
@ViewChild('shareModal') public childModal: ModalDirective;
enabled = true; enabled = true;
url = ''; url = '';
@ -36,6 +36,8 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
passwordProtection = false; passwordProtection = false;
ValidityTypes: any; ValidityTypes: any;
modalRef: BsModalRef;
text = { text = {
Yes: 'Yes', Yes: 'Yes',
No: 'No' No: 'No'
@ -44,7 +46,8 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
constructor(private _sharingService: ShareService, constructor(private _sharingService: ShareService,
public _galleryService: GalleryService, public _galleryService: GalleryService,
private _notification: NotificationService, private _notification: NotificationService,
public i18n: I18n) { public i18n: I18n,
private modalService: BsModalService) {
this.ValidityTypes = ValidityTypes; this.ValidityTypes = ValidityTypes;
this.text.Yes = i18n('Yes'); this.text.Yes = i18n('Yes');
@ -99,10 +102,13 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
this.url = Config.Client.publicUrl + '/share/' + this.sharing.sharingKey; this.url = Config.Client.publicUrl + '/share/' + this.sharing.sharingKey;
} }
async showModal() { async openModal(template: TemplateRef<any>) {
await this.get(); await this.get();
this.input.password = ''; this.input.password = '';
this.childModal.show(); if (this.modalRef) {
this.modalRef.hide();
}
this.modalRef = this.modalService.show(template);
document.body.style.paddingRight = '0px'; document.body.style.paddingRight = '0px';
} }
@ -111,7 +117,8 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
} }
public hideModal() { public hideModal() {
this.childModal.hide(); this.modalRef.hide();
this.modalRef = null;
this.sharing = null; this.sharing = null;
} }