add message errors in new action.

This commit is contained in:
tiago.kayaya
2021-12-14 14:58:34 +01:00
parent e524062ed9
commit 7e5388e4e1
7 changed files with 41 additions and 28 deletions
@@ -66,7 +66,7 @@ export class NewActionPage implements OnInit {
private publication: PublicationsService,
private toastService: ToastService
) {
) {
this.folder = new PublicationFolder();
@@ -76,7 +76,7 @@ export class NewActionPage implements OnInit {
this.folder.DateBegin = new Date().toISOString()
this.folder.DateEnd = (new Date(new Date().getTime() + 15 * 60000)).toISOString()
}
ngOnInit() {
@@ -102,7 +102,13 @@ export class NewActionPage implements OnInit {
}
runValidation() {
this.validateFrom = true
this.validateFrom = true;
if(new Date(this.folder.DateBegin).toISOString() > new Date(this.folder.DateEnd).toISOString()){
this.toastService.badRequest("A data de início não pode ser superior a data de fim");
}
else if(this.folder.DateBegin > new Date().toISOString()){
this.toastService.badRequest("A data de início não pode ser superior a data actual");
}
}
injectValidation() {
@@ -134,8 +140,8 @@ export class NewActionPage implements OnInit {
DateEnd: this.folder.DateEnd,
ActionType: this.segment,
}
const loader = this.toastService.loading()
try {
@@ -144,7 +150,7 @@ export class NewActionPage implements OnInit {
this.toastService.successMessage("Ação presidencial criado");
this.close();
} catch (error) {
this.toastService.badRequest("Ação presidencial não criado");
} finally {
loader.remove()
@@ -156,5 +162,5 @@ export class NewActionPage implements OnInit {
close(){
this.modalController.dismiss();
}
}
+6 -1
View File
@@ -51,7 +51,9 @@ export class FileService {
private platform: Platform,
private loadingCtrl: LoadingController,
private http: HttpClient,
) { }
) {
this.headers = new HttpHeaders();
}
uploadFile(formData:any){
@@ -71,6 +73,9 @@ export class FileService {
params = params.set("path", guid);
this.headers = this.headers.set('responseType', 'blob');
this.headers = this.headers.set('Content-Type', 'application/octet-stream');
let options = {
headers: this.headers,
params: params
@@ -201,13 +201,11 @@ export class NewEventPage implements OnInit {
}
})
}
this.taskParticipants = removeDuplicate(this.taskParticipants);
this.taskParticipantsCc = removeDuplicate(this.taskParticipantsCc);
this.setIntervenient.emit(this.taskParticipants);
this.setIntervenientCC.emit(this.taskParticipantsCc);
}
@@ -307,7 +305,6 @@ export class NewEventPage implements OnInit {
close(){
this.deleteTemporaryData();
this.cloneAllmobileComponent.emit();
this.clearContact.emit();
this.setIntervenient.emit([]);
@@ -425,10 +422,8 @@ export class NewEventPage implements OnInit {
(id) => {
console.log(id);
const eventId: any = id;
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
return {
SourceTitle: e.Assunto,
@@ -149,9 +149,9 @@
<!-- <ion-fab-button (click)="addFile()" color="light">
<ion-icon name="document"></ion-icon>
</ion-fab-button> -->
<ion-fab-button (click)="addImage()" color="light">
<!-- <ion-fab-button (click)="addImage()" color="light">
<ion-icon name="image"></ion-icon>
</ion-fab-button>
</ion-fab-button> -->
<!-- <ion-fab-button class="hide-desktop" (click)="takePicture()" color="light">
<ion-icon name="camera"></ion-icon>
</ion-fab-button> -->
@@ -123,9 +123,9 @@
<!-- <ion-fab-button hidden (click)="addFile()" color="light">
<ion-icon name="document"></ion-icon>
</ion-fab-button> -->
<ion-fab-button (click)="addImage()" color="light">
<!-- <ion-fab-button (click)="addImage()" color="light">
<ion-icon name="image"></ion-icon>
</ion-fab-button>
</ion-fab-button> -->
<!-- <ion-fab-button (click)="takePicture()" color="light">
<ion-icon name="camera"></ion-icon>
</ion-fab-button> -->
@@ -250,6 +250,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if(msg.file.type == "application/img"){
let response:any = await this.fileService.getFile(msg.file.guid).toPromise();
console.log(response);
alert(response);
//this.openPreview(msg);
@@ -28,27 +28,27 @@ export class NewActionPage implements OnInit {
public stepMinute = 5;
public stepSecond = 5;
public endMinDate = new Date(new Date().getTime() + 15 * 60000);
Form: FormGroup;
validateFrom = false
public dateControlStart = new FormControl(moment("DD MM YYYY hh"));
public dateControlEnd = new FormControl(moment("DD MM YYYY hh"));
@Output() closeDesktopComponent= new EventEmitter<any>();
@Output() getActions= new EventEmitter<any>();
constructor(
private publication: PublicationsService,
private toastService: ToastService
) {
) {
this.folder = new PublicationFolder();
this.folder = Object.assign(this.folder, {
DateBegin: moment(new Date()),
DateEnd: moment(new Date(new Date().getTime() + 15 * 60000)),
DateBegin: new Date().toISOString(),
DateEnd: (new Date(new Date().getTime() + 15 * 60000)).toISOString(),
})
}
@@ -76,9 +76,15 @@ export class NewActionPage implements OnInit {
return ['ok']
}
}
runValidation() {
this.validateFrom = true
this.validateFrom = true;
if((new Date(this.folder.DateBegin).getTime()) > (new Date(this.folder.DateEnd).getTime())){
this.toastService._badRequest("A data de início não pode ser superior a data de fim");
}
else if(new Date(this.folder.DateBegin).getTime() > new Date().getTime()){
this.toastService._badRequest("A data de início não pode ser superior a data actual");
}
}
injectValidation() {
@@ -119,21 +125,21 @@ export class NewActionPage implements OnInit {
ActionType: this.segment,
}
console.log(this.folder);
const loader = this.toastService.loading()
try {
await this.publication.CreatePublicationFolder(this.folder).toPromise()
this.close();
this.toastService.successMessage('Acção presidencial criada')
this.toastService._successMessage('Acção presidencial criada')
this.getActions.emit()
} catch (error) {
this.toastService.badRequest('Não foi possivel criar a acção presidencial')
this.toastService._badRequest('Não foi possivel criar a acção presidencial')
} finally {
loader.remove()
}
}
close(){