Improve page

This commit is contained in:
Peter Maquiran
2021-07-29 15:40:24 +01:00
parent eb474ca53c
commit 39a3863106
11 changed files with 140 additions and 119 deletions
@@ -1,12 +1,9 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AnimationController, ModalController, NavParams } from '@ionic/angular';
import { Router } from '@angular/router';
import { ModalController, NavParams } from '@ionic/angular';
import { Event } from 'src/app/models/event.model'
import { EventBody } from 'src/app/models/eventbody.model';
import { ProcessesService } from 'src/app/services/processes.service';
import { EventPerson } from 'src/app/models/eventperson.model';
import { EventsService } from 'src/app/services/events.service';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { SearchPage } from 'src/app/pages/search/search.page';
import { SearchDocument } from 'src/app/models/search-document';
import { User } from 'src/app/models/user.model';
@@ -21,6 +18,7 @@ import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-pick
import { MAT_DATE_LOCALE } from '@angular/material/core';
import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discart-expedient-modal/discart-expedient-modal.page';
import { DocumentService } from 'src/app/Rules/document.service';
import { DocumentSetUpMeeting, Attachments } from 'src/app/models/CallMeeting';
const moment = _rollupMoment || _moment;
@@ -95,49 +93,47 @@ export class DocumentSetUpMeetingPage implements OnInit {
taskDocId:string;
loadedAttachments:any;
documents:SearchDocument[] = [];
documents: SearchDocument[] = [];
attachments:SearchDocument[] = [];
adding: "intervenient" | "CC" = "intervenient";
postData: Event;
eventBody: EventBody;
formLocationSatus: boolean = false;
showAttendees= false;
loggeduser: User;
emptyTextDescription = "Sem intervenientes selecionados";
document: any;
constructor(
private modalController: ModalController,
private router:Router,
private navParams: NavParams,
private processes:ProcessesService,
private attachmentsService: AttachmentsService,
private calendarService: EventsService,
authService: AuthService,
private animationController: AnimationController,
private toastService: ToastService,
private activatedRoute: ActivatedRoute,
private documentService: DocumentService
) {
this.loggeduser = authService.ValidatedUser;
this.task = this.navParams.get('task');
this.postData = new Event();
this.eventBody = { BodyType : "1", Text : ""};
this.postData.Body = this.eventBody;
this.document = this.navParams.get('document')
this.postData = new Event();
this.postData.Body ={ BodyType : "1", Text : ""};
/* Initialize 'Subject' with the title of the expedient */
this.postData.Subject = this.task.Folio;
this.postData.CalendarName = "Oficial";
this.postData.Category = 'Reunião'
}
}
ngOnInit() {
this.adding = "intervenient";
console.log(this.task);
this.getAttachments();
this.setDefaultTime()
}
@@ -146,12 +142,6 @@ export class DocumentSetUpMeetingPage implements OnInit {
this.postData.EndDate = (new Date(new Date().getTime() + 15 * 60000))
}
getAttachments() {
this.attachmentsService.getAttachmentsBySerial(this.task.SerialNumber).subscribe(res=>{
this.loadedAttachments = res;
});
}
close() {
this.modalController.dismiss(null);
}
@@ -198,7 +188,7 @@ export class DocumentSetUpMeetingPage implements OnInit {
})
}
async saveTask(){
async saveTask() {
if(this.loggeduser.Profile == 'MDGPR') {
this.injectValidation()
@@ -207,33 +197,65 @@ export class DocumentSetUpMeetingPage implements OnInit {
let Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this.eventBody={
BodyType: '1',
Text: this.postData.Body.Text,
let data: DocumentSetUpMeeting = {
EventProcess: {
Body: this.postData.Body.Text,
Location: this.postData.Location,
StartDate: this.dateStart,
EndDate: this.dateEnd,
EventType: 'Reunião',
ParticipantsList: Attendees,
EventRecurrence: null,
Subject: this.postData.Subject,
IsRecurring: this.postData.IsRecurring,
Message: this.postData.Subject,
IsAllDayEvent: this.postData.IsRecurring,
},
Attachments: []
}
this.postData = {
EventId: '',
Subject: this.postData.Subject,
Body: this.eventBody,
Location: this.postData.Location,
CalendarId: '',
CalendarName: this.postData.CalendarName,
StartDate: this.dateStart,
EndDate: this.dateEnd,
EventType: 'Reunião',
Attendees: Attendees,
IsMeeting: false,
IsRecurring: false,
AppointmentState: 0,
TimeZone: 'UTC',
Organizer: null,
Category: 'Reunião',
HasAttachments: true,
EventRecurrence: null,
if(this.document.Documents) {
this.document.Documents.forEach( (ele) => {
console.log(ele)
data.Attachments.push({
ApplicationId: 361,
Source: 1,
SourceId: ele.docID || ele.docId || ele.DocId,
SourceName: ele.Assunto
})
});
} else {
data.Attachments.push({
ApplicationId: 8,
Source: 1,
SourceId: this.document.docID || this.document.docId || this.document.DocId,
SourceName: this.document.Assunto
})
}
this.attachments.forEach((e)=> {
console.log('e', e)
data.Attachments.push({
ApplicationId: e.ApplicationType,
Source: 1,
SourceId: e.Id,
SourceName: e.Assunto
})
})
const loader = this.toastService.loading()
try {
await this.documentService.setUpMeeting(data).toPromise()
this.toastService.successMessage('Processo criado')
this.close()
} catch(e) {
this.toastService.badRequest("Processo não criado")
} finally {
loader.remove()
}
// this.documentService.setUpMeeting()
}
async addParticipants() {
@@ -310,7 +332,7 @@ export class DocumentSetUpMeetingPage implements OnInit {
async getDoc() {
const modal = await this.modalController.create({
component: SearchPage,
cssClass: 'modal-width-100-width-background modal',
cssClass: 'modal modal-desktop modal-width-100-width-background',
componentProps: {
type: 'AccoesPresidenciais & ArquivoDespachoElect',
showSearchInput: true,
@@ -321,13 +343,13 @@ export class DocumentSetUpMeetingPage implements OnInit {
modal.onDidDismiss().then((res)=> {
if(res){
const data = res.data;
this.documents.push(data.selected);
this.attachments.push(data.selected);
}
});
}
removeAttachment(index: number) {
this.documents = this.documents.filter( (e, i) => index != i);
this.attachments = this.attachments.filter( (e, i) => index != i);
}
validateFormInputs(){