Some refactoring for get_value_as_html for Compound metadata.

This commit is contained in:
mateuswetah 2020-04-14 17:35:45 -03:00
parent 81b45f46a5
commit 2fe1383416
4 changed files with 95 additions and 49 deletions

View File

@ -128,39 +128,50 @@ class Compound extends Metadata_Type {
$separator = $item_metadata->get_multivalue_separator(); $separator = $item_metadata->get_multivalue_separator();
if ( $item_metadata->is_multiple() ) { if ( $item_metadata->is_multiple() ) {
$return .= '<div class="tainacan-compound-group">'; if ( sizeof($value) > 0 ) {
foreach ( $value as $compound_element ) {
$return .= '<div class="tainacan-compound-metadatum">'; $return .= '<div class="tainacan-compound-group">';
$count = 0;
foreach ( $compound_element as $meta ) {
if ( $meta instanceof Item_Metadata_Entity ) { foreach ( $value as $compound_element ) {
$return .= '<label class="label">' . $meta->get_metadatum()->get_name() . "</label>\n"; $count++;
$return .= '<p>' . $meta->get_value_as_html() . '</p>' . "\n\n";
} if ( sizeof($compound_element) > 0 ) {
$return .= '<div class="tainacan-compound-metadatum">';
foreach ( $compound_element as $meta ) {
if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) {
$return .= '<label class="label">' . $meta->get_metadatum()->get_name() . "</label>\n";
$return .= '<p>' . $meta->get_value_as_html() . '</p>' . "\n\n";
}
}
if ($count < sizeof($compound_element)) {
$return .= '</div>' . "\n" . $separator . "\n";
}
}
} }
$return .= '</div>' . "\n" . $separator . "\n"; $return .= '</div>' . "\n\n";
} }
$return .= '</div>' . "\n\n";
} else { } else {
foreach ( $value as $meta ) { foreach ( $value as $meta ) {
$return .= '<div class="tainacan-metadatum">'; if ( $meta->get_value_as_html() != '' ) {
if ( $meta instanceof Item_Metadata_Entity ) { $return .= '<div class="tainacan-metadatum">';
$return .= '<label class="label">' . $meta->get_metadatum()->get_name() . "</label>\n";
$return .= '<p>' . $meta->get_value_as_html() . '</p>'; if ( $meta instanceof Item_Metadata_Entity ) {
} $return .= '<label class="label">' . $meta->get_metadatum()->get_name() . "</label>\n";
$return .= '<p>' . $meta->get_value_as_html() . '</p>';
$return .= '</div>' . "\n\n"; }
$return .= '</div>' . "\n\n";
}
} }

View File

@ -192,7 +192,8 @@
& .hierarchy-separator { & .hierarchy-separator {
color: var(--tainacan-info-color); color: var(--tainacan-info-color);
} }
&.metadata-type-textarea { &.metadata-type-textarea,
&.metadata-type-compound {
.multivalue-separator { .multivalue-separator {
display: block; display: block;
max-height: 1px; max-height: 1px;
@ -203,4 +204,30 @@
margin: 1em auto; margin: 1em auto;
} }
} }
.tainacan-compound-group {
margin-left: 2px;
padding-left: 0.875em;
border-left: 1px solid var(--tainacan-gray3);
.tainacan-compound-metadatum .label {
margin-bottom: 0.25em;
font-size: 1em;
color: var(--tainacan-info-color);
}
.tainacan-compound-metadatum p {
margin-bottom: 0.75em;
font-size: 1em;
}
.multivalue-separator {
display: block;
max-height: 1px;
width: 35px;
background: var(--tainacan-gray3);
content: none;
color: transparent;
margin: 1em auto;
}
}
} }

View File

@ -104,8 +104,8 @@
transition: background-color 0.3s ease; transition: background-color 0.3s ease;
p { p {
line-height: 2; line-height: 1.8;
font-size: 0.875em !important; font-size: 1.0em !important;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
@ -144,27 +144,6 @@
font-size: 0.75em; font-size: 0.75em;
margin-bottom: 1em; margin-bottom: 1em;
color: var(--tainacan-info-color); color: var(--tainacan-info-color);
.tainacan-compound-group {
margin-left: 2px;
padding-left: 0.75em;
border-left: 1px solid var(--tainacan-info-color);
.tainacan-compound-metadatum .label {
font-size: 1.125em;
color: var(--tainacan-info-color);
}
.multivalue-separator {
display: block;
max-height: 1px;
width: 35px;
background: var(--tainacan-gray3);
content: none;
color: transparent;
margin: 1em auto;
}
}
} }
& span:last-of-type>.metadata-value { & span:last-of-type>.metadata-value {

View File

@ -148,6 +148,35 @@ a:hover {
.hierarchy-separator { .hierarchy-separator {
color: var(--tainacan-gray3); color: var(--tainacan-gray3);
} }
.metadata-value {
.tainacan-compound-group {
margin-left: 2px;
padding-left: 0.875em;
border-left: 1px solid var(--tainacan-gray3);
.tainacan-compound-metadatum .label {
margin-bottom: 0.25em;
font-size: 1em;
color: var(--tainacan-info-color);
}
.tainacan-compound-metadatum p {
margin-bottom: 0.75em;
font-size: 1em;
}
.multivalue-separator {
display: block;
max-height: 1px;
width: 35px;
background: var(--tainacan-gray3);
content: none;
color: transparent;
margin: 1em auto;
}
}
}
.metadata-type-textarea, .metadata-type-textarea,
.metadata-type-compound { .metadata-type-compound {
.multivalue-separator { .multivalue-separator {