Added a new "adaptive" chore period type (closes #1495)

This commit is contained in:
Bernd Bestel
2022-02-10 18:06:33 +01:00
parent 091a93ff4e
commit 69a7ea6057
12 changed files with 147 additions and 13 deletions

View File

@@ -176,6 +176,10 @@ $('.input-group-chore-period-type').on('change keyup', function(e)
{
$('#chore-schedule-info').text(__n(periodInterval, 'This means the next execution of this chore is scheduled every year on the same day (based on the start date)', 'This means the next execution of this chore is scheduled every %s years on the same day (based on the start date)'));
}
else if (periodType === 'adaptive')
{
$('#chore-schedule-info').text(__t('This means the next execution of this chore is scheduled dynamically based on the past average execution frequency'));
}
Grocy.FrontendHelpers.ValidateForm('chore-form');
});
@@ -190,23 +194,23 @@ $('.input-group-chore-assignment-type').on('change', function(e)
if (assignmentType === 'no-assignment')
{
$('#chore-assignment-type-info').attr("data-original-title", __t('This means the next execution of this chore will not be assigned to anyone'));
$('#chore-assignment-type-info').text(__t('This means the next execution of this chore will not be assigned to anyone'));
}
else if (assignmentType === 'who-least-did-first')
{
$('#chore-assignment-type-info').attr("data-original-title", __t('This means the next execution of this chore will be assigned to the one who executed it least'));
$('#chore-assignment-type-info').text(__t('This means the next execution of this chore will be assigned to the one who executed it least'));
$("#assignment_config").attr("required", "");
$("#assignment_config").removeAttr("disabled");
}
else if (assignmentType === 'random')
{
$('#chore-assignment-type-info').attr("data-original-title", __t('This means the next execution of this chore will be assigned randomly'));
$('#chore-assignment-type-info').text(__t('This means the next execution of this chore will be assigned randomly'));
$("#assignment_config").attr("required", "");
$("#assignment_config").removeAttr("disabled");
}
else if (assignmentType === 'in-alphabetical-order')
{
$('#chore-assignment-type-info').attr("data-original-title", __t('This means the next execution of this chore will be assigned to the next one in alphabetical order'));
$('#chore-assignment-type-info').text(__t('This means the next execution of this chore will be assigned to the next one in alphabetical order'));
$("#assignment_config").attr("required", "");
$("#assignment_config").removeAttr("disabled");
}

View File

@@ -31,6 +31,15 @@ Grocy.Components.ChoreCard.Refresh = function(choreId)
$("#chorecard-chore-last-tracked-timeago").removeClass("timeago-date-only");
}
if (choreDetails.average_execution_frequency_hours == null)
{
$('#chorecard-average-execution-frequency').text(__t("Unknown"));
}
else
{
$('#chorecard-average-execution-frequency').text(moment.duration(parseInt(choreDetails.average_execution_frequency_hours) / 24, "days").humanize());
}
RefreshContextualTimeago(".chorecard");
},
function(xhr)