Add action links to area pages.

This commit is contained in:
Michael Stenta 2017-06-26 09:29:30 -04:00
parent b9688b40d3
commit 43ffaca789
7 changed files with 17 additions and 97 deletions

View File

@ -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().
*/

View File

@ -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().
*/

View File

@ -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().
*/

View File

@ -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().
*/

View File

@ -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,
),
),

View File

@ -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/%');
}
}
}

View File

@ -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().
*/