add dropdown manu to attachment list

This commit is contained in:
Peter Maquiran
2024-02-23 09:31:55 +01:00
parent e778039632
commit 887e2e163a
10 changed files with 106 additions and 34 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
interface Document {
export interface IDraft {
ApplicationId: string;
Assunto: string;
DocDate: string;
@@ -656,7 +656,7 @@ export class DespachoPrPage implements OnInit {
"FolderId": "",
"Sender": "",
"SourceDocId": "",
"content": resd.data.content,
"content": resd.data.content || " ",
"path": resd.data.path,
"ownerId": resd.data.ownerId,
"status": resd.data.status,
@@ -223,7 +223,7 @@ export class DespachoPage implements OnInit {
"FolderId": "",
"Sender": "",
"SourceDocId": "",
"content": resd.data.content,
"content": resd.data.content || " ",
"path": resd.data.path,
"ownerId": resd.data.ownerId,
"status": resd.data.status,
@@ -493,7 +493,7 @@ export class DiplomaAssinarPage implements OnInit {
"FolderId": "",
"Sender": "",
"SourceDocId": "",
"content": resd.data.content,
"content": resd.data.content || " ",
"path": resd.data.path,
"ownerId": resd.data.ownerId,
"status": resd.data.status,
@@ -548,7 +548,7 @@ export class DiplomaPage implements OnInit {
"FolderId": "",
"Sender": "",
"SourceDocId": "",
"content": resd.data.content,
"content": resd.data.content || " ",
"path": resd.data.path,
"ownerId": resd.data.ownerId,
"status": resd.data.status,
@@ -9,13 +9,28 @@ import { ViewerAttachmentPageRoutingModule } from './viewer-attachment-routing.m
import { ViewerAttachmentPage } from './viewer-attachment.page';
import { EditorModule } from '@tinymce/tinymce-angular';
import {MatMenuModule} from '@angular/material/menu';
import {MatButtonModule} from '@angular/material/button';
import {MatIconModule} from '@angular/material/icon';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
ViewerAttachmentPageRoutingModule,
EditorModule
EditorModule,
MatMenuModule,
MatButtonModule,
MatIconModule,
],
declarations: [ViewerAttachmentPage, ],
exports: [ViewerAttachmentPage],
@@ -5,7 +5,7 @@
<div *ngFor="let attachment of taskViewerAttachment; let i = index"
class="ion-no-margin ion-no-padding cursor-pointer attachment-list" class="pa-10 mx-10 card-text"
[ngClass]="{'selected-card': i === selectedIndex}" >
<div (click)="clickDocument(attachment, i )">
<div class="attachment" (mousedown)="startHold($event, attachment, i)" (mouseup)="endHold()" (click)="clickDocument(attachment, i )">
<div *ngIf="attachment.Assunto" class="attach-title-item tex-left">
{{ attachment.Assunto }}<span class="document-type" *ngIf="attachment.content != ''">Rascunho</span>
@@ -15,16 +15,41 @@
{{ attachment.DocDate | date: 'dd/MM/yy' }}
</div>
<button mat-icon-button [matMenuTriggerFor]="menu" aria-label="Example icon-button with a menu" style="
width: 0px;
height: 0px;
/* top: -40px; */
position: absolute;
"></button>
<mat-menu #menu="matMenu">
<button (click)="openExpedientActionsModal('0', attachment)" mat-menu-item>
<span>Efetuar Despacho</span>
</button>
<button (click)="openExpedientActionsModal('1', attachment)" mat-menu-item >
<span>Solicitar Parecer</span>
</button>
<button *ngIf="!p.userRole(['PR']) && !p.userPermission([p.permissionList.Gabinete.pr_tasks])" (click)="openExpedientActionsModal('1', attachment)" mat-menu-item >
<span>Pedido de Deferimento</span>
</button>
<button (click)="openBookMeetingModal(attachment)" mat-menu-item>
<span>Marcar Reunião</span>
</button>
<button *ngIf="p.userRole('PR')" mat-menu-item>
<span>Assinar</span>
</button>
</mat-menu>
</div>
</div>
</div>
<div [ngClass]="{'d-none': taskViewerAttachment[selectedIndex].content != ''}" #iframeContainer class="height-100 flex-1" >
<div [ngClass]="{'d-none': draft}" #iframeContainer class="height-100 flex-1" >
</div>
<editor
<editor
*ngIf="taskViewerAttachment[selectedIndex].content"
class="container-img height-100"
apiKey="wr5dk69kive0qr9ig6y5spqvlj3a0tsiwnzdsexnz241k69p"
@@ -47,9 +72,5 @@
initialValue='{{content}}'
[(ngModel)]="content"
(ngModelChange)="onEditorContentChange()"
></editor>
</div>
@@ -3,6 +3,12 @@ import { IonicSlides } from '@ionic/angular';
import { ViewerAttachment, ViewerAttachmentParams } from './prop';
import { MiddlewareRepositoryService } from "src/app/shared/repository/middleware/middleware-repository.service"
import { DeviceService } from "src/app/services/device.service"
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { ProcessesService } from 'src/app/services/processes.service';
import { Subject, fromEvent, interval } from 'rxjs';
import { switchMap, take } from 'rxjs/operators';
import { PermissionService } from 'src/app/services/permission.service';
@Component({
selector: 'app-viewer-attachment',
templateUrl: './viewer-attachment.page.html',
@@ -19,32 +25,36 @@ export class ViewerAttachmentPage implements OnInit {
editorContent: "";
content: ""
private saveTimeout: any;
draft = false
constructor(
public middlewareRepositoryService: MiddlewareRepositoryService,
public DeviceService: DeviceService
public DeviceService: DeviceService,
private processes: ProcessesService,
private erroHandler: HttpErrorHandle,
public p: PermissionService,
) { }
ngOnInit() {
this.validateParams()
const selectFirst = this.taskViewerAttachment[0]
}
async clickDocument(viewerAttachment: ViewerAttachment, i) {
if(!this.taskViewerAttachment[this.selectedIndex]?.content) {
this.draft = false
} else if (this.taskViewerAttachment[this.selectedIndex]?.content == '') {
this.draft = false
} else {
this.draft =true
}
let count = 0
try {
setTimeout(async ()=> {
this.selectedIndex = i;
this.iframeContainer.nativeElement.innerHTML = ""
this.iframeContainer
const linkRequest = await this.middlewareRepositoryService.getViewerLink({
ApplicationId: viewerAttachment.ApplicationId,
DocId: viewerAttachment.DocId
@@ -61,8 +71,15 @@ export class ViewerAttachmentPage implements OnInit {
newIframe.width = '100%'
newIframe.height = '100%'
this.iframeContainer.nativeElement.innerHTML = ""
this.iframeContainer
this.iframeContainer.nativeElement.appendChild(newIframe)
this.iframeContainer.nativeElement.style.display = 'flex'
} else {
this.iframeContainer.nativeElement.style.display = 'none'
}
}, 1000)
} catch (error) {
this.clickDocument(viewerAttachment, i);
@@ -97,18 +114,38 @@ export class ViewerAttachmentPage implements OnInit {
}
onEditorContentChange() {
console.log('Autosave successful! Content saved to local storage1.');
if (this.saveTimeout) {
clearTimeout(this.saveTimeout);
}
private holdStart: number = 0;
private holdEnd: number = 0;
private holdDuration: number = 500; // Adjust the duration needed for a "hold"
private holdTimer: any;
private isHoldTriggered: boolean = false;
this.saveTimeout = setTimeout(() => {
this.saveDraft();
clearTimeout(this.saveTimeout);
}, 5000);
startHold(event: TouchEvent, attachment: any, index: number): void {
event.preventDefault();
this.holdStart = new Date().getTime();
// Handle your logic for the initial touch (if needed)
this.clickDocument(attachment, index);
this.holdTimer = setTimeout(() => {
const currentTime = new Date().getTime();
if (currentTime - this.holdStart >= this.holdDuration) {
// Your logic for "hold to click" action goes here
console.log('Hold to click action triggered!');
console.log(event)
window['e'] = event;
(event as any).target.parentElement.querySelector('button').click()
this.isHoldTriggered = true;
}
}, this.holdDuration);
}
endHold(): void {
clearTimeout(this.holdTimer);
this.holdEnd = new Date().getTime();
this.isHoldTriggered = false;
}
saveDraft() {}
openExpedientActionsModal(a: any, b:any) {}
openBookMeetingModal(a: any) {}
}
@@ -92,7 +92,7 @@
</div>
<!-- <div class="d-flex justify-center align-center font-25" (click)="clickDocumentUPdateIndex(Document.DocId, Document, Document.content);"> -->
<div class="d-flex justify-center align-center font-25" >
<div class="d-flex justify-center align-center font-25" *ngIf="!Document.content">
<button mat-icon-button [matMenuTriggerFor]="menu" aria-label="Example icon-button with a menu">
<mat-icon>more_vert</mat-icon>
</button>
@@ -28,7 +28,6 @@ export class TaskDetailsPage implements OnInit {
selectedIndex = 0
dropButton = true
constructor(
public ThemeService: ThemeService,
public DeviceService: DeviceService,