mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
Use the new area argument position function in farm_ui_area_links().
This commit is contained in:
parent
0ded4a4408
commit
3120539ca7
1 changed files with 12 additions and 23 deletions
|
@ -753,30 +753,19 @@ function farm_ui_area_links($id, $entity_type) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Use the area ID as the View's default argument.
|
||||
// If the entity is a log, and it doesn't apply to areas, skip it.
|
||||
if ($entity_type == 'log' && (empty($info['areas']) || $info['areas'] !== TRUE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine the position of the area ID argument in the View, and build
|
||||
// the arguments array accordingly. If the area ID is in the second
|
||||
// argument position, then we assume that asset ID is the first argument,
|
||||
// and we set that to 'all' to include all assets.
|
||||
$args = array($id);
|
||||
|
||||
// If the entity is a log...
|
||||
if ($entity_type == 'log') {
|
||||
|
||||
// Only proceed if the log type has 'areas' set to TRUE.
|
||||
if (empty($info['areas']) || $info['areas'] !== TRUE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Log View arguments are a bit more complicated than Asset Views.
|
||||
// Most logs apply to assets, so have an asset contextual filter
|
||||
// first, and an area contextual filter second. Some logs do not
|
||||
// apply to assets, so the first contextual filter is the area ID.
|
||||
// The pattern we follow here is: if the entity UI info has
|
||||
// 'farm_asset' set to 'none', then we assume that 'area ID' is the
|
||||
// first argument. Otherwise, we assume that 'asset ID' is the first,
|
||||
// and 'area ID' is the second. In the case of area links, we only
|
||||
// care about the 'area ID', so we set the 'asset ID' argument to
|
||||
// 'all'.
|
||||
if ($info['farm_asset'] != 'none') {
|
||||
array_unshift($args, 'all');
|
||||
}
|
||||
$area_argument_position = farm_ui_views_area_argument_position($entity_type, $bundle);
|
||||
if ($area_argument_position == 2) {
|
||||
array_unshift($args, 'all');
|
||||
}
|
||||
|
||||
// Load the View and generate a preview to count rows.
|
||||
|
|
Loading…
Reference in a new issue