Allows setting DATE values for DTSTART and DUE

This commit is contained in:
korelstar 2016-10-25 20:46:17 +02:00
parent a86a734b06
commit 88436ce862
8 changed files with 141 additions and 6 deletions

View file

@ -76,6 +76,16 @@ angular.module('Tasks').run([
sameElse: '[' + t('tasks', 'Due on') + '] MMM DD, YYYY, HH:mm'
}
});
moment.locale('details_allday', {
calendar: {
lastDay: '[' + t('tasks', 'Due yesterday') + ']',
sameDay: '[' + t('tasks', 'Due today') + ']',
nextDay: '[' + t('tasks', 'Due tomorrow') + ']',
lastWeek: '[' + t('tasks', 'Due on') + '] MMM DD, YYYY',
nextWeek: '[' + t('tasks', 'Due on') + '] MMM DD, YYYY',
sameElse: '[' + t('tasks', 'Due on') + '] MMM DD, YYYY'
}
});
moment.locale('start', {
calendar: {
lastDay: '[' + t('tasks', 'Started yesterday') + '], HH:mm',
@ -92,6 +102,22 @@ angular.module('Tasks').run([
}
}
});
moment.locale('start_allday', {
calendar: {
lastDay: '[' + t('tasks', 'Started yesterday') + ']',
sameDay: '[' + t('tasks', 'Starts today') + ']',
nextDay: '[' + t('tasks', 'Starts tomorrow') + ']',
lastWeek: '[' + t('tasks', 'Started on') + '] MMM DD, YYYY',
nextWeek: '[' + t('tasks', 'Starts on') + '] MMM DD, YYYY',
sameElse: function() {
if (this.diff(moment()) > 0) {
return '[' + t('tasks', 'Starts on') + '] MMM DD, YYYY';
} else {
return '[' + t('tasks', 'Started on') + '] MMM DD, YYYY';
}
}
}
});
moment.locale('reminder', {
calendar: {
lastDay: t('tasks', '[Remind me yesterday at ]HH:mm'),

View file

@ -290,6 +290,13 @@ angular.module('Tasks').controller('DetailsController', [
_tasksbusinesslayer.deleteDueDate(task);
};
this._$scope.isAllDayPossible = function(task) {
return !angular.isUndefined(task) && task.calendar.writable && (task.due || task.start);
};
this._$scope.toggleAllDay = function(task) {
_tasksbusinesslayer.setAllDay(task, !task.allDay);
};
this._$scope.setreminderday = function(date) {
return _tasksbusinesslayer.setReminderDate(_$scope.route.taskID, moment(date, 'MM/DD/YYYY'), 'day');
};

View file

@ -23,7 +23,7 @@ angular.module('Tasks').filter('dateDetails', function() {
'use strict';
return function(due) {
if (moment(due, "YYYYMMDDTHHmmss").isValid()) {
return moment(due, "YYYYMMDDTHHmmss").locale('details').calendar();
return moment(due, "YYYYMMDDTHHmmss").locale(due.isDate ? 'details_allday' : 'details').calendar();
} else {
return t('tasks', 'Set due date');
}

View file

@ -23,7 +23,7 @@ angular.module('Tasks').filter('startDetails', function() {
'use strict';
return function(due) {
if (moment(due, "YYYYMMDDTHHmmss").isValid()) {
return moment(due, "YYYYMMDDTHHmmss").locale('start').calendar();
return moment(due, "YYYYMMDDTHHmmss").locale(due.isDate ? 'start_allday' : 'start').calendar();
} else {
return t('tasks', 'Set start date');
}

View file

@ -151,6 +151,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
if (type === null) {
type = 'day';
}
var allDay = task.allDay;
var due = moment(task.due, "YYYY-MM-DDTHH:mm:ss");
if (type === 'day') {
if (moment(due).isValid()) {
@ -170,6 +171,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
return;
}
task.due = due.format('YYYY-MM-DDTHH:mm:ss');
task.due.isDate = allDay;
// this.checkReminderDate(task);
this.doUpdate(task);
};
@ -194,6 +196,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
if (type === null) {
type = 'day';
}
var allDay = task.allDay;
var start = moment(task.start, "YYYY-MM-DDTHH:mm:ss");
if (type === 'day') {
if (moment(start).isValid()) {
@ -211,6 +214,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
return;
}
task.start = start.format('YYYY-MM-DDTHH:mm:ss');
task.start.isDate = allDay;
// this.checkReminderDate(taskID);
this.doUpdate(task);
};
@ -224,6 +228,11 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
this.doUpdate(task);
};
TasksBusinessLayer.prototype.setAllDay = function(task, allDay) {
task.allDay = allDay;
this.doUpdate(task);
};
TasksBusinessLayer.prototype.initReminder = function(taskID) {
var p, task;
if (!this.checkReminderDate(taskID)) {

View file

@ -231,6 +231,28 @@ angular.module('Tasks').factory('VTodo', ['$filter', 'ICalFactory', 'RandomStrin
this.updateLastModified();
this.data = this.components.toString();
},
get allDay() {
var vtodos = this.components.getAllSubcomponents('vtodo');
var start = vtodos[0].getFirstPropertyValue('dtstart');
var due = vtodos[0].getFirstPropertyValue('due');
var d = due ? due : start;
return d!=null && d.isDate;
},
set allDay(allDay) {
var vtodos = this.components.getAllSubcomponents('vtodo');
var start = vtodos[0].getFirstPropertyValue('dtstart');
if(start) {
start.isDate = allDay;
vtodos[0].updatePropertyWithValue('dtstart', start);
}
var due = vtodos[0].getFirstPropertyValue('due');
if(due) {
due.isDate = allDay;
vtodos[0].updatePropertyWithValue('due', due);
}
this.updateLastModified();
this.data = this.components.toString();
},
get comments() {
return null;
},

View file

@ -68,6 +68,16 @@ angular.module('Tasks').run([
sameElse: '[' + t('tasks', 'Due on') + '] MMM DD, YYYY, HH:mm'
}
});
moment.locale('details_allday', {
calendar: {
lastDay: '[' + t('tasks', 'Due yesterday') + ']',
sameDay: '[' + t('tasks', 'Due today') + ']',
nextDay: '[' + t('tasks', 'Due tomorrow') + ']',
lastWeek: '[' + t('tasks', 'Due on') + '] MMM DD, YYYY',
nextWeek: '[' + t('tasks', 'Due on') + '] MMM DD, YYYY',
sameElse: '[' + t('tasks', 'Due on') + '] MMM DD, YYYY'
}
});
moment.locale('start', {
calendar: {
lastDay: '[' + t('tasks', 'Started yesterday') + '], HH:mm',
@ -84,6 +94,22 @@ angular.module('Tasks').run([
}
}
});
moment.locale('start_allday', {
calendar: {
lastDay: '[' + t('tasks', 'Started yesterday') + ']',
sameDay: '[' + t('tasks', 'Starts today') + ']',
nextDay: '[' + t('tasks', 'Starts tomorrow') + ']',
lastWeek: '[' + t('tasks', 'Started on') + '] MMM DD, YYYY',
nextWeek: '[' + t('tasks', 'Starts on') + '] MMM DD, YYYY',
sameElse: function() {
if (this.diff(moment()) > 0) {
return '[' + t('tasks', 'Starts on') + '] MMM DD, YYYY';
} else {
return '[' + t('tasks', 'Started on') + '] MMM DD, YYYY';
}
}
}
});
moment.locale('reminder', {
calendar: {
lastDay: t('tasks', '[Remind me yesterday at ]HH:mm'),
@ -478,6 +504,13 @@ angular.module('Tasks').controller('DetailsController', [
_tasksbusinesslayer.deleteDueDate(task);
};
this._$scope.isAllDayPossible = function(task) {
return !angular.isUndefined(task) && task.calendar.writable && (task.due || task.start);
};
this._$scope.toggleAllDay = function(task) {
_tasksbusinesslayer.setAllDay(task, !task.allDay);
};
this._$scope.setreminderday = function(date) {
return _tasksbusinesslayer.setReminderDate(_$scope.route.taskID, moment(date, 'MM/DD/YYYY'), 'day');
};
@ -1684,7 +1717,7 @@ angular.module('Tasks').filter('dateDetails', function() {
'use strict';
return function(due) {
if (moment(due, "YYYYMMDDTHHmmss").isValid()) {
return moment(due, "YYYYMMDDTHHmmss").locale('details').calendar();
return moment(due, "YYYYMMDDTHHmmss").locale(due.isDate ? 'details_allday' : 'details').calendar();
} else {
return t('tasks', 'Set due date');
}
@ -1823,7 +1856,7 @@ angular.module('Tasks').filter('startDetails', function() {
'use strict';
return function(due) {
if (moment(due, "YYYYMMDDTHHmmss").isValid()) {
return moment(due, "YYYYMMDDTHHmmss").locale('start').calendar();
return moment(due, "YYYYMMDDTHHmmss").locale(due.isDate ? 'start_allday' : 'start').calendar();
} else {
return t('tasks', 'Set start date');
}
@ -2147,6 +2180,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
if (type === null) {
type = 'day';
}
var allDay = task.allDay;
var due = moment(task.due, "YYYY-MM-DDTHH:mm:ss");
if (type === 'day') {
if (moment(due).isValid()) {
@ -2166,6 +2200,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
return;
}
task.due = due.format('YYYY-MM-DDTHH:mm:ss');
task.due.isDate = allDay;
// this.checkReminderDate(task);
this.doUpdate(task);
};
@ -2190,6 +2225,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
if (type === null) {
type = 'day';
}
var allDay = task.allDay;
var start = moment(task.start, "YYYY-MM-DDTHH:mm:ss");
if (type === 'day') {
if (moment(start).isValid()) {
@ -2207,6 +2243,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
return;
}
task.start = start.format('YYYY-MM-DDTHH:mm:ss');
task.start.isDate = allDay;
// this.checkReminderDate(taskID);
this.doUpdate(task);
};
@ -2220,6 +2257,11 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
this.doUpdate(task);
};
TasksBusinessLayer.prototype.setAllDay = function(task, allDay) {
task.allDay = allDay;
this.doUpdate(task);
};
TasksBusinessLayer.prototype.initReminder = function(taskID) {
var p, task;
if (!this.checkReminderDate(taskID)) {
@ -4294,6 +4336,28 @@ angular.module('Tasks').factory('VTodo', ['$filter', 'ICalFactory', 'RandomStrin
this.updateLastModified();
this.data = this.components.toString();
},
get allDay() {
var vtodos = this.components.getAllSubcomponents('vtodo');
var start = vtodos[0].getFirstPropertyValue('dtstart');
var due = vtodos[0].getFirstPropertyValue('due');
var d = due ? due : start;
return d!=null && d.isDate;
},
set allDay(allDay) {
var vtodos = this.components.getAllSubcomponents('vtodo');
var start = vtodos[0].getFirstPropertyValue('dtstart');
if(start) {
start.isDate = allDay;
vtodos[0].updatePropertyWithValue('dtstart', start);
}
var due = vtodos[0].getFirstPropertyValue('due');
if(due) {
due.isDate = allDay;
vtodos[0].updatePropertyWithValue('due', due);
}
this.updateLastModified();
this.data = this.components.toString();
},
get comments() {
return null;
},

View file

@ -29,7 +29,7 @@
<span class="icon detail-save handler end-edit"></span>
<div class="section-edit">
<input class="datepicker-input medium focus" type="text" key-value="" placeholder="dd.mm.yyyy" value="{{ task.start | dateTaskList }}" datepicker="start">
<input class="timepicker-input medium focus handler" type="text" key-value="" placeholder="hh:mm" value="{{ task.start | timeTaskList }}" timepicker="start">
<input class="timepicker-input medium focus handler" ng-hide="task.allDay" type="text" key-value="" placeholder="hh:mm" value="{{ task.start | timeTaskList }}" timepicker="start">
</div>
</div>
<div class="section detail-date handler" ng-class="{'date':isDue(task.due), 'editing':route.parameter=='duedate'}" ng-click="editDueDate($event, task)">
@ -44,9 +44,16 @@
<span class="icon detail-save handler end-edit"></span>
<div class="section-edit">
<input class="datepicker-input medium focus" type="text" key-value="" placeholder="dd.mm.yyyy" value="{{ task.due | dateTaskList }}" datepicker="due">
<input class="timepicker-input medium focus" type="text" key-value="" placeholder="hh:mm" value="{{ task.due | timeTaskList }}" timepicker="due">
<input class="timepicker-input medium focus" ng-hide="task.allDay" type="text" key-value="" placeholder="hh:mm" value="{{ task.due | timeTaskList }}" timepicker="due">
</div>
</div>
<div class="section detail-all-day handler" ng-click="toggleAllDay(task)" ng-if="isAllDayPossible(task)">
<span class="icon detail-checkbox disabled" ng-class="{'detail-checked': task.allDay, 'disabled': !task.calendar.writable}"></span>
<div class="section-title">
<text><?php p($l->t('All day')); ?></text>
</div>
</div>
<!-- <div class="section detail-reminder handler" ng-class="{'date':isDue(task.reminder.date), 'editing':route.parameter=='reminder'}" ng-click="editReminder($event, task)">
<span class="icon detail-reminder" ng-class="{'overdue':isOverDue(task.reminder.date)}"></span>
<span class="icon detail-remindertype" ng-click="changeReminderType(task)" ng-show="task.due || task.start"></span>