mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Add faild and success message
This commit is contained in:
@@ -16,6 +16,8 @@ import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { ViewPublicationsPage } from '../view-publications/view-publications.page';
|
||||
import { LoadingService } from 'src/app/services/loading.service';
|
||||
import { BadRequestComponent } from '../../popover/bad-request/bad-request.component';
|
||||
import { SuccessMessageComponent } from '../../popover/success-message/success-message.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-publication',
|
||||
@@ -137,7 +139,7 @@ export class NewPublicationPage implements OnInit {
|
||||
async save(){
|
||||
if(this.publicationType == '3'){
|
||||
|
||||
if(this.capturedImage != ''){
|
||||
if(this.capturedImage != '') {
|
||||
this.publication = {
|
||||
DateIndex: this.publication.DateIndex,
|
||||
DocumentId:this.publication.DocumentId,
|
||||
@@ -151,8 +153,18 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
console.log('Edit change image');
|
||||
console.log(this.publication);
|
||||
this.publications.UpdatePublication(this.publication.ProcessId, this.publication);
|
||||
this.goBack();
|
||||
|
||||
try {
|
||||
console.log(this.publication);
|
||||
|
||||
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||
this.successMessage()
|
||||
|
||||
this.goBack();
|
||||
} catch (error) {
|
||||
this.badRequest()
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
this.publication = {
|
||||
@@ -166,10 +178,17 @@ export class NewPublicationPage implements OnInit {
|
||||
FileBase64: this.publication.FileBase64,
|
||||
FileExtension: 'jpeg',
|
||||
}
|
||||
console.log('Edit - keep image');
|
||||
console.log(this.publication);
|
||||
this.publications.UpdatePublication(this.publication.ProcessId, this.publication);
|
||||
this.goBack();
|
||||
|
||||
try {
|
||||
console.log(this.publication);
|
||||
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||
this.successMessage()
|
||||
|
||||
this.goBack();
|
||||
} catch (error) {
|
||||
this.badRequest()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
@@ -186,10 +205,16 @@ export class NewPublicationPage implements OnInit {
|
||||
FileExtension: 'jpeg',
|
||||
}
|
||||
|
||||
console.log(this.publication);
|
||||
this.publications.CreatePublication(this.folderId, this.publication);
|
||||
try {
|
||||
console.log(this.publication);
|
||||
await this.publications.CreatePublication(this.folderId, this.publication).toPromise()
|
||||
this.successMessage()
|
||||
|
||||
this.goBackToViewPublications.emit();
|
||||
} catch (error) {
|
||||
this.badRequest()
|
||||
}
|
||||
|
||||
this.goBackToViewPublications.emit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,4 +273,39 @@ export class NewPublicationPage implements OnInit {
|
||||
this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
|
||||
} */
|
||||
|
||||
|
||||
async successMessage(message?: string) {
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: SuccessMessageComponent,
|
||||
componentProps: {
|
||||
message: message || 'Processo efetuado' ,
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
|
||||
modal.present()
|
||||
|
||||
setTimeout(()=>{
|
||||
modal.dismiss()
|
||||
},3000)
|
||||
|
||||
}
|
||||
|
||||
async badRequest() {
|
||||
const modal = await this.modalController.create({
|
||||
component: BadRequestComponent,
|
||||
componentProps: {
|
||||
message: 'Processo não realizado com sucesso',
|
||||
},
|
||||
cssClass: 'modal modal-desktop'
|
||||
});
|
||||
|
||||
modal.present()
|
||||
|
||||
setTimeout(()=>{
|
||||
modal.dismiss()
|
||||
},3000)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user