import { Component } from '@angular/core'; import { AlertController, ToastController, Events } from 'ionic-angular'; import { DateIdUtil } from '@canvuus-internal/mvp0-task-core'; import { UniversalAttachment } from '@canvuus-internal/mvp0-task-data'; import { LocalUserService } from '@canvuus-internal/mvp0-task-view'; import { CommonEvents } from '@canvuus-internal/mvp0-task-view'; @Component({ selector: 'mvp0-universal-attachment', // templateUrl: 'mvp0-universal-attachment.html', template: ` {{title}}

` }) export class Mvp0UniversalAttachmentComponent { // temporary title: string; public data: UniversalAttachment; constructor(private alertCtrl: AlertController, private toastCtrl: ToastController, private events: Events, private localUserService: LocalUserService ) { // console.log('Hello Mvp0UniversalAttachment Component'); // temporary this.data = new UniversalAttachment(); this.data.userId = this.localUserService.currentUserId; // .... // tbd.... this.title = '(Title)'; } // tbd refreshData(_data: UniversalAttachment): void { console.log('Mvp0UniversalAttachmentComponent: >>> refreshData() _data = ' + _data); if (_data) { this.data = _data.clone(); // ?? } else { // ???? } // tbd.... if(this.data.title) { this.title = this.data.title; } else { // ??? let todayId = this.localUserService.todayId; this.title = DateIdUtil.getLocaleDateString(todayId); } // console.log('>>> refreshData() this.data = ' + this.data); } saveAttachment(): void { // console.log('saveAttachment()'); // ??? this.events.publish(CommonEvents.MVP0_DATA_UNIVERSALATTACHMENT_UPDATE); } }