diff --git a/src/admin/components/lists/items-list.vue b/src/admin/components/lists/items-list.vue index b831a6beb..a8372275e 100644 --- a/src/admin/components/lists/items-list.vue +++ b/src/admin/components/lists/items-list.vue @@ -185,9 +185,10 @@ export default { if( ! metadata || metadata.value === false || metadata.value == undefined || metadata.value == '' ) return ''; - if( Array.isArray( metadata.value ) ){ + if( metadata.value instanceof Array ){ let result = []; for( let val of metadata.value ){ + this.$console.log(val); result.push( ( val.name ) ? val.name : val ) } return result.join(', '); diff --git a/src/api/endpoints/class-tainacan-rest-items-controller.php b/src/api/endpoints/class-tainacan-rest-items-controller.php index a710990a9..a949a3867 100644 --- a/src/api/endpoints/class-tainacan-rest-items-controller.php +++ b/src/api/endpoints/class-tainacan-rest-items-controller.php @@ -99,9 +99,10 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_REST_Controller { foreach($item_metadata as $index => $me){ $field = $me->get_field(); $slug = $field->get_slug(); + $item_metadata_array = $me->__toArray(); $item_array['metadata'][$slug]['name'] = $field->get_name(); - $item_array['metadata'][$slug]['value'] = $me->get_value(); + $item_array['metadata'][$slug]['value'] = $item_metadata_array['value']; $item_array['metadata'][$slug]['multiple'] = $field->get_multiple(); } diff --git a/src/classes/repositories/class-tainacan-item-metadata.php b/src/classes/repositories/class-tainacan-item-metadata.php index 8b07bb487..65d80ecc9 100644 --- a/src/classes/repositories/class-tainacan-item-metadata.php +++ b/src/classes/repositories/class-tainacan-item-metadata.php @@ -189,12 +189,14 @@ class Item_Metadata extends Repository { } } - /** - * Get the value for a Item field. - * - * @param Entities\Item_Metadata_Entity $item_metadata - * @return mixed - */ + /** + * Get the value for a Item field. + * + * @param Entities\Item_Metadata_Entity $item_metadata + * + * @return mixed + * @throws \Exception + */ public function get_value(Entities\Item_Metadata_Entity $item_metadata) { $unique = ! $item_metadata->is_multiple(); @@ -272,7 +274,7 @@ class Item_Metadata extends Repository { } } - + /** * Transforms the array saved as meta_value with the IDs of post_meta saved as a value for compound fields * and converts it into an array of Item Metadatada Entitites @@ -280,7 +282,9 @@ class Item_Metadata extends Repository { * @param array $ids The array of post_meta ids * @param Entities\Item $item The item this post_meta is related to * @param int $compund_meta_id the meta_id of the parent compound metadata + * * @return array An array of Item_Metadata_Entity objects + * @throws \Exception */ private function extract_compound_value(array $ids, Entities\Item $item, $compund_meta_id) { diff --git a/src/classes/repositories/class-tainacan-logs.php b/src/classes/repositories/class-tainacan-logs.php index 029c747a4..fa66209c7 100644 --- a/src/classes/repositories/class-tainacan-logs.php +++ b/src/classes/repositories/class-tainacan-logs.php @@ -243,7 +243,7 @@ class Logs extends Repository { (method_exists($new_value, 'get_title') ? $new_value->get_title() : $new_value->get_field()->get_name()); $msn = sprintf( esc_html__( 'A %s has been created/updated.', 'tainacan' ), $class_name); - $description = sprintf( esc_html__("The '%s' %s has been created/updated.", 'tainacan' ), $name, strtolower($class_name)); + $description = sprintf( esc_html__("The %s %s has been created/updated.", 'tainacan' ), $name, strtolower($class_name)); }