Use asset names helper function to generate log names when using the group/move actions.

This commit is contained in:
Michael Stenta 2021-08-30 16:57:29 -04:00
parent 835209e5a2
commit 8f98db20b6
3 changed files with 13 additions and 2 deletions

View File

@ -6,3 +6,4 @@ core_version_requirement: ^9
dependencies:
- farm:farm_entity
- farm:farm_location
- farm:farm_log

View File

@ -201,9 +201,14 @@ class AssetGroupActionForm extends ConfirmFormBase {
$date = $form_state->getValue('date');
$done = (bool) $form_state->getValue('done', FALSE);
// Generate a name for the log.
$asset_names = farm_log_asset_names_summary($accessible_entities);
$group_names = farm_log_asset_names_summary($groups);
$log_name = $this->t('Group :assets into :groups', [':assets' => $asset_names, ':groups' => $group_names]);
// Create the log.
// @todo Populate the log name with a summary helper function.
$log = Log::create([
'name' => $log_name,
'type' => 'observation',
'timestamp' => $date->getTimestamp(),
'asset' => $accessible_entities,

View File

@ -200,9 +200,14 @@ class AssetMoveActionForm extends ConfirmFormBase {
$date = $form_state->getValue('date');
$done = (bool) $form_state->getValue('done', FALSE);
// Generate a name for the log.
$asset_names = farm_log_asset_names_summary($accessible_entities);
$location_names = farm_log_asset_names_summary($locations);
$log_name = $this->t('Move :assets to :locations', [':assets' => $asset_names, ':locations' => $location_names]);
// Create the log.
// @todo Populate the log name with a summary helper function.
$log = Log::create([
'name' => $log_name,
'type' => 'activity',
'timestamp' => $date->getTimestamp(),
'asset' => $accessible_entities,