...
 
Commits (2)
......@@ -2,7 +2,7 @@
class="m-poster-date-selector--input"
[class.selected]="hasDateSelected()"
mdl-datetime-picker
[date]="date"
[date]="getDate()"
(dateChange)="onDateChange($event)"
>
<input
......@@ -12,7 +12,7 @@
[hidden]="true"
/>
<m-tooltip icon="date_range">
{{ tooltipDate || 'now' }}
{{ getDate() || 'Post Immediately' }}
</m-tooltip>
<span></span>
</div>
......@@ -8,6 +8,7 @@ m-poster-date-selector {
.m-poster-date-selector--input {
align-items: center;
margin-right: -4px;
input {
font-size: 12px;
......
......@@ -14,8 +14,6 @@ export class PosterDateSelectorComponent {
@Input() dateFormat: string = 'short';
tooltipDate: string;
onDateChange(newDate) {
const validation = this.validate(newDate);
if (validation !== true) {
......@@ -23,14 +21,14 @@ export class PosterDateSelectorComponent {
return;
}
this.date = this.tooltipDate = newDate;
this.date = newDate;
newDate = new Date(newDate).getTime();
newDate = Math.floor(+newDate / 1000);
this.dateChange.emit(newDate);
}
hasDateSelected() {
return this.tooltipDate && this.tooltipDate !== '';
return this.date && this.date !== '';
}
validate(newDate) {
......@@ -50,4 +48,12 @@ export class PosterDateSelectorComponent {
return true;
}
getDate() {
const tempDate = parseInt(this.date);
if (tempDate) {
this.date = new Date(tempDate * 1000).toString();
}
return this.date;
}
}
......@@ -23,7 +23,11 @@ export class MaterialDateTimePickerDirective {
@HostListener('click')
onHostClick() {
if (!this.open) {
this.picker = new DateTimePicker()
let options = {};
if (this.date) {
options = { default: new Date(this.date).toString() };
}
this.picker = new DateTimePicker(options)
.on('submit', this.submitCallback.bind(this))
.on('close', this.close.bind(this));
this.open = true;
......
......@@ -522,5 +522,6 @@
class="mdl-card__supporting-text m-activity--pending"
*ngIf="isScheduled(activity.time_created)"
>
This is a scheduled post.
This activity is scheduled to be shown on {{activity.time_created * 1000 |
date:'medium'}}.
</div>
......@@ -32,7 +32,7 @@ export class PosterComponent {
meta: any = {
message: '',
wire_threshold: null,
time_created: Math.floor(Date.now() / 1000),
time_created: null,
};
tags = [];
minds = window.Minds;
......@@ -56,8 +56,6 @@ export class PosterComponent {
protected resizeSubject: Subject<number> = new Subject<number>();
protected time_created: any;
constructor(
public session: Session,
public client: Client,
......@@ -195,7 +193,6 @@ export class PosterComponent {
this.attachment.reset();
this.meta = { wire_threshold: null };
this.inProgress = false;
this.time_created = null;
})
.catch(e => {
this.inProgress = false;
......