From 43ffaca789cccf153153b189f4ec2571784d7327 Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Mon, 26 Jun 2017 09:29:30 -0400 Subject: [PATCH] Add action links to area pages. --- .../farm_log_activity.module | 19 +------------------ .../farm_log_input/farm_log_input.module | 19 +------------------ .../farm_log_observation.module | 19 +------------------ .../farm_soil_test/farm_soil_test.module | 19 +------------------ modules/farm/farm_ui/farm_ui.api.php | 4 ++++ modules/farm/farm_ui/farm_ui.module | 15 ++++++++------- .../farm_water_test/farm_water_test.module | 19 +------------------ 7 files changed, 17 insertions(+), 97 deletions(-) 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 0004d8310..817231706 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 @@ -17,29 +17,12 @@ function farm_log_activity_farm_ui_entities() { 'label' => t('Activity'), 'label_plural' => t('Activities'), 'view' => 'farm_log_activity', + 'areas' => TRUE, ), ), ); } -/** - * Implements hook_farm_ui_actions(). - */ -function farm_log_activity_farm_ui_actions() { - - // Define farm area actions. - $actions = array( - 'activity' => array( - 'title' => t('Add an activity'), - 'href' => 'log/add/farm_activity', - 'paths' => array( - 'taxonomy/term/%', - ), - ), - ); - return $actions; -} - /** * Implements hook_farm_taxonomy_term_view_views(). */ 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 9d99ced9e..085d9ddee 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 @@ -17,29 +17,12 @@ function farm_log_input_farm_ui_entities() { 'label' => t('Input'), 'label_plural' => t('Inputs'), 'view' => 'farm_log_input', + 'areas' => TRUE, ), ), ); } -/** - * Implements hook_farm_ui_actions(). - */ -function farm_log_input_farm_ui_actions() { - - // Define farm area actions. - $actions = array( - 'input' => array( - 'title' => t('Add an input'), - 'href' => 'log/add/farm_input', - 'paths' => array( - 'taxonomy/term/%', - ), - ), - ); - return $actions; -} - /** * Implements hook_farm_taxonomy_term_view_views(). */ 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 dc4ab2f75..8b9bf7c70 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 @@ -17,29 +17,12 @@ function farm_log_observation_farm_ui_entities() { 'label' => t('Observation'), 'label_plural' => t('Observations'), 'view' => 'farm_log_observation', + 'areas' => TRUE, ), ), ); } -/** - * Implements hook_farm_ui_actions(). - */ -function farm_log_observation_farm_ui_actions() { - - // Define farm area actions. - $actions = array( - 'observation' => array( - 'title' => t('Add an observation'), - 'href' => 'log/add/farm_observation', - 'paths' => array( - 'taxonomy/term/%', - ), - ), - ); - return $actions; -} - /** * Implements hook_farm_taxonomy_term_view_views(). */ 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 96732fc20..cce85a992 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 @@ -17,29 +17,12 @@ function farm_soil_test_farm_ui_entities() { 'label_plural' => t('Soil tests'), 'view' => 'farm_log_soil_tests', 'farm_asset' => 'none', + 'areas' => TRUE, ), ), ); } -/** - * Implements hook_farm_ui_actions(). - */ -function farm_soil_test_farm_ui_actions() { - - // Define farm area actions. - $actions = array( - 'soil_test' => array( - 'title' => t('Add a soil test'), - 'href' => 'log/add/farm_soil_test', - 'paths' => array( - 'taxonomy/term/%', - ), - ), - ); - return $actions; -} - /** * Implements hook_farm_taxonomy_term_view_views(). */ diff --git a/modules/farm/farm_ui/farm_ui.api.php b/modules/farm/farm_ui/farm_ui.api.php index 294aca3eb..3d8b83730 100644 --- a/modules/farm/farm_ui/farm_ui.api.php +++ b/modules/farm/farm_ui/farm_ui.api.php @@ -71,6 +71,10 @@ function hook_farm_ui_entities() { // Set it to 'all' if the log can apply to all asset types (this is the // default behavior). 'farm_asset' => 'planting', + + // Set 'areas' to TRUE if the log type can be used on areas. + // This will add an action link on area pages. + 'areas' => TRUE, ), ), diff --git a/modules/farm/farm_ui/farm_ui.module b/modules/farm/farm_ui/farm_ui.module index c9febdef3..dcc3608e1 100644 --- a/modules/farm/farm_ui/farm_ui.module +++ b/modules/farm/farm_ui/farm_ui.module @@ -218,7 +218,7 @@ function farm_ui_farm_ui_actions() { ); } - // If the entity is a log, add an action link on asset view pages. + // If the entity is a log, add an action link on asset and area pages. if ($entity_type == 'log') { // If 'farm_asset' is empty, or if it is set to 'all', add to all @@ -227,14 +227,15 @@ function farm_ui_farm_ui_actions() { $actions[$bundle]['assets'] = array('all'); } - // Or, if 'farm_asset' is set to 'none', don't display anything. - elseif ($info['farm_asset'] == 'none') { - continue; + // Otherwise, if 'farm_asset' is not set to 'none', pass the specified + // asset through. + elseif ($info['farm_asset'] != 'none') { + $actions[$bundle]['assets'] = array($info['farm_asset']); } - // Otherwise, pass the specified asset through. - else { - $actions[$bundle]['assets'] = array($info['farm_asset']); + // Only add an action link on area pages if 'areas' is set to TRUE. + if (!empty($info['areas']) && $info['areas'] === TRUE) { + $actions[$bundle]['paths'] = array('taxonomy/term/%'); } } } 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 f27911a64..2daf09f89 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 @@ -17,29 +17,12 @@ function farm_water_test_farm_ui_entities() { 'label_plural' => t('Water test'), 'view' => 'farm_water_test', 'farm_asset' => 'none', + 'areas' => TRUE, ), ), ); } -/** - * Implements hook_farm_ui_actions(). - */ -function farm_water_test_farm_ui_actions() { - - // Define farm area actions. - $actions = array( - 'water_test' => array( - 'title' => t('Add a water test'), - 'href' => 'log/add/farm_water_test', - 'paths' => array( - 'taxonomy/term/%', - ), - ), - ); - return $actions; -} - /** * Implements hook_farm_taxonomy_term_view_views(). */