Merge pull request #107 from nextcloud/lintjs

Lint javascript files
This commit is contained in:
Raimund Schlüßler 2017-09-10 18:00:12 +02:00 committed by GitHub
commit 0badabe2c5
24 changed files with 1476 additions and 1376 deletions

View file

@ -34,6 +34,7 @@
"inject": true,
"module": true,
"t": true,
"n": true,
"it": true,
"exports": true,
"escapeHTML": true,

View file

@ -76,16 +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('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',
@ -102,78 +102,78 @@ 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'),
sameDay: t('tasks', '[Remind me today at ]HH:mm'),
nextDay: t('tasks', '[Remind me tomorrow at ]HH:mm'),
lastWeek: t('tasks', '[Remind me on ]MMM DD, YYYY,[ at ]HH:mm'),
nextWeek: t('tasks', '[Remind me on ]MMM DD, YYYY,[ at ]HH:mm'),
sameElse: t('tasks', '[Remind me on ]MMM DD, YYYY,[ at ]HH:mm')
}
});
moment.locale('tasks', {
calendar: {
lastDay: '[' + t('tasks', 'Yesterday') + ']',
sameDay: '[' + t('tasks', 'Today') + ']',
nextDay: '[' + t('tasks', 'Tomorrow') + ']',
lastWeek: 'DD.MM.YYYY',
nextWeek: 'DD.MM.YYYY',
sameElse: 'DD.MM.YYYY'
}
});
moment.locale('details_short', {
calendar: {
lastDay: '[' + t('tasks', 'Yesterday') + ']',
sameDay: '[' + t('tasks', 'Today') + ']',
nextDay: '[' + t('tasks', 'Tomorrow') + ']',
lastWeek: 'MMM DD, YYYY',
nextWeek: 'MMM DD, YYYY',
sameElse: 'MMM DD, YYYY'
}
});
moment.locale('list_week', {
calendar: {
lastDay: '[' + t('tasks', 'Yesterday') + ']',
sameDay: '[' + t('tasks', 'Today') + '], MMM. DD',
nextDay: '[' + t('tasks', 'Tomorrow') + '], MMM. DD',
lastWeek: 'ddd, MMM. DD',
nextWeek: 'ddd, MMM. DD',
sameElse: 'ddd, MMM. DD'
}
});
return moment.locale('en', {
relativeTime: {
future: t('tasks', "in %s"),
past: t('tasks', "%s ago"),
s: t('tasks', "seconds"),
m: t('tasks', "a minute"),
mm: t('tasks', "%d minutes"),
h: t('tasks', "an hour"),
hh: t('tasks', "%d hours"),
d: t('tasks', "a day"),
dd: t('tasks', "%d days"),
M: t('tasks', "a month"),
MM: t('tasks', "%d months"),
y: t('tasks', "a year"),
yy: t('tasks', "%d years")
}
});
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'),
sameDay: t('tasks', '[Remind me today at ]HH:mm'),
nextDay: t('tasks', '[Remind me tomorrow at ]HH:mm'),
lastWeek: t('tasks', '[Remind me on ]MMM DD, YYYY,[ at ]HH:mm'),
nextWeek: t('tasks', '[Remind me on ]MMM DD, YYYY,[ at ]HH:mm'),
sameElse: t('tasks', '[Remind me on ]MMM DD, YYYY,[ at ]HH:mm')
}
});
moment.locale('tasks', {
calendar: {
lastDay: '[' + t('tasks', 'Yesterday') + ']',
sameDay: '[' + t('tasks', 'Today') + ']',
nextDay: '[' + t('tasks', 'Tomorrow') + ']',
lastWeek: 'DD.MM.YYYY',
nextWeek: 'DD.MM.YYYY',
sameElse: 'DD.MM.YYYY'
}
});
moment.locale('details_short', {
calendar: {
lastDay: '[' + t('tasks', 'Yesterday') + ']',
sameDay: '[' + t('tasks', 'Today') + ']',
nextDay: '[' + t('tasks', 'Tomorrow') + ']',
lastWeek: 'MMM DD, YYYY',
nextWeek: 'MMM DD, YYYY',
sameElse: 'MMM DD, YYYY'
}
});
moment.locale('list_week', {
calendar: {
lastDay: '[' + t('tasks', 'Yesterday') + ']',
sameDay: '[' + t('tasks', 'Today') + '], MMM. DD',
nextDay: '[' + t('tasks', 'Tomorrow') + '], MMM. DD',
lastWeek: 'ddd, MMM. DD',
nextWeek: 'ddd, MMM. DD',
sameElse: 'ddd, MMM. DD'
}
});
return moment.locale('en', {
relativeTime: {
future: t('tasks', "in %s"),
past: t('tasks', "%s ago"),
s: t('tasks', "seconds"),
m: t('tasks', "a minute"),
mm: t('tasks', "%d minutes"),
h: t('tasks', "an hour"),
hh: t('tasks', "%d hours"),
d: t('tasks', "a day"),
dd: t('tasks', "%d days"),
M: t('tasks', "a month"),
MM: t('tasks', "%d months"),
y: t('tasks', "a year"),
yy: t('tasks', "%d years")
}
});
}
]);

View file

@ -126,13 +126,13 @@ angular.module('Tasks').controller('DetailsController', [
var task;
task = _$tasksmodel.getById(_$scope.route.taskID);
if (!(angular.isUndefined(task) || task === null)) {
if (task.due && task.start) {
return params;
} else if (task.start) {
return params.slice(0, 2);
} else {
return params.slice(2);
}
if (task.due && task.start) {
return params;
} else if (task.start) {
return params.slice(0, 2);
} else {
return params.slice(2);
}
}
};
this._$scope.deleteTask = function(task) {
@ -214,7 +214,7 @@ angular.module('Tasks').controller('DetailsController', [
}
};
this._$scope.setEditRoute = function(type) {
this._$scope.setEditRoute = function(type) {
var calendarID = _$scope.route.calendarID;
var collectionID = _$scope.route.collectionID;
if (calendarID) {
@ -222,7 +222,7 @@ angular.module('Tasks').controller('DetailsController', [
} else if (collectionID) {
$location.path('/collections/' + collectionID + '/tasks/' + _$scope.route.taskID + '/edit/' + type);
}
};
};
this._$scope.resetRoute = function() {
var calendarID = _$scope.route.calendarID;
@ -290,91 +290,91 @@ 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.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) {
this._$scope.setreminderday = function(date) {
return _tasksbusinesslayer.setReminderDate(_$scope.route.taskID, moment(date, 'MM/DD/YYYY'), 'day');
};
this._$scope.setremindertime = function(date) {
return _tasksbusinesslayer.setReminderDate(_$scope.route.taskID, moment(date, 'HH:mm'), 'time');
};
this._$scope.reminderType = function(task) {
if (!angular.isUndefined(task)) {
if (task.reminder === null) {
if (moment(task.start, "YYYYMMDDTHHmmss").isValid() || moment(task.due, "YYYYMMDDTHHmmss").isValid()) {
return 'DURATION';
} else {
return 'DATE-TIME';
}
} else {
return task.reminder.type;
}
}
};
this._$scope.changeReminderType = function(task) {
_tasksbusinesslayer.checkReminderDate(task.id);
if (this.reminderType(task) === 'DURATION') {
if (task.reminder) {
task.reminder.type = 'DATE-TIME';
} else {
task.reminder = {
type: 'DATE-TIME'
};
}
} else {
if (task.reminder) {
task.reminder.type = 'DURATION';
} else {
task.reminder = {
type: 'DURATION'
};
}
}
return _tasksbusinesslayer.setReminder(task.id);
};
this._$scope.setReminderDuration = function(taskID) {
return _tasksbusinesslayer.setReminder(_$scope.route.taskID);
};
this._$scope.addComment = function() {
var comment,
_this = this;
if (_$scope.CommentContent) {
_$scope.isAddingComment = true;
comment = {
tmpID: 'newComment' + Date.now(),
comment: _$scope.CommentContent,
taskID: _$scope.route.taskID,
time: moment().format('YYYYMMDDTHHmmss'),
name: $('#expandDisplayName').text()
};
_tasksbusinesslayer.addComment(comment, function(data) {
_$tasksmodel.updateComment(data);
_$scope.isAddingComment = false;
}, function() {
_$scope.isAddingComment = false;
});
_$scope.CommentContent = '';
}
};
this._$scope.sendComment = function(event) {
if (event.keyCode === 13) {
return _$scope.addComment();
}
};
this._$scope.deleteComment = function(commentID) {
return _tasksbusinesslayer.deleteComment(_$scope.route.taskID, commentID);
};
this._$scope.commentStrings = function() {
return {
button: t('tasks', 'Comment'),
input: t('tasks', 'Add a comment')
};
};
this._$scope.setremindertime = function(date) {
return _tasksbusinesslayer.setReminderDate(_$scope.route.taskID, moment(date, 'HH:mm'), 'time');
};
this._$scope.reminderType = function(task) {
if (!angular.isUndefined(task)) {
if (task.reminder === null) {
if (moment(task.start, "YYYYMMDDTHHmmss").isValid() || moment(task.due, "YYYYMMDDTHHmmss").isValid()) {
return 'DURATION';
} else {
return 'DATE-TIME';
}
} else {
return task.reminder.type;
}
}
};
this._$scope.changeReminderType = function(task) {
_tasksbusinesslayer.checkReminderDate(task.id);
if (this.reminderType(task) === 'DURATION') {
if (task.reminder) {
task.reminder.type = 'DATE-TIME';
} else {
task.reminder = {
type: 'DATE-TIME'
};
}
} else {
if (task.reminder) {
task.reminder.type = 'DURATION';
} else {
task.reminder = {
type: 'DURATION'
};
}
}
return _tasksbusinesslayer.setReminder(task.id);
};
this._$scope.setReminderDuration = function(taskID) {
return _tasksbusinesslayer.setReminder(_$scope.route.taskID);
};
this._$scope.addComment = function() {
var comment,
_this = this;
if (_$scope.CommentContent) {
_$scope.isAddingComment = true;
comment = {
tmpID: 'newComment' + Date.now(),
comment: _$scope.CommentContent,
taskID: _$scope.route.taskID,
time: moment().format('YYYYMMDDTHHmmss'),
name: $('#expandDisplayName').text()
};
_tasksbusinesslayer.addComment(comment, function(data) {
_$tasksmodel.updateComment(data);
_$scope.isAddingComment = false;
}, function() {
_$scope.isAddingComment = false;
});
_$scope.CommentContent = '';
}
};
this._$scope.sendComment = function(event) {
if (event.keyCode === 13) {
return _$scope.addComment();
}
};
this._$scope.deleteComment = function(commentID) {
return _tasksbusinesslayer.deleteComment(_$scope.route.taskID, commentID);
};
this._$scope.commentStrings = function() {
return {
button: t('tasks', 'Comment'),
input: t('tasks', 'Add a comment')
};
};
this._$scope.addCategory = function(category, model) {
_$scope.task.categories = _$scope.task.cats;
var default_categories = _$scope.settingsmodel.getById('various').categories;
@ -391,7 +391,7 @@ angular.module('Tasks').controller('DetailsController', [
return DetailsController;
})();
return new DetailsController($scope, $window, TasksModel, TasksBusinessLayer, $route, $location, $timeout, $routeParams, SettingsModel, Loading, ListsModel);
})();
return new DetailsController($scope, $window, TasksModel, TasksBusinessLayer, $route, $location, $timeout, $routeParams, SettingsModel, Loading, ListsModel);
}
]);

View file

@ -25,247 +25,245 @@ angular.module('Tasks').controller('ListController', [
function($scope, $rootScope, $window, $routeParams, ListsModel, TasksBusinessLayer, CollectionsModel, ListsBusinessLayer, $location,
SearchBusinessLayer, CalendarService, TasksModel, $timeout) {
'use strict';
var ListController;
ListController = (function() {
function ListController(_$scope, $rootScope, _$window, _$routeParams, _$listsmodel, _$tasksbusinesslayer, _$collectionsmodel, _$listsbusinesslayer, $location,
_$searchbusinesslayer, _$calendarservice, _$tasksmodel, _$timeout) {
var ListController;
ListController = (function() {
function ListController(_$scope, $rootScope, _$window, _$routeParams, _$listsmodel, _$tasksbusinesslayer, _$collectionsmodel, _$listsbusinesslayer, $location,
_$searchbusinesslayer, _$calendarservice, _$tasksmodel, _$timeout) {
this._$scope = _$scope;
this._$window = _$window;
this._$routeParams = _$routeParams;
this._$listsmodel = _$listsmodel;
this._$tasksmodel = _$tasksmodel;
this._$tasksbusinesslayer = _$tasksbusinesslayer;
this._$collectionsmodel = _$collectionsmodel;
this._$listsbusinesslayer = _$listsbusinesslayer;
this.$location = $location;
this._$timeout = _$timeout;
this._$searchbusinesslayer = _$searchbusinesslayer;
this._$calendarservice = _$calendarservice;
this._$scope.collections = this._$collectionsmodel.getAll();
this._$scope.calendars = this._$listsmodel.getAll();
this._$scope.draggedTasks = [];
this._$scope.TasksBusinessLayer = this._$tasksbusinesslayer;
this._$scope.nameError = false;
this._$scope.color = '#31CC7C';
this._$scope = _$scope;
this._$window = _$window;
this._$routeParams = _$routeParams;
this._$listsmodel = _$listsmodel;
this._$tasksmodel = _$tasksmodel;
this._$tasksbusinesslayer = _$tasksbusinesslayer;
this._$collectionsmodel = _$collectionsmodel;
this._$listsbusinesslayer = _$listsbusinesslayer;
this.$location = $location;
this._$timeout = _$timeout;
this._$searchbusinesslayer = _$searchbusinesslayer;
this._$calendarservice = _$calendarservice;
this._$scope.collections = this._$collectionsmodel.getAll();
this._$scope.calendars = this._$listsmodel.getAll();
this._$scope.draggedTasks = [];
this._$scope.TasksBusinessLayer = this._$tasksbusinesslayer;
this._$scope.nameError = false;
this._$scope.color = '#31CC7C';
this._$scope.deleteMessage = function (calendar) {
return t('tasks', 'This will delete the Calendar "%s" and all of its entries.').replace('%s', calendar.displayname);
};
this._$scope.deleteMessage = function (calendar) {
return t('tasks', 'This will delete the Calendar "%s" and all of its entries.').replace('%s', calendar.displayname);
};
this._$scope["delete"] = function(calendar) {
return _$listsbusinesslayer["delete"](calendar).then(function() {
$location.path('/calendars/' + _$listsmodel.getStandardList().uri);
return $scope.$apply();
});
};
this._$scope.startCreate = function() {
_$scope.status.addingList = true;
_$scope.nameError = false;
$('.hasTooltip').tooltip('hide');
_$timeout(function() {
$('#newList').focus();
}, 50);
};
this._$scope.create = function() {
var check = _$scope.isNameAllowed(_$scope.status.newListName);
if (check.allowed) {
_$scope.status.addingList = false;
_$scope.isAddingList = true;
_$listsbusinesslayer.add(_$scope.status.newListName, _$scope.color).then(function(calendar) {
$location.path('/calendars/' + calendar.uri);
this._$scope["delete"] = function(calendar) {
return _$listsbusinesslayer["delete"](calendar).then(function() {
$location.path('/calendars/' + _$listsmodel.getStandardList().uri);
return $scope.$apply();
});
_$scope.status.newListName = '';
}
};
};
this._$scope.cancelCreate = function() {
this._$scope.startCreate = function() {
_$scope.status.addingList = true;
_$scope.nameError = false;
$('.hasTooltip').tooltip('hide');
_$timeout(function() {
$('#newList').focus();
}, 50);
};
this._$scope.create = function() {
var check = _$scope.isNameAllowed(_$scope.status.newListName);
if (check.allowed) {
_$scope.status.addingList = false;
_$scope.isAddingList = true;
_$listsbusinesslayer.add(_$scope.status.newListName, _$scope.color).then(function(calendar) {
$location.path('/calendars/' + calendar.uri);
return $scope.$apply();
});
_$scope.status.newListName = '';
}
};
this._$scope.cancelCreate = function() {
$('.hasTooltip').tooltip('hide');
_$scope.nameError = false;
_$scope.status.addingList = false;
_$scope.status.newListName = "";
};
this._$scope.startEdit = function(calendar) {
_$scope.status.addingList = false;
_$scope.nameError = false;
$('.hasTooltip').tooltip('hide');
calendar.prepareUpdate();
$location.path('/calendars/' + _$scope.route.calendarID + '/edit/name');
_$timeout(function() {
$('#list_' + calendar.uri + ' input.edit').focus();
}, 50);
};
this._$scope.showCalDAVUrl = function(calendar) {
_$scope.status.addingList = false;
_$scope.nameError = false;
$location.path('/calendars/' + _$scope.route.calendarID + '/edit/caldav');
_$timeout(function() {
$('#list_' + calendar.uri + ' input.caldav').focus();
}, 50);
};
this._$scope.hideCalDAVUrl = function() {
$location.path('/calendars/' + _$scope.route.calendarID);
};
this._$scope.download = function (calendar) {
var url = calendar.url;
// cut off last slash to have a fancy name for the ics
if (url.slice(url.length - 1) === '/') {
url = url.slice(0, url.length - 1);
}
url += '?export';
$window.open(url);
};
this._$scope.checkNew = function(event,name) {
_$scope.checkName(event,name);
};
this._$scope.checkEdit = function(event,calendar) {
_$scope.checkName(event,calendar.displayname,calendar.uri);
if (event.keyCode === 27) {
_$scope.cancelEdit(calendar);
}
};
this._$scope.checkName = function(event,name,uri) {
var check = _$scope.isNameAllowed(name,uri);
var $input = $(event.currentTarget);
if (!check.allowed) {
$input.attr('title', check.msg)
.tooltip({placement: 'bottom', trigger: 'manual'})
.tooltip('fixTitle').tooltip('show');
_$scope.nameError = true;
} else {
$input.tooltip('hide');
_$scope.nameError = false;
}
if (event.keyCode === 27) {
event.preventDefault();
$input.tooltip('hide');
_$scope.status.addingList = false;
_$scope.status.newListName = "";
_$scope.nameError = false;
}
};
$rootScope.$on('cancelEditCalendar', function(s, calendarUri) {
var calendar = _$listsmodel.getByUri(calendarUri);
_$scope.cancelEdit(calendar);
});
this._$scope.cancelEdit = function(calendar) {
calendar.resetToPreviousState();
$('.hasTooltip').tooltip('hide');
_$scope.nameError = false;
$location.path('/calendars/' + _$scope.route.calendarID);
};
this._$scope.saveEdit = function(calendar) {
var check = _$scope.isNameAllowed(calendar.displayname, calendar.uri);
if (check.allowed) {
_$listsbusinesslayer.rename(calendar);
$location.path('/calendars/' + _$scope.route.calendarID);
}
};
this._$scope.isNameAllowed = function(name, uri) {
var check = {
allowed: false,
msg: ''
};
if (_$listsmodel.isNameAlreadyTaken(name, uri)) {
check.msg = t('tasks', 'The name "%s" is already used.').replace('%s', name);
} else if (!name) {
check.msg = t('tasks', 'An empty name is not allowed.');
} else {
check.allowed = true;
}
return check;
};
this._$scope.getCollectionCount = function(collectionID) {
var filter;
filter = _$searchbusinesslayer.getFilter();
return _$collectionsmodel.getCount(collectionID, filter);
};
this._$scope.startEdit = function(calendar) {
_$scope.status.addingList = false;
_$scope.nameError = false;
$('.hasTooltip').tooltip('hide');
calendar.prepareUpdate();
$location.path('/calendars/' + _$scope.route.calendarID + '/edit/name');
_$timeout(function() {
$('#list_' + calendar.uri + ' input.edit').focus();
}, 50);
};
this._$scope.hideCollection = function(collectionID) {
var collection;
collection = _$collectionsmodel.getById(collectionID);
switch (collection.show) {
case 0:
return true;
case 1:
return false;
case 2:
return this.getCollectionCount(collectionID) < 1;
}
};
this._$scope.showCalDAVUrl = function(calendar) {
_$scope.status.addingList = false;
_$scope.nameError = false;
$location.path('/calendars/' + _$scope.route.calendarID + '/edit/caldav');
_$timeout(function() {
$('#list_' + calendar.uri + ' input.caldav').focus();
}, 50);
};
this._$scope.getCollectionString = function(collectionID) {
var filter;
if (collectionID !== 'completed') {
this._$scope.hideCalDAVUrl = function() {
$location.path('/calendars/' + _$scope.route.calendarID);
};
this._$scope.download = function (calendar) {
var url = calendar.url;
// cut off last slash to have a fancy name for the ics
if (url.slice(url.length - 1) === '/') {
url = url.slice(0, url.length - 1);
}
url += '?export';
$window.open(url);
};
this._$scope.checkNew = function(event,name) {
_$scope.checkName(event,name);
};
this._$scope.checkEdit = function(event,calendar) {
_$scope.checkName(event,calendar.displayname,calendar.uri);
if (event.keyCode === 27) {
_$scope.cancelEdit(calendar);
}
};
this._$scope.checkName = function(event,name,uri) {
var check = _$scope.isNameAllowed(name,uri);
var $input = $(event.currentTarget);
if (!check.allowed) {
$input.attr('title', check.msg)
.tooltip({placement: 'bottom', trigger: 'manual'})
.tooltip('fixTitle').tooltip('show');
_$scope.nameError = true;
} else {
$input.tooltip('hide');
_$scope.nameError = false;
}
if (event.keyCode === 27) {
event.preventDefault();
$input.tooltip('hide');
_$scope.status.addingList = false;
_$scope.status.newListName = "";
_$scope.nameError = false;
}
};
$rootScope.$on('cancelEditCalendar', function(s, calendarUri) {
var calendar = _$listsmodel.getByUri(calendarUri);
_$scope.cancelEdit(calendar);
});
this._$scope.cancelEdit = function(calendar) {
calendar.resetToPreviousState();
$('.hasTooltip').tooltip('hide');
_$scope.nameError = false;
$location.path('/calendars/' + _$scope.route.calendarID);
};
this._$scope.saveEdit = function(calendar) {
var check = _$scope.isNameAllowed(calendar.displayname, calendar.uri);
if (check.allowed) {
_$listsbusinesslayer.rename(calendar);
$location.path('/calendars/' + _$scope.route.calendarID);
}
};
this._$scope.isNameAllowed = function(name, uri) {
var check = {
allowed: false,
msg: ''
};
if (_$listsmodel.isNameAlreadyTaken(name, uri)) {
check.msg = t('tasks', 'The name "%s" is already used.').replace('%s', name);
} else if (!name) {
check.msg = t('tasks', 'An empty name is not allowed.');
} else {
check.allowed = true;
}
return check;
};
this._$scope.getCollectionCount = function(collectionID) {
var filter;
filter = _$searchbusinesslayer.getFilter();
return _$collectionsmodel.getCount(collectionID, filter);
} else {
return '';
}
};
};
this._$scope.getListCount = function(listID, type) {
var filter;
filter = _$searchbusinesslayer.getFilter();
return _$listsmodel.getCount(listID, type, filter);
};
this._$scope.hideCollection = function(collectionID) {
var collection;
collection = _$collectionsmodel.getById(collectionID);
switch (collection.show) {
case 0:
return true;
case 1:
return false;
case 2:
return this.getCollectionCount(collectionID) < 1;
}
};
this._$scope.dragoverList = function($event, index) {
var calendarID = $($event.target).closest('li.list').attr('calendarID');
var calendar = _$listsmodel.getByUri(calendarID);
return calendar.writable;
};
this._$scope.getCollectionString = function(collectionID) {
var filter;
if (collectionID !== 'completed') {
filter = _$searchbusinesslayer.getFilter();
return _$collectionsmodel.getCount(collectionID, filter);
} else {
return '';
}
};
this._$scope.dropList = function($event, index, item) {
if ($event.dataTransfer.dropEffect === 'move') {
// we can't simply use item as task, since the directive seems to not copy all properties --> task.calendar.uri == undefined
var task = _$tasksmodel.getByUri(item.uri);
this._$scope.getListCount = function(listID, type) {
var filter;
filter = _$searchbusinesslayer.getFilter();
return _$listsmodel.getCount(listID, type, filter);
};
this._$scope.dragoverList = function($event, index) {
var calendarID = $($event.target).closest('li.list').attr('calendarID');
var calendar = _$listsmodel.getByUri(calendarID);
_$tasksbusinesslayer.changeCalendar(task, calendar).then(function() {
_$scope.$apply();
});
}
return true;
};
return calendar.writable;
};
this._$scope.dragoverCollection = function($event, index) {
if ($event.dataTransfer.effectAllowed === 'copy' || ($event.dataTransfer.effectAllowed === 'copyMove' && $event.ctrlKey)) {
return false;
}
var collectionID;
collectionID = $($event.target).closest('li.collection').attr('collectionID');
return collectionID === 'starred' || collectionID === 'completed' || collectionID === 'today';
};
this._$scope.dropList = function($event, index, item) {
if ($event.dataTransfer.dropEffect === 'move') {
// we can't simply use item as task, since the directive seems to not copy all properties --> task.calendar.uri == undefined
var task = _$tasksmodel.getByUri(item.uri);
var calendarID = $($event.target).closest('li.list').attr('calendarID');
var calendar = _$listsmodel.getByUri(calendarID);
_$tasksbusinesslayer.changeCalendar(task, calendar).then(function() {
_$scope.$apply();
});
}
return true;
};
this._$scope.dropCollection = function($event, index, item) {
if ($event.dataTransfer.dropEffect === 'move') {
var collectionID = $($event.target).closest('li.collection').attr('collectionID');
_$tasksbusinesslayer.changeCollection(item.uri, collectionID);
}
return true;
};
}
this._$scope.dragoverCollection = function($event, index) {
if ($event.dataTransfer.effectAllowed === 'copy' || ($event.dataTransfer.effectAllowed === 'copyMove' && $event.ctrlKey)) {
return false;
}
var collectionID;
collectionID = $($event.target).closest('li.collection').attr('collectionID');
return collectionID === 'starred' || collectionID === 'completed' || collectionID === 'today';
};
return ListController;
})();
return new ListController($scope, $rootScope, $window, $routeParams, ListsModel, TasksBusinessLayer, CollectionsModel, ListsBusinessLayer, $location,
SearchBusinessLayer, CalendarService, TasksModel, $timeout);
this._$scope.dropCollection = function($event, index, item) {
if ($event.dataTransfer.dropEffect === 'move') {
var collectionID = $($event.target).closest('li.collection').attr('collectionID');
_$tasksbusinesslayer.changeCollection(item.uri, collectionID);
}
return true;
};
}
return ListController;
})();
return new ListController($scope, $rootScope, $window, $routeParams, ListsModel, TasksBusinessLayer, CollectionsModel, ListsBusinessLayer, $location,
SearchBusinessLayer, CalendarService, TasksModel, $timeout);
}
]);

View file

@ -20,71 +20,71 @@
*/
angular.module('Tasks').controller('SettingsController', [
'$scope', '$window', 'Status', '$location', 'CollectionsModel', 'SettingsBusinessLayer', 'SettingsModel', function($scope, $window, Status, $location, CollectionsModel, SettingsBusinessLayer, SettingsModel) {
'use strict';
var SettingsController;
SettingsController = (function() {
function SettingsController(_$scope, _$window, _$status, _$location, _$collectionsmodel, _$settingsbusinesslayer, _$settingsmodel) {
var _this = this;
this._$scope = _$scope;
this._$window = _$window;
this._$status = _$status;
this._$location = _$location;
this._$collectionsmodel = _$collectionsmodel;
this._$settingsbusinesslayer = _$settingsbusinesslayer;
this._$settingsmodel = _$settingsmodel;
this._$scope.status = this._$status.getStatus();
this._$scope.collections = this._$collectionsmodel.getAll();
this._$scope.settingsmodel = this._$settingsmodel;
this._$scope.collectionOptions = [
{
id: 0,
name: t('tasks', 'Hidden')
}, {
id: 1,
name: t('tasks', 'Visible')
}, {
id: 2,
name: t('tasks', 'Automatic')
}
];
this._$scope.startOfWeekOptions = [
{
id: 0,
name: t('tasks', 'Sunday')
}, {
id: 1,
name: t('tasks', 'Monday')
}, {
id: 2,
name: t('tasks', 'Tuesday')
}, {
id: 3,
name: t('tasks', 'Wednesday')
}, {
id: 4,
name: t('tasks', 'Thursday')
}, {
id: 5,
name: t('tasks', 'Friday')
}, {
id: 6,
name: t('tasks', 'Saturday')
}
];
this._$scope.setVisibility = function(collectionID) {
var collection;
collection = _$collectionsmodel.getById(collectionID);
return _$settingsbusinesslayer.setVisibility(collectionID, collection.show);
};
this._$scope.setStartOfWeek = function() {
return _$settingsbusinesslayer.set('various', 'startOfWeek', _$settingsmodel.getById('various').startOfWeek);
};
}
'$scope', '$window', 'Status', '$location', 'CollectionsModel', 'SettingsBusinessLayer', 'SettingsModel', function($scope, $window, Status, $location, CollectionsModel, SettingsBusinessLayer, SettingsModel) {
'use strict';
var SettingsController;
SettingsController = (function() {
function SettingsController(_$scope, _$window, _$status, _$location, _$collectionsmodel, _$settingsbusinesslayer, _$settingsmodel) {
var _this = this;
this._$scope = _$scope;
this._$window = _$window;
this._$status = _$status;
this._$location = _$location;
this._$collectionsmodel = _$collectionsmodel;
this._$settingsbusinesslayer = _$settingsbusinesslayer;
this._$settingsmodel = _$settingsmodel;
this._$scope.status = this._$status.getStatus();
this._$scope.collections = this._$collectionsmodel.getAll();
this._$scope.settingsmodel = this._$settingsmodel;
this._$scope.collectionOptions = [
{
id: 0,
name: t('tasks', 'Hidden')
}, {
id: 1,
name: t('tasks', 'Visible')
}, {
id: 2,
name: t('tasks', 'Automatic')
}
];
this._$scope.startOfWeekOptions = [
{
id: 0,
name: t('tasks', 'Sunday')
}, {
id: 1,
name: t('tasks', 'Monday')
}, {
id: 2,
name: t('tasks', 'Tuesday')
}, {
id: 3,
name: t('tasks', 'Wednesday')
}, {
id: 4,
name: t('tasks', 'Thursday')
}, {
id: 5,
name: t('tasks', 'Friday')
}, {
id: 6,
name: t('tasks', 'Saturday')
}
];
this._$scope.setVisibility = function(collectionID) {
var collection;
collection = _$collectionsmodel.getById(collectionID);
return _$settingsbusinesslayer.setVisibility(collectionID, collection.show);
};
this._$scope.setStartOfWeek = function() {
return _$settingsbusinesslayer.set('various', 'startOfWeek', _$settingsmodel.getById('various').startOfWeek);
};
}
return SettingsController;
return SettingsController;
})();
return new SettingsController($scope, $window, Status, $location, CollectionsModel, SettingsBusinessLayer, SettingsModel);
}
]);
})();
return new SettingsController($scope, $window, Status, $location, CollectionsModel, SettingsBusinessLayer, SettingsModel);
}
]);

View file

@ -21,15 +21,22 @@
(function() {
'use strict';
var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
var __indexOf = [].indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) {
return i;
}
}
return -1;
};
angular.module('Tasks').controller('TasksController', [
angular.module('Tasks').controller('TasksController', [
'$scope', '$window', '$routeParams', 'TasksModel', 'ListsModel', 'CollectionsModel', 'TasksBusinessLayer', '$location',
'SettingsBusinessLayer', 'SearchBusinessLayer', 'VTodo', 'SettingsModel',
function($scope, $window, $routeParams, TasksModel, ListsModel, CollectionsModel, TasksBusinessLayer, $location,
SettingsBusinessLayer, SearchBusinessLayer, VTodo, SettingsModel) {
var TasksController;
TasksController = (function() {
var TasksController;
TasksController = (function() {
function TasksController(_$scope, _$window, _$routeParams, _$tasksmodel, _$listsmodel, _$collectionsmodel, _tasksbusinesslayer, $location,
_settingsbusinesslayer, _searchbusinesslayer, vtodo, _$settingsmodel) {
var _this = this;
@ -57,7 +64,7 @@
this._$scope.addTask = function(taskName, related, calendar, parent) {
var _ref, _this = this;
if (calendar === null) {
calendar = '';
calendar = '';
}
_$scope.isAddingTask = true;
var task = {
@ -164,12 +171,12 @@
}
};
this._$scope.focusTaskInput = function() {
this._$scope.focusTaskInput = function() {
_$scope.status.focusTaskInput = true;
};
this._$scope.focusSubtaskInput = function() {
};
this._$scope.focusSubtaskInput = function() {
_$scope.status.focusSubtaskInput = true;
};
};
this._$scope.openDetails = function(id, $event) {
var calendarID = _$scope.route.calendarID;
@ -263,33 +270,33 @@
return _$tasksmodel.filteredTasks(filter);
};
this._$scope.dayHasEntry = function() {
this._$scope.dayHasEntry = function() {
return function(date) {
var filter, task, tasks, _i, _len;
filter = _searchbusinesslayer.getFilter();
tasks = _$tasksmodel.filteredTasks(filter);
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
var filter, task, tasks, _i, _len;
filter = _searchbusinesslayer.getFilter();
tasks = _$tasksmodel.filteredTasks(filter);
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
if (task.completed || !_$tasksmodel.hasNoParent(task)) {
continue;
continue;
}
if (_$tasksmodel.taskAtDay(task, date)) {
return true;
return true;
}
}
return false;
}
return false;
};
};
this._$scope.taskAtDay = function(task, day) {
};
this._$scope.taskAtDay = function(task, day) {
return function(task) {
return _$tasksmodel.taskAtDay(task, day);
return _$tasksmodel.taskAtDay(task, day);
};
};
this._$scope.filterLists = function() {
};
this._$scope.filterLists = function() {
return function(calendar) {
return _$scope.getCount(calendar.uri, _$scope.route.collectionID);
return _$scope.getCount(calendar.uri, _$scope.route.collectionID);
};
};
};
this._$scope.getCount = function(calendarID, type) {
var filter = _searchbusinesslayer.getFilter();
@ -380,7 +387,7 @@
_settingsbusinesslayer.set('various', 'sortDirection', _$scope.settingsmodel.getById('various').sortDirection);
};
this._$scope.dropAsSubtask = function($event, item, index) {
this._$scope.dropAsSubtask = function($event, item, index) {
if ($event.dataTransfer.dropEffect === 'move') {
var parentID = $($event.target).closest('.task-item').attr('taskID');
var task = _$tasksmodel.getByUri(item.uri);
@ -390,7 +397,7 @@
$('.subtasks-container').removeClass('dropzone-visible');
return true;
};
};
this._$scope.dropAsRootTask = function($event, item, index) {
if ($event.dataTransfer.dropEffect === 'move') {
@ -440,10 +447,10 @@
return TasksController;
})();
return new TasksController($scope, $window, $routeParams, TasksModel, ListsModel, CollectionsModel, TasksBusinessLayer, $location, SettingsBusinessLayer,
SearchBusinessLayer, VTodo, SettingsModel);
})();
return new TasksController($scope, $window, $routeParams, TasksModel, ListsModel, CollectionsModel, TasksBusinessLayer, $location, SettingsBusinessLayer,
SearchBusinessLayer, VTodo, SettingsModel);
}
]);
]);
}).call(this);

View file

@ -22,35 +22,35 @@
angular.module('Tasks').directive('datepicker', function() {
'use strict';
return {
restrict: 'A',
scope: false,
link: function(scope, elm, attr) {
return elm.datepicker({
onSelect: function(date, inst) {
scope['set' + attr.datepicker + 'day'](date);
return scope.$apply();
},
beforeShow: function(input, inst) {
var dp, marginLeft;
dp = $(inst).datepicker('widget');
marginLeft = -Math.abs($(input).outerWidth() - dp.outerWidth()) / 2 + 'px';
dp.css({
'margin-left': marginLeft
restrict: 'A',
scope: false,
link: function(scope, elm, attr) {
return elm.datepicker({
onSelect: function(date, inst) {
scope['set' + attr.datepicker + 'day'](date);
return scope.$apply();
},
beforeShow: function(input, inst) {
var dp, marginLeft;
dp = $(inst).datepicker('widget');
marginLeft = -Math.abs($(input).outerWidth() - dp.outerWidth()) / 2 + 'px';
dp.css({
'margin-left': marginLeft
});
$("div.ui-datepicker:before").css({
'left': 100 + 'px'
});
return $('.hasDatepicker').datepicker("option", "firstDay", scope.settingsmodel.getById('various').startOfWeek);
},
beforeShowDay: function(date) {
if (moment(date).startOf('day').diff(moment(scope.task[attr.datepicker], "YYYYMMDDTHHmmss").startOf('day'), 'days') === 0) {
return [1, "selected"];
} else {
return [1, ""];
}
},
minDate: null
});
$("div.ui-datepicker:before").css({
'left': 100 + 'px'
});
return $('.hasDatepicker').datepicker("option", "firstDay", scope.settingsmodel.getById('various').startOfWeek);
},
beforeShowDay: function(date) {
if (moment(date).startOf('day').diff(moment(scope.task[attr.datepicker], "YYYYMMDDTHHmmss").startOf('day'), 'days') === 0) {
return [1, "selected"];
} else {
return [1, ""];
}
},
minDate: null
});
}
}
};
});

View file

@ -22,20 +22,20 @@
angular.module('Tasks').directive('ocClickFocus', [
'$timeout', function($timeout) {
'use strict';
return function(scope, elm, attr) {
var options;
options = scope.$eval(attr.ocClickFocus);
if (angular.isDefined(options) && angular.isDefined(options.selector)) {
return elm.click(function() {
if (angular.isDefined(options.timeout)) {
return $timeout(function() {
return $(options.selector).focus();
}, options.timeout);
} else {
return $(options.selector).focus();
return function(scope, elm, attr) {
var options;
options = scope.$eval(attr.ocClickFocus);
if (angular.isDefined(options) && angular.isDefined(options.selector)) {
return elm.click(function() {
if (angular.isDefined(options.timeout)) {
return $timeout(function() {
return $(options.selector).focus();
}, options.timeout);
} else {
return $(options.selector).focus();
}
});
}
});
}
};
};
}
]);

View file

@ -22,18 +22,18 @@
angular.module('Tasks').directive('timepicker', function() {
'use strict';
return {
restrict: 'A',
link: function(scope, elm, attr) {
return elm.timepicker({
onSelect: function(date, inst) {
scope['set' + attr.timepicker + 'time'](date);
return scope.$apply();
},
myPosition: 'center top',
atPosition: 'center bottom',
hourText: t('tasks', 'Hours'),
minuteText: t('tasks', 'Minutes')
});
}
restrict: 'A',
link: function(scope, elm, attr) {
return elm.timepicker({
onSelect: function(date, inst) {
scope['set' + attr.timepicker + 'time'](date);
return scope.$apply();
},
myPosition: 'center top',
atPosition: 'center bottom',
hourText: t('tasks', 'Hours'),
minuteText: t('tasks', 'Minutes')
});
}
};
});

View file

@ -24,11 +24,6 @@ angular.module('Tasks').directive('watchTop', function() {
return {
restrict: 'A',
link: function(scope, element, attr) {
({
scope: {
"divTop": "="
}
});
return scope.$watch(function() {
scope.divTop = element.prev().outerHeight(true);
});

View file

@ -20,54 +20,63 @@
*/
angular.module('Tasks').filter('reminderDetails', function() {
'use strict';
'use strict';
return function(reminder, scope) {
var ds, time, token, _i, _len, _ref;
if (!(angular.isUndefined(reminder) || reminder === null)) {
if (reminder.type === 'DATE-TIME' && moment(reminder.date, "YYYYMMDDTHHmmss").isValid()) {
return moment(reminder.date, "YYYYMMDDTHHmmss").locale('reminder').calendar();
} else if (reminder.type === 'DURATION' && reminder.duration) {
ds = t('tasks', 'Remind me');
_ref = scope.durations;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
token = _ref[_i];
if (+reminder.duration[token.id]) {
time = 1;
ds += ' ' + reminder.duration[token.id] + ' ';
if (+reminder.duration[token.id] === 1) {
ds += token.name;
} else {
ds += token.names;
}
}
}
if (!time) {
if (reminder.duration.params.related === 'END') {
ds += ' ' + t('tasks', 'at the end');
function before(related) {
if (related === 'END') {
return ' ' + t('tasks', 'before end');
} else {
ds += ' ' + t('tasks', 'at the beginning');
return ' ' + t('tasks', 'before beginning');
}
} else {
if (reminder.duration.params.invert) {
if (reminder.duration.params.related === 'END') {
ds += ' ' + t('tasks', 'before end');
} else {
ds += ' ' + t('tasks', 'before beginning');
}
} else {
if (reminder.duration.params.related === 'END') {
ds += ' ' + t('tasks', 'after end');
} else {
ds += ' ' + t('tasks', 'after beginning');
}
}
}
return ds;
} else {
return t('tasks', 'Remind me');
}
} else {
return t('tasks', 'Remind me');
}
function after(related) {
if (related === 'END') {
return ' ' + t('tasks', 'after end');
} else {
return ' ' + t('tasks', 'after beginning');
}
}
function tokenName(reminder, token) {
if (+reminder.duration[token.id] === 1) {
return token.name;
} else {
return token.names;
}
}
var ds, time, token, _ref;
if (!(angular.isUndefined(reminder) || reminder === null)) {
if (reminder.type === 'DATE-TIME' && moment(reminder.date, "YYYYMMDDTHHmmss").isValid()) {
return moment(reminder.date, "YYYYMMDDTHHmmss").locale('reminder').calendar();
} else if (reminder.type === 'DURATION' && reminder.duration) {
ds = t('tasks', 'Remind me');
_ref = scope.durations;
for (var _i = 0, _len = _ref.length; _i < _len; _i++) {
token = _ref[_i];
if (+reminder.duration[token.id]) {
time = 1;
ds += ' ' + reminder.duration[token.id] + ' ';
ds += tokenName(reminder, token);
}
}
if (!time) {
if (reminder.duration.params.related === 'END') {
ds += ' ' + t('tasks', 'at the end');
} else {
ds += ' ' + t('tasks', 'at the beginning');
}
} else {
if (reminder.duration.params.invert) {
ds += before(reminder.duration.params.related);
} else {
ds += after(reminder.duration.params.related);
}
}
return ds;
} else {
return t('tasks', 'Remind me');
}
} else {
return t('tasks', 'Remind me');
}
};
});

View file

@ -21,87 +21,91 @@
(function() {
'use strict';
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
var __bind = function(fn, me){
return function(){
return fn.apply(me, arguments);
};
};
angular.module('Tasks').factory('SearchBusinessLayer', [
'ListsModel', 'Persistence', 'TasksModel', '$rootScope', '$routeParams', '$location', function(ListsModel, Persistence, TasksModel, $rootScope, $routeParams, $location) {
var SearchBusinessLayer;
SearchBusinessLayer = (function() {
function SearchBusinessLayer(_$listsmodel, _persistence, _$tasksmodel, _$rootScope, _$routeparams, _$location) {
this._$listsmodel = _$listsmodel;
this._persistence = _persistence;
this._$tasksmodel = _$tasksmodel;
this._$rootScope = _$rootScope;
this._$routeparams = _$routeparams;
this._$location = _$location;
this.getFilter = __bind(this.getFilter, this);
this.setFilter = __bind(this.setFilter, this);
this.attach = __bind(this.attach, this);
this.initialize();
this._$searchString = '';
angular.module('Tasks').factory('SearchBusinessLayer', [
'ListsModel', 'Persistence', 'TasksModel', '$rootScope', '$routeParams', '$location', function(ListsModel, Persistence, TasksModel, $rootScope, $routeParams, $location) {
var SearchBusinessLayer;
SearchBusinessLayer = (function() {
function SearchBusinessLayer(_$listsmodel, _persistence, _$tasksmodel, _$rootScope, _$routeparams, _$location) {
this._$listsmodel = _$listsmodel;
this._persistence = _persistence;
this._$tasksmodel = _$tasksmodel;
this._$rootScope = _$rootScope;
this._$routeparams = _$routeparams;
this._$location = _$location;
this.getFilter = __bind(this.getFilter, this);
this.setFilter = __bind(this.setFilter, this);
this.attach = __bind(this.attach, this);
this.initialize();
this._$searchString = '';
}
SearchBusinessLayer.prototype.attach = function(search) {
var _this = this;
search.setFilter('tasks', function(query) {
return _this._$rootScope.$apply(function() {
return _this.setFilter(query);
});
});
search.setRenderer('task', this.renderTaskResult.bind(this));
return search.setHandler('task', this.handleTaskClick.bind(this));
};
SearchBusinessLayer.prototype.setFilter = function(query) {
this._$searchString = query;
};
SearchBusinessLayer.prototype.getFilter = function() {
return this._$searchString;
};
SearchBusinessLayer.prototype.initialize = function() {
var _this = this;
this.handleTaskClick = function($row, result, event) {
return _this._$location.path('/lists/' + result.calendarid + '/tasks/' + result.id);
};
this.renderTaskResult = function($row, result) {
var $template;
if (!_this._$tasksmodel.filterTasks(result, _this._$routeparams.listID) || !_this._$tasksmodel.isLoaded(result)) {
$template = $('div.task-item.template');
$template = $template.clone();
$row = $('<tr class="result"></tr>').append($template.removeClass('template'));
$row.data('result', result);
$row.find('span.title').text(result.name);
if (result.starred) {
$row.find('span.task-star').addClass('task-starred');
}
if (result.completed) {
$row.find('div.task-item').addClass('done');
$row.find('span.task-checkbox').addClass('svg-checkmark');
}
if (result.complete) {
$row.find('div.percentdone').css({
'width': result.complete + '%',
'background-color': '' + _this._$listsmodel.getColor(result.calendarid)
});
}
if (result.note) {
$row.find('div.title-wrapper').addClass('attachment');
}
return $row;
} else {
return null;
}
};
return OC.Plugins.register('OCA.Search', this);
};
return SearchBusinessLayer;
})();
return new SearchBusinessLayer(ListsModel, Persistence, TasksModel, $rootScope, $routeParams, $location);
}
SearchBusinessLayer.prototype.attach = function(search) {
var _this = this;
search.setFilter('tasks', function(query) {
return _this._$rootScope.$apply(function() {
return _this.setFilter(query);
});
});
search.setRenderer('task', this.renderTaskResult.bind(this));
return search.setHandler('task', this.handleTaskClick.bind(this));
};
SearchBusinessLayer.prototype.setFilter = function(query) {
this._$searchString = query;
};
SearchBusinessLayer.prototype.getFilter = function() {
return this._$searchString;
};
SearchBusinessLayer.prototype.initialize = function() {
var _this = this;
this.handleTaskClick = function($row, result, event) {
return _this._$location.path('/lists/' + result.calendarid + '/tasks/' + result.id);
};
this.renderTaskResult = function($row, result) {
var $template;
if (!_this._$tasksmodel.filterTasks(result, _this._$routeparams.listID) || !_this._$tasksmodel.isLoaded(result)) {
$template = $('div.task-item.template');
$template = $template.clone();
$row = $('<tr class="result"></tr>').append($template.removeClass('template'));
$row.data('result', result);
$row.find('span.title').text(result.name);
if (result.starred) {
$row.find('span.task-star').addClass('task-starred');
}
if (result.completed) {
$row.find('div.task-item').addClass('done');
$row.find('span.task-checkbox').addClass('svg-checkmark');
}
if (result.complete) {
$row.find('div.percentdone').css({
'width': result.complete + '%',
'background-color': '' + _this._$listsmodel.getColor(result.calendarid)
});
}
if (result.note) {
$row.find('div.title-wrapper').addClass('attachment');
}
return $row;
} else {
return null;
}
};
return OC.Plugins.register('OCA.Search', this);
};
return SearchBusinessLayer;
})();
return new SearchBusinessLayer(ListsModel, Persistence, TasksModel, $rootScope, $routeParams, $location);
}
]);
]);
}).call(this);

View file

@ -187,7 +187,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
} else {
return;
}
if(due.isBefore(start) || due.isSame(start)) {
if (due.isBefore(start) || due.isSame(start)) {
start.subtract(olddue.diff(due), 'ms');
task.start = this.momentToICALTime(start, allDay);
}
@ -263,7 +263,7 @@ angular.module('Tasks').factory('TasksBusinessLayer', [
TasksBusinessLayer.prototype.setAllDay = function(task, allDay) {
task.allDay = allDay;
if(allDay) {
if (allDay) {
var due = moment(task.due, "YYYY-MM-DDTHH:mm:ss");
var start = moment(task.start, "YYYY-MM-DDTHH:mm:ss");
if(start.isAfter(due) || start.isSame(due)) {

View file

@ -21,118 +21,118 @@
(function() {
'use strict';
angular.module('Tasks').factory('_Model', [
function() {
var Model;
Model = (function() {
function Model() {
this._data = [];
this._dataMap = {};
this._filterCache = {};
angular.module('Tasks').factory('_Model', [
function() {
var Model;
Model = (function() {
function Model() {
this._data = [];
this._dataMap = {};
this._filterCache = {};
}
Model.prototype.handle = function(data) {
var item, _i, _len, _results;
_results = [];
for (_i = 0, _len = data.length; _i < _len; _i++) {
item = data[_i];
_results.push(this.add(item));
}
return _results;
};
Model.prototype.add = function(data, clearCache) {
if (clearCache === null) {
clearCache = true;
}
if (clearCache) {
this._invalidateCache();
}
if (angular.isDefined(this._dataMap[data.id])) {
return this.update(data, clearCache);
} else {
this._data.push(data);
this._dataMap[data.id] = data;
}
};
Model.prototype.update = function(data, clearCache) {
var entry, key, value, _results;
if (clearCache === null) {
clearCache = true;
}
if (clearCache) {
this._invalidateCache();
}
entry = this.getById(data.id);
_results = [];
for (key in data) {
value = data[key];
if (key === 'id') {
continue;
} else {
_results.push(entry[key] = value);
}
}
return _results;
};
Model.prototype.getById = function(id) {
return this._dataMap[id];
};
Model.prototype.getAll = function() {
return this._data;
};
Model.prototype.removeById = function(id, clearCache) {
var counter, data, entry, _i, _len, _ref;
if (clearCache === null) {
clearCache = true;
}
_ref = this._data;
for (counter = _i = 0, _len = _ref.length; _i < _len; counter = ++_i) {
entry = _ref[counter];
if (entry.id === id) {
this._data.splice(counter, 1);
data = this._dataMap[id];
delete this._dataMap[id];
if (clearCache) {
this._invalidateCache();
}
return data;
}
}
};
Model.prototype.clear = function() {
this._data.length = 0;
this._dataMap = {};
return this._invalidateCache();
};
Model.prototype._invalidateCache = function() {
this._filterCache = {};
};
Model.prototype.get = function(query) {
var hash;
hash = query.hashCode();
if (!angular.isDefined(this._filterCache[hash])) {
this._filterCache[hash] = query.exec(this._data);
}
return this._filterCache[hash];
};
Model.prototype.size = function() {
return this._data.length;
};
return Model;
})();
return Model;
}
Model.prototype.handle = function(data) {
var item, _i, _len, _results;
_results = [];
for (_i = 0, _len = data.length; _i < _len; _i++) {
item = data[_i];
_results.push(this.add(item));
}
return _results;
};
Model.prototype.add = function(data, clearCache) {
if (clearCache === null) {
clearCache = true;
}
if (clearCache) {
this._invalidateCache();
}
if (angular.isDefined(this._dataMap[data.id])) {
return this.update(data, clearCache);
} else {
this._data.push(data);
this._dataMap[data.id] = data;
}
};
Model.prototype.update = function(data, clearCache) {
var entry, key, value, _results;
if (clearCache === null) {
clearCache = true;
}
if (clearCache) {
this._invalidateCache();
}
entry = this.getById(data.id);
_results = [];
for (key in data) {
value = data[key];
if (key === 'id') {
continue;
} else {
_results.push(entry[key] = value);
}
}
return _results;
};
Model.prototype.getById = function(id) {
return this._dataMap[id];
};
Model.prototype.getAll = function() {
return this._data;
};
Model.prototype.removeById = function(id, clearCache) {
var counter, data, entry, _i, _len, _ref;
if (clearCache === null) {
clearCache = true;
}
_ref = this._data;
for (counter = _i = 0, _len = _ref.length; _i < _len; counter = ++_i) {
entry = _ref[counter];
if (entry.id === id) {
this._data.splice(counter, 1);
data = this._dataMap[id];
delete this._dataMap[id];
if (clearCache) {
this._invalidateCache();
}
return data;
}
}
};
Model.prototype.clear = function() {
this._data.length = 0;
this._dataMap = {};
return this._invalidateCache();
};
Model.prototype._invalidateCache = function() {
this._filterCache = {};
};
Model.prototype.get = function(query) {
var hash;
hash = query.hashCode();
if (!angular.isDefined(this._filterCache[hash])) {
this._filterCache[hash] = query.exec(this._data);
}
return this._filterCache[hash];
};
Model.prototype.size = function() {
return this._data.length;
};
return Model;
})();
return Model;
}
]);
]);
}).call(this);

View file

@ -21,50 +21,71 @@
(function() {
'use strict';
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
angular.module('Tasks').factory('CollectionsModel', [
'TasksModel', '_Model', function(TasksModel, _Model) {
var CollectionsModel;
CollectionsModel = (function(_super) {
__extends(CollectionsModel, _super);
function CollectionsModel(_$tasksmodel) {
this._$tasksmodel = _$tasksmodel;
this._nameCache = {};
CollectionsModel.__super__.constructor.call(this);
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key)) {
child[key] = parent[key];
}
}
function Ctor() {
this.constructor = child;
}
Ctor.prototype = parent.prototype;
child.prototype = new Ctor();
child.__super__ = parent.prototype;
return child;
},
__indexOf = [].indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) {
return i;
}
}
return -1;
};
CollectionsModel.prototype.add = function(data, clearCache) {
if (clearCache === null) {
clearCache = true;
}
this._nameCache[data.displayname] = data;
if (angular.isDefined(data.id)) {
return CollectionsModel.__super__.add.call(this, data, clearCache);
}
};
angular.module('Tasks').factory('CollectionsModel', [
'TasksModel', '_Model', function(TasksModel, _Model) {
var CollectionsModel = (function(_super) {
CollectionsModel.prototype.getCount = function(collectionID, filter) {
var count, task, tasks, _i, _len;
if (filter === null) {
filter = '';
}
count = 0;
tasks = this._$tasksmodel.filteredTasks(filter);
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
count += this._$tasksmodel.filterTasks(task, collectionID) && !task.related;
}
return count;
};
function CollectionsModel(_$tasksmodel) {
this._$tasksmodel = _$tasksmodel;
this._nameCache = {};
CollectionsModel.__super__.constructor.call(this);
}
return CollectionsModel;
__extends(CollectionsModel, _super);
})(_Model);
return new CollectionsModel(TasksModel);
}
]);
CollectionsModel.prototype.add = function(data, clearCache) {
if (clearCache === null) {
clearCache = true;
}
this._nameCache[data.displayname] = data;
if (angular.isDefined(data.id)) {
return CollectionsModel.__super__.add.call(this, data, clearCache);
}
};
CollectionsModel.prototype.getCount = function(collectionID, filter) {
var count, task, tasks, _i, _len;
if (filter === null) {
filter = '';
}
count = 0;
tasks = this._$tasksmodel.filteredTasks(filter);
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
count += this._$tasksmodel.filterTasks(task, collectionID) && !task.related;
}
return count;
};
return CollectionsModel;
})(_Model);
return new CollectionsModel(TasksModel);
}
]);
}).call(this);

View file

@ -21,153 +21,174 @@
(function() {
'use strict';
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
angular.module('Tasks').factory('ListsModel', [
'TasksModel', '_Model', function(TasksModel, _Model) {
var ListsModel;
ListsModel = (function(_super) {
__extends(ListsModel, _super);
function ListsModel(_$tasksmodel) {
this._$tasksmodel = _$tasksmodel;
this._tmpUriCache = {};
this._data = [];
this._dataMap = {};
this._filterCache = {};
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key)) {
child[key] = parent[key];
}
}
ListsModel.prototype.add = function(calendar, clearCache) {
var updateByUri;
if (clearCache === null) {
clearCache = true;
}
updateByUri = angular.isDefined(calendar.uri) && angular.isDefined(this.getByUri(calendar.uri));
if (updateByUri) {
return this.update(calendar, clearCache);
} else {
if (angular.isDefined(calendar.uri)) {
if (clearCache) {
this._invalidateCache();
}
if (!angular.isDefined(this._dataMap[calendar.uri])) {
this._data.push(calendar);
this._dataMap[calendar.uri] = calendar;
}
function Ctor() {
this.constructor = child;
}
Ctor.prototype = parent.prototype;
child.prototype = new Ctor();
child.__super__ = parent.prototype;
return child;
},
__indexOf = [].indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) {
return i;
}
}
};
}
return -1;
};
ListsModel.prototype.getByUri = function(uri) {
return this._dataMap[uri];
};
angular.module('Tasks').factory('ListsModel', [
'TasksModel', '_Model', function(TasksModel, _Model) {
var ListsModel = (function(_super) {
ListsModel.prototype.update = function(list, clearCache) {
var tmplist;
if (clearCache === null) {
clearCache = true;
}
tmplist = this._tmpIdCache[list.tmpID];
if (angular.isDefined(list.id) && angular.isDefined(tmplist) && angular.isUndefined(tmplist.id)) {
tmplist.id = list.id;
this._dataMap[list.id] = tmplist;
}
list["void"] = false;
return ListsModel.__super__.update.call(this, list, clearCache);
};
ListsModel.prototype["delete"] = function(calendar, clearCache) {
var counter, data, entry, _i, _len, _ref;
if (clearCache === null) {
clearCache = true;
}
_ref = this._data;
for (counter = _i = 0, _len = _ref.length; _i < _len; counter = ++_i) {
entry = _ref[counter];
if (entry === calendar) {
this._data.splice(counter, 1);
data = this._dataMap[calendar.uri];
delete this._dataMap[calendar.uri];
if (clearCache) {
this._invalidateCache();
}
return data;
}
}
};
ListsModel.prototype.getStandardList = function() {
var calendars;
if (this.size()) {
calendars = this.getAll();
return calendars[0];
}
};
ListsModel.prototype.isNameAlreadyTaken = function(displayname, uri) {
var calendar, calendars, ret, _i, _len;
calendars = this.getAll();
ret = false;
for (_i = 0, _len = calendars.length; _i < _len; _i++) {
calendar = calendars[_i];
if (calendar.displayname === displayname && calendar.uri !== uri) {
ret = true;
function ListsModel(_$tasksmodel) {
this._$tasksmodel = _$tasksmodel;
this._tmpUriCache = {};
this._data = [];
this._dataMap = {};
this._filterCache = {};
}
}
return ret;
};
ListsModel.prototype.getCount = function(calendarID, collectionID, filter) {
var count, task, tasks, _i, _len;
if (filter === null) {
filter = '';
}
count = 0;
tasks = this._$tasksmodel.filteredTasks(filter);
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
count += this._$tasksmodel.filterTasks(task, collectionID) && task.calendar.uri === calendarID && !task.related;
}
// if (collectionID === 'completed' && filter === '') {
// count += this.notLoaded(calendarID);
// }
return count;
};
__extends(ListsModel, _super);
ListsModel.prototype.loadedCompleted = function(calendarID) {
if (angular.isUndefined(this.getById(calendarID))) {
return false;
} else {
return this.getById(calendarID).loadedCompleted;
}
};
ListsModel.prototype.add = function(calendar, clearCache) {
var updateByUri;
if (clearCache === null) {
clearCache = true;
}
updateByUri = angular.isDefined(calendar.uri) && angular.isDefined(this.getByUri(calendar.uri));
if (updateByUri) {
return this.update(calendar, clearCache);
} else {
if (angular.isDefined(calendar.uri)) {
if (clearCache) {
this._invalidateCache();
}
if (!angular.isDefined(this._dataMap[calendar.uri])) {
this._data.push(calendar);
this._dataMap[calendar.uri] = calendar;
}
}
}
};
ListsModel.prototype.setLoadedCompleted = function(calendarID) {
this.getById(calendarID).loadedCompleted = true;
};
ListsModel.prototype.getByUri = function(uri) {
return this._dataMap[uri];
};
ListsModel.prototype.getColor = function(calendarID) {
if (angular.isUndefined(this.getById(calendarID))) {
return '#CCCCCC';
} else {
return this.getById(calendarID).calendarcolor;
}
};
ListsModel.prototype.update = function(list, clearCache) {
var tmplist;
if (clearCache === null) {
clearCache = true;
}
tmplist = this._tmpIdCache[list.tmpID];
if (angular.isDefined(list.id) && angular.isDefined(tmplist) && angular.isUndefined(tmplist.id)) {
tmplist.id = list.id;
this._dataMap[list.id] = tmplist;
}
list["void"] = false;
return ListsModel.__super__.update.call(this, list, clearCache);
};
ListsModel.prototype.getName = function(calendarID) {
if (angular.isUndefined(this.getById(calendarID))) {
return '';
} else {
return this.getById(calendarID).displayname;
}
};
ListsModel.prototype["delete"] = function(calendar, clearCache) {
var counter, data, entry, _i, _len, _ref;
if (clearCache === null) {
clearCache = true;
}
_ref = this._data;
for (counter = _i = 0, _len = _ref.length; _i < _len; counter = ++_i) {
entry = _ref[counter];
if (entry === calendar) {
this._data.splice(counter, 1);
data = this._dataMap[calendar.uri];
delete this._dataMap[calendar.uri];
if (clearCache) {
this._invalidateCache();
}
return data;
}
}
};
return ListsModel;
ListsModel.prototype.getStandardList = function() {
var calendars;
if (this.size()) {
calendars = this.getAll();
return calendars[0];
}
};
})(_Model);
return new ListsModel(TasksModel);
}
]);
ListsModel.prototype.isNameAlreadyTaken = function(displayname, uri) {
var calendar, calendars, ret, _i, _len;
calendars = this.getAll();
ret = false;
for (_i = 0, _len = calendars.length; _i < _len; _i++) {
calendar = calendars[_i];
if (calendar.displayname === displayname && calendar.uri !== uri) {
ret = true;
}
}
return ret;
};
ListsModel.prototype.getCount = function(calendarID, collectionID, filter) {
var count, task, tasks, _i, _len;
if (filter === null) {
filter = '';
}
count = 0;
tasks = this._$tasksmodel.filteredTasks(filter);
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
count += this._$tasksmodel.filterTasks(task, collectionID) && task.calendar.uri === calendarID && !task.related;
}
// if (collectionID === 'completed' && filter === '') {
// count += this.notLoaded(calendarID);
// }
return count;
};
ListsModel.prototype.loadedCompleted = function(calendarID) {
if (angular.isUndefined(this.getById(calendarID))) {
return false;
} else {
return this.getById(calendarID).loadedCompleted;
}
};
ListsModel.prototype.setLoadedCompleted = function(calendarID) {
this.getById(calendarID).loadedCompleted = true;
};
ListsModel.prototype.getColor = function(calendarID) {
if (angular.isUndefined(this.getById(calendarID))) {
return '#CCCCCC';
} else {
return this.getById(calendarID).calendarcolor;
}
};
ListsModel.prototype.getName = function(calendarID) {
if (angular.isUndefined(this.getById(calendarID))) {
return '';
} else {
return this.getById(calendarID).displayname;
}
};
return ListsModel;
})(_Model);
return new ListsModel(TasksModel);
}
]);
}).call(this);

View file

@ -21,43 +21,61 @@
(function() {
'use strict';
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
angular.module('Tasks').factory('SettingsModel', [
'_Model', function(_Model) {
var SettingsModel;
SettingsModel = (function(_super) {
__extends(SettingsModel, _super);
function SettingsModel() {
this._nameCache = {};
SettingsModel.__super__.constructor.call(this);
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key)) {
child[key] = parent[key];
}
}
function Ctor() {
this.constructor = child;
}
Ctor.prototype = parent.prototype;
child.prototype = new Ctor();
child.__super__ = parent.prototype;
return child;
},
__indexOf = [].indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) {
return i;
}
}
return -1;
};
SettingsModel.prototype.add = function(data, clearCache) {
if (clearCache === null) {
clearCache = true;
}
this._nameCache[data.displayname] = data;
if (angular.isDefined(data.id)) {
return SettingsModel.__super__.add.call(this, data, clearCache);
} else {
return this._data.push(data);
}
};
angular.module('Tasks').factory('SettingsModel', [
'_Model', function(_Model) {
var SettingsModel = (function(_super) {
SettingsModel.prototype.toggle = function(type, setting) {
var set;
set = this.getById(type);
this.getById(type)[setting] = !set[setting];
};
function SettingsModel() {
this._nameCache = {};
SettingsModel.__super__.constructor.call(this);
}
return SettingsModel;
__extends(SettingsModel, _super);
})(_Model);
return new SettingsModel();
}
]);
SettingsModel.prototype.add = function(data, clearCache) {
if (clearCache === null) {
clearCache = true;
}
this._nameCache[data.displayname] = data;
if (angular.isDefined(data.id)) {
return SettingsModel.__super__.add.call(this, data, clearCache);
} else {
return this._data.push(data);
}
};
SettingsModel.prototype.toggle = function(type, setting) {
var set;
set = this.getById(type);
this.getById(type)[setting] = !set[setting];
};
return SettingsModel;
})(_Model);
return new SettingsModel();
}
]);
}).call(this);

View file

@ -21,394 +21,420 @@
(function() {
'use strict';
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
angular.module('Tasks').factory('TasksModel', [
'_Model', function(_Model) {
var TasksModel = (function(_super) {
__extends(TasksModel, _super);
function TasksModel() {
this._tmpIdCache = {};
TasksModel.__super__.constructor.call(this);
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key)) {
child[key] = parent[key];
}
}
function Ctor() {
this.constructor = child;
}
Ctor.prototype = parent.prototype;
child.prototype = new Ctor();
child.__super__ = parent.prototype;
return child;
},
__indexOf = [].indexOf || function(item) {
for (var i = 0, l = this.length; i < l; i++) {
if (i in this && this[i] === item) {
return i;
}
}
return -1;
};
TasksModel.prototype.ad = function(task, clearCache) {
if (clearCache === null) {
clearCache = true;
angular.module('Tasks').factory('TasksModel', [
'_Model', function(_Model) {
var TasksModel = (function(_super) {
function TasksModel() {
this._tmpIdCache = {};
TasksModel.__super__.constructor.call(this);
}
var updateByUri = angular.isDefined(task.uri) && angular.isDefined(this.getByUri(task.uri));
if (updateByUri) {
return this.update(task, clearCache);
} else {
if (angular.isDefined(task.uri)) {
if (clearCache) {
__extends(TasksModel, _super);
TasksModel.prototype.ad = function(task, clearCache) {
if (clearCache === null) {
clearCache = true;
}
var updateByUri = angular.isDefined(task.uri) && angular.isDefined(this.getByUri(task.uri));
if (updateByUri) {
return this.update(task, clearCache);
} else {
if (angular.isDefined(task.uri)) {
if (clearCache) {
this._invalidateCache();
}
if (!angular.isDefined(this._dataMap[task.uri])) {
this._data.push(task);
this._dataMap[task.uri] = task;
}
}
}
};
TasksModel.prototype.getByUri = function(uri) {
return this._dataMap[uri];
};
TasksModel.prototype.update = function(task, clearCache) {
var entry, key, value, _results;
if (clearCache === null) {
clearCache = true;
}
if (clearCache) {
this._invalidateCache();
}
entry = this.getByUri(task.uri);
entry.components = task.components;
entry.components.toString();
return entry;
};
TasksModel.prototype.removeById = function(taskID) {
return TasksModel.__super__.removeById.call(this, taskID);
};
TasksModel.prototype["delete"] = function(task, clearCache) {
var counter, data, entry, _i, _len, _ref;
if (clearCache === null) {
clearCache = true;
}
_ref = this._data;
for (counter = _i = 0, _len = _ref.length; _i < _len; counter = ++_i) {
entry = _ref[counter];
if (entry === task) {
this._data.splice(counter, 1);
data = this._dataMap[task.uri];
delete this._dataMap[task.uri];
if (clearCache) {
this._invalidateCache();
}
if (!angular.isDefined(this._dataMap[task.uri])) {
this._data.push(task);
this._dataMap[task.uri] = task;
}
return data;
}
}
}
};
};
TasksModel.prototype.getByUri = function(uri) {
return this._dataMap[uri];
};
TasksModel.prototype.update = function(task, clearCache) {
var entry, key, value, _results;
if (clearCache === null) {
clearCache = true;
}
if (clearCache) {
this._invalidateCache();
}
entry = this.getByUri(task.uri);
entry.components = task.components;
entry.components.toString();
return entry;
};
TasksModel.prototype.removeById = function(taskID) {
return TasksModel.__super__.removeById.call(this, taskID);
};
TasksModel.prototype["delete"] = function(task, clearCache) {
var counter, data, entry, _i, _len, _ref;
if (clearCache === null) {
clearCache = true;
}
_ref = this._data;
for (counter = _i = 0, _len = _ref.length; _i < _len; counter = ++_i) {
entry = _ref[counter];
if (entry === task) {
this._data.splice(counter, 1);
data = this._dataMap[task.uri];
delete this._dataMap[task.uri];
if (clearCache) {
this._invalidateCache();
}
return data;
}
}
};
TasksModel.prototype.removeByList = function(listID) {
var id, task, taskIDs, tasks, _i, _j, _len, _len1, _results;
tasks = this.getAll();
taskIDs = [];
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
if (task.calendarid === listID) {
taskIDs.push(task.id);
}
}
_results = [];
for (_j = 0, _len1 = taskIDs.length; _j < _len1; _j++) {
id = taskIDs[_j];
_results.push(this.removeById(id));
}
return _results;
};
TasksModel.prototype.taskAtDay = function(task, date) {
var diff, due, duediff, start, startdiff;
start = moment(task.start, "YYYYMMDDTHHmmss");
due = moment(task.due, "YYYYMMDDTHHmmss");
if (start.isValid() && !due.isValid()) {
diff = start.diff(moment().startOf('day'), 'days', true);
if (!date && diff < date + 1) {
return true;
} else if (diff < date + 1 && diff >= date) {
return true;
}
}
if (due.isValid() && !start.isValid()) {
diff = due.diff(moment().startOf('day'), 'days', true);
if (!date && diff < date + 1) {
return true;
} else if (diff < date + 1 && diff >= date) {
return true;
}
}
if (start.isValid() && due.isValid()) {
startdiff = start.diff(moment().startOf('day'), 'days', true);
duediff = due.diff(moment().startOf('day'), 'days', true);
if (!date && (startdiff < date + 1 || duediff < date + 1)) {
return true;
} else if (startdiff < date + 1 && startdiff >= date && duediff >= date) {
return true;
} else if (duediff < date + 1 && duediff >= date && startdiff >= date) {
return true;
}
}
return false;
};
TasksModel.prototype.isLoaded = function(task) {
if (this.getById(task.id)) {
return true;
} else {
return false;
}
};
TasksModel.prototype.hasSubtasks = function(uid) {
var task, tasks, _i, _len;
tasks = this.getAll();
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
if (task.related === uid) {
return true;
}
}
return false;
};
TasksModel.prototype.hasCompletedSubtasks = function(uid) {
var task, tasks, _i, _len;
tasks = this.getAll();
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
if (task.related === uid && task.completed) {
return true;
}
}
return false;
};
TasksModel.prototype.hasNoParent = function(task) {
var t, tasks, _i, _len;
if (!task.related) {
return true;
} else {
tasks = this.getAll();
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
t = tasks[_i];
if (task.related === t.uid && task !== t) {
return false;
}
}
return true;
}
};
TasksModel.prototype.getIdByUid = function(uid) {
var task, tasks, _i, _len;
tasks = this.getAll();
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
if (task.uid === uid) {
return task.id;
TasksModel.prototype.removeByList = function(listID) {
var id, task, taskIDs, tasks, _results;
tasks = this.getAll();
taskIDs = [];
for (var _i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
if (task.calendarid === listID) {
taskIDs.push(task.id);
}
}
}
return false;
};
TasksModel.prototype.getByUid = function(uid) {
var task, tasks, _i, _len;
tasks = this.getAll();
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
if (task.uid === uid) {
return task;
_results = [];
for (var _j = 0, _len1 = taskIDs.length; _j < _len1; _j++) {
id = taskIDs[_j];
_results.push(this.removeById(id));
}
}
return null;
};
return _results;
};
TasksModel.prototype.getChildren = function(task) {
var children, t, tasks, _i, _len;
tasks = this.getAll();
children = [];
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
t = tasks[_i];
if (t.related === task.uid && t !== task) {
children.push(t);
TasksModel.prototype.taskAtDay = function(task, date) {
var diff, due, duediff, start, startdiff;
start = moment(task.start, "YYYYMMDDTHHmmss");
due = moment(task.due, "YYYYMMDDTHHmmss");
if (start.isValid() && !due.isValid()) {
diff = start.diff(moment().startOf('day'), 'days', true);
if (!date && diff < date + 1) {
return true;
} else if (diff < date + 1 && diff >= date) {
return true;
}
}
}
return children;
};
if (due.isValid() && !start.isValid()) {
diff = due.diff(moment().startOf('day'), 'days', true);
if (!date && diff < date + 1) {
return true;
} else if (diff < date + 1 && diff >= date) {
return true;
}
}
if (start.isValid() && due.isValid()) {
startdiff = start.diff(moment().startOf('day'), 'days', true);
duediff = due.diff(moment().startOf('day'), 'days', true);
if (!date && (startdiff < date + 1 || duediff < date + 1)) {
return true;
} else if (startdiff < date + 1 && startdiff >= date && duediff >= date) {
return true;
} else if (duediff < date + 1 && duediff >= date && startdiff >= date) {
return true;
}
}
return false;
};
TasksModel.prototype.getDescendantIDs = function(task) {
var child, children, descendantIDs, _i, _len;
children = this.getChildren(task);
descendantIDs = [];
for (_i = 0, _len = children.length; _i < _len; _i++) {
child = children[_i];
descendantIDs = descendantIDs.concat(child.uri);
descendantIDs = descendantIDs.concat(this.getDescendantIDs(child));
}
return descendantIDs;
};
TasksModel.prototype.isLoaded = function(task) {
if (this.getById(task.id)) {
return true;
} else {
return false;
}
};
TasksModel.prototype.filterTasks = function(task, filter) {
switch (filter) {
case 'completed':
return task.completed === true;
case 'all':
return task.completed === false;
case 'current':
return task.completed === false && this.current(task.start, task.due);
case 'starred':
return task.completed === false && task.priority > 5;
case 'today':
return task.completed === false && (this.today(task.start) || this.today(task.due));
case 'week':
return task.completed === false && (this.week(task.start) || this.week(task.due));
default:
return '' + task.calendar.uri === '' + filter;
}
};
TasksModel.prototype.hasSubtasks = function(uid) {
var tasks = this.getAll();
for (var _i = 0, _len = tasks.length; _i < _len; _i++) {
var task = tasks[_i];
if (task.related === uid) {
return true;
}
}
return false;
};
TasksModel.prototype.filteredTasks = function(needle) {
var ancestors, parentID, ret, task, tasks, _i, _len;
ret = [];
tasks = this.getAll();
if (!needle) {
ret = tasks;
} else {
for (_i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
if (this.filterTasksByString(task, needle)) {
if (this.objectExists(task, ret)) {
continue;
}
ret.push(task);
parentID = this.getIdByUid(task.related);
ancestors = this.getAncestor(parentID, ret);
if (ancestors) {
ret = ret.concat(ancestors);
}
}
}
}
return ret;
};
TasksModel.prototype.hasCompletedSubtasks = function(uid) {
var tasks = this.getAll();
for (var _i = 0, _len = tasks.length; _i < _len; _i++) {
var task = tasks[_i];
if (task.related === uid && task.completed) {
return true;
}
}
return false;
};
TasksModel.prototype.objectExists = function(task, ret) {
var re, _i, _len;
for (_i = 0, _len = ret.length; _i < _len; _i++) {
re = ret[_i];
if (re.id === task.id) {
return true;
}
}
return false;
};
TasksModel.prototype.hasNoParent = function(task) {
if (!task.related) {
return true;
} else {
var tasks = this.getAll();
for (var _i = 0, _len = tasks.length; _i < _len; _i++) {
var t = tasks[_i];
if (task.related === t.uid && task !== t) {
return false;
}
}
return true;
}
};
TasksModel.prototype.filterTasksByString = function(task, filter) {
var category, comment, key, keys, value, _i, _j, _len, _len1, _ref, _ref1;
keys = ['name', 'note', 'location', 'categories', 'comments'];
filter = filter.toLowerCase();
for (key in task) {
value = task[key];
if (__indexOf.call(keys, key) >= 0) {
if (key === 'comments') {
_ref = task.comments;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
comment = _ref[_i];
if (comment.comment.toLowerCase().indexOf(filter) !== -1) {
return true;
}
}
} else if (key === 'categories') {
_ref1 = task.categories;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
category = _ref1[_j];
if (category.toLowerCase().indexOf(filter) !== -1) {
return true;
}
}
} else if (value.toLowerCase().indexOf(filter) !== -1) {
return true;
}
}
}
return false;
};
TasksModel.prototype.getIdByUid = function(uid) {
var tasks = this.getAll();
for (var _i = 0, _len = tasks.length; _i < _len; _i++) {
var task = tasks[_i];
if (task.uid === uid) {
return task.id;
}
}
return false;
};
TasksModel.prototype.setReminder = function(taskID, reminder) {
return this.update({
id: taskID,
reminder: reminder
});
};
TasksModel.prototype.getByUid = function(uid) {
var tasks = this.getAll();
for (var _i = 0, _len = tasks.length; _i < _len; _i++) {
var task = tasks[_i];
if (task.uid === uid) {
return task;
}
}
return null;
};
TasksModel.prototype.overdue = function(due) {
return moment(due, "YYYYMMDDTHHmmss").isValid() && moment(due, "YYYYMMDDTHHmmss").diff(moment()) < 0;
};
TasksModel.prototype.getChildren = function(task) {
var children, t, tasks;
tasks = this.getAll();
children = [];
for (var _i = 0, _len = tasks.length; _i < _len; _i++) {
t = tasks[_i];
if (t.related === task.uid && t !== task) {
children.push(t);
}
}
return children;
};
TasksModel.prototype.due = function(due) {
return moment(due, 'YYYYMMDDTHHmmss').isValid();
};
TasksModel.prototype.getDescendantIDs = function(task) {
var child, children, descendantIDs;
children = this.getChildren(task);
descendantIDs = [];
for (var _i = 0, _len = children.length; _i < _len; _i++) {
child = children[_i];
descendantIDs = descendantIDs.concat(child.uri);
descendantIDs = descendantIDs.concat(this.getDescendantIDs(child));
}
return descendantIDs;
};
TasksModel.prototype.today = function(due) {
return moment(due, "YYYYMMDDTHHmmss").isValid() && moment(due, "YYYYMMDDTHHmmss").diff(moment().startOf('day'), 'days', true) < 1;
};
TasksModel.prototype.filterTasks = function(task, filter) {
switch (filter) {
case 'completed':
return task.completed === true;
case 'all':
return task.completed === false;
case 'current':
return task.completed === false && this.current(task.start, task.due);
case 'starred':
return task.completed === false && task.priority > 5;
case 'today':
return task.completed === false && (this.today(task.start) || this.today(task.due));
case 'week':
return task.completed === false && (this.week(task.start) || this.week(task.due));
default:
return '' + task.calendar.uri === '' + filter;
}
};
TasksModel.prototype.week = function(due) {
return moment(due, "YYYYMMDDTHHmmss").isValid() && moment(due, "YYYYMMDDTHHmmss").diff(moment().startOf('day'), 'days', true) < 7;
};
TasksModel.prototype.filteredTasks = function(needle) {
var ancestors, parentID, ret, task, tasks;
ret = [];
tasks = this.getAll();
if (!needle) {
ret = tasks;
} else {
for (var _i = 0, _len = tasks.length; _i < _len; _i++) {
task = tasks[_i];
if (this.filterTasksByString(task, needle)) {
if (this.objectExists(task, ret)) {
continue;
}
ret.push(task);
parentID = this.getIdByUid(task.related);
ancestors = this.getAncestor(parentID, ret);
if (ancestors) {
ret = ret.concat(ancestors);
}
}
}
}
return ret;
};
TasksModel.prototype.current = function(start, due) {
return !moment(start, "YYYYMMDDTHHmmss").isValid() || moment(start, "YYYYMMDDTHHmmss").diff(moment(), 'days', true) < 0 || moment(due, "YYYYMMDDTHHmmss").diff(moment(), 'days', true) < 0;
};
TasksModel.prototype.objectExists = function(task, ret) {
for (var _i = 0, _len = ret.length; _i < _len; _i++) {
var re = ret[_i];
if (re.id === task.id) {
return true;
}
}
return false;
};
TasksModel.prototype.addComment = function(comment) {
var task;
task = this.getById(comment.taskID);
if (task.comments) {
task.comments.push(comment);
} else {
task.comments = [comment];
}
};
TasksModel.prototype.filterTasksByString = function(task, filter) {
var key, keys, value;
keys = ['name', 'note', 'location', 'categories', 'comments'];
filter = filter.toLowerCase();
for (key in task) {
value = task[key];
if (__indexOf.call(keys, key) >= 0) {
if (key === 'comments') {
if (this.searchComments(task.comments, filter)) {
return true;
}
} else if (key === 'categories') {
if (this.searchCategories(task.categories, filter)) {
return true;
}
} else if (value.toLowerCase().indexOf(filter) !== -1) {
return true;
}
}
}
return false;
};
TasksModel.prototype.updateComment = function(comment) {
var com, i, task, _i, _len, _ref, _results;
task = this.getById(comment.taskID);
i = 0;
_ref = task.comments;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
com = _ref[_i];
if (com.tmpID === comment.tmpID) {
task.comments[i] = comment;
break;
}
_results.push(i++);
}
return _results;
};
TasksModel.prototype.searchComments = function(comments, filter) {
for (var _i = 0, _len = comments.length; _i < _len; _i++) {
var comment = comments[_i];
if (comment.comment.toLowerCase().indexOf(filter) !== -1) {
return true;
}
}
return false;
};
TasksModel.prototype.deleteComment = function(taskID, commentID) {
var comment, i, task, _i, _len, _ref, _results;
task = this.getById(taskID);
i = 0;
_ref = task.comments;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
comment = _ref[_i];
if (comment.id === commentID) {
task.comments.splice(i, 1);
break;
}
_results.push(i++);
}
return _results;
};
TasksModel.prototype.searchCategories = function(categories, filter) {
for (var _i = 0, _len = categories.length; _i < _len; _i++) {
var category = categories[_i];
if (category.toLowerCase().indexOf(filter) !== -1) {
return true;
}
}
return false;
};
return TasksModel;
TasksModel.prototype.setReminder = function(taskID, reminder) {
return this.update({
id: taskID,
reminder: reminder
});
};
})(_Model);
return new TasksModel();
}
]);
TasksModel.prototype.overdue = function(due) {
return moment(due, "YYYYMMDDTHHmmss").isValid() && moment(due, "YYYYMMDDTHHmmss").diff(moment()) < 0;
};
TasksModel.prototype.due = function(due) {
return moment(due, 'YYYYMMDDTHHmmss').isValid();
};
TasksModel.prototype.today = function(due) {
return moment(due, "YYYYMMDDTHHmmss").isValid() && moment(due, "YYYYMMDDTHHmmss").diff(moment().startOf('day'), 'days', true) < 1;
};
TasksModel.prototype.week = function(due) {
return moment(due, "YYYYMMDDTHHmmss").isValid() && moment(due, "YYYYMMDDTHHmmss").diff(moment().startOf('day'), 'days', true) < 7;
};
TasksModel.prototype.current = function(start, due) {
return !moment(start, "YYYYMMDDTHHmmss").isValid() || moment(start, "YYYYMMDDTHHmmss").diff(moment(), 'days', true) < 0 || moment(due, "YYYYMMDDTHHmmss").diff(moment(), 'days', true) < 0;
};
TasksModel.prototype.addComment = function(comment) {
var task;
task = this.getById(comment.taskID);
if (task.comments) {
task.comments.push(comment);
} else {
task.comments = [comment];
}
};
TasksModel.prototype.updateComment = function(comment) {
var com, i, task, _i, _len, _ref, _results;
task = this.getById(comment.taskID);
i = 0;
_ref = task.comments;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
com = _ref[_i];
if (com.tmpID === comment.tmpID) {
task.comments[i] = comment;
break;
}
_results.push(i++);
}
return _results;
};
TasksModel.prototype.deleteComment = function(taskID, commentID) {
var comment, i, task, _i, _len, _ref, _results;
task = this.getById(taskID);
i = 0;
_ref = task.comments;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
comment = _ref[_i];
if (comment.id === commentID) {
task.comments.splice(i, 1);
break;
}
_results.push(i++);
}
return _results;
};
return TasksModel;
})(_Model);
return new TasksModel();
}
]);
}).call(this);

View file

@ -238,7 +238,7 @@ angular.module('Tasks').factory('VTodo', ['$filter', 'ICalFactory', 'RandomStrin
var start = vtodos[0].getFirstPropertyValue('dtstart');
var due = vtodos[0].getFirstPropertyValue('due');
var d = due ? due : start;
return d!=null && d.isDate;
return d!==null && d.isDate;
},
set allDay(allDay) {
var vtodos = this.components.getAllSubcomponents('vtodo');

View file

@ -124,8 +124,8 @@ angular.module('Tasks').factory('Persistence', [
};
return this._request.post('/apps/tasks/settings/{type}/{setting}/{value}', params);
};
return Persistence;
})();
return new Persistence(Request, Loading, $rootScope, CalendarService);
return Persistence;
})();
return new Persistence(Request, Loading, $rootScope, CalendarService);
}
]);

View file

@ -27,15 +27,15 @@ angular.module('Tasks').factory('Status', [
function Status() {
this._$status = {
addingList: false,
focusTaskInput: false
focusTaskInput: false
};
}
Status.prototype.getStatus = function() {
return this._$status;
};
Status.prototype.getStatus = function() {
return this._$status;
};
return Status;
return Status;
})();
return new Status();

View file

@ -98,8 +98,8 @@ gulp.task('default', ['build', 'vendor', 'svg_sprite']);
gulp.task('lint', () => {
return gulp.src(lintSources)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'));
// .pipe(jshint.reporter('fail'));
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('scsslint', () => {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long