mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
Add current location field to Asset View.
This commit is contained in:
parent
0241c7759f
commit
2bb5e442a7
4 changed files with 111 additions and 1 deletions
|
@ -0,0 +1,4 @@
|
|||
# Schema for the asset location views field handler.
|
||||
views.field.asset_location:
|
||||
type: views.field.field
|
||||
label: 'Asset location field handler'
|
|
@ -50,6 +50,23 @@ function farm_location_entity_base_field_info(EntityTypeInterface $entity_type)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_data_alter().
|
||||
*/
|
||||
function farm_location_views_data_alter(array &$data) {
|
||||
|
||||
// Add the current asset location computed field to Views.
|
||||
if (isset($data['asset'])) {
|
||||
$data['asset']['location'] = [
|
||||
'title' => t('Current location'),
|
||||
'field' => [
|
||||
'id' => 'asset_location',
|
||||
'field_name' => 'location',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default value for asset location and fixed boolean fields.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\farm_location\Plugin\views\field;
|
||||
|
||||
use Drupal\views\Plugin\views\field\EntityField;
|
||||
|
||||
/**
|
||||
* A field that displays asset location.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* @ViewsField("asset_location")
|
||||
*/
|
||||
class AssetLocation extends EntityField {
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ dependencies:
|
|||
module:
|
||||
- asset
|
||||
- csv_serialization
|
||||
- farm_location
|
||||
- image
|
||||
- options
|
||||
- rest
|
||||
|
@ -94,6 +95,7 @@ display:
|
|||
name: name
|
||||
type: type
|
||||
flag_value: flag_value
|
||||
location: location
|
||||
status: status
|
||||
info:
|
||||
asset_bulk_form:
|
||||
|
@ -132,13 +134,20 @@ display:
|
|||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
status:
|
||||
location:
|
||||
sortable: false
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
status:
|
||||
sortable: true
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
default: name
|
||||
empty_table: true
|
||||
row:
|
||||
|
@ -528,6 +537,70 @@ display:
|
|||
entity_type: asset
|
||||
entity_field: flag
|
||||
plugin_id: field
|
||||
location:
|
||||
id: location
|
||||
table: asset
|
||||
field: location
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: Location
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
click_sort_column: target_id
|
||||
type: entity_reference_label
|
||||
settings:
|
||||
link: true
|
||||
group_column: target_id
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
entity_type: asset
|
||||
plugin_id: asset_location
|
||||
status:
|
||||
id: status
|
||||
table: asset_field_data
|
||||
|
|
Loading…
Reference in a new issue