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; ApplicationId: string;
Assunto: string; Assunto: string;
DocDate: string; DocDate: string;
@@ -656,7 +656,7 @@ export class DespachoPrPage implements OnInit {
"FolderId": "", "FolderId": "",
"Sender": "", "Sender": "",
"SourceDocId": "", "SourceDocId": "",
"content": resd.data.content, "content": resd.data.content || " ",
"path": resd.data.path, "path": resd.data.path,
"ownerId": resd.data.ownerId, "ownerId": resd.data.ownerId,
"status": resd.data.status, "status": resd.data.status,
@@ -223,7 +223,7 @@ export class DespachoPage implements OnInit {
"FolderId": "", "FolderId": "",
"Sender": "", "Sender": "",
"SourceDocId": "", "SourceDocId": "",
"content": resd.data.content, "content": resd.data.content || " ",
"path": resd.data.path, "path": resd.data.path,
"ownerId": resd.data.ownerId, "ownerId": resd.data.ownerId,
"status": resd.data.status, "status": resd.data.status,
@@ -493,7 +493,7 @@ export class DiplomaAssinarPage implements OnInit {
"FolderId": "", "FolderId": "",
"Sender": "", "Sender": "",
"SourceDocId": "", "SourceDocId": "",
"content": resd.data.content, "content": resd.data.content || " ",
"path": resd.data.path, "path": resd.data.path,
"ownerId": resd.data.ownerId, "ownerId": resd.data.ownerId,
"status": resd.data.status, "status": resd.data.status,
@@ -548,7 +548,7 @@ export class DiplomaPage implements OnInit {
"FolderId": "", "FolderId": "",
"Sender": "", "Sender": "",
"SourceDocId": "", "SourceDocId": "",
"content": resd.data.content, "content": resd.data.content || " ",
"path": resd.data.path, "path": resd.data.path,
"ownerId": resd.data.ownerId, "ownerId": resd.data.ownerId,
"status": resd.data.status, "status": resd.data.status,
@@ -9,13 +9,28 @@ import { ViewerAttachmentPageRoutingModule } from './viewer-attachment-routing.m
import { ViewerAttachmentPage } from './viewer-attachment.page'; import { ViewerAttachmentPage } from './viewer-attachment.page';
import { EditorModule } from '@tinymce/tinymce-angular'; 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({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
FormsModule, FormsModule,
IonicModule, IonicModule,
ViewerAttachmentPageRoutingModule, ViewerAttachmentPageRoutingModule,
EditorModule EditorModule,
MatMenuModule,
MatButtonModule,
MatIconModule,
], ],
declarations: [ViewerAttachmentPage, ], declarations: [ViewerAttachmentPage, ],
exports: [ViewerAttachmentPage], exports: [ViewerAttachmentPage],
@@ -5,7 +5,7 @@
<div *ngFor="let attachment of taskViewerAttachment; let i = index" <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" class="ion-no-margin ion-no-padding cursor-pointer attachment-list" class="pa-10 mx-10 card-text"
[ngClass]="{'selected-card': i === selectedIndex}" > [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"> <div *ngIf="attachment.Assunto" class="attach-title-item tex-left">
{{ attachment.Assunto }}<span class="document-type" *ngIf="attachment.content != ''">Rascunho</span> {{ attachment.Assunto }}<span class="document-type" *ngIf="attachment.content != ''">Rascunho</span>
@@ -15,12 +15,37 @@
{{ attachment.DocDate | date: 'dd/MM/yy' }} {{ attachment.DocDate | date: 'dd/MM/yy' }}
</div> </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>
</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> </div>
@@ -47,9 +72,5 @@
initialValue='{{content}}' initialValue='{{content}}'
[(ngModel)]="content" [(ngModel)]="content"
(ngModelChange)="onEditorContentChange()"
></editor> ></editor>
</div> </div>
@@ -3,6 +3,12 @@ import { IonicSlides } from '@ionic/angular';
import { ViewerAttachment, ViewerAttachmentParams } from './prop'; import { ViewerAttachment, ViewerAttachmentParams } from './prop';
import { MiddlewareRepositoryService } from "src/app/shared/repository/middleware/middleware-repository.service" import { MiddlewareRepositoryService } from "src/app/shared/repository/middleware/middleware-repository.service"
import { DeviceService } from "src/app/services/device.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({ @Component({
selector: 'app-viewer-attachment', selector: 'app-viewer-attachment',
templateUrl: './viewer-attachment.page.html', templateUrl: './viewer-attachment.page.html',
@@ -19,32 +25,36 @@ export class ViewerAttachmentPage implements OnInit {
editorContent: ""; editorContent: "";
content: "" content: ""
private saveTimeout: any; private saveTimeout: any;
draft = false
constructor( constructor(
public middlewareRepositoryService: MiddlewareRepositoryService, public middlewareRepositoryService: MiddlewareRepositoryService,
public DeviceService: DeviceService public DeviceService: DeviceService,
private processes: ProcessesService,
private erroHandler: HttpErrorHandle,
public p: PermissionService,
) { } ) { }
ngOnInit() { ngOnInit() {
this.validateParams() this.validateParams()
const selectFirst = this.taskViewerAttachment[0] const selectFirst = this.taskViewerAttachment[0]
} }
async clickDocument(viewerAttachment: ViewerAttachment, i) { 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 let count = 0
try { try {
setTimeout(async ()=> { setTimeout(async ()=> {
this.selectedIndex = i; this.selectedIndex = i;
this.iframeContainer.nativeElement.innerHTML = ""
this.iframeContainer
const linkRequest = await this.middlewareRepositoryService.getViewerLink({ const linkRequest = await this.middlewareRepositoryService.getViewerLink({
ApplicationId: viewerAttachment.ApplicationId, ApplicationId: viewerAttachment.ApplicationId,
DocId: viewerAttachment.DocId DocId: viewerAttachment.DocId
@@ -61,8 +71,15 @@ export class ViewerAttachmentPage implements OnInit {
newIframe.width = '100%' newIframe.width = '100%'
newIframe.height = '100%' newIframe.height = '100%'
this.iframeContainer.nativeElement.innerHTML = ""
this.iframeContainer
this.iframeContainer.nativeElement.appendChild(newIframe) this.iframeContainer.nativeElement.appendChild(newIframe)
this.iframeContainer.nativeElement.style.display = 'flex'
} else {
this.iframeContainer.nativeElement.style.display = 'none'
} }
}, 1000) }, 1000)
} catch (error) { } catch (error) {
this.clickDocument(viewerAttachment, i); this.clickDocument(viewerAttachment, i);
@@ -97,18 +114,38 @@ export class ViewerAttachmentPage implements OnInit {
} }
onEditorContentChange() { private holdStart: number = 0;
console.log('Autosave successful! Content saved to local storage1.'); private holdEnd: number = 0;
if (this.saveTimeout) { private holdDuration: number = 500; // Adjust the duration needed for a "hold"
clearTimeout(this.saveTimeout); private holdTimer: any;
private isHoldTriggered: boolean = false;
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);
} }
this.saveTimeout = setTimeout(() => { endHold(): void {
this.saveDraft(); clearTimeout(this.holdTimer);
clearTimeout(this.saveTimeout); this.holdEnd = new Date().getTime();
}, 5000); this.isHoldTriggered = false;
} }
openExpedientActionsModal(a: any, b:any) {}
saveDraft() {} openBookMeetingModal(a: any) {}
} }
@@ -92,7 +92,7 @@
</div> </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" (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"> <button mat-icon-button [matMenuTriggerFor]="menu" aria-label="Example icon-button with a menu">
<mat-icon>more_vert</mat-icon> <mat-icon>more_vert</mat-icon>
</button> </button>
@@ -28,7 +28,6 @@ export class TaskDetailsPage implements OnInit {
selectedIndex = 0 selectedIndex = 0
dropButton = true dropButton = true
constructor( constructor(
public ThemeService: ThemeService, public ThemeService: ThemeService,
public DeviceService: DeviceService, public DeviceService: DeviceService,