diff --git a/js/app/app.js b/js/app/app.js index c89dae1c..104d5ffb 100644 --- a/js/app/app.js +++ b/js/app/app.js @@ -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'), diff --git a/js/app/controllers/detailscontroller.js b/js/app/controllers/detailscontroller.js index 32d95859..03597e2b 100644 --- a/js/app/controllers/detailscontroller.js +++ b/js/app/controllers/detailscontroller.js @@ -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'); }; diff --git a/js/app/filters/dateDetails.js b/js/app/filters/dateDetails.js index d8b3393e..043f4583 100644 --- a/js/app/filters/dateDetails.js +++ b/js/app/filters/dateDetails.js @@ -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'); } diff --git a/js/app/filters/startDetails.js b/js/app/filters/startDetails.js index cd61deb1..1a30ed78 100644 --- a/js/app/filters/startDetails.js +++ b/js/app/filters/startDetails.js @@ -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'); } diff --git a/js/app/services/businesslayer/tasksbusinesslayer.js b/js/app/services/businesslayer/tasksbusinesslayer.js index b6824d2b..82a9789a 100644 --- a/js/app/services/businesslayer/tasksbusinesslayer.js +++ b/js/app/services/businesslayer/tasksbusinesslayer.js @@ -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)) { diff --git a/js/app/services/models/vtodo.js b/js/app/services/models/vtodo.js index c6829c0c..358c1069 100644 --- a/js/app/services/models/vtodo.js +++ b/js/app/services/models/vtodo.js @@ -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; }, diff --git a/js/public/app.js b/js/public/app.js index b09d2a6f..058c80b6 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -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; }, diff --git a/templates/part.details.php b/templates/part.details.php index ae5d5be8..d51b392f 100644 --- a/templates/part.details.php +++ b/templates/part.details.php @@ -29,7 +29,7 @@