Commit 3a63c929 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FIX #16636 TIME 1:10 be able to access the main document from the list of...

FIX #16636 TIME 1:10 be able to access the main document from the list of documents when an attached document is selected
parent dd23507a
import { Component, Input, OnInit, Output, EventEmitter, ViewChild, AfterViewInit } from '@angular/core';
import { Component, Input, OnInit, Output, EventEmitter, ViewChild, AfterViewInit, OnDestroy } from '@angular/core';
import { SignaturesContentService } from '../../service/signatures.service';
import { HttpClient } from '@angular/common/http';
import { DomSanitizer } from '@angular/platform-browser';
import { IonSlides, MenuController } from '@ionic/angular';
import { Subscription } from 'rxjs';
import { ActionsService } from '../../service/actions.service';
@Component({
selector: 'app-document-list',
templateUrl: 'document-list.component.html',
styleUrls: ['document-list.component.scss'],
})
export class DocumentListComponent implements OnInit, AfterViewInit {
export class DocumentListComponent implements OnInit, AfterViewInit, OnDestroy {
@Input() docList: any;
@Input() currentDocId: any;
......@@ -18,6 +20,8 @@ export class DocumentListComponent implements OnInit, AfterViewInit {
@ViewChild('slides', { static: false }) slides: IonSlides;
subscription: Subscription;
loading: boolean = true;
scrolling: boolean = false;
......@@ -30,9 +34,16 @@ export class DocumentListComponent implements OnInit, AfterViewInit {
constructor(
public http: HttpClient,
public signaturesService: SignaturesContentService,
private menu: MenuController,
private actionsService: ActionsService,
private sanitizer: DomSanitizer,
private menu: MenuController
) { }
) {
this.subscription = this.actionsService.catchEvent().subscribe((event: any) => {
if (event === 'scrollToTop') {
this.slides.slideTo(0, 0);
}
});
}
ngOnInit(): void {
this.docList.forEach((element: any, index: number) => {
......@@ -49,6 +60,10 @@ export class DocumentListComponent implements OnInit, AfterViewInit {
this.loading = false;
}
ngOnDestroy(): void {
this.subscription.unsubscribe();
}
loadDoc(id: string) {
this.triggerEvent.emit(id);
this.menu.close('right-menu');
......
import { Component, OnInit, ViewChild, TemplateRef, ViewContainerRef, Injectable } from '@angular/core';
import { Component, OnInit, ViewChild, TemplateRef, ViewContainerRef, Injectable, OnDestroy } from '@angular/core';
import { SignaturesContentService } from '../service/signatures.service';
import { DomSanitizer } from '@angular/platform-browser';
import { MatBottomSheet, MatBottomSheetConfig } from '@angular/material/bottom-sheet';
......@@ -18,7 +18,7 @@ import { LocalStorageService } from '../service/local-storage.service';
import { ActionSheetController, AlertController, LoadingController, MenuController, ModalController, NavController } from '@ionic/angular';
import { NgxExtendedPdfViewerService } from 'ngx-extended-pdf-viewer';
import { catchError, exhaustMap, tap } from 'rxjs/operators';
import { of } from 'rxjs';
import { of, Subscription } from 'rxjs';
import { SignatureMethodService } from '../service/signature-method/signature-method.service';
import { FunctionsService } from '../service/functions.service';
import { ActionsService } from '../service/actions.service';
......@@ -31,7 +31,7 @@ import { SuccessInfoValidBottomSheetComponent } from '../modal/success-info-vali
})
export class DocumentComponent implements OnInit {
export class DocumentComponent implements OnInit, OnDestroy {
@ViewChild('mainContent') mainContent: any;
@ViewChild('img') img: any;
......@@ -73,6 +73,8 @@ export class DocumentComponent implements OnInit {
workflow: [],
};
subscription: Subscription;
signaturesContent: any = [];
docList: any = [];
......@@ -125,6 +127,16 @@ export class DocumentComponent implements OnInit {
private cookieService: CookieService,
) {
this.draggable = false;
this.subscription = this.actionsService.catchEvent().subscribe((event: any) => {
if (event.id === 'gotoDocument' && event.documentIndex === 0) {
this.loadDoc(event.documentIndex);
this.actionsService.setEvent('scrollToTop');
}
});
}
ngOnDestroy(): void {
this.subscription.unsubscribe();
}
imageLoaded(ev: any) {
......
......@@ -77,7 +77,7 @@
</ion-label>
</ion-item>
<ion-menu-toggle auto-hide="false" *ngFor="let document of signaturesService.documentsList;let i=index">
<ion-item class="doc-item" (click)="filterService.currentIndex = i" routerDirection="root"
<ion-item class="doc-item" (click)="filterService.currentIndex = i; goTo(document.id);" routerDirection="root"
[routerLink]="['/documents/'+document.id]" detail="false"
[class.selected]="router.url === '/documents/'+document.id">
<ion-icon *ngIf="document.mode == 'sign'" color="primary" slot="start" name="pencil-outline"></ion-icon>
......
......@@ -165,4 +165,8 @@ export class SidebarComponent implements OnInit, AfterViewInit {
canIndex() {
return this.authService.user.appPrivileges.map((item: any) => item.id).indexOf('indexation') > -1;
}
goTo() {
this.actionsService.setEvent({id: 'gotoDocument', documentIndex: 0});
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment