Finish first version of tasks feature

This commit is contained in:
Bernd Bestel
2018-09-23 19:26:13 +02:00
parent f85a67a1ff
commit 06f25b7006
16 changed files with 239 additions and 24 deletions

View File

@@ -29,6 +29,10 @@ if (Grocy.Components.DateTimePicker.GetInputElement().data('init-with-now') ===
{
startDate = moment().format(Grocy.Components.DateTimePicker.GetInputElement().data('format'));
}
if (Grocy.Components.DateTimePicker.GetInputElement().data('init-value').length > 0)
{
startDate = moment(Grocy.Components.DateTimePicker.GetInputElement().data('init-value')).format(Grocy.Components.DateTimePicker.GetInputElement().data('format'));
}
var limitDate = moment('2999-12-31 23:59:59');
if (Grocy.Components.DateTimePicker.GetInputElement().data('limit-end-to-now') === true)

View File

@@ -2,9 +2,14 @@
{
e.preventDefault();
var jsonData = $('#task-form').serializeJSON();
jsonData.assigned_to_user_id = jsonData.user_id;
delete jsonData.user_id;
jsonData.due_date = Grocy.Components.DateTimePicker.GetValue();
if (Grocy.EditMode === 'create')
{
Grocy.Api.Post('add-object/tasks', $('#task-form').serializeJSON(),
Grocy.Api.Post('add-object/tasks', jsonData,
function(result)
{
window.location.href = U('/tasks');
@@ -17,7 +22,7 @@
}
else
{
Grocy.Api.Post('edit-object/tasks/' + Grocy.EditObjectId, $('#task-form').serializeJSON(),
Grocy.Api.Post('edit-object/tasks/' + Grocy.EditObjectId, jsonData,
function(result)
{
window.location.href = U('/tasks');

View File

@@ -35,9 +35,23 @@ $(document).on('click', '.do-task-button', function(e)
var taskName = $(e.currentTarget).attr('data-task-name');
var doneTime = moment().format('YYYY-MM-DD HH:mm:ss');
Grocy.Api.Get('tasks/mark-task-done/' + taskId + '?tracked_time=' + doneTime,
Grocy.Api.Get('tasks/mark-task-as-completed/' + taskId + '?done_time=' + doneTime,
function()
{
if (!$("#show-done-tasks").is(":checked"))
{
$('#task-' + taskId + '-row').fadeOut(500, function ()
{
$(this).remove();
});
}
else
{
$('#task-' + taskId + '-row').addClass("text-muted");
$('#task-' + taskId + '-name').addClass("text-strike-through");
$('.do-task-button[data-task-id="' + taskId + '"]').addClass("disabled");
}
toastr.success(L('Marked task #1 as completed on #2', taskName, doneTime));
RefreshContextualTimeago();
RefreshStatistics();
@@ -88,6 +102,23 @@ $(document).on('click', '.delete-task-button', function (e)
});
});
$("#show-done-tasks").change(function()
{
if (this.checked)
{
window.location.href = U('/tasks?include_done');
}
else
{
window.location.href = U('/tasks');
}
});
if (GetUriParam('include_done'))
{
$("#show-done-tasks").prop('checked', true);
}
function RefreshStatistics()
{
var nextXDays = $("#info-due-tasks").data("next-x-days");