Last updates fixing errors on recent metadata blocks. #566.
This commit is contained in:
parent
7c9607de94
commit
263de085ca
|
@ -1033,7 +1033,7 @@ class Item extends Entity {
|
|||
|
||||
$metadata_section = $args['metadata_section'];
|
||||
$metadata_section_object = null;
|
||||
|
||||
|
||||
// A metadata section object was passed
|
||||
if ( $metadata_section instanceof \Tainacan\Entities\Metadata_Section ) {
|
||||
$metadata_section_object = $metadata_section;
|
||||
|
@ -1045,7 +1045,7 @@ class Item extends Entity {
|
|||
// The default metadata section was passed
|
||||
} elseif ( $metadata_section == \Tainacan\Entities\Metadata_Section::$default_section_slug ) {
|
||||
$metadata_section_object = $Tainacan_Metadata_Sections->get_default_section($this->get_collection_id());
|
||||
|
||||
|
||||
// A metadata section slug was passed
|
||||
} elseif ( is_string($metadata_section) ) {
|
||||
$query = $Tainacan_Metadata_Sections->fetch(['slug' => $metadata_section], 'OBJECT');
|
||||
|
|
|
@ -136,9 +136,9 @@ class Metadata_Sections extends Repository {
|
|||
* @return \Tainacan\Entities\Metadata_Section|false return de the default metadata section or false otherwise.
|
||||
*/
|
||||
public function get_default_section ($collection) {
|
||||
if($collection instanceof Entities\Collection) {
|
||||
if ($collection instanceof Entities\Collection) {
|
||||
$collection_id = $collection->get_id();
|
||||
} else if (is_int($collection)) {
|
||||
} else if (is_numeric($collection)) {
|
||||
$collection_id = $collection;
|
||||
$collection = \tainacan_collections()->fetch($collection, 'OBJECT');
|
||||
} else {
|
||||
|
|
|
@ -1262,6 +1262,7 @@ class Theme_Helper {
|
|||
|
||||
// Gets the current Item. This way, the function can be used in the loop without needing to pass it
|
||||
$item = isset($args['itemId']) ? $this->tainacan_get_item($args['itemId']) : $this->tainacan_get_item();
|
||||
$item_id = $item->get_id();
|
||||
if (!$item)
|
||||
return;
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ export default function ({ attributes, setAttributes, className, isSelected }) {
|
|||
.then(response => {
|
||||
|
||||
let metadataSection = response.data ? response.data : [];
|
||||
|
||||
|
||||
getMetadataSectionTemplates({
|
||||
sectionId: String(metadataSection.id),
|
||||
sectionName: metadataSection.name,
|
||||
|
@ -113,12 +113,13 @@ export default function ({ attributes, setAttributes, className, isSelected }) {
|
|||
'tainacan/metadata-section-description',
|
||||
]);
|
||||
}
|
||||
|
||||
if (sectionMetadata.length) {
|
||||
metadataSectionTemplate.push([
|
||||
'tainacan/item-metadata',
|
||||
{
|
||||
sectionId: String(sectionId),
|
||||
itemId: isDynamic ? Number(itemId) : 0,
|
||||
itemId: isNaN(itemId) ? 0 : Number(itemId),
|
||||
collectionId: Number(collectionId),
|
||||
metadata: sectionMetadata,
|
||||
dataSource: 'parent',
|
||||
|
|
|
@ -15,7 +15,7 @@ function tainacan_blocks_render_metadata_section( $block_attributes, $content, $
|
|||
$collection_id = isset($block_attributes['collectionId']) ? $block_attributes['collectionId'] : false;
|
||||
$section_id = isset($block_attributes['sectionId']) ? $block_attributes['sectionId'] : false;
|
||||
$template_mode = isset($block_attributes['templateMode']) ? $block_attributes['templateMode'] : false;
|
||||
|
||||
|
||||
// Builds args from backend query
|
||||
$args = [
|
||||
'metadata_section' => $section_id
|
||||
|
|
|
@ -159,7 +159,7 @@ export default function ({ attributes, setAttributes, className, isSelected }) {
|
|||
{ isModalOpen ?
|
||||
<SingleItemModal
|
||||
modalTitle={ templateMode ? __('Select one metadata section', 'tainacan') : __('Select one item to render its metadata section', 'tainacan') }
|
||||
applyButtonLabel={ templateMode ? __('Show this metadata section', 'tainacan') : __('Show this metadata section for this item', 'tainacan') }
|
||||
applyButtonLabel={ templateMode ? __('Show metadata sections', 'tainacan') : __('Show metadata sections for this item', 'tainacan') }
|
||||
existingCollectionId={ collectionId }
|
||||
existingItemId={ itemId }
|
||||
onSelectCollection={ (selectedCollectionId) => {
|
||||
|
|
Loading…
Reference in New Issue