mirror of
https://github.com/grocy/grocy.git
synced 2025-08-08 07:19:32 +00:00
Make it possible to track any information on chore execution (by using Userfields, closes #825)
This commit is contained in:
parent
27b46e1abf
commit
198216f38b
@ -70,7 +70,10 @@
|
||||
- This happens automatically on consuming a recipe/product from the meal plan page
|
||||
- Fixed that stock fulfillment checking used the desired servings of the recipe (those selected on the recipes page, not them from the meal plan entry)
|
||||
|
||||
### Chores fixes
|
||||
### Chores improvements(fixes
|
||||
- It's now possible to track any addtional info on a chore execution by using Userfields
|
||||
- => Configure the desired Userfields for the entity `chores_log`
|
||||
- => The on chore execution tracking entered information is then visible on the corresponding chore journal entry
|
||||
- Fixed that tracking chores with "Done by" a different user was not possible
|
||||
|
||||
### Userfield fixes
|
||||
|
@ -62,7 +62,9 @@ class ChoresController extends BaseController
|
||||
return $this->renderPage($response, 'choresjournal', [
|
||||
'choresLog' => $this->getDatabase()->chores_log()->orderBy('tracked_time', 'DESC'),
|
||||
'chores' => $this->getDatabase()->chores()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
|
||||
'users' => $this->getDatabase()->users()->orderBy('username')
|
||||
'users' => $this->getDatabase()->users()->orderBy('username'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('chores_log'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('chores_log')
|
||||
]);
|
||||
}
|
||||
|
||||
@ -85,7 +87,8 @@ class ChoresController extends BaseController
|
||||
{
|
||||
return $this->renderPage($response, 'choretracking', [
|
||||
'chores' => $this->getDatabase()->chores()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
|
||||
'users' => $this->getDatabase()->users()->orderBy('username')
|
||||
'users' => $this->getDatabase()->users()->orderBy('username'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('chores_log'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -5447,7 +5447,7 @@
|
||||
"stock_log",
|
||||
"stock",
|
||||
"stock_current_locations",
|
||||
"api_keys"
|
||||
"chores_log"
|
||||
]
|
||||
},
|
||||
"ExposedEntityNoListing": {
|
||||
@ -5462,7 +5462,8 @@
|
||||
"stock_log",
|
||||
"api_keys",
|
||||
"stock",
|
||||
"stock_current_locations"
|
||||
"stock_current_locations",
|
||||
"chores_log"
|
||||
]
|
||||
},
|
||||
"ExposedEntityNoDelete": {
|
||||
@ -5470,7 +5471,8 @@
|
||||
"enum": [
|
||||
"stock_log",
|
||||
"stock",
|
||||
"stock_current_locations"
|
||||
"stock_current_locations",
|
||||
"chores_log"
|
||||
]
|
||||
},
|
||||
"ExposedEntityEditRequiresAdmin": {
|
||||
|
@ -16,16 +16,20 @@
|
||||
Grocy.Api.Post('chores/' + jsonForm.chore_id + '/execute', { 'tracked_time': Grocy.Components.DateTimePicker.GetValue(), 'done_by': $("#user_id").val() },
|
||||
function(result)
|
||||
{
|
||||
Grocy.FrontendHelpers.EndUiBusy("choretracking-form");
|
||||
toastr.success(__t('Tracked execution of chore %1$s on %2$s', choreDetails.chore.name, Grocy.Components.DateTimePicker.GetValue()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoChoreExecution(' + result.id + ')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||
Grocy.Components.ChoreCard.Refresh($('#chore_id').val());
|
||||
Grocy.EditObjectId = result.id;
|
||||
Grocy.Components.UserfieldsForm.Save(function()
|
||||
{
|
||||
Grocy.FrontendHelpers.EndUiBusy("choretracking-form");
|
||||
toastr.success(__t('Tracked execution of chore %1$s on %2$s', choreDetails.chore.name, Grocy.Components.DateTimePicker.GetValue()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoChoreExecution(' + result.id + ')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||
Grocy.Components.ChoreCard.Refresh($('#chore_id').val());
|
||||
|
||||
$('#chore_id').val('');
|
||||
$('#chore_id_text_input').focus();
|
||||
$('#chore_id_text_input').val('');
|
||||
Grocy.Components.DateTimePicker.SetValue(moment().format('YYYY-MM-DD HH:mm:ss'));
|
||||
$('#chore_id_text_input').trigger('change');
|
||||
Grocy.FrontendHelpers.ValidateForm('choretracking-form');
|
||||
$('#chore_id').val('');
|
||||
$('#chore_id_text_input').focus();
|
||||
$('#chore_id_text_input').val('');
|
||||
Grocy.Components.DateTimePicker.SetValue(moment().format('YYYY-MM-DD HH:mm:ss'));
|
||||
$('#chore_id_text_input').trigger('change');
|
||||
Grocy.FrontendHelpers.ValidateForm('choretracking-form');
|
||||
});
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@ -59,7 +59,9 @@ class UserfieldsService extends BaseService
|
||||
$userEntities[] = 'userentity-' . $userentity->name;
|
||||
}
|
||||
|
||||
return array_merge($exposedDefaultEntities, $userEntities, $specialEntities);
|
||||
$entitiesSorted = array_merge($exposedDefaultEntities, $userEntities, $specialEntities);
|
||||
sort($entitiesSorted);
|
||||
return $entitiesSorted;
|
||||
}
|
||||
|
||||
public function GetField($fieldId)
|
||||
|
@ -77,6 +77,10 @@
|
||||
@if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS)
|
||||
<th>{{ $__t('Done by') }}</th>
|
||||
@endif
|
||||
|
||||
@include('components.userfields_thead', array(
|
||||
'userfields' => $userfields
|
||||
))
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="d-none">
|
||||
@ -116,6 +120,11 @@
|
||||
@endif
|
||||
</td>
|
||||
@endif
|
||||
|
||||
@include('components.userfields_tbody', array(
|
||||
'userfields' => $userfields,
|
||||
'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $choreLogEntry->id)
|
||||
))
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
@ -52,6 +52,11 @@
|
||||
value="{{ GROCY_USER_ID }}">
|
||||
@endif
|
||||
|
||||
@include('components.userfieldsform', array(
|
||||
'userfields' => $userfields,
|
||||
'entity' => 'chores_log'
|
||||
))
|
||||
|
||||
<button id="save-choretracking-button"
|
||||
class="btn btn-success">{{ $__t('OK') }}</button>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user