mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
issue 923
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { ModalController, NavParams } from '@ionic/angular';
|
||||
import * as moment from 'moment';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-edit-action',
|
||||
@@ -7,9 +13,99 @@ import { Component, OnInit } from '@angular/core';
|
||||
})
|
||||
export class EditActionPage implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
Form: FormGroup;
|
||||
validateFrom = false
|
||||
|
||||
ngOnInit() {
|
||||
public date: any;
|
||||
public disabled = false;
|
||||
public showSpinners = true;
|
||||
public showSeconds = false;
|
||||
public touchUi = false;
|
||||
public enableMeridian = false;
|
||||
public minDate: any;
|
||||
public maxDate: any;
|
||||
public stepHour = 1;
|
||||
public stepMinute = 5;
|
||||
public stepSecond = 5;
|
||||
public dateControlStart = new FormControl(moment("DD MM YYYY hh"));
|
||||
public dateControlEnd = new FormControl(moment("DD MM YYYY hh"));
|
||||
|
||||
folder: PublicationFolder;
|
||||
folderId: string;
|
||||
@Output() closeDesktopComponent= new EventEmitter<any>();
|
||||
@Output() updateDesktopComponent= new EventEmitter<any>();
|
||||
|
||||
constructor(
|
||||
private publicationsService: PublicationsService,
|
||||
private toastService: ToastService,
|
||||
private navParams: NavParams,
|
||||
private modalController: ModalController,
|
||||
) {
|
||||
this.folder = new PublicationFolder();
|
||||
this.folderId = this.navParams.get('folderId');
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.getPublicationDetail();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
|
||||
getPublicationDetail() {
|
||||
this.publicationsService.GetPresidentialAction(this.folderId).subscribe( res => {
|
||||
this.folder = res;
|
||||
|
||||
this.dateControlStart = new FormControl(moment(new Date(this.folder.DateBegin)));
|
||||
this.dateControlEnd = new FormControl(moment(new Date(this.folder.DateEnd)));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
get dateValid() {
|
||||
if (window.innerWidth <= 800) {
|
||||
return this.folder.DateBegin < this.folder.DateEnd? ['ok']: []
|
||||
} else {
|
||||
return ['ok']
|
||||
}
|
||||
}
|
||||
|
||||
runValidation() {
|
||||
this.validateFrom = true
|
||||
}
|
||||
|
||||
injectValidation() {
|
||||
|
||||
this.Form = new FormGroup({
|
||||
Subject: new FormControl(this.folder.Description, [
|
||||
Validators.required,
|
||||
// Validators.minLength(4)
|
||||
]),
|
||||
Date: new FormControl(this.dateValid, [
|
||||
Validators.required
|
||||
]),
|
||||
})
|
||||
}
|
||||
|
||||
async save() {
|
||||
let body = {
|
||||
ProcessId: this.folderId,
|
||||
Description: this.folder.Description,
|
||||
Detail: this.folder.Detail,
|
||||
DateBegin: this.folder.DateBegin,
|
||||
DateEnd: this.folder.DateEnd,
|
||||
ActionType: this.folder.ActionType,
|
||||
}
|
||||
console.log(body);
|
||||
|
||||
try {
|
||||
await this.publicationsService.UpdatePresidentialAction(body).toPromise()
|
||||
this.close();
|
||||
this.updateDesktopComponent.emit();
|
||||
this.toastService.successMessage('Acção presidencial atualizada')
|
||||
} catch (error) {
|
||||
this.toastService.badRequest('Não foi possivel atualizar a acção presidencial')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user