This commit is contained in:
tiago.kayaya
2021-06-30 15:01:30 +01:00
12 changed files with 176 additions and 153 deletions
@@ -18,6 +18,7 @@ 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 { ToastService } from 'src/app/services/toast.service';
@Component({
selector: 'app-new-publication',
@@ -52,6 +53,7 @@ export class NewPublicationPage implements OnInit {
private navParams: NavParams,
private publications: PublicationsService,
private camera: Camera,
private toastService: ToastService,
) {
this.publicationType = this.navParams.get('publicationType');
@@ -112,7 +114,7 @@ export class NewPublicationPage implements OnInit {
if(this.publicationType == '3'){
console.log(this.navParams.get('publication'));
if(this.capturedImage != ''){
if(this.capturedImage != '') {
this.publication = {
DateIndex: this.publication.DateIndex,
DocumentId:this.publication.DocumentId,
@@ -124,10 +126,18 @@ export class NewPublicationPage implements OnInit {
FileBase64: this.capturedImage,
FileExtension: 'jpeg',
}
console.log('Edit change image');
console.log(this.publication);
this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise();
this.close();
try {
console.log(this.publication);
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
this.toastService.successMessage("Publicação criado")
this.close();
} catch (error) {
this.toastService.badRequest("Publicação não criado")
}
}
else{
this.publication = {
@@ -141,10 +151,18 @@ 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).toPromise();
this.close();
/* console.log('Edit - keep image');
console.log(this.publication); */
try {
console.log(this.publication);
await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
this.toastService.successMessage("Publicação criado")
this.close();
} catch (error) {
this.toastService.badRequest("Publicação não criado")
}
}
}
else{
@@ -164,6 +182,19 @@ export class NewPublicationPage implements OnInit {
console.log(this.publication); */
this.publications.CreatePublication(this.folderId, this.publication).toPromise();
this.close();
try {
console.log(this.publication);
await this.publications.CreatePublication(this.folderId, this.publication).toPromise()
this.toastService.successMessage("Publicação criado")
this.close();
} catch (error) {
this.toastService.badRequest("Publicação não criado")
}
}
}
@@ -177,13 +208,13 @@ export class NewPublicationPage implements OnInit {
this.capturedImage = '';
}
setTitle(){
if(this.publicationType == '1'){
if(this.publicationType == '1') {
this.publicationTitle = 'Nova Publicação Rápida';
}
else if(this.publicationType == '2'){
else if(this.publicationType == '2') {
this.publicationTitle = 'Nova Publicação';
}
else if(this.publicationType == '3'){
else if(this.publicationType == '3') {
this.publicationTitle = 'Editar Publicação';
this.pub = this.navParams.get('publication');
}