This commit is contained in:
Peter Maquiran
2023-07-25 15:56:42 +01:00
parent a26f7c4f75
commit 2628bc91e8
6 changed files with 111 additions and 66 deletions
+3 -1
View File
@@ -33,6 +33,7 @@ import { PermissionService } from 'src/app/services/permission.service';
import { environment } from 'src/environments/environment';
import { RoleIdService } from 'src/app/services/role-id.service'
import { EventListStore } from 'src/app/models/agenda/AgendaEventList';
import { ContactsService } from 'src/app/services/contacts.service';
@Component({
selector: 'app-agenda',
@@ -180,7 +181,8 @@ export class AgendaPage implements OnInit {
private backgroundservice: BackgroundService,
public ThemeService: ThemeService,
public p: PermissionService,
public RoleIdService: RoleIdService
public RoleIdService: RoleIdService,
private ContactsService: ContactsService
) {
this.dateAdapter.setLocale('es');
@@ -17,6 +17,7 @@ import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-pick
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'
import { environment } from 'src/environments/environment';
import { ContactsService } from 'src/app/services/contacts.service';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -96,7 +97,8 @@ export class EditEventPage implements OnInit {
private toastService: ToastService,
private router: Router,
public ThemeService: ThemeService,
private httpErrorHandle: HttpErrorHandle
private httpErrorHandle: HttpErrorHandle,
private contactsService: ContactsService
) {
/* this.postEvent = new Event(); */
@@ -108,6 +110,20 @@ export class EditEventPage implements OnInit {
this.caller = this.navParams.get('caller');
this.initCalendarName = this.postEvent.CalendarName;
for(const index in this.postEvent.Attendees) {
const user = this.postEvent.Attendees[index]
const userData = this.contactsService.constacts.find(e => user.EmailAddress == e.EmailAddress)
if(userData) {
this.postEvent.Attendees[index].UserType = userData.UserType
}
}
if(this.postEvent){
if( this.postEvent.Body){
if(typeof(this.postEvent.Body.Text) == 'string'){
+6
View File
@@ -17,6 +17,8 @@ export class ContactsService {
loggeduser: LoginUserRespose;
headers: HttpHeaders;
constacts: EventPerson[] = []
constructor(
private http: HttpClient,
user: AuthService,
@@ -26,6 +28,10 @@ export class ContactsService {
this.changeProfileService.registerCallback(() => {
this.setHeader()
})
this.getContacts("").subscribe( result => {
this.constacts = result
})
}
setHeader() {
@@ -15,7 +15,7 @@
<ion-content>
<div class="main-content">
<div class="ion-item-container" [class.input-error]="Form?.get('Subject')?.invalid && validateFrom ">
<ion-input autocomplete="on" autocorrect="on" spellcheck="true" placeholder="Assunto*" [(ngModel)]="postEvent.Subject"></ion-input>
<ion-input autocomplete="on" autocorrect="on" spellcheck="true" placeholder="Assunto*" [(ngModel)]="_postEvent.Subject"></ion-input>
</div>
<div *ngIf="Form && validateFrom" >
<div *ngIf="Form.get('Subject').invalid " class="input-errror-message">
@@ -34,7 +34,7 @@
<ion-icon slot="start" src="assets/images/icons-location.svg"></ion-icon>
</div>
<div class="ion-input-class flex-grow-1" [class.input-error]="Form?.get('Location')?.invalid && validateFrom ">
<ion-input autocomplete="on" autocorrect="on" spellcheck="true" placeholder="Localização*" [(ngModel)]="postEvent.Location"></ion-input>
<ion-input autocomplete="on" autocorrect="on" spellcheck="true" placeholder="Localização*" [(ngModel)]="_postEvent.Location"></ion-input>
</div>
</div>
<!-- Error messages -->
@@ -80,7 +80,7 @@
<div class="ion-input-class flex-grow-1">
<mat-form-field appearance="none" floatLabel="never" class="width-100 " >
<mat-select placeholder="Selecione agenda*" [(ngModel)]="postEvent.CalendarName" [disabled]=true>
<mat-select placeholder="Selecione agenda*" [(ngModel)]="_postEvent.CalendarName" [disabled]=true>
<mat-option *ngFor="let calendars of CalendarNamesOptions" value="{{calendars}}">
Agenda {{ calendars }}
</mat-option>
@@ -100,7 +100,7 @@
<mat-form-field appearance="none" floatLabel="never" class="width-100" required>
<!-- <input matInput type="text" > -->
<mat-select placeholder="Selecione o tipo de evento*" matInput [(ngModel)]="postEvent.Category" >
<mat-select placeholder="Selecione o tipo de evento*" matInput [(ngModel)]="_postEvent.Category" >
<mat-option value="Reunião">
Reunião
</mat-option>
@@ -130,7 +130,7 @@
<mat-form-field appearance="none" floatLabel="never" class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Choose a date"
[(ngModel)]="postEvent.StartDate"
[(ngModel)]="_postEvent.StartDate"
[max]="maxDate"
[disabled]="disabled"
>
@@ -158,10 +158,10 @@
<mat-form-field appearance="none" floatLabel="never" floatLabel="never" class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="fim"
placeholder="Choose a date"
[(ngModel)]="postEvent.EndDate"
[(ngModel)]="_postEvent.EndDate"
[max]="maxDate"
[disabled]="disabled"
[min]="postEvent.StartDate"
[min]="_postEvent.StartDate"
>
<mat-datepicker-toggle id="new-fim" matSuffix [for]="fim"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #fim
@@ -186,7 +186,7 @@
<mat-form-field appearance="none" floatLabel="never" class="width-100" value="false" interface="action-sheet" required>
<mat-select
placeholder="Selecione repetição*"
[(ngModel)]="postEvent.EventRecurrence.Type"
[(ngModel)]="_postEvent.EventRecurrence.Type"
(ngModelChange)="onSelectedRecurringChanged($event)">
<mat-option
*ngFor="let recurring of recurringTypes"
@@ -200,7 +200,7 @@
</div>
</div> -->
<div *ngIf="postEvent.EventRecurrence.Type != '-1'" class="container-div width-100">
<div *ngIf="_postEvent.EventRecurrence.Type != '-1'" class="container-div width-100">
<div class="ion-item-class-2 d-flex">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
@@ -210,9 +210,9 @@
<mat-form-field class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="occurrrence"
placeholder="Choose a date"
[(ngModel)]="postEvent.EventRecurrence.LastOccurrence"
[(ngModel)]="_postEvent.EventRecurrence.LastOccurrence"
[disabled]="disabled"
[min]="postEvent.EndDate"
[min]="_postEvent.EndDate"
>
<mat-datepicker-toggle id="last-occurrence" matSuffix [for]="occurrrence"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #occurrrence
@@ -285,7 +285,7 @@
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
</div>
<div class="ion-input-class-no-height width-100">
<ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" [(ngModel)]="postEvent.Body.Text" placeholder="Detalhes" rows="6" cols="20"></ion-textarea>
<ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" [(ngModel)]="_postEvent.Body.Text" placeholder="Detalhes" rows="6" cols="20"></ion-textarea>
</div>
</div>
</div>
@@ -14,6 +14,7 @@ import { ParticipantsPipe } from 'src/app/pipes/participants.pipe';
import { ThemeService } from 'src/app/services/theme.service'
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { ContactsService } from 'src/app/services/contacts.service'
@Component({
selector: 'app-edit-event',
@@ -73,6 +74,9 @@ export class EditEventPage implements OnInit {
@ViewChild('inicio') inicio: any;
@ViewChild('picker1') picker1: any;
@Input() _postEvent: Event;
public options = [
{ value: true, label: 'True' },
{ value: false, label: 'False' }
@@ -95,24 +99,39 @@ export class EditEventPage implements OnInit {
public alertController: AlertController,
private attachmentsService: AttachmentsService,
public ThemeService: ThemeService,
private httpErrorHandle: HttpErrorHandle
private httpErrorHandle: HttpErrorHandle,
private contactsService: ContactsService
) {}
ngOnInit() {
this._postEvent = this.postEvent
if(!this.restoreTemporaryData()) {
// clear
if(this.postEvent) {
if( this.postEvent.Body){
if(typeof(this.postEvent.Body.Text) == 'string'){
this.postEvent.Body.Text = this.postEvent.Body.Text.replace(/<[^>]+>/g, '');
if(this._postEvent) {
if( this._postEvent.Body){
if(typeof(this._postEvent.Body.Text) == 'string'){
this._postEvent.Body.Text = this._postEvent.Body.Text.replace(/<[^>]+>/g, '');
}
}
}
if (this.postEvent.Attendees != null) {
const result = this.participantsPipe.transform(this.postEvent.Attendees)
for(const index in this._postEvent.Attendees) {
const user = this._postEvent.Attendees[index]
const userData = this.contactsService.constacts.find(e => user.EmailAddress == e.EmailAddress)
if(userData) {
this._postEvent.Attendees[index].UserType = userData.UserType
} else {
console.log('user not set')
}
}
if (this._postEvent.Attendees != null) {
const result = this.participantsPipe.transform(this._postEvent.Attendees)
this.taskParticipants = result.taskParticipants
this.taskParticipantsCc = result.taskParticipantsCc
@@ -124,23 +143,25 @@ export class EditEventPage implements OnInit {
}
}
this.initCalendarName = this.postEvent.CalendarName;
this.initCalendarName = this._postEvent.CalendarName;
this.getRecurrenceTypes();
setTimeout(() => {
this.postEvent.EventRecurrence.Type = this.postEvent.EventRecurrence.Type.toString();
this._postEvent.EventRecurrence.Type = this._postEvent.EventRecurrence.Type.toString();
}, 500);
this.CalendarNameOwnerName = this.eventsService.detectCalendarNameByCalendarId(this.postEvent.CalendarId)
this.CalendarNameOwnerName = this.eventsService.detectCalendarNameByCalendarId(this._postEvent.CalendarId)
this.changeAgenda()
}
ngOnChanges(changes: any): void {
this.loadedEventAttachments = this.postEvent.Attachments
this.loadedEventAttachments = this._postEvent.Attachments
}
close() {
@@ -166,30 +187,30 @@ export class EditEventPage implements OnInit {
injectValidation() {
if (typeof(this.postEvent.EventRecurrence.Type) == 'number') {
const str: any = this.postEvent.EventRecurrence.Type.toString()
this.postEvent.EventRecurrence.Type = str
if (typeof(this._postEvent.EventRecurrence.Type) == 'number') {
const str: any = this._postEvent.EventRecurrence.Type.toString()
this._postEvent.EventRecurrence.Type = str
}
this.Form = new FormGroup({
Subject: new FormControl(this.postEvent.Subject, [
Subject: new FormControl(this._postEvent.Subject, [
Validators.required,
// Validators.minLength(4)
]),
Location: new FormControl(this.postEvent.Location, [
Location: new FormControl(this._postEvent.Location, [
Validators.required,
]),
CalendarName: new FormControl(this.postEvent.CalendarName),
Categories: new FormControl(this.postEvent.Category, [
CalendarName: new FormControl(this._postEvent.CalendarName),
Categories: new FormControl(this._postEvent.Category, [
Validators.required
]),
dateOccurrence: new FormControl(this.postEvent.EventRecurrence.Type.toString() == '-1' ? ['ok']: this.postEvent.EventRecurrence.LastOccurrence && new Date(this.postEvent.EventRecurrence.LastOccurrence).getTime() > new Date(this.postEvent.EndDate).getTime() ? 'ok': null, [
dateOccurrence: new FormControl(this._postEvent.EventRecurrence.Type.toString() == '-1' ? ['ok']: this._postEvent.EventRecurrence.LastOccurrence && new Date(this._postEvent.EventRecurrence.LastOccurrence).getTime() > new Date(this._postEvent.EndDate).getTime() ? 'ok': null, [
Validators.required
]),
participantes: new FormControl(this.taskParticipants, [
// Validators.required
]),
Date: new FormControl( new Date(this.postEvent.StartDate).toLocaleString('pt') <= new Date(this.postEvent.EndDate).toLocaleString('pt')? 'ok': null,[
Date: new FormControl( new Date(this._postEvent.StartDate).toLocaleString('pt') <= new Date(this._postEvent.EndDate).toLocaleString('pt')? 'ok': null,[
Validators.required
]),
@@ -254,10 +275,10 @@ export class EditEventPage implements OnInit {
if(ev.length > 1){
this.postEvent.EventRecurrence.Type = ev.filter(data => data != '-1');
this._postEvent.EventRecurrence.Type = ev.filter(data => data != '-1');
}
if(ev.length == 0){
this.postEvent.EventRecurrence.Type = "-1";
this._postEvent.EventRecurrence.Type = "-1";
}
}
@@ -282,10 +303,10 @@ export class EditEventPage implements OnInit {
defineLastOccurrence(valor:number, opcao:boolean){
var time = new Date(this.postEvent.EndDate);
var time = new Date(this._postEvent.EndDate);
if (opcao == true) {
time.setDate(time.getDate() + valor);
this.postEvent.EventRecurrence.LastOccurrence = time;
this._postEvent.EventRecurrence.LastOccurrence = time;
} else {
time = new Date(
time.getFullYear() + valor,
@@ -294,7 +315,7 @@ export class EditEventPage implements OnInit {
time.getHours(),
time.getMinutes()
);
this.postEvent.EventRecurrence.LastOccurrence = time;
this._postEvent.EventRecurrence.LastOccurrence = time;
}
}
@@ -309,27 +330,27 @@ export class EditEventPage implements OnInit {
return false
}
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this._postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
if(!this.postEvent.EventRecurrence.hasOwnProperty('Type')) {
this.postEvent.EventRecurrence.Type = '-1'
if(!this._postEvent.EventRecurrence.hasOwnProperty('Type')) {
this._postEvent.EventRecurrence.Type = '-1'
} else {
}
if(this.postEvent.EventRecurrence.Type == undefined) {
this.postEvent.EventRecurrence.Type = '-1'
if(this._postEvent.EventRecurrence.Type == undefined) {
this._postEvent.EventRecurrence.Type = '-1'
}
this.showLoader = true;
try {
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
await this.eventsService.editEvent(this.postEvent, 2, 3).toPromise()
if(this.initCalendarName != this.postEvent.CalendarName) {
await this.eventsService.editEvent(this._postEvent, 2, 3).toPromise()
if(this.initCalendarName != this._postEvent.CalendarName) {
let body = {
"EventId": this.postEvent.EventId,
"CalendarDestinationName": this.postEvent.CalendarName,
"EventId": this._postEvent.EventId,
"CalendarDestinationName": this._postEvent.CalendarName,
}
try {
@@ -339,11 +360,11 @@ export class EditEventPage implements OnInit {
this.showLoader = false;
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
} else {
await this.eventsService.editEvent(this.postEvent, 2, 3, this.postEvent.CalendarId).toPromise()
if(this.initCalendarName != this.postEvent.CalendarName) {
await this.eventsService.editEvent(this._postEvent, 2, 3, this._postEvent.CalendarId).toPromise()
if(this.initCalendarName != this._postEvent.CalendarName) {
let body = {
"EventId": this.postEvent.EventId,
"CalendarDestinationName": this.postEvent.CalendarName,
"EventId": this._postEvent.EventId,
"CalendarDestinationName": this._postEvent.CalendarName,
}
try {
@@ -382,7 +403,7 @@ export class EditEventPage implements OnInit {
//data.selected
const DocumentToSave = {
SourceTitle: e.SourceName,
ParentId: this.postEvent.EventId,
ParentId: this._postEvent.EventId,
Source: '1',
SourceId: e.SourceId,
ApplicationId: e.ApplicationId.toString(),
@@ -429,7 +450,7 @@ export class EditEventPage implements OnInit {
saveTemporaryData() {
window['temp.path:/home/agenda/edit-event.component.ts'] = {
postEvent: this.postEvent,
postEvent: this._postEvent,
eventBody: this.eventBody,
segment: this.segment
}
@@ -440,7 +461,7 @@ export class EditEventPage implements OnInit {
const restoredData = window['temp.path:/home/agenda/edit-event.component.ts']
if(JSON.stringify(restoredData) != "{}" && undefined != restoredData){
this.postEvent = restoredData.postEvent
this._postEvent = restoredData.postEvent
this.eventBody = restoredData.eventBody
this.segment = restoredData.segment
@@ -456,7 +477,7 @@ export class EditEventPage implements OnInit {
}
async getAttachments(eventId: string){
if(this.postEvent.HasAttachments) {
if(this._postEvent.HasAttachments) {
let rest: any;
try {
rest = this.attachmentsService.getAttachmentsById(eventId).toPromise()
@@ -497,7 +518,7 @@ export class EditEventPage implements OnInit {
const ApplicationIdDocumentToSave: any = {
SourceName: data.selected.Assunto,
ParentId: this.postEvent.EventId,
ParentId: this._postEvent.EventId,
SourceId: data.selected.Id,
Stakeholders: data.selected.Stakeholders | data.selected.EntidadeOrganicaNome,
ApplicationId: data.selected.ApplicationType.toString(),
@@ -528,11 +549,11 @@ export class EditEventPage implements OnInit {
} else if (this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Oficial']) {
this.CalendarNamesOptions = ['Oficial']
this.postEvent.CalendarName = 'Oficial'
this._postEvent.CalendarName = 'Oficial'
} else if (this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Pessoal']) {
this.CalendarNamesOptions = ['Pessoal']
this.postEvent.CalendarName = 'Pessoal'
this._postEvent.CalendarName = 'Pessoal'
} else {
this.CalendarNamesOptions = ['Oficial', 'Pessoal']
+6 -6
View File
@@ -1,12 +1,12 @@
export let versionData = {
"shortSHA": "54a6fb5b6",
"SHA": "54a6fb5b6eb5d1afc53a6067dfd64519c3c3fa87",
"shortSHA": "a26f7c4f7",
"SHA": "a26f7c4f7507ee84a621083e23ee50d3c5ecc092",
"branch": "developer-catch-merge",
"lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Mon Jul 24 13:52:48 2023 +0100'",
"lastCommitMessage": "change",
"lastCommitNumber": "5107",
"lastCommitTime": "'Tue Jul 25 13:47:48 2023 +0100'",
"lastCommitMessage": "fix aparecer",
"lastCommitNumber": "5108",
"change": "",
"changeStatus": "On branch developer-catch-merge\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/modals/create-process/create-process.page.ts\n\tmodified: src/app/models/Excludetask.ts\n\tmodified: src/app/services/processes.service.ts\n\tmodified: version/git-version.ts",
"changeStatus": "On branch developer-catch-merge\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/pages/agenda/agenda.page.ts\n\tmodified: src/app/pages/agenda/edit-event/edit-event.page.ts\n\tmodified: src/app/services/contacts.service.ts\n\tmodified: src/app/shared/agenda/edit-event/edit-event.page.html\n\tmodified: src/app/shared/agenda/edit-event/edit-event.page.ts",
"changeAuthor": "peter.maquiran"
}