Build breadcrumbs and action links for log entities in farm_ui module.

This commit is contained in:
Michael Stenta 2017-06-25 10:33:35 -04:00
parent 9b3fc109cc
commit 8a83ed5791
14 changed files with 168 additions and 45 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

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

View File

@ -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;

View File

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

View File

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

View File

@ -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;

View File

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

View File

@ -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(

View File

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

View File

@ -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;

View File

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