Merge pull request #400 from tainacan/compound_import_csv

Compound import csv
This commit is contained in:
vnmedeiros 2020-07-08 14:41:57 -03:00 committed by GitHub
commit 785e156681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1070 additions and 673 deletions

View File

@ -31,7 +31,7 @@ class Background_Importer extends Background_Process {
$data = $batch->data;
$key = $batch->key;
define('TAINACAN_DOING_IMPORT', true);
if (!defined('TAINACAN_DOING_IMPORT')) define('TAINACAN_DOING_IMPORT', true);
$className = $data['class_name'];
if (class_exists($className)) {

View File

@ -51,7 +51,13 @@ class CSV extends Importer {
$this->set_option('item_comment_status_index', $index);
}
} else {
$columns[] = $rawColumn;
if ( preg_match ('/.*\|compound\(.*\)/', $rawColumn ) ) {
$data = preg_split("/[()]+/", $rawColumn, -1, PREG_SPLIT_NO_EMPTY);
$parent = $data[0] . ( isset($data[2]) ? $data[2] : '' );
$columns[] = [$parent => explode($this->get_option('delimiter'), $data[1])];
} else {
$columns[] = $rawColumn;
}
}
}
return $columns;
@ -105,7 +111,16 @@ class CSV extends Importer {
*/
public function process_item( $index, $collection_definition ) {
$processedItem = [];
$headers = $this->raw_source_metadata();
$compoundHeaders = [];
$headers = array_map(function ($header) use (&$compoundHeaders) {
if ( preg_match ('/.*\|compound\(.*\)/', $header ) ) {
$data = preg_split("/[()]+/", $header, -1, PREG_SPLIT_NO_EMPTY);
$header = $data[0] . ( isset($data[2]) ? $data[2] : '' );
$compoundHeaders[$header] = $data[1];
return $header;
}
return $header;
}, $this->raw_source_metadata());
$item_line = (int) $index + 2;
@ -157,9 +172,9 @@ class CSV extends Importer {
foreach ( $collection_definition['mapping'] as $metadatum_id => $header) {
$column = null;
foreach ( $headers as $indexRaw => $headerRaw ) {
if( $headerRaw === $header ) {
if( (is_array($header) && $headerRaw === key($header)) || ($headerRaw === $header) ) {
$column = $indexRaw;
}
}
}
if(is_null($column))
@ -168,10 +183,33 @@ class CSV extends Importer {
$valueToInsert = $this->handle_encoding( $values[ $column ] );
$metadatum = new \Tainacan\Entities\Metadatum($metadatum_id);
$processedItem[ $header ] = ( $metadatum->is_multiple() ) ?
explode( $this->get_option('multivalued_delimiter'), $valueToInsert) : $valueToInsert;
}
if( $metadatum->get_metadata_type() == 'Tainacan\Metadata_Types\Compound' ) {
$valueToInsert = $metadatum->is_multiple()
? explode( $this->get_option('multivalued_delimiter'), $valueToInsert)
: [$valueToInsert];
$key = key($header);
$returnValue = [];
foreach($valueToInsert as $index => $metadatumValue) {
$childrenHeaders = str_getcsv($compoundHeaders[$key], $this->get_option('delimiter'), $this->get_option('enclosure'));
$childrenValue = str_getcsv($metadatumValue, $this->get_option('delimiter'), $this->get_option('enclosure'));
if ( sizeof($childrenHeaders) != sizeof($childrenValue) ) {
$this->add_error_log(' Mismatch count headers childrens and row columns ');
return false;
}
$tmp = [];
foreach($childrenValue as $i => $value ) {
$tmp[ $childrenHeaders[$i] ] = $value;
}
$returnValue[] = $tmp;
}
$processedItem[ $key ] = $returnValue;
} else {
$processedItem[ $header ] = ( $metadatum->is_multiple() ) ?
explode( $this->get_option('multivalued_delimiter'), $valueToInsert) : $valueToInsert;
}
}
if( !empty( $this->get_option('document_index') ) ) $processedItem['special_document'] = '';
if( !empty( $this->get_option('attachment_index') ) ) $processedItem['special_attachments'] = '';
if( !empty( $this->get_option('item_status_index') ) ) $processedItem['special_item_status'] = '';
@ -245,154 +283,167 @@ class CSV extends Importer {
public function options_form() {
ob_start();
?>
<div class="field">
<label class="label"><?php _e('CSV Delimiter', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('CSV Delimiter', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The character used to separate each column in your CSV (e.g. , or ;)', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="delimiter" value="<?php echo esc_attr($this->get_option('delimiter')); ?>">
</div>
</div>
<div class="field">
<label class="label"><?php _e('Multivalued metadata delimiter', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Multivalued metadata delimiter', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The character used to separate each value inside a cell with multiple values (e.g. ||). Note that the target metadatum must accept multiple values.', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="multivalued_delimiter" value="<?php echo $this->get_option('multivalued_delimiter'); ?>">
</div>
</div>
<div class="field">
<label class="label"><?php _e('Enclosure', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Enclosure', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The character that wraps the content of each cell in your CSV. (e.g. ")', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="enclosure" value="<?php echo $this->get_option('enclosure'); ?>">
</div>
</div>
<div class="field is-grouped">
<div class="field is-expanded">
<label class="label"><?php _e('File Encoding', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('File Encoding', 'tainacan'); ?></h5>
<div class="columns is-multiline">
<div class="column">
<div class="field">
<label class="label"><?php _e('CSV Delimiter', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('CSV Delimiter', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The character used to separate each column in your CSV (e.g. , or ;)', 'tainacan'); ?></p>
</div>
</div>
<div class="help-tooltip-body">
<p><?php _e('The encoding of the CSV file.', 'tainacan'); ?></p>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="delimiter" value="<?php echo esc_attr($this->get_option('delimiter')); ?>">
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label"><?php _e('Multivalued metadata delimiter', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Multivalued metadata delimiter', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The character used to separate each value inside a cell with multiple values (e.g. ||). Note that the target metadatum must accept multiple values.', 'tainacan'); ?></p>
</div>
</div>
</div>
</span>
<div class="control is-clearfix">
<div class="select">
<select name="encode">
<option value="utf8" <?php selected($this->get_option('encode'), 'utf8'); ?> >UTF-8</option>
<option value="iso88591" <?php selected($this->get_option('encode'), 'iso88591'); ?> >ISO-88591</option>
</select>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="multivalued_delimiter" value="<?php echo $this->get_option('multivalued_delimiter'); ?>">
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label"><?php _e('Enclosure', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Enclosure', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The character that wraps the content of each cell in your CSV. (e.g. ")', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="enclosure" value="<?php echo $this->get_option('enclosure'); ?>">
</div>
</div>
</div>
<div class="field is-expanded">
<label class="label"><?php _e('Repeated Item', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Repeated Item', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Choose the action when a repeated item is found', 'tainacan'); ?></p>
<div class="column">
<div class="field is-expanded">
<label class="label"><?php _e('File Encoding', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('File Encoding', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The encoding of the CSV file.', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<div class="select is-fullwidth">
<select name="encode">
<option value="utf8" <?php selected($this->get_option('encode'), 'utf8'); ?> >UTF-8</option>
<option value="iso88591" <?php selected($this->get_option('encode'), 'iso88591'); ?> >ISO-88591</option>
</select>
</div>
</span>
<div class="control is-clearfix">
<div class="select">
<select name="repeated_item">
<option value="update" <?php selected($this->get_option('repeated_item'), 'update'); ?> >Update</option>
<option value="ignore" <?php selected($this->get_option('repeated_item'), 'ignore'); ?> >Ignore</option>
</select>
</div>
</div>
</div>
</div>
<div class="field">
<label class="label"><?php _e('Importing attachments', 'tainacan'); ?></label>
<p>
<?php echo nl2br(__('Check the documentation to learn how to set up your .csv file correctly for importing files <a href="https://tainacan.github.io/tainacan-wiki/#/importers?id=importador-csv-items">on this link.</a>', 'tainacan')); ?>
</p>
<br>
<label class="label"><?php _e('Server path', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Server path', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e("When using CSV special field to add documents or attachments that you've uploaded to the server, inform the full path to the folder here (e.g. /home/user/files/)", 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="server_path" value="<?php echo $this->get_option('server_path'); ?>">
</div>
</div>
<div class="columns">
<div class="column">
<div class="field is-expanded">
<label class="label"><?php _e('Repeated Item', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Repeated Item', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Choose the action when a repeated item is found', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<div class="select is-fullwidth">
<select name="repeated_item">
<option value="update" <?php selected($this->get_option('repeated_item'), 'update'); ?> ><?php _e('Update', 'tainacan'); ?></option>
<option value="ignore" <?php selected($this->get_option('repeated_item'), 'ignore'); ?> ><?php _e('Ignore', 'tainacan'); ?></option>
</select>
</div>
</div>
</div>
</div>
<div class="column is-three-quarters">
<div class="field is-expanded">
<label class="label"><?php _e('Server path', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Server path', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e("When using CSV special field to add documents or attachments that you've uploaded to the server, inform the full path to the folder here (e.g. /home/user/files/)", 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="server_path" value="<?php echo $this->get_option('server_path'); ?>">
</div>
<p class="help">
<strong><?php _e('Importing attachments', 'tainacan'); ?>: </strong><?php echo nl2br(__('Check the documentation to learn how to set up your .csv file correctly for importing files <a href="https://tainacan.github.io/tainacan-wiki/#/importers?id=importador-csv-items">on this link.</a>', 'tainacan')); ?>
</p>
</div>
</div>
</div>
<?php
@ -658,7 +709,10 @@ class CSV extends Importer {
continue;
}
$tainacan_metadatum_id = array_search( $metadatum_source, $collection_definition['mapping'] );
foreach($collection_definition['mapping'] as $id => $value) {
if( (is_array($value) && key($value) == $metadatum_source) || ($value == $metadatum_source) )
$tainacan_metadatum_id = $id;
}
$metadatum = $Tainacan_Metadata->fetch( $tainacan_metadatum_id );
if( $this->is_empty_value( $values ) ) continue;
@ -681,6 +735,19 @@ class CSV extends Importer {
}
$singleItemMetadata->set_value( $terms );
}
} elseif( $metadatum->get_metadata_type() == 'Tainacan\Metadata_Types\Compound' ) {
$children_mapping = $collection_definition['mapping'][$tainacan_metadatum_id][$metadatum_source];
$singleItemMetadata = [];
foreach($values as $compoundValue) {
$tmp = [];
foreach($children_mapping as $tainacan_children_metadatum_id => $tainacan_children_header) {
$metadatumChildren = $Tainacan_Metadata->fetch( $tainacan_children_metadatum_id, 'OBJECT' );
$compoundItemMetadata = new Entities\Item_Metadata_Entity( $item, $metadatumChildren);
$compoundItemMetadata->set_value($compoundValue[$tainacan_children_header]);
$tmp[] = $compoundItemMetadata;
}
$singleItemMetadata[] = $tmp;
}
} else {
$singleItemMetadata->set_value( $values );
}
@ -702,13 +769,33 @@ class CSV extends Importer {
}
foreach ( $itemMetadataArray as $itemMetadata ) {
$itemMetadata->set_item( $insertedItem ); // *I told you
if( $itemMetadata->validate() ) {
$result = $Tainacan_Item_Metadata->insert( $itemMetadata );
} else {
$this->add_error_log('Error saving value for ' . $itemMetadata->get_metadatum()->get_name() . " in item " . $insertedItem->get_title());
$this->add_error_log($itemMetadata->get_errors());
continue;
if($itemMetadata instanceof Entities\Item_Metadata_Entity ) {
$itemMetadata->set_item( $insertedItem ); // *I told you
if( $itemMetadata->validate() ) {
$result = $Tainacan_Item_Metadata->insert( $itemMetadata );
} else {
$this->add_error_log('Error saving value for ' . $itemMetadata->get_metadatum()->get_name() . " in item " . $insertedItem->get_title());
$this->add_error_log($itemMetadata->get_errors());
continue;
}
} elseif ( is_array($itemMetadata) ) {
if($updating_item == true) {
$this->deleteAllValuesCompoundItemMetadata($insertedItem, $itemMetadata[0][0]->get_metadatum()->get_parent());
}
foreach($itemMetadata as $compoundItemMetadata) {
$parent_meta_id = null;
foreach($compoundItemMetadata as $itemChildren) {
$itemChildren->set_parent_meta_id($parent_meta_id);
if( $itemChildren->validate() ) {
$item_children_metadata = $Tainacan_Item_Metadata->insert($itemChildren);
$parent_meta_id = $item_children_metadata->get_parent_meta_id();
} else {
$this->add_error_log('Error saving value for ' . $itemChildren->get_metadatum()->get_name() . " in item " . $insertedItem->get_title());
$this->add_error_log($itemChildren->get_errors());
continue;
}
}
}
}
//if( $result ){
@ -740,6 +827,19 @@ class CSV extends Importer {
}
}
private function deleteAllValuesCompoundItemMetadata($item, $compoundMetadataID) {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$compound_metadata = $Tainacan_Metadata->fetch($compoundMetadataID, 'OBJECT');
$compound_item_metadata = new Entities\Item_Metadata_Entity($item, $compound_metadata);
$compound_item_metadata_value = $compound_item_metadata->get_value();
foreach($compound_item_metadata_value as $item_metadata_value) {
foreach ($item_metadata_value as $itemMetadata) {
$Tainacan_Item_Metadata->remove_compound_value($item, $compound_metadata, $itemMetadata->get_parent_meta_id());
}
}
}
/**
* @param $value
* @return bool
@ -844,10 +944,13 @@ class CSV extends Importer {
if( !is_numeric($metadatum_id) ) {
$metadatum = $this->create_new_metadata( $header, $collection['id']);
if( is_object($metadatum) ){
if( is_object($metadatum) && $metadatum instanceof \Tainacan\Entities\Metadatum ){
unset($collection['mapping'][$metadatum_id]);
$collection['mapping'][$metadatum->get_id()] = $header;
} elseif ( is_array($metadatum) && sizeof($metadatum) == 2) {
$parent_header = key($header);
unset($collection['mapping'][$metadatum_id]);
$collection['mapping'][$metadatum[0]->get_id()] = [$parent_header=>$metadatum[1]];
}
}

View File

@ -548,44 +548,49 @@ class Flickr_Importer extends Importer {
public function options_form(){
ob_start();
?>
<div class="field">
<label class="label"><?php _e('API ID', 'tainacan'); ?></label>
<p>
<?php printf(
# translators %s are for opening and closing the link
__('In order to import photos from Flickr you need to %sapply for a Flickr API Key%s.', 'tainacan'),
# translator you may get the link to the console in the current language. e.g. https://console.developers.google.com/?hl=pt-br
sprintf('<a target="_blank" href="%s">', __('https://www.flickr.com/services/api/misc.api_keys.html', 'tainacan') ),
'</a>'
); ?>
</p>
<br/>
<p>
<?php _e('Get your API Key and paste it below:', 'tainacan'); ?>
</p>
<div class="control is-clearfix">
<input class="input" type="text" name="api_id" value="">
<div class="columns">
<div class="column">
<div class="field">
<label class="label"><?php _e('API ID', 'tainacan'); ?></label>
<p>
<?php printf(
# translators %s are for opening and closing the link
__('In order to import photos from Flickr you need to %sapply for a Flickr API Key%s.', 'tainacan'),
# translator you may get the link to the console in the current language. e.g. https://console.developers.google.com/?hl=pt-br
sprintf('<a target="_blank" href="%s">', __('https://www.flickr.com/services/api/misc.api_keys.html', 'tainacan') ),
'</a>'
); ?>
</p>
<br/>
<p>
<?php _e('Get your API Key and paste it below:', 'tainacan'); ?>
</p>
<div class="control is-clearfix">
<input class="input" type="text" name="api_id" value="">
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label"><?php _e('Supported URLs', 'tainacan'); ?></label>
<p>
<?php _e('The following URL types are supported:', 'tainacan'); ?>
<br/><br/>
<?php _e('User profile', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> <code>https://www.flickr.com/photos/username</code>
<br/>
<?php _e('Albums', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> <code>https://www.flickr.com/photos/username/albums/123456</code>
<br/>
<?php _e('Photos', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> <code>https://www.flickr.com/photos/username/123456</code>
</p>
</div>
</div>
</div>
<label class="label"><?php _e('Supported URLs', 'tainacan'); ?></label>
<p>
<?php _e('The following URL types are supported:', 'tainacan'); ?>
<br/><br/>
<?php _e('User profile', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> https://www.flickr.com/photos/username
<br/>
<?php _e('Albums', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> https://www.flickr.com/photos/username/albums/123456
<br/>
<?php _e('Photos', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> https://www.flickr.com/photos/username/123456
</p>
<?php
return ob_get_clean();

View File

@ -923,10 +923,23 @@ abstract class Importer {
* @return bool
* @throws \Exception
*/
public function create_new_metadata( $metadata_description, $collection_id){
public function create_new_metadata( $metadata_description, $collection_id, $parent_id = null){
$taxonomy_repo = \Tainacan\Repositories\Taxonomies::get_instance();
$metadata_repo = \Tainacan\Repositories\Metadata::get_instance();
if(is_array($metadata_description)) {
$parent_metadata_description = key($metadata_description);
$parent_compound = $this->create_new_metadata($parent_metadata_description, $collection_id);
if($parent_compound == false) return false;
$children_mapping = [];
foreach($metadata_description[$parent_metadata_description] as $children_metadata_description) {
$children_compound = $this->create_new_metadata($children_metadata_description, $collection_id, $parent_compound->get_id());
if ( $children_compound == false )
return false;
$children_mapping[$children_compound->get_id()] = $children_metadata_description;
}
return [$parent_compound, $children_mapping];
}
$properties = array_filter( explode('|', $metadata_description) );
if( is_array($properties) && count($properties) < 2 ){
@ -953,6 +966,14 @@ abstract class Importer {
$type = ucfirst($type);
$newMetadatum->set_metadata_type('Tainacan\Metadata_Types\\'.$type);
$newMetadatum->set_collection_id( (isset($collection_id)) ? $collection_id : 'default');
$newMetadatum->set_status('auto-draft');
if($newMetadatum->validate()) {
$newMetadatum = $metadata_repo->insert( $newMetadatum );
} else {
$this->add_log('Error creating metadata ' . $name . ' in collection ' . $collection_id);
$this->add_log($newMetadatum->get_errors());
return false;
}
$newMetadatum->set_status('publish');
if( strcmp(strtolower($type), "taxonomy") === 0 ){
@ -1001,12 +1022,16 @@ abstract class Importer {
$newMetadatum->set_collection_key('no');
}
if(isset($parent_id) && $parent_id != null) {
$newMetadatum->set_parent($parent_id);
}
if($newMetadatum->validate()){
$inserted_metadata = $metadata_repo->insert( $newMetadatum );
$this->add_log('Metadata created: ' . $inserted_metadata->get_name());
return $inserted_metadata;
} else{
} else {
$this->add_log('Error creating metadata ' . $name . ' in collection ' . $collection_id);
$this->add_log($newMetadatum->get_errors());

View File

@ -839,29 +839,33 @@ class Oaipmh_Importer extends Importer {
public function options_form(){
ob_start();
?>
<div class="field">
<label class="label"><?php _e('Create set as', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<vdiv class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Create set as', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Choose the action to manipulate sets', 'tainacan'); ?></p>
</div>
</vdiv>
</span>
<div class="control is-clearfix">
<div class="select">
<select name="using_set">
<option value="collection" <?php selected($this->get_option('using_set'), 'collection'); ?> ><?php _e('Collections', 'tainacan'); ?></option>
<option value="taxonomy" <?php selected($this->get_option('using_set'), 'taxonomy'); ?> ><?php _e('Taxonomies', 'tainacan'); ?></option>
</select>
<div class="columns">
<div class="column">
<div class="field">
<label class="label"><?php _e('Create set as', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<vdiv class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Create set as', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Choose the action to manipulate sets', 'tainacan'); ?></p>
</div>
</vdiv>
</span>
<div class="control is-clearfix">
<div class="select">
<select name="using_set">
<option value="collection" <?php selected($this->get_option('using_set'), 'collection'); ?> ><?php _e('Collections', 'tainacan'); ?></option>
<option value="taxonomy" <?php selected($this->get_option('using_set'), 'taxonomy'); ?> ><?php _e('Taxonomies', 'tainacan'); ?></option>
</select>
</div>
</div>
</div>
</div>
</div>

View File

@ -104,198 +104,219 @@ class Test_Importer extends Importer {
public function options_form() {
ob_start();
?>
<div class="columns is-multiline">
<div class="field">
<label class="label"><?php _e('Number of items in collection 1', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Number of items in collection 1', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The total of items to created in first collection (e.g. 20)', 'tainacan'); ?></p>
</div>
<div class="column is-half">
<div class="field">
<label class="label"><?php _e('Number of items in collection 1', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Number of items in collection 1', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The total of items to created in first collection (e.g. 20)', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="number" name="items_col_1" value="<?php echo $this->get_option('items_col_1'); ?>">
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="number" name="items_col_1" value="<?php echo $this->get_option('items_col_1'); ?>">
</div>
</div>
</div>
<div class="field">
<label class="label"><?php _e('Number of extra metadata to create in first collection', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Number of extra metadata', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Create additional text metadata with random values in first collection', 'tainacan'); ?></p>
</div>
<div class="column is-half">
<div class="field">
<label class="label"><?php _e('Number of extra metadata to create in first collection', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Number of extra metadata', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Create additional text metadata with random values in first collection', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="number" name="additonal_metadata" value="<?php echo $this->get_option('additonal_metadata'); ?>">
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="number" name="additonal_metadata" value="<?php echo $this->get_option('additonal_metadata'); ?>">
</div>
</div>
</div>
<div class="field">
<label class="label"><?php _e('Create second collection with a relationship', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Create second collection', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Create second collection with a relationship with the first collection created', 'tainacan'); ?></p>
</div>
<div class="column is-half">
<div class="field">
<label class="label"><?php _e('Create second collection with a relationship', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Create second collection', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Create second collection with a relationship with the first collection created', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<label class="checkbox">
<input
type="checkbox"
name="second_collection"
<?php echo ( $this->get_option('second_collection') && $this->get_option('second_collection') === 'yes' ) ? 'checked' : '' ?>
value="yes">
<?php _e('Yes', 'tainacan'); ?>
</label>
</div>
</span>
<div class="control is-clearfix">
<label class="checkbox">
<input
type="checkbox"
name="second_collection"
<?php echo ( $this->get_option('second_collection') && $this->get_option('second_collection') === 'yes' ) ? 'checked' : '' ?>
value="yes">
<?php _e('Yes', 'tainacan'); ?>
</label>
</div>
</div>
</div>
<div class="field">
<label class="label"><?php _e('Number of items in collection 2', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Number of items in collection 2', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The total of items to created in second collection (e.g. 20)', 'tainacan'); ?></p>
</div>
<div class="column is-half">
<div class="field">
<label class="label"><?php _e('Number of items in collection 2', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Number of items in collection 2', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The total of items to created in second collection (e.g. 20)', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="number" name="items_col_2" value="<?php echo $this->get_option('items_col_2'); ?>">
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="number" name="items_col_2" value="<?php echo $this->get_option('items_col_2'); ?>">
</div>
</div>
</div>
<hr>
<h2><?php _e('Images', 'tainacan') ?></h2><br>
<div class="field">
<label class="label"><?php _e('Add random images from flickr', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Add random images from flickr', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Add random images from flickr using [https://loremflickr.com/] in first collection', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<label class="checkbox">
<input
type="checkbox"
name="add_random_images"
<?php echo ( $this->get_option('add_random_images') && $this->get_option('add_random_images') === 'yes' ) ? 'checked' : '' ?>
value="yes">
<?php _e('Yes', 'tainacan'); ?>
</label>
</div>
</div>
<div class="columns is-multiline">
<div class="field">
<label class="label"><?php _e('Horizontal image size (0 for random)', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Horizontal image size', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Horizontal image size in pixels ( 0 for random size )', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="number" name="horizontal_image_size" value="<?php echo $this->get_option('horizontal_image_size'); ?>">
<div class="column is-12">
<h2><?php _e('Images', 'tainacan') ?></h2>
</div>
</div>
<div class="field">
<label class="label"><?php _e('Vertical image size (0 for random)', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Vertical image size', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Vertical image size in pixels ( 0 for random size )', 'tainacan'); ?></p>
</div>
<div class="column">
<div class="field">
<label class="label"><?php _e('Add random images from flickr', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Add random images from flickr', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Add random images from flickr using [https://loremflickr.com/] in first collection', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<label class="checkbox">
<input
type="checkbox"
name="add_random_images"
<?php echo ( $this->get_option('add_random_images') && $this->get_option('add_random_images') === 'yes' ) ? 'checked' : '' ?>
value="yes">
<?php _e('Yes', 'tainacan'); ?>
</label>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="number" name="vertical_image_size" value="<?php echo $this->get_option('vertical_image_size'); ?>">
</div>
</div>
</div>
<div class="field">
<label class="label"><?php _e('Keyword Search', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Keyword Search', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Optionally ype one keyword which it will be used to find images in flickr (e.g. dogs, cat). Default is "kitten".', 'tainacan'); ?></p>
</div>
<div class="field">
<label class="label"><?php _e('Keyword Search', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Keyword Search', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Optionally ype one keyword which it will be used to find images in flickr (e.g. dogs, cat). Default is "kitten".', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="keyword_images" value="<?php echo $this->get_option('keyword_images'); ?>">
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="keyword_images" value="<?php echo $this->get_option('keyword_images'); ?>">
</div>
</div>
<div class="column">
<div class="field">
<label class="label"><?php _e('Horizontal image size (0 for random)', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Horizontal image size', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Horizontal image size in pixels ( 0 for random size )', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="number" name="horizontal_image_size" value="<?php echo $this->get_option('horizontal_image_size'); ?>">
</div>
</div>
<div class="field">
<label class="label"><?php _e('Vertical image size (0 for random)', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Vertical image size', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Vertical image size in pixels ( 0 for random size )', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="number" name="vertical_image_size" value="<?php echo $this->get_option('vertical_image_size'); ?>">
</div>
</div>
</div>
</div>
<?php

View File

@ -378,48 +378,55 @@ class Youtube_Importer extends Importer {
public function options_form(){
ob_start();
?>
<div class="field">
<label class="label"><?php _e('API Key', 'tainacan'); ?></label>
<div class="columns">
<div class="column">
<div class="field">
<label class="label"><?php _e('API Key', 'tainacan'); ?></label>
<p>
<?php printf(
# translators %s are for opening and closing the link
__('In order to import videos from Youtube you need to create a project and get an API Key from the %sGoogle Developers Console%s.', 'tainacan'),
# translator you may get the link to the console in the current language. e.g. https://console.developers.google.com/?hl=pt-br
sprintf('<a target="_blank" href="%s">', __('https://console.developers.google.com', 'tainacan') ),
'</a>'
); ?>
</p>
<br/>
<p>
<?php _e('Get your API Key and paste it below:', 'tainacan'); ?>
</p>
<p>
<?php printf(
# translators %s are for opening and closing the link
__('In order to import videos from Youtube you need to create a project and get an API Key from the %sGoogle Developers Console%s.', 'tainacan'),
# translator you may get the link to the console in the current language. e.g. https://console.developers.google.com/?hl=pt-br
sprintf('<a target="_blank" href="%s">', __('https://console.developers.google.com', 'tainacan') ),
'</a>'
); ?>
</p>
<br/>
<p>
<?php _e('Get your API Key and paste it below:', 'tainacan'); ?>
</p>
<div class="control is-clearfix">
<input class="input" type="text" name="api_id" value="<?php echo $this->get_option('api_id'); ?>">
<div class="control is-clearfix">
<input class="input" type="text" name="api_id" value="<?php echo $this->get_option('api_id'); ?>">
</div>
</div>
</div>
<div class="column">
<div class="field">
<label class="label"><?php _e('Supported URLs', 'tainacan'); ?></label>
<p>
<?php _e('The following URL types are supported:', 'tainacan'); ?>
<br/><br/>
<?php _e('User profile', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> <code>https://www.youtube.com/user/username</code>
<br/>
<?php _e('Playlists', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> <code>https://www.youtube.com/playlist?123456</code>
<br/>
<?php _e('Channels', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> <code>https://www.youtube.com/channel/123456</code>
<br/>
<?php _e('Videos', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> <code>https://www.youtube.com/watch?v=123456</code>
</p>
</div>
</div>
</div>
<label class="label"><?php _e('Supported URLs', 'tainacan'); ?></label>
<p>
<?php _e('The following URL types are supported:', 'tainacan'); ?>
<br/><br/>
<?php _e('User profile', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> https://www.youtube.com/user/username
<br/>
<?php _e('Playlists', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> https://www.youtube.com/playlist?123456
<br/>
<?php _e('Channels', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> https://www.youtube.com/channel/123456
<br/>
<?php _e('Videos', 'tainacan'); ?> -
<?php _e('Example: ', 'tainacan'); ?> https://www.youtube.com/watch?v=123456
</p>
<?php
return ob_get_clean();

View File

@ -40,69 +40,74 @@ class Term_Importer extends Importer {
public function options_form() {
ob_start();
?>
<div class="field">
<label class="label"><?php _e('CSV Delimiter', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
<div class="columns">
<div class="column">
<div class="field">
<label class="label"><?php _e('CSV Delimiter', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('CSV Delimiter', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The character used to separate each column in your CSV (e.g. , or ;)', 'tainacan'); ?></p>
</div>
</div>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('CSV Delimiter', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('The character used to separate each column in your CSV (e.g. , or ;)', 'tainacan'); ?></p>
<div class="control is-clearfix">
<input class="input" type="text" name="delimiter" value="<?php echo $this->get_option('delimiter'); ?>">
</div>
</div>
</span>
<div class="control is-clearfix">
<input class="input" type="text" name="delimiter" value="<?php echo $this->get_option('delimiter'); ?>">
</div>
</div>
<div class="field import_term_csv_taxonomies">
<label class="label"><?php _e('Target taxonomy:', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
<div class="column">
<div class="field import_term_csv_taxonomies">
<label class="label"><?php _e('Target taxonomy:', 'tainacan'); ?></label>
<span class="help-wrapper">
<a class="help-button has-text-secondary">
<span class="icon is-small">
<i class="tainacan-icon tainacan-icon-help" ></i>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Existing Taxonomy', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Inform the taxonomy you want to import the terms to.', 'tainacan'); ?></p>
<p><?php _e('Select an existing taxonomy or create a new one on the fly.', 'tainacan'); ?></p>
</div>
</div>
</span>
</a>
<div class="help-tooltip">
<div class="help-tooltip-header">
<h5><?php _e('Existing Taxonomy', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Inform the taxonomy you want to import the terms to.', 'tainacan'); ?></p>
<p><?php _e('Select an existing taxonomy or create a new one on the fly.', 'tainacan'); ?></p>
</div>
</div>
</span>
<div class="control is-clearfix">
<div class="select">
<select name="select_taxonomy" class="select_taxonomy">
<option value="" selected><?php _e('Create a new taxonomy', 'tainacan'); ?></option>
<?php
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$taxonomies = $Tainacan_Taxonomies->fetch( ['nopaging' => true], 'OBJECT' );
foreach( $taxonomies as $taxonomie) {
?>
<option value="<?php echo $taxonomie->get_db_identifier();?>"><?php echo $taxonomie->get_name() ?> </option>
<div class="control is-clearfix">
<div class="select is-fullwidth">
<select name="select_taxonomy" class="select_taxonomy">
<option value="" selected><?php _e('Create a new taxonomy', 'tainacan'); ?></option>
<?php
}
?>
</select>
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$taxonomies = $Tainacan_Taxonomies->fetch( ['nopaging' => true], 'OBJECT' );
foreach( $taxonomies as $taxonomie) {
?>
<option value="<?php echo $taxonomie->get_db_identifier();?>"><?php echo $taxonomie->get_name() ?> </option>
<?php
}
?>
</select>
</div>
<input class="input new_taxonomy" type="text" name="new_taxonomy" value="<?php echo $this->get_option('new_taxonomy'); ?>" placeholder="<?php _e('New taxonomy name', 'tainacan'); ?>" >
</div>
</div>
<input class="input new_taxonomy" type="text" name="new_taxonomy" value="<?php echo $this->get_option('new_taxonomy'); ?>" placeholder="<?php _e('New taxonomy name', 'tainacan'); ?>" >
</div>
</div>
<?php
return ob_get_clean();
}

View File

@ -11,55 +11,12 @@
class="tainacan-form"
label-width="120px"
v-if="importer != undefined && importer != null">
<div class="columns is-gapless">
<div
v-if="importer.options_form != undefined && importer.options_form != null && importer.options_form != ''"
class="column">
<!-- Importer custom options -->
<form id="importerOptionsForm">
<div v-html="importer.options_form"/>
</form>
</div>
<div
<div
v-if="importer.manual_collection || importer.accepts.file || importer.accepts.url"
class="column">
<!-- Target collection selection -------------------------------- -->
<b-field
v-if="importer.manual_collection"
:addons="false"
:label="$i18n.get('label_target_collection')">
<help-button
:title="$i18n.get('label_target_collection')"
:message="$i18n.get('info_target_collection_helper')"/>
<br>
<div class="is-inline">
<b-select
expanded
id="tainacan-select-target-collection"
:value="collectionId"
@input="onSelectCollection($event)"
:loading="isFetchingCollections"
:placeholder="$i18n.get('instruction_select_a_target_collection')">
<option
v-for="collection of collections"
v-if="collection.current_user_can_edit_items"
:key="collection.id"
:value="collection.id">{{ collection.name }}
</option>
</b-select>
<router-link
v-if="$userCaps.hasCapability('tnc_rep_edit_collections')"
tag="a"
style="font-size: 0.875em;"
class="add-link"
:to="{ path: $routerHelper.getNewCollectionPath(), query: { fromImporter: true }}">
<span class="icon">
<i class="tainacan-icon tainacan-icon-add"/>
</span>
{{ $i18n.get('new_blank_collection') }}
</router-link>
</div>
</b-field>
class="columns">
<div class="column">
<!-- File Source input -->
<b-field
v-if="importer.accepts.file"
@ -104,6 +61,11 @@
</span>
</a>
</div>
<div
class="control selected-source-file"
v-if="importerFile == undefined && importer.tmp_file">
<p>{{ $i18n.get('label_select_file') + ': ' + importer.tmp_file }}</p>
</div>
</b-field>
<!-- URL source input -------------------------------- -->
@ -118,10 +80,69 @@
id="tainacan-url-link-source"
v-model="url"/>
</b-field>
</div>
<div
v-if="importer.manual_collection"
style="margin-top: 2em;"
class="column is-narrow">
<span class="icon">
<i class="tainacan-icon tainacan-icon-pointer tainacan-icon-36px has-text-gray2" />
</span>
</div>
<div
v-if="importer.manual_collection"
class="column">
<!-- Target collection selection -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_target_collection')">
<help-button
:title="$i18n.get('label_target_collection')"
:message="$i18n.get('info_target_collection_helper')"/>
<br>
<div class="is-inline">
<b-select
expanded
id="tainacan-select-target-collection"
:value="collectionId"
@input="onSelectCollection($event)"
:loading="isFetchingCollections"
:placeholder="$i18n.get('instruction_select_a_target_collection')">
<option
v-for="collection of collections"
v-if="collection.current_user_can_edit_items"
:key="collection.id"
:value="collection.id">{{ collection.name }}
</option>
</b-select>
<router-link
v-if="$userCaps.hasCapability('tnc_rep_edit_collections')"
tag="a"
style="font-size: 0.875em;"
class="add-link"
:to="{ path: $routerHelper.getNewCollectionPath(), query: { fromImporter: true }}">
<span class="icon">
<i class="tainacan-icon tainacan-icon-add"/>
</span>
{{ $i18n.get('new_blank_collection') }}
</router-link>
</div>
</b-field>
</div>
</div>
<hr v-if="(importer.manual_collection || importer.accepts.file || importer.accepts.url) && (importer.options_form != undefined && importer.options_form != null && importer.options_form != '')">
<div v-if="importer.options_form != undefined && importer.options_form != null && importer.options_form != ''">
<!-- Importer custom options -->
<form id="importerOptionsForm">
<div v-html="importer.options_form"/>
</form>
</div>
<!-- Form submit -------------------------------- -->
<div class="columns is-gapless field is-grouped form-submit">
<div class="control">
@ -168,6 +189,7 @@
</div>
</div>
</form>
<b-loading
:active.sync="isLoading"
:can-cancel="false"/>
@ -286,7 +308,7 @@ export default {
},
onUploadFile() {
return new Promise((resolve, reject) => {
this.updateImporterFile({ sessionId: this.sessionId, file: (this.importerFile.length != undefined && this.importerFile.length > 0) ? this.importerFile[0] : this.importerFile})
this.updateImporterFile({ sessionId: this.sessionId, file: (this.importerFile && this.importerFile.length != undefined && this.importerFile.length > 0) ? this.importerFile[0] : this.importerFile})
.then(updatedImporter => {
this.importer = updatedImporter;
resolve();
@ -436,13 +458,9 @@ export default {
@import "../../scss/_variables.scss";
.columns.is-gapless {
/deep/ .columns {
padding-left: var(--tainacan-one-column);
padding-right: var(--tainacan-one-column);
.column:not(:first-child) {
margin-left: var(--tainacan-one-column);
}
}
.field {
@ -474,7 +492,7 @@ export default {
display: inline;
}
.drop-inner{
padding: 1em 3em;
padding: 0.25em 0.5em;
}
.mapping-header-label {
@ -498,13 +516,16 @@ export default {
.selected-source-file {
border: 1px solid var(--tainacan-gray2);
padding: 2px 10px;
font-size: .75em;
padding: calc(0.375em - 1px) 10px !important;
font-size: .875em;
line-height: 1.5em;
display: flex;
justify-content: space-between;
align-items: center;
}
hr {
margin: 0.5rem 0 1.5rem 0;
}
</style>

View File

@ -25,32 +25,45 @@
</nav>
</div>
<b-loading
:active.sync="isLoading"
:can-cancel="false"/>
<form
class="tainacan-form"
label-width="120px"
v-if="importer != undefined && importer != null">
<p>{{ $i18n.get('info_metadata_mapping_helper') }}</p>
<br>
<b-loading
:is-full-page="false"
:active.sync="isLoadingSourceInfo"
:can-cancel="false"/>
<!-- Metadata Mapping -->
<b-field
v-if="importer.manual_mapping"
:addons="false"
:label="$i18n.get('label_metadata_mapping')">
<help-button
:title="$i18n.get('label_metadata_mapping')"
:message="$i18n.get('info_metadata_mapping_helper')"/>
<div
v-if="importerSourceInfo != undefined &&
importerSourceInfo != null &&
!isLoading">
<div
v-if="importerSourceInfo != undefined &&
importerSourceInfo != null &&
!isLoading">
<template v-if="importerSourceInfo.source_metadata.length > 0 || (importerSourceInfo.source_special_fields && importerSourceInfo.source_special_fields.length > 0)">
<p class="mapping-header-label is-pulled-left">{{ $i18n.get('label_from_source_collection') }}</p>
<p class="mapping-header-label is-pulled-right">{{ $i18n.get('label_to_target_collection') }}</p>
</template>
<div
class="source-metadatum"
v-for="(sourceMetadatum, index) of importerSourceInfo.source_metadata"
:key="index">
class="mapping-header"
v-if="importerSourceInfo.source_metadata.length > 0 || (importerSourceInfo.source_special_fields && importerSourceInfo.source_special_fields.length > 0)">
<p>{{ $i18n.get('label_from_source_collection') }}</p>
<hr>
<span class="icon">
<i class="tainacan-icon tainacan-icon-pointer" />
</span>
<hr>
<p>{{ $i18n.get('label_to_target_collection') }}</p>
</div>
<div
class="source-metadatum"
v-for="(sourceMetadatum, index) of importerSourceInfo.source_metadata"
:key="index">
<template v-if="typeof sourceMetadatum == 'string'">
<p>{{ sourceMetadatum }}</p>
<b-select
v-if="collectionMetadata != undefined &&
@ -59,7 +72,7 @@
:value="checkCurrentSelectedCollectionMetadatum(sourceMetadatum)"
@input="onSelectCollectionMetadata($event, sourceMetadatum)"
:placeholder="$i18n.get('label_select_metadatum')">
<option :value="undefined">
<option :value="null">
{{ $i18n.get('label_select_metadatum') }}
</option>
<option
@ -71,6 +84,7 @@
v-for="(collectionMetadatum, metadatumIndex) of collectionMetadata"
:key="metadatumIndex"
:value="collectionMetadatum.id"
v-if="!checkIfMetadatumIsChild(collectionMetadatum)"
:disabled="checkIfMetadatumIsAvailable(collectionMetadatum.id)">
<span class="metadatum-name">
{{ collectionMetadatum.name }}
@ -80,101 +94,167 @@
</span>
</option>
</b-select>
<p v-if="collectionMetadata == undefined || collectionMetadata.length <= 0">{{ $i18n.get('info_select_collection_to_list_metadata') }}</p>
</div>
<div
v-if="importerSourceInfo.source_special_fields && importerSourceInfo.source_special_fields.length > 0"
class="source-metadatum"
:key="specialFieldIndex"
v-for="(specialField, specialFieldIndex) of importerSourceInfo.source_special_fields">
<p style="font-style: italic">{{ specialField }}</p>
<p>{{ $i18n.get('info_special_fields_mapped_default') }}</p>
</div>
<p v-if="importerSourceInfo.source_metadata.length <= 0">{{ $i18n.get('info_no_metadata_source_file') }}<br></p>
<p v-if="(!importerSourceInfo.source_special_fields || importerSourceInfo.source_special_fields.length <= 0)">{{ $i18n.get('info_no_special_fields_available') }}<br></p>
<b-modal
@close="onMetadatumEditionCanceled()"
:active.sync="isNewMetadatumModalActive"
trap-focus
aria-modal
aria-role="dialog">
</template>
<template v-else-if="typeof sourceMetadatum == 'object' && Object.entries(sourceMetadatum)[0]">
<p>{{ Object.entries(sourceMetadatum)[0][0] }}</p>
<b-select
v-if="collectionMetadata != undefined &&
collectionMetadata.length > 0 &&
!isFetchingCollectionMetadata"
:value="checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true)"
@input="onSelectCollectionMetadata($event, Object.entries(sourceMetadatum)[0][0], true, Object.entries(sourceMetadatum)[0][1])"
:placeholder="$i18n.get('label_select_metadatum')">
<option :value="null">
{{ $i18n.get('label_select_metadatum') }}
</option>
<option
v-if="collection && collection.current_user_can_edit_metadata"
:value="'create_metadata' + index">
{{ $i18n.get('label_create_metadatum') }}
</option>
<option
v-for="(collectionMetadatum, metadatumIndex) of collectionMetadata"
:key="metadatumIndex"
:value="collectionMetadatum.id"
v-if="!checkIfMetadatumIsChild(collectionMetadatum)"
:disabled="!checkIfMetadatumIsCompound(collectionMetadatum) || checkIfMetadatumIsAvailable(collectionMetadatum.id)">
<span class="metadatum-name">
{{ collectionMetadatum.name }}
</span>
<span class="label-details">
({{ collectionMetadatum.metadata_type_object.name }}) <em>{{ (collectionMetadatum.collection_id != collectionId) ? $i18n.get('label_inherited') : '' }}</em>
</span>
</option>
</b-select>
<div
autofocus="true"
tabindex="-1"
role="dialog"
aria-modal>
<b-loading
:is-full-page="isFullPage"
:active.sync="isLoadingMetadatumTypes"/>
:class="{ 'disabled-child-source-metadatum': [undefined, null, false, 'create_metadata' + index].includes(checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true)) }"
class="child-source-metadatum">
<div
v-if="selectedMetadatumType == undefined && !isEditingMetadatum"
class="tainacan-modal-content">
<div class="tainacan-modal-title">
<h2>{{ $i18n.get('instruction_select_metadatum_type') }}</h2>
<hr>
</div>
<section class="tainacan-form">
<div class="metadata-types-container">
<div
class="metadata-type"
v-for="(metadatumType, index) of metadatumTypes"
:key="index"
@click="onSelectMetadatumType(metadatumType)">
<h4>{{ metadatumType.name }}</h4>
</div>
</div>
<div class="field is-grouped form-submit">
<div class="control">
<button
id="button-cancel-importer-edition"
class="button is-outlined"
type="button"
@click="onMetadatumEditionCanceled(); isNewMetadatumModalActive = false">
{{ $i18n.get('cancel') }}</button>
</div>
</div>
</section>
</div>
<div
v-if="isEditingMetadatum"
class="tainacan-modal-content">
<div class="tainacan-modal-title">
<h2>{{ $i18n.get('instruction_configure_new_metadatum') }}</h2>
<a
class="back-link"
@click="isEditingMetadatum = false">
{{ $i18n.get('back') }}
</a>
<hr>
</div>
<metadatum-edition-form
:collection-id="collectionId"
:is-repository-level="false"
@onEditionFinished="onMetadatumEditionFinished()"
@onEditionCanceled="onMetadatumEditionCanceled()"
:index="0"
:original-metadatum="metadatum"
:edited-metadatum="editedMetadatum"
:is-on-modal="true"/>
class="source-metadatum"
v-for="(childSourceMetadatum, childIndex) of Object.entries(sourceMetadatum)[0][1]"
:key="childIndex">
<p>{{ childSourceMetadatum }}</p>
<b-select
v-if="collectionMetadata != undefined &&
collectionMetadata.length > 0 &&
!isFetchingCollectionMetadata"
:disabled="[undefined, null, false, 'create_metadata' + index].includes(checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true))"
:value="checkCurrentSelectedCollectionChildMetadatum(childSourceMetadatum, checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true))"
@input="onSelectCollectionChildMetadata($event, childSourceMetadatum, checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true), Object.entries(sourceMetadatum)[0][0])"
:placeholder="$i18n.get('label_select_metadatum')">
<option :value="null">
{{ $i18n.get('label_select_metadatum') }}
</option>
<option
v-for="(collectionMetadatum, metadatumIndex) of getChildOfSelectedCompoundMetadata(sourceMetadatum)"
:key="metadatumIndex"
:value="collectionMetadatum.id"
:disabled="checkIfChildMetadatumIsAvailable(collectionMetadatum.id, checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true), Object.entries(sourceMetadatum)[0][0])">
<span class="metadatum-name">
{{ collectionMetadatum.name }}
</span>
<span class="label-details">
({{ collectionMetadatum.metadata_type_object.name }}) <em>{{ (collectionMetadatum.collection_id != collectionId) ? $i18n.get('label_inherited') : '' }}</em>
</span>
</option>
</b-select>
</div>
</div>
</b-modal>
<a
v-if="collectionId != null && collectionId != undefined && importerSourceInfo.source_metadata.length > 0 && collection && collection.current_user_can_edit_metadata"
style="font-size: 0.875em;"
class="is-inline is-pulled-right add-link has-text-secondary"
@click="createNewMetadatum()">
<span class="icon">
<i class="tainacan-icon tainacan-icon-add"/>
</span>
{{ $i18n.get('label_add_more_metadata') }}</a>
</template>
<p v-if="collectionMetadata == undefined || collectionMetadata.length <= 0">{{ $i18n.get('info_select_collection_to_list_metadata') }}</p>
</div>
<div
v-if="importerSourceInfo == undefined ||
importerSourceInfo == null">
<p>{{ $i18n.get('info_upload_a_source_to_see_metadata') }}</p>
v-if="importerSourceInfo.source_special_fields && importerSourceInfo.source_special_fields.length > 0"
class="source-metadatum"
:key="specialFieldIndex"
v-for="(specialField, specialFieldIndex) of importerSourceInfo.source_special_fields">
<p style="font-style: italic">{{ specialField }}</p>
<p>{{ $i18n.get('info_special_fields_mapped_default') }}</p>
</div>
</b-field>
<p v-if="importerSourceInfo.source_metadata.length <= 0">{{ $i18n.get('info_no_metadata_source_file') }}<br></p>
<p v-if="(!importerSourceInfo.source_special_fields || importerSourceInfo.source_special_fields.length <= 0)">{{ $i18n.get('info_no_special_fields_available') }}<br></p>
<b-modal
@close="onMetadatumEditionCanceled()"
:active.sync="isNewMetadatumModalActive"
trap-focus
aria-modal
aria-role="dialog">
<div
autofocus="true"
tabindex="-1"
role="dialog"
aria-modal>
<b-loading
:is-full-page="isFullPage"
:active.sync="isLoadingMetadatumTypes"/>
<div
v-if="selectedMetadatumType == undefined && !isEditingMetadatum"
class="tainacan-modal-content">
<div class="tainacan-modal-title">
<h2>{{ $i18n.get('instruction_select_metadatum_type') }}</h2>
<hr>
</div>
<section class="tainacan-form">
<div class="metadata-types-container">
<div
class="metadata-type"
v-for="(metadatumType, index) of metadatumTypes"
:key="index"
@click="onSelectMetadatumType(metadatumType)">
<h4>{{ metadatumType.name }}</h4>
</div>
</div>
<div class="field is-grouped form-submit">
<div class="control">
<button
id="button-cancel-importer-edition"
class="button is-outlined"
type="button"
@click="onMetadatumEditionCanceled(); isNewMetadatumModalActive = false">
{{ $i18n.get('cancel') }}</button>
</div>
</div>
</section>
</div>
<div
v-if="isEditingMetadatum"
class="tainacan-modal-content">
<div class="tainacan-modal-title">
<h2>{{ $i18n.get('instruction_configure_new_metadatum') }}</h2>
<a
class="back-link"
@click="isEditingMetadatum = false">
{{ $i18n.get('back') }}
</a>
<hr>
</div>
<metadatum-edition-form
:collection-id="collectionId"
:is-repository-level="false"
@onEditionFinished="onMetadatumEditionFinished()"
@onEditionCanceled="onMetadatumEditionCanceled()"
:index="0"
:original-metadatum="metadatum"
:edited-metadatum="editedMetadatum"
:is-on-modal="true"/>
</div>
</div>
</b-modal>
<a
v-if="collectionId != null && collectionId != undefined && importerSourceInfo.source_metadata.length > 0 && collection && collection.current_user_can_edit_metadata"
style="font-size: 0.875em;"
class="is-inline is-pulled-right add-link has-text-secondary"
@click="createNewMetadatum()">
<span class="icon">
<i class="tainacan-icon tainacan-icon-add"/>
</span>
{{ $i18n.get('label_add_more_metadata') }}</a>
</div>
<div
v-if="importerSourceInfo == undefined ||
importerSourceInfo == null">
<p>{{ $i18n.get('info_upload_a_source_to_see_metadata') }}</p>
</div>
<!-- Form submit -------------------------------- -->
<div class="field is-grouped form-submit">
@ -277,10 +357,6 @@
</div>
</form>
</b-modal>
<b-loading
:active.sync="isLoading"
:can-cancel="false"/>
</div>
</template>
@ -298,6 +374,7 @@ export default {
importerId: Number,
importer: null,
isLoading: false,
isLoadingSourceInfo: false,
isLoadingRun: false,
mappedCollection: {
'id': Number,
@ -396,15 +473,18 @@ export default {
this.importer = JSON.parse(JSON.stringify(res));
this.isLoading = false;
this.isLoadingSourceInfo = true;
this.fetchImporterSourceInfo(this.sessionId)
.then(importerSourceInfo => {
this.importerSourceInfo = importerSourceInfo;
this.mappedCollection['total_items'] = this.importerSourceInfo.source_total_items;
this.isLoadingSourceInfo = false;
this.loadMetadata();
})
.catch((errors) => {
this.isLoadingSourceInfo = false;
this.$console.log(errors);
});
@ -422,11 +502,13 @@ export default {
this.fetchMetadata({
collectionId: this.collectionId,
isRepositoryLevel: false,
isContextEdit: false
isContextEdit: false,
parent: 'any'
}).then((resp) => {
resp.request
.then((metadata) => {
this.collectionMetadata = JSON.parse(JSON.stringify(metadata));
this.isFetchingCollectionMetadata = false;
this.fetchMappingImporter({ collection: this.collectionId, sessionId: this.sessionId })
@ -461,13 +543,46 @@ export default {
return false;
},
checkCurrentSelectedCollectionMetadatum(sourceMetadatum) {
checkIfChildMetadatumIsAvailable(metadatumId, parentId, parentSource) {
if (this.mappedCollection['mapping'][parentId] &&
this.mappedCollection['mapping'][parentId][parentSource] &&
this.mappedCollection['mapping'][parentId][parentSource][metadatumId] &&
this.importerSourceInfo != undefined &&
this.importerSourceInfo != null)
return true;
else
return false;
},
checkIfMetadatumIsCompound(metadatum) {
return metadatum.metadata_type_object && metadatum.metadata_type_object.component && metadatum.metadata_type_object.component == 'tainacan-compound';
},
checkCurrentSelectedCollectionMetadatum(sourceMetadatum, isCompound) {
for (let key in this.mappedCollection['mapping']) {
if (this.mappedCollection['mapping'][key] == sourceMetadatum)
return key;
if (isCompound && Object.keys(this.mappedCollection['mapping'][key]) && Object.keys(this.mappedCollection['mapping'][key])[0] && Object.keys(this.mappedCollection['mapping'][key])[0] == sourceMetadatum)
return key;
}
return undefined;
},
checkCurrentSelectedCollectionChildMetadatum(sourceMetadatum, parent) {
if (this.mappedCollection['mapping'][parent] && Object.values(this.mappedCollection['mapping'][parent]) && Object.values(this.mappedCollection['mapping'][parent])[0]) {
let parentMappings = Object.values(this.mappedCollection['mapping'][parent])[0]
for (let key in parentMappings) {
if (parentMappings[key] == sourceMetadatum)
return key;
}
return undefined;
}
return undefined;
},
checkIfMetadatumIsChild(metadatum) {
return metadatum.parent && metadatum.parent > 0;
},
getChildOfSelectedCompoundMetadata(sourceMetadatum) {
return this.collectionMetadata.filter((metadatum) => metadatum.parent == this.checkCurrentSelectedCollectionMetadatum(Object.entries(sourceMetadatum)[0][0], true));
},
onRunImporter(skipTitleCheck) {
if (skipTitleCheck !== true) {
@ -506,18 +621,49 @@ export default {
this.$console.log(errors);
});
},
onSelectCollectionMetadata(selectedMetadatum, sourceMetadatum) {
onSelectCollectionChildMetadata(selectedMetadatum, sourceMetadatum, parentId, parentSource) {
if (this.mappedCollection['mapping'][parentId] && this.mappedCollection['mapping'][parentId] && this.mappedCollection['mapping'][parentId][parentSource]) {
let parentMappings = Array.isArray(this.mappedCollection['mapping'][parentId][parentSource]) ? {} : this.mappedCollection['mapping'][parentId][parentSource];
let removedKey = '';
for (let key in parentMappings) {
if (parentMappings[key] == sourceMetadatum)
removedKey = key;
}
if (removedKey != '')
delete parentMappings[removedKey];
if (selectedMetadatum)
parentMappings[selectedMetadatum] = sourceMetadatum;
this.mappedCollection['mapping'][parentId][parentSource] = parentMappings;
// Necessary for causing reactivity to re-check if metadata remains available
this.collectionMetadata.push("");
this.collectionMetadata.pop();
}
},
onSelectCollectionMetadata(selectedMetadatum, sourceMetadatum, isCompound, childSourceMetadata) {
let removedKey = '';
for (let key in this.mappedCollection['mapping']) {
if(this.mappedCollection['mapping'][key] == sourceMetadatum)
if (this.mappedCollection['mapping'][key] == sourceMetadatum)
removedKey = key;
if (isCompound && Object.keys(this.mappedCollection['mapping'][key]) && Object.keys(this.mappedCollection['mapping'][key])[0] && Object.keys(this.mappedCollection['mapping'][key])[0] == sourceMetadatum)
removedKey = key;
}
if (removedKey != '')
delete this.mappedCollection['mapping'][removedKey];
this.mappedCollection['mapping'][selectedMetadatum] = sourceMetadatum;
let mappingValue = '';
if (isCompound) {
mappingValue = {}
mappingValue[sourceMetadatum] = childSourceMetadata;
} else {
mappingValue = sourceMetadatum;
}
this.mappedCollection['mapping'][selectedMetadatum] = mappingValue;
// Necessary for causing reactivity to re-check if metadata remains available
this.collectionMetadata.push("");
@ -571,7 +717,8 @@ export default {
this.fetchMetadata({
collectionId: this.collectionId,
isRepositoryLevel: false,
isContextEdit: false
isContextEdit: false,
parent: 'any'
}).then((resp) => {
resp.request
.then((metadata) => {
@ -679,7 +826,7 @@ export default {
}
.source-metadatum {
padding: 2px 0;
padding: 2px 0 2px 8px;
min-height: 35px;
border-bottom: 1px solid var(--tainacan-gray2);
width: 100%;
@ -687,6 +834,40 @@ export default {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
&>p {
font-weight: normal;
transition: font-weight 0.1s ease;
}
&:hover {
&>p {
font-weight: bold;
}
}
}
.child-source-metadatum {
flex-basis: 100%;
border-left: 1px solid var(--tainacan-gray2);
padding-left: 1em;
opacity: 1;
transition: border-left 0.2s ease, opacity 0.2s ease;
.source-metadatum {
border-bottom: none;
margin-bottom: 0;
margin-top: 2px;
padding-top: 8px;
padding-bottom: 0px;
border-top: 1px solid var(--tainacan-gray2);
}
&.disabled-child-source-metadatum {
border-left: 1px solid var(--tainacan-gray1);
opacity: 0.70;
}
}
.is-inline .control{
@ -696,9 +877,33 @@ export default {
padding: 1em 3em;
}
.mapping-header-label {
.mapping-header {
display: flex;
justify-content: space-between;
align-items: center;
color: var(--tainacan-info-color);
margin: 12px 0 6px 0;
font-size: 0.875em;
font-weight: bold;
margin: 18px 0 6px 0;
p {
white-space: nowrap;
}
hr {
width: 100%;
margin-left: 12px;
margin-right: 12px;
height: 1px;
}
@media screen and (max-width: 768px) {
p {
white-space: normal;
}
hr {
display: none;
}
}
}
.modal .animation-content {

View File

@ -586,7 +586,7 @@
}
}
.actions-cell {
width: 46px;
width: 52px;
}
.actions-container {
align-items: center;

View File

@ -257,6 +257,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_text' => __( 'Text', 'tainacan' ),
'label_url' => __( 'URL', 'tainacan' ),
'label_select_file' => __( 'Select File', 'tainacan' ),
'label_selected_file' => __( 'Selected file', 'tainacan' ),
'label_expand_all' => __( 'Expand all', 'tainacan' ),
'label_collapse_all' => __( 'Collapse all', 'tainacan' ),
'label_view_term' => __( 'View Term', 'tainacan' ),
@ -306,7 +307,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_create_metadatum' => __( 'Create metadatum', 'tainacan' ),
'label_select_metadatum_type' => __( 'Select a metadatum type', 'tainacan' ),
'label_add_more_metadata' => __( 'Add more metadata', 'tainacan' ),
'label_from_source_collection' => __( 'From source collection', 'tainacan' ),
'label_from_source_collection' => __( 'From source file', 'tainacan' ),
'label_to_target_collection' => __( 'To target collection', 'tainacan' ),
'label_add_value' => __( 'Add value', 'tainacan' ),
'label_remove_value' => __( 'Remove value', 'tainacan' ),