Added a chore period type "yearly" (closes #407)

This commit is contained in:
Bernd Bestel 2019-10-04 11:24:51 +02:00
parent 28b23fd313
commit ba6bfa6a2c
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
7 changed files with 19 additions and 2 deletions

View File

@ -5,7 +5,8 @@
- Fixed that recipes were displayed without ingredients if the total recipe count was > 100 - Fixed that recipes were displayed without ingredients if the total recipe count was > 100
### Chores improvements ### Chores improvements
- Added a "period interval" option per chore to have more flexible schedules (possible for the daily/weekly/monthly schedules, means "schedule this chore only every x days/weeks/months" to have for example biweekly schedules) - Added a new period type "yearly" (for yearly schedules)
- Added a "period interval" option per chore to have more flexible schedules (possible for the daily/weekly/monthly/yearly schedules, means "schedule this chore only every x days/weeks/months" to have for example biweekly schedules)
### General & other improvements ### General & other improvements
- New Input shorthands for date fields to increase/decrease the date by 1 month/year (shift + arrow keys, see the full list [here](https://github.com/grocy/grocy#input-shorthands-for-date-fields)) - New Input shorthands for date fields to increase/decrease the date by 1 month/year (shift + arrow keys, see the full list [here](https://github.com/grocy/grocy#input-shorthands-for-date-fields))

View File

@ -26,3 +26,6 @@ msgstr ""
msgid "monthly" msgid "monthly"
msgstr "" msgstr ""
msgid "yearly"
msgstr ""

View File

@ -1558,3 +1558,9 @@ msgstr ""
msgid "This means the next execution of this chore should only be scheduled every %s months" msgid "This means the next execution of this chore should only be scheduled every %s months"
msgstr "" msgstr ""
msgid "This means the next execution of this chore is scheduled 1 year after the last execution"
msgstr ""
msgid "This means the next execution of this chore should only be scheduled every %s years"
msgstr ""

View File

@ -34,6 +34,7 @@ SELECT
WHEN period_config LIKE '%saturday%' THEN DATETIME(IFNULL(MAX(l.tracked_time), DATETIME('now', 'localtime')), '1 days', '+' || CAST((h.period_interval - 1) * 7 AS TEXT) || ' days', 'weekday 6') WHEN period_config LIKE '%saturday%' THEN DATETIME(IFNULL(MAX(l.tracked_time), DATETIME('now', 'localtime')), '1 days', '+' || CAST((h.period_interval - 1) * 7 AS TEXT) || ' days', 'weekday 6')
END END
WHEN 'monthly' THEN DATETIME(IFNULL(MAX(l.tracked_time), DATETIME('now', 'localtime')), '+' || CAST(h.period_interval AS TEXT) || ' month', 'start of month', '+' || CAST(h.period_days - 1 AS TEXT) || ' day') WHEN 'monthly' THEN DATETIME(IFNULL(MAX(l.tracked_time), DATETIME('now', 'localtime')), '+' || CAST(h.period_interval AS TEXT) || ' month', 'start of month', '+' || CAST(h.period_days - 1 AS TEXT) || ' day')
WHEN 'yearly' THEN DATETIME(IFNULL(MAX(l.tracked_time), DATETIME('now', 'localtime')), '+' || CAST(h.period_interval AS TEXT) || ' years')
END AS next_estimated_execution_time, END AS next_estimated_execution_time,
h.track_date_only, h.track_date_only,
h.rollover, h.rollover,

View File

@ -157,6 +157,11 @@ $('.input-group-chore-period-type').on('change', function(e)
$("#period_days").parent().find(".invalid-feedback").text(__t('The amount must be between %1$s and %2$s', "1", "31")); $("#period_days").parent().find(".invalid-feedback").text(__t('The amount must be between %1$s and %2$s', "1", "31"));
$('#chore-period-interval-info').text(__t('This means the next execution of this chore should only be scheduled every %s months', periodInterval.toString())); $('#chore-period-interval-info').text(__t('This means the next execution of this chore should only be scheduled every %s months', periodInterval.toString()));
} }
else if (periodType === 'yearly')
{
$('#chore-period-type-info').text(__t('This means the next execution of this chore is scheduled 1 year after the last execution'));
$('#chore-period-interval-info').text(__t('This means the next execution of this chore should only be scheduled every %s years', periodInterval.toString()));
}
Grocy.FrontendHelpers.ValidateForm('chore-form'); Grocy.FrontendHelpers.ValidateForm('chore-form');
}); });

View File

@ -11,6 +11,7 @@ class ChoresService extends BaseService
const CHORE_PERIOD_TYPE_DAILY = 'daily'; const CHORE_PERIOD_TYPE_DAILY = 'daily';
const CHORE_PERIOD_TYPE_WEEKLY = 'weekly'; const CHORE_PERIOD_TYPE_WEEKLY = 'weekly';
const CHORE_PERIOD_TYPE_MONTHLY = 'monthly'; const CHORE_PERIOD_TYPE_MONTHLY = 'monthly';
const CHORE_PERIOD_TYPE_YEARLY = 'yearly';
const CHORE_ASSIGNMENT_TYPE_NO_ASSIGNMENT = 'no-assignment'; const CHORE_ASSIGNMENT_TYPE_NO_ASSIGNMENT = 'no-assignment';
const CHORE_ASSIGNMENT_TYPE_WHO_LEAST_DID_FIRST = 'who-least-did-first'; const CHORE_ASSIGNMENT_TYPE_WHO_LEAST_DID_FIRST = 'who-least-did-first';

View File

@ -94,7 +94,7 @@
'min' => '1', 'min' => '1',
'additionalCssClasses' => 'input-group-chore-period-type', 'additionalCssClasses' => 'input-group-chore-period-type',
'invalidFeedback' => $__t('This cannot be lower than %s', '1'), 'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
'additionalGroupCssClasses' => 'period-type-input period-type-daily period-type-weekly period-type-monthly', 'additionalGroupCssClasses' => 'period-type-input period-type-daily period-type-weekly period-type-monthly period-type-yearly',
'hintId' => 'chore-period-interval-info' 'hintId' => 'chore-period-interval-info'
)) ))