From 8a83ed57919993a8ff3a235bcf6ac05e15af895a Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Sun, 25 Jun 2017 10:33:35 -0400 Subject: [PATCH] Build breadcrumbs and action links for log entities in farm_ui module. --- modules/farm/farm_crop/farm_crop.module | 18 ++++++++++++------ .../farm/farm_equipment/farm_equipment.module | 10 +++++++--- .../farm/farm_livestock/farm_livestock.module | 10 +++++++--- .../farm_livestock_eggs.module | 19 ++++++++----------- .../farm_log_activity.module | 18 +++++++++++++++--- .../farm_log_harvest/farm_log_harvest.module | 18 +++++++++++++++--- .../farm_log_input/farm_log_input.module | 18 +++++++++++++++--- .../farm_log_observation.module | 18 +++++++++++++++--- .../farm_log_sale/farm_log_sale.module | 18 +++++++++++++++--- .../farm_soil_test/farm_soil_test.module | 18 +++++++++++++++--- modules/farm/farm_ui/farm_ui.api.php | 17 +++++++++++++++++ modules/farm/farm_ui/farm_ui.info | 1 + modules/farm/farm_ui/farm_ui.module | 12 +++++++++++- .../farm_water_test/farm_water_test.module | 18 +++++++++++++++--- 14 files changed, 168 insertions(+), 45 deletions(-) diff --git a/modules/farm/farm_crop/farm_crop.module b/modules/farm/farm_crop/farm_crop.module index 776040d87..76204611b 100644 --- a/modules/farm/farm_crop/farm_crop.module +++ b/modules/farm/farm_crop/farm_crop.module @@ -161,6 +161,18 @@ function farm_crop_farm_ui_entities() { 'view' => 'farm_plantings', ), ), + 'log' => array( + 'farm_seeding' => array( + 'label' => t('Seeding'), + 'label_plural' => t('Seedings'), + 'view' => 'farm_log_seeding', + ), + 'farm_transplanting' => array( + 'label' => t('Transplanting'), + 'label_plural' => t('Transplantings'), + 'view' => 'farm_log_transplanting', + ), + ), 'taxonomy_term' => array( 'farm_crops' => array( 'label' => t('Crop/variety'), @@ -190,9 +202,6 @@ function farm_crop_farm_ui_actions() { 'assets' => array( 'planting', ), - 'views' => array( - 'farm_log_seeding', - ), ), 'transplanting' => array( 'title' => t('Add a transplanting'), @@ -200,9 +209,6 @@ function farm_crop_farm_ui_actions() { 'assets' => array( 'planting', ), - 'views' => array( - 'farm_log_transplanting', - ), ), ); return $actions; diff --git a/modules/farm/farm_equipment/farm_equipment.module b/modules/farm/farm_equipment/farm_equipment.module index ec5f5547b..9a5f6edb6 100644 --- a/modules/farm/farm_equipment/farm_equipment.module +++ b/modules/farm/farm_equipment/farm_equipment.module @@ -18,6 +18,13 @@ function farm_equipment_farm_ui_entities() { 'view' => 'farm_equipment', ), ), + 'log' => array( + 'farm_maintenance' => array( + 'label' => t('Maintenance'), + 'label_plural' => t('Maintenance'), + 'view' => 'farm_log_maintenance', + ), + ), ); } @@ -34,9 +41,6 @@ function farm_equipment_farm_ui_actions() { 'assets' => array( 'equipment', ), - 'views' => array( - 'farm_log_maintenance', - ), ), ); return $actions; diff --git a/modules/farm/farm_livestock/farm_livestock.module b/modules/farm/farm_livestock/farm_livestock.module index 4d5b5002c..04e679aa5 100644 --- a/modules/farm/farm_livestock/farm_livestock.module +++ b/modules/farm/farm_livestock/farm_livestock.module @@ -18,6 +18,13 @@ function farm_livestock_farm_ui_entities() { 'view' => 'farm_animals', ), ), + 'log' => array( + 'farm_medical' => array( + 'label' => t('Medical record'), + 'label_plural' => t('Medical records'), + 'view' => 'farm_log_medical', + ), + ), 'taxonomy_term' => array( 'farm_animal_groups' => array( 'label' => t('Group'), @@ -61,9 +68,6 @@ function farm_livestock_farm_ui_actions() { 'assets' => array( 'animal', ), - 'views' => array( - 'farm_log_medical', - ), ), ); return $actions; diff --git a/modules/farm/farm_livestock/farm_livestock_eggs/farm_livestock_eggs.module b/modules/farm/farm_livestock/farm_livestock_eggs/farm_livestock_eggs.module index 190842e67..60a32b2f8 100644 --- a/modules/farm/farm_livestock/farm_livestock_eggs/farm_livestock_eggs.module +++ b/modules/farm/farm_livestock/farm_livestock_eggs/farm_livestock_eggs.module @@ -7,19 +7,16 @@ include_once 'farm_livestock_eggs.features.inc'; /** - * Implements hook_farm_ui_actions(). + * Implements hook_farm_ui_entities(). */ -function farm_livestock_eggs_farm_ui_actions() { - - // Define farm area actions. - $actions = array( - 'eggs' => array( - 'title' => t('Add eggs'), - 'href' => 'log/add/farm_eggs', - 'views' => array( - 'farm_log_eggs', +function farm_livestock_eggs_farm_ui_entities() { + return array( + 'log' => array( + 'farm_eggs' => array( + 'label' => t('Egg log'), + 'label_plural' => t('Egg logs'), + 'view' => 'farm_log_eggs', ), ), ); - return $actions; } diff --git a/modules/farm/farm_log/farm_log_activity/farm_log_activity.module b/modules/farm/farm_log/farm_log_activity/farm_log_activity.module index 9ece51c93..1d6f788b1 100644 --- a/modules/farm/farm_log/farm_log_activity/farm_log_activity.module +++ b/modules/farm/farm_log/farm_log_activity/farm_log_activity.module @@ -7,6 +7,21 @@ // Include Features code. include_once 'farm_log_activity.features.inc'; +/** + * Implements hook_farm_ui_entities(). + */ +function farm_log_activity_farm_ui_entities() { + return array( + 'log' => array( + 'farm_activity' => array( + 'label' => t('Activity'), + 'label_plural' => t('Activities'), + 'view' => 'farm_log_activity', + ), + ), + ); +} + /** * Implements hook_farm_ui_actions(). */ @@ -20,9 +35,6 @@ function farm_log_activity_farm_ui_actions() { 'assets' => array( 'all', ), - 'views' => array( - 'farm_log_activity', - ), 'paths' => array( 'taxonomy/term/%', ), diff --git a/modules/farm/farm_log/farm_log_harvest/farm_log_harvest.module b/modules/farm/farm_log/farm_log_harvest/farm_log_harvest.module index 5cfa2e7fd..03c4ddcd4 100644 --- a/modules/farm/farm_log/farm_log_harvest/farm_log_harvest.module +++ b/modules/farm/farm_log/farm_log_harvest/farm_log_harvest.module @@ -7,6 +7,21 @@ // Include Features code. include_once 'farm_log_harvest.features.inc'; +/** + * Implements hook_farm_ui_entities(). + */ +function farm_log_harvest_farm_ui_entities() { + return array( + 'log' => array( + 'farm_harvest' => array( + 'label' => t('Harvest'), + 'label_plural' => t('Harvests'), + 'view' => 'farm_log_harvest', + ), + ), + ); +} + /** * Implements hook_farm_ui_actions(). */ @@ -20,9 +35,6 @@ function farm_log_harvest_farm_ui_actions() { 'assets' => array( 'all', ), - 'views' => array( - 'farm_log_harvest', - ), ), ); return $actions; diff --git a/modules/farm/farm_log/farm_log_input/farm_log_input.module b/modules/farm/farm_log/farm_log_input/farm_log_input.module index 5839fe221..8ef7974b5 100644 --- a/modules/farm/farm_log/farm_log_input/farm_log_input.module +++ b/modules/farm/farm_log/farm_log_input/farm_log_input.module @@ -7,6 +7,21 @@ // Include Features code. include_once 'farm_log_input.features.inc'; +/** + * Implements hook_farm_ui_entities(). + */ +function farm_log_input_farm_ui_entities() { + return array( + 'log' => array( + 'farm_input' => array( + 'label' => t('Input'), + 'label_plural' => t('Inputs'), + 'view' => 'farm_log_input', + ), + ), + ); +} + /** * Implements hook_farm_ui_actions(). */ @@ -20,9 +35,6 @@ function farm_log_input_farm_ui_actions() { 'assets' => array( 'all', ), - 'views' => array( - 'farm_log_input', - ), 'paths' => array( 'taxonomy/term/%', ), diff --git a/modules/farm/farm_log/farm_log_observation/farm_log_observation.module b/modules/farm/farm_log/farm_log_observation/farm_log_observation.module index 0d1762570..62df546d5 100644 --- a/modules/farm/farm_log/farm_log_observation/farm_log_observation.module +++ b/modules/farm/farm_log/farm_log_observation/farm_log_observation.module @@ -7,6 +7,21 @@ // Include Features code. include_once 'farm_log_observation.features.inc'; +/** + * Implements hook_farm_ui_entities(). + */ +function farm_log_observation_farm_ui_entities() { + return array( + 'log' => array( + 'farm_observation' => array( + 'label' => t('Observation'), + 'label_plural' => t('Observations'), + 'view' => 'farm_log_observation', + ), + ), + ); +} + /** * Implements hook_farm_ui_actions(). */ @@ -20,9 +35,6 @@ function farm_log_observation_farm_ui_actions() { 'assets' => array( 'all', ), - 'views' => array( - 'farm_log_observation', - ), 'paths' => array( 'taxonomy/term/%', ), diff --git a/modules/farm/farm_log/farm_log_sale/farm_log_sale.module b/modules/farm/farm_log/farm_log_sale/farm_log_sale.module index 021e7d932..7ee53338f 100644 --- a/modules/farm/farm_log/farm_log_sale/farm_log_sale.module +++ b/modules/farm/farm_log/farm_log_sale/farm_log_sale.module @@ -6,6 +6,21 @@ include_once 'farm_log_sale.features.inc'; +/** + * Implements hook_farm_ui_entities(). + */ +function farm_log_sale_farm_ui_entities() { + return array( + 'log' => array( + 'farm_sale' => array( + 'label' => t('Sale'), + 'label_plural' => t('Sales'), + 'view' => 'farm_log_sale', + ), + ), + ); +} + /** * Implements hook_farm_ui_actions(). */ @@ -19,9 +34,6 @@ function farm_log_sale_farm_ui_actions() { 'assets' => array( 'all', ), - 'views' => array( - 'farm_log_sale', - ), ), ); return $actions; diff --git a/modules/farm/farm_soil/farm_soil_test/farm_soil_test.module b/modules/farm/farm_soil/farm_soil_test/farm_soil_test.module index 7b02f39c9..1240dd492 100644 --- a/modules/farm/farm_soil/farm_soil_test/farm_soil_test.module +++ b/modules/farm/farm_soil/farm_soil_test/farm_soil_test.module @@ -6,6 +6,21 @@ include_once 'farm_soil_test.features.inc'; +/** + * Implements hook_farm_ui_entities(). + */ +function farm_soil_test_farm_ui_entities() { + return array( + 'log' => array( + 'farm_soil_test' => array( + 'label' => t('Soil test'), + 'label_plural' => t('Soil tests'), + 'view' => 'farm_log_soil_tests', + ), + ), + ); +} + /** * Implements hook_farm_ui_actions(). */ @@ -16,9 +31,6 @@ function farm_soil_test_farm_ui_actions() { 'soil_test' => array( 'title' => t('Add a soil test'), 'href' => 'log/add/farm_soil_test', - 'views' => array( - 'farm_log_soil_tests', - ), 'paths' => array( 'taxonomy/term/%', ), diff --git a/modules/farm/farm_ui/farm_ui.api.php b/modules/farm/farm_ui/farm_ui.api.php index 104c94295..5e7aac1d0 100644 --- a/modules/farm/farm_ui/farm_ui.api.php +++ b/modules/farm/farm_ui/farm_ui.api.php @@ -49,6 +49,23 @@ function hook_farm_ui_entities() { ), ), + // Define log entity types provided by this module. + 'log' => array( + + // Seedings: + 'farm_seeding' => array( + + // Label. + 'label' => t('Seeding'), + + // Label (plural). + 'label_plural' => t('Seedings'), + + // View of seedings (optional). + 'view' => 'farm_log_seeding', + ), + ), + // Define taxonomy_term vocabularies provided by this module. 'taxonomy_term' => array( diff --git a/modules/farm/farm_ui/farm_ui.info b/modules/farm/farm_ui/farm_ui.info index 0fc85c182..e21fc9b6e 100644 --- a/modules/farm/farm_ui/farm_ui.info +++ b/modules/farm/farm_ui/farm_ui.info @@ -3,5 +3,6 @@ description = Provides standardized user interface elements to farmOS modules. core = 7.x package = farmOS dependencies[] = farm_asset +dependencies[] = farm_log dependencies[] = taxonomy dependencies[] = views diff --git a/modules/farm/farm_ui/farm_ui.module b/modules/farm/farm_ui/farm_ui.module index b5da81321..f653c4919 100644 --- a/modules/farm/farm_ui/farm_ui.module +++ b/modules/farm/farm_ui/farm_ui.module @@ -15,9 +15,10 @@ function farm_ui_entity_view($entity, $type, $view_mode, $langcode) { return; } - // We are only concerned with farm_asset and taxonomy_term entities. + // We are only concerned with farm_asset, log, and taxonomy_term, entities. $entity_types = array( 'farm_asset', + 'log', 'taxonomy_term', ); if (!in_array($type, $entity_types)) { @@ -27,6 +28,7 @@ function farm_ui_entity_view($entity, $type, $view_mode, $langcode) { // Determine the bundle based on the type. switch ($type) { case 'farm_asset': + case 'log': $bundle = $entity->type; break; case 'taxonomy_term': @@ -83,6 +85,11 @@ function farm_ui_entity_type_breadcrumb($type, $bundle) { $breadcrumb[] = l(t('Assets'), 'farm/assets'); } + // Or, if this is a log entity, add a link to the full logs list. + elseif ($type == 'log') { + $breadcrumb[] = l(t('Logs'), 'farm/logs'); + } + // If this is a taxonomy_term entity, and it is linked to a specific asset // type, add the asset breadcrumb trail (recurse into this function again). if ($type == 'taxonomy_term' && !empty($ui_info['farm_asset'])) { @@ -193,6 +200,9 @@ function farm_ui_farm_ui_actions() { case 'farm_asset': $path = 'farm/asset/add/' . $bundle; break; + case 'log': + $path = 'log/add/' . $bundle; + break; case 'taxonomy_term': $path = 'admin/structure/taxonomy/' . $bundle . '/add'; break; diff --git a/modules/farm/farm_water/farm_water_test/farm_water_test.module b/modules/farm/farm_water/farm_water_test/farm_water_test.module index 793deccac..b8c582353 100644 --- a/modules/farm/farm_water/farm_water_test/farm_water_test.module +++ b/modules/farm/farm_water/farm_water_test/farm_water_test.module @@ -6,6 +6,21 @@ include_once 'farm_water_test.features.inc'; +/** + * Implements hook_farm_ui_entities(). + */ +function farm_water_test_farm_ui_entities() { + return array( + 'log' => array( + 'farm_water_test' => array( + 'label' => t('Water test'), + 'label_plural' => t('Water test'), + 'view' => 'farm_water_test', + ), + ), + ); +} + /** * Implements hook_farm_ui_actions(). */ @@ -16,9 +31,6 @@ function farm_water_test_farm_ui_actions() { 'water_test' => array( 'title' => t('Add a water test'), 'href' => 'log/add/farm_water_test', - 'views' => array( - 'farm_water_test', - ), 'paths' => array( 'taxonomy/term/%', ),