feat: add option `display_in_related_items` on relationship metadata type
This commit is contained in:
parent
f675fa9602
commit
4034ca811e
|
@ -618,6 +618,10 @@ class Items extends Repository {
|
|||
[
|
||||
'key' => '_option_collection_id',
|
||||
'value' => $current_collection->get_id()
|
||||
],
|
||||
[
|
||||
'key' => '_option_display_in_related_items',
|
||||
'value' => 'yes'
|
||||
]
|
||||
]
|
||||
], 'OBJECT');
|
||||
|
|
|
@ -62,6 +62,10 @@ class Relationship extends Metadata_Type {
|
|||
'repeated' => [
|
||||
'title' =>__( 'Allow repeated items', 'tainacan' ),
|
||||
'description' => __( 'Allows different items to be related to the same item selected in another collection.', 'tainacan' ),
|
||||
],
|
||||
'display_in_related_items' => [
|
||||
'title' =>__( 'Display in related items', 'tainacan' ),
|
||||
'description' => __( 'Include items on related item list.', 'tainacan' ),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
@ -119,6 +123,15 @@ class Relationship extends Metadata_Type {
|
|||
$readable_option_value = $option_value;
|
||||
break;
|
||||
|
||||
case 'display_in_related_items':
|
||||
if ($option_value == 'yes')
|
||||
$readable_option_value = __('Yes', 'tainacan');
|
||||
else if ($option_value == 'no')
|
||||
$readable_option_value = __('No', 'tainacan');
|
||||
else
|
||||
$readable_option_value = $option_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
$readable_option_value = $option_value;
|
||||
}
|
||||
|
@ -148,6 +161,12 @@ class Relationship extends Metadata_Type {
|
|||
'search' => __('Search option must be a numeric Metadatum ID','tainacan')
|
||||
];
|
||||
}
|
||||
// empty is ok
|
||||
if ( !empty($this->get_option('display_in_related_items')) && !in_array($this->get_option('display_in_related_items'), ['yes', 'no']) ) {
|
||||
return [
|
||||
'search' => __('Display in related items must be a option yes or no','tainacan')
|
||||
];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue