Add sensor type to sensor asset view and expose sensor type as a filter.
This commit is contained in:
parent
01e1f05c46
commit
a36ffec752
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Farm Sensor Views data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_views_data().
|
||||||
|
*/
|
||||||
|
function farm_sensor_views_data() {
|
||||||
|
|
||||||
|
// Describe the {farm_sensor} table to Views.
|
||||||
|
$data['farm_sensor']['table']['group'] = t('Sensor');
|
||||||
|
|
||||||
|
// Create an implicit relationship to the farm_asset table, so that when the
|
||||||
|
// base table is farm_asset, sensor fields are automatically available.
|
||||||
|
$data['farm_sensor']['table']['join'] = array(
|
||||||
|
'farm_asset' => array(
|
||||||
|
'left_field' => 'id',
|
||||||
|
'field' => 'id',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Sensor reading name.
|
||||||
|
$data['farm_sensor']['type'] = array(
|
||||||
|
'title' => t('Sensor type'),
|
||||||
|
'help' => t('Type of sensor.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_string',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
|
@ -201,6 +201,11 @@ function farm_sensor_views_default_views() {
|
||||||
$handler->display->display_options['fields']['id']['field'] = 'id';
|
$handler->display->display_options['fields']['id']['field'] = 'id';
|
||||||
$handler->display->display_options['fields']['id']['label'] = 'Asset ID';
|
$handler->display->display_options['fields']['id']['label'] = 'Asset ID';
|
||||||
$handler->display->display_options['fields']['id']['separator'] = '';
|
$handler->display->display_options['fields']['id']['separator'] = '';
|
||||||
|
/* Field: Sensor: Sensor type */
|
||||||
|
$handler->display->display_options['fields']['type']['id'] = 'type';
|
||||||
|
$handler->display->display_options['fields']['type']['table'] = 'farm_sensor';
|
||||||
|
$handler->display->display_options['fields']['type']['field'] = 'type';
|
||||||
|
$handler->display->display_options['fields']['type']['label'] = 'Sensor Type';
|
||||||
/* Field: Farm asset: Name */
|
/* Field: Farm asset: Name */
|
||||||
$handler->display->display_options['fields']['name']['id'] = 'name';
|
$handler->display->display_options['fields']['name']['id'] = 'name';
|
||||||
$handler->display->display_options['fields']['name']['table'] = 'farm_asset';
|
$handler->display->display_options['fields']['name']['table'] = 'farm_asset';
|
||||||
|
@ -325,6 +330,19 @@ function farm_sensor_views_default_views() {
|
||||||
$handler->display->display_options['filters']['archived_boolean']['expose']['label'] = 'Archived';
|
$handler->display->display_options['filters']['archived_boolean']['expose']['label'] = 'Archived';
|
||||||
$handler->display->display_options['filters']['archived_boolean']['expose']['operator'] = 'archived_boolean_op';
|
$handler->display->display_options['filters']['archived_boolean']['expose']['operator'] = 'archived_boolean_op';
|
||||||
$handler->display->display_options['filters']['archived_boolean']['expose']['identifier'] = 'archived_boolean';
|
$handler->display->display_options['filters']['archived_boolean']['expose']['identifier'] = 'archived_boolean';
|
||||||
|
/* Filter criterion: Sensor: Sensor type */
|
||||||
|
$handler->display->display_options['filters']['type_1']['id'] = 'type_1';
|
||||||
|
$handler->display->display_options['filters']['type_1']['table'] = 'farm_sensor';
|
||||||
|
$handler->display->display_options['filters']['type_1']['field'] = 'type';
|
||||||
|
$handler->display->display_options['filters']['type_1']['operator'] = 'contains';
|
||||||
|
$handler->display->display_options['filters']['type_1']['exposed'] = TRUE;
|
||||||
|
$handler->display->display_options['filters']['type_1']['expose']['operator_id'] = 'type_1_op';
|
||||||
|
$handler->display->display_options['filters']['type_1']['expose']['label'] = 'Sensor Type';
|
||||||
|
$handler->display->display_options['filters']['type_1']['expose']['operator'] = 'type_1_op';
|
||||||
|
$handler->display->display_options['filters']['type_1']['expose']['identifier'] = 'sensor_type';
|
||||||
|
$handler->display->display_options['filters']['type_1']['expose']['remember_roles'] = array(
|
||||||
|
2 => '2',
|
||||||
|
);
|
||||||
|
|
||||||
/* Display: Page */
|
/* Display: Page */
|
||||||
$handler = $view->new_display('page', 'Page', 'page');
|
$handler = $view->new_display('page', 'Page', 'page');
|
||||||
|
@ -384,6 +402,7 @@ function farm_sensor_views_default_views() {
|
||||||
t('Delete'),
|
t('Delete'),
|
||||||
t('Asset ID'),
|
t('Asset ID'),
|
||||||
t('.'),
|
t('.'),
|
||||||
|
t('Sensor Type'),
|
||||||
t('Name'),
|
t('Name'),
|
||||||
t('Description'),
|
t('Description'),
|
||||||
t('Flags'),
|
t('Flags'),
|
||||||
|
|
Loading…
Reference in New Issue