Fixes setting value for multiple config

This commit is contained in:
Rodrigo Guimarães 2020-12-23 17:56:08 -03:00
parent 5ca77d3373
commit 539a3721e4
3 changed files with 14 additions and 19 deletions

View File

@ -2,7 +2,7 @@
# Executa o comando 'sass' para verificar se existe (veja http://stackoverflow.com/a/677212/329911)
command -v sass >/dev/null 2>&1 || {
echo >&2 "SASS parece não está disponivel.";
echo >&2 "Sass parece não estar disponivel.";
exit 1;
}

View File

@ -189,12 +189,8 @@ class REST_Item_Metadata_Controller extends REST_Controller {
if ($body) {
$item_id = $request['item_id'];
$metadatum_id = $request['metadatum_id'];
$value = $body['values'];
if (is_array($value)) {
$value = implode(' ', $value);
}
$value = $this->filter_value($value);
$metadatum_id = $request['metadatum_id'];
$parent_meta_id = isset( $body['parent_meta_id'] ) && $body['parent_meta_id'] > 0 ? $body['parent_meta_id'] : null;
$item = $this->item_repository->fetch($item_id);
@ -202,6 +198,11 @@ class REST_Item_Metadata_Controller extends REST_Controller {
$item_metadata = new Entities\Item_Metadata_Entity( $item, $metadatum, null, $parent_meta_id);
if (is_array($value) && !$item_metadata->is_multiple()) {
$value = implode(' ', $value);
}
$value = $this->filter_value($value);
$item_metadata->set_value($value);
if ($item_metadata->validate()) {

View File

@ -199,10 +199,9 @@ class Item_Metadata_Entity extends Entity {
public function get_value_as_array() {
$value = $this->get_value();
$primitive_type = $this->get_metadatum()->get_metadata_type_object()->get_primitive_type();
if ( $this->is_multiple() ) {
$return = [];
if ($this->is_multiple()) {
foreach ($value as $v) {
if( is_array($v) ) {
$options = $this->get_metadatum()->get_metadata_type_object()->get_options();
@ -227,11 +226,7 @@ class Item_Metadata_Entity extends Entity {
$return[] = $v;
}
}
} else {
$return = '';
if ($primitive_type === 'compound') {
$compounds = [];
$compounds_not_ordinate = [];
@ -274,7 +269,6 @@ class Item_Metadata_Entity extends Entity {
}
return $return;
}
/**