diff --git a/src/app/pages/agenda/view-event/view-event.page.ts b/src/app/pages/agenda/view-event/view-event.page.ts index 406312249..4d7378c27 100644 --- a/src/app/pages/agenda/view-event/view-event.page.ts +++ b/src/app/pages/agenda/view-event/view-event.page.ts @@ -109,16 +109,20 @@ export class ViewEventPage implements OnInit { }); } - loadEvent(){ + loadEvent() { const loader = this.toastService.loading(); this.eventsService.getEvent(this.eventId).subscribe(res => { this.loadedEvent = res; - - console.log(res); - /* this.today = new Date(res.StartDate); this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */ loader.remove() + }, ()=>{ + + loader.remove() + this.toastService.badRequest('Este evento já não existe na sua agenda') + this.modalController.dismiss('Eevent not Foud'); + this.router.navigate(['/home/agenda']); + }); } diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts index b23d7951f..ad25f1dfc 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -14,6 +14,7 @@ import { Camera, CameraOptions } from '@ionic-native/camera/ngx'; import { ToastService } from 'src/app/services/toast.service'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { ThemePalette } from '@angular/material/core'; +import { formatDate } from 'src/plugin/momentG.js' @Component({ selector: 'app-new-publication', @@ -218,14 +219,16 @@ export class NewPublicationPage implements OnInit { } else { - + const date = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss') + alert(date) + this.publication = { - DateIndex: new Date(), + DateIndex: date, DocumentId:null, ProcessId:this.folderId, Title: this.pub.Title, Message: this.pub.Message, - DatePublication: new Date(), + DatePublication: date, OriginalFileName: this.capturedImageTitle, FileBase64: this.capturedImage, FileExtension: 'jpeg', diff --git a/src/app/pages/publications/publications.page.html b/src/app/pages/publications/publications.page.html index 2dc6c80a3..05567c79b 100644 --- a/src/app/pages/publications/publications.page.html +++ b/src/app/pages/publications/publications.page.html @@ -35,7 +35,7 @@
- diff --git a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.ts b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.ts index 8eb0251e8..0066df0bc 100644 --- a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.ts +++ b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.ts @@ -119,6 +119,7 @@ export class PublicationDetailPage implements OnInit { componentProps:{ publicationType: publicationType, publication: this.publication, + folderId: this.folderId }, cssClass: 'new-publication modal modal-desktop', backdropDismiss: false diff --git a/src/app/pages/publications/view-publications/view-publications.page.html b/src/app/pages/publications/view-publications/view-publications.page.html index 77480b5d8..b49b541c0 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.html +++ b/src/app/pages/publications/view-publications/view-publications.page.html @@ -1,6 +1,5 @@ - @@ -24,13 +23,13 @@ - + -
+
{ this.loadedEvent = res; this.today = new Date(res.StartDate); @@ -99,6 +99,8 @@ export class ViewEventPage implements OnInit { this.viewEventDetailDismiss.emit({ type: 'close' }) + + this.toastService.badRequest('Este evento já não existe na sua agenda') }) ; } diff --git a/src/app/shared/publication/view-publications/view-publications.page.ts b/src/app/shared/publication/view-publications/view-publications.page.ts index 825343571..3cb0a5e9a 100644 --- a/src/app/shared/publication/view-publications/view-publications.page.ts +++ b/src/app/shared/publication/view-publications/view-publications.page.ts @@ -39,6 +39,10 @@ export class ViewPublicationsPage implements OnInit { ngOnInit() { console.log(this.folderId); + + if(typeof(this.folderId) == 'object') { + this.folderId = this.folderId['ProcessId'] + } this.getPublications(); this.getPublicationDetail(); @@ -47,6 +51,10 @@ export class ViewPublicationsPage implements OnInit { ngOnChanges(changes: any): void { console.log(this.folderId) + if(typeof(this.folderId) == 'object') { + this.folderId = this.folderId['ProcessId'] + } + this.getPublications(); this.getPublicationDetail(); } diff --git a/src/plugin/momentG.js b/src/plugin/momentG.js index cf1d662b1..dedd24f3a 100644 --- a/src/plugin/momentG.js +++ b/src/plugin/momentG.js @@ -60,5 +60,74 @@ class momentG { } module.exports = { - momentG: momentG.run -}; \ No newline at end of file + momentG: momentG.run, + formatDate: formatDate +}; + + + +var monthNames = [ + "January", "February", "March", "April", "May", "June", "July", + "August", "September", "October", "November", "December" +]; +var dayOfWeekNames = [ + "Sunday", "Monday", "Tuesday", + "Wednesday", "Thursday", "Friday", "Saturday" +]; + +function formatDate(date, patternStr){ + if (!patternStr) { + patternStr = 'M/d/yyyy'; + } + var day = date.getDate(), + month = date.getMonth(), + year = date.getFullYear(), + hour = date.getHours(), + minute = date.getMinutes(), + second = date.getSeconds(), + miliseconds = date.getMilliseconds(), + h = hour % 12, + hh = twoDigitPad(h), + HH = twoDigitPad(hour), + mm = twoDigitPad(minute), + ss = twoDigitPad(second), + aaa = hour < 12 ? 'AM' : 'PM', + EEEE = dayOfWeekNames[date.getDay()], + EEE = EEEE.substr(0, 3), + dd = twoDigitPad(day), + M = month + 1, + MM = twoDigitPad(M), + MMMM = monthNames[month], + MMM = MMMM.substr(0, 3), + yyyy = year + "", + yy = yyyy.substr(2, 2) + ; + // checks to see if month name will be used + patternStr = patternStr + .replace('hh', hh).replace('h', h) + .replace('HH', HH).replace('H', hour) + .replace('mm', mm).replace('m', minute) + .replace('ss', ss).replace('s', second) + .replace('S', miliseconds) + .replace('dd', dd).replace('d', day) + + .replace('EEEE', EEEE).replace('EEE', EEE) + .replace('yyyy', yyyy) + .replace('yy', yy) + .replace('aaa', aaa); + if (patternStr.indexOf('MMM') > -1) { + patternStr = patternStr + .replace('MMMM', MMMM) + .replace('MMM', MMM); + } + else { + patternStr = patternStr + .replace('MM', MM) + .replace('M', M); + } + return patternStr; +} + +function twoDigitPad(num) { + return num < 10 ? "0" + num : num; +} \ No newline at end of file