Fixes category column in items list

This commit is contained in:
weryques 2018-04-04 15:57:48 -03:00
parent b0bd770edb
commit 359cdc7e3a
4 changed files with 16 additions and 10 deletions

View File

@ -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(', ');

View File

@ -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();
}

View File

@ -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) {

View File

@ -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));
}