Merge branch 'release/0.19.1'
This commit is contained in:
commit
f5a06300d9
|
@ -464,6 +464,7 @@ class REST_Items_Controller extends REST_Controller {
|
|||
$meta_id = $meta['key'];
|
||||
$meta_value = is_array($meta['value']) ? $meta['value'] : [$meta['value']];
|
||||
$meta_label = isset($meta['label']) ? $meta['label'] : $meta_value;
|
||||
$meta_type = 'CHAR';
|
||||
$filter_type_component = false;
|
||||
$arg_type = 'meta';
|
||||
$f = false;
|
||||
|
@ -535,6 +536,11 @@ class REST_Items_Controller extends REST_Controller {
|
|||
return apply_filters("tainacan-item-get-author-name", $name);
|
||||
}, $meta_label);
|
||||
break;
|
||||
case 'int':
|
||||
case 'float':
|
||||
case 'numeric':
|
||||
$meta_type = 'NUMERIC';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -549,7 +555,8 @@ class REST_Items_Controller extends REST_Controller {
|
|||
'arg_type' => $arg_type,
|
||||
'value' => $meta_value,
|
||||
'label' => $meta_label,
|
||||
'compare' => isset($meta['compare']) ? $meta['compare'] : '='
|
||||
'compare' => isset($meta['compare']) ? $meta['compare'] : '=',
|
||||
'type' => $meta_type,
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -596,6 +603,17 @@ class REST_Items_Controller extends REST_Controller {
|
|||
$collection_id = $request['collection_id'];
|
||||
}
|
||||
$filters_args = $this->prepare_filters_arguments($args, $collection_id);
|
||||
if(isset($args['meta_query']) && !empty($args['meta_query']) && is_array($filters_args) && !empty($filters_args)) {
|
||||
foreach($filters_args as $filters_arg) {
|
||||
if($filters_arg['filter'] !== false) {
|
||||
for($idx = 0; $idx < count($args['meta_query']); $idx++) {
|
||||
if($args['meta_query'][$idx]['key'] == $filters_arg['metadatum']['metadatum_id']) {
|
||||
$args['meta_query'][$idx]['type'] = $filters_arg['type'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$max_items_per_page = $TAINACAN_API_MAX_ITEMS_PER_PAGE;
|
||||
if ( $max_items_per_page > -1 ) {
|
||||
|
|
|
@ -488,8 +488,6 @@ class REST_Metadata_Controller extends REST_Controller {
|
|||
|
||||
$metadatum = $this->metadatum_repository->fetch($metadatum_id);
|
||||
|
||||
$error_message = __('Metadata with this ID was not found', 'tainacan');
|
||||
|
||||
if ($metadatum) {
|
||||
// These conditions are for verify if endpoints are used correctly
|
||||
if(!$collection_id && $metadatum->get_collection_id() !== 'default') {
|
||||
|
@ -498,14 +496,14 @@ class REST_Metadata_Controller extends REST_Controller {
|
|||
return new \WP_REST_Response( [
|
||||
'error_message' => $error_message,
|
||||
'metadatum_id' => $metadatum_id
|
||||
] );
|
||||
], 400 );
|
||||
} elseif ($collection_id && $metadatum->get_collection_id() === 'default'){
|
||||
$error_message = __('This metadata is not a collection metadata', 'tainacan');
|
||||
|
||||
return new \WP_REST_Response( [
|
||||
'error_message' => $error_message,
|
||||
'metadatum_id' => $metadatum_id
|
||||
] );
|
||||
], 400 );
|
||||
}
|
||||
|
||||
if (isset($request['repository_level']) && $confirm_repository) {
|
||||
|
@ -515,7 +513,7 @@ class REST_Metadata_Controller extends REST_Controller {
|
|||
$prepared_metadata = $this->prepare_item_for_updating($metadatum, $attributes);
|
||||
|
||||
if($prepared_metadata->validate()){
|
||||
$updated_metadata = $this->metadatum_repository->update($prepared_metadata);
|
||||
$updated_metadata = $this->metadatum_repository->update($prepared_metadata, $attributes);
|
||||
|
||||
$response = $this->prepare_item_for_response($updated_metadata, $request);
|
||||
|
||||
|
@ -529,6 +527,7 @@ class REST_Metadata_Controller extends REST_Controller {
|
|||
], 400);
|
||||
}
|
||||
|
||||
$error_message = __('Metadata with this ID was not found', 'tainacan');
|
||||
return new \WP_REST_Response( [
|
||||
'error_message' => $error_message,
|
||||
'metadatum_id' => $metadatum_id
|
||||
|
|
|
@ -609,7 +609,7 @@ class Item extends Entity {
|
|||
}
|
||||
|
||||
// Some checks to see if things are really ok
|
||||
if ( !($metadatum instanceof \Tainacan\Entities\Metadatum) ) {
|
||||
if ( !($metadatum_object instanceof \Tainacan\Entities\Metadatum) ) {
|
||||
return $return;
|
||||
} else {
|
||||
// Makes sure the current Metadatum is desired
|
||||
|
|
|
@ -258,8 +258,11 @@ class Metadatum extends Entity {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_metadata_section_id(){
|
||||
return $this->get_mapped_property('metadata_section_id');
|
||||
function get_metadata_section_id() {
|
||||
$mapped_metadata_section_id = $this->get_mapped_property('metadata_section_id');
|
||||
if($this->is_repository_level())
|
||||
return $mapped_metadata_section_id;
|
||||
return is_array($mapped_metadata_section_id) ? $mapped_metadata_section_id[0] : $mapped_metadata_section_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -450,7 +453,10 @@ class Metadatum extends Entity {
|
|||
* @param [string] $value
|
||||
* @return void
|
||||
*/
|
||||
function set_metadata_section_id( $value) {
|
||||
function set_metadata_section_id($value) {
|
||||
if( !is_array($value) ) {
|
||||
$value = [$value];
|
||||
}
|
||||
return $this->set_mapped_property('metadata_section_id', $value);
|
||||
}
|
||||
|
||||
|
@ -497,6 +503,15 @@ class Metadatum extends Entity {
|
|||
return $this->get_required() === 'yes';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if is repository level, else return false
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function is_repository_level() {
|
||||
return $this->get_collection_id() === 'default';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*
|
||||
|
|
|
@ -377,10 +377,39 @@ class Metadata_Sections extends Repository {
|
|||
}
|
||||
|
||||
public function get_default_section_metadata_object_list (Entities\Collection $collection, $args = []) {
|
||||
$metadata_repository = \Tainacan\Repositories\Metadata::get_instance();
|
||||
$metadata_sections_ids = $this->fetch_ids();
|
||||
$collection_metadata_sections_id = array_diff(array_map(function($el) {return $el->get_id();} , $this->fetch_by_collection($collection)), [\Tainacan\Entities\Metadata_Section::$default_section_slug]);
|
||||
|
||||
if ( empty($collection_metadata_sections_id) ) {
|
||||
$not_post_ids = [];
|
||||
} else {
|
||||
$args_exclude = array(
|
||||
'meta_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
array(
|
||||
'key' => 'collection_id',
|
||||
'value' => 'default',
|
||||
'compare' => '='
|
||||
),
|
||||
array(
|
||||
'key' => 'metadata_section_id',
|
||||
'value' => $collection_metadata_sections_id,
|
||||
'compare' => 'IN'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$list_exclude = $metadata_repository->fetch_by_collection($collection, $args_exclude);
|
||||
$not_post_ids = array_map(function($el) { return $el->get_id(); }, $list_exclude);
|
||||
}
|
||||
|
||||
$args = array_merge(
|
||||
$args,
|
||||
array(
|
||||
'post__not_in' => $not_post_ids,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'relation' => 'OR',
|
||||
|
@ -390,21 +419,18 @@ class Metadata_Sections extends Repository {
|
|||
'compare' => '='
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'key' => 'metadata_section_id',
|
||||
'compare' => 'NOT EXISTS'
|
||||
)
|
||||
'key' => 'metadata_section_id',
|
||||
'compare' => 'NOT EXISTS'
|
||||
),
|
||||
array(
|
||||
'key' => 'metadata_section_id',
|
||||
'value' => $metadata_sections_ids,
|
||||
'compare' => 'NOT IN'
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$metadata_repository = \Tainacan\Repositories\Metadata::get_instance();
|
||||
$metadata_list = $metadata_repository->fetch_by_collection($collection, $args);
|
||||
return $metadata_list;
|
||||
}
|
||||
|
@ -482,4 +508,26 @@ class Metadata_Sections extends Repository {
|
|||
|
||||
return parent::can_read($entity, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if $user can edit/create a metadata section
|
||||
*
|
||||
* @param Entities\Entity $entity
|
||||
* @param int|\WP_User|null $user default is null for the current user
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function can_edit( Entities\Entity $entity, $user = null ) {
|
||||
if ( is_null($entity) )
|
||||
return false;
|
||||
if ($entity instanceof Entities\Metadata_Section && $entity->get_id() == Entities\Metadata_Section::$default_section_slug ) {
|
||||
$collection = $entity->get_collection();
|
||||
if($collection instanceof Entities\Collection) {
|
||||
return current_user_can( 'tnc_col_' . $collection->get_id() . '_edit_metasection' );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return parent::can_edit($entity, $user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ class Metadata extends Repository {
|
|||
'default' => 'no'
|
||||
],
|
||||
'metadata_section_id' => [
|
||||
'map' => 'meta',
|
||||
'map' => 'meta_multi',
|
||||
'title' => __( 'Metadata section', 'tainacan' ),
|
||||
'type' => ['integer', 'string', 'array'],
|
||||
'description' => __( 'The metadata section ID', 'tainacan' ),
|
||||
|
@ -743,6 +743,30 @@ class Metadata extends Repository {
|
|||
return $new_metadatum;
|
||||
}
|
||||
|
||||
public function pre_update_metadata_repository_level($metadatum, $attributes) {
|
||||
if (isset($attributes['target_collection_id']) && is_numeric($attributes['target_collection_id']) && $metadatum->is_repository_level()) {
|
||||
$collection = \tainacan_collections()->fetch($attributes['target_collection_id'], 'OBJECT');
|
||||
|
||||
$new_metadata_section_id = $metadatum->get_metadata_section_id();
|
||||
$new_metadata_section_id = is_array($new_metadata_section_id) ? $new_metadata_section_id[0] : $new_metadata_section_id;
|
||||
|
||||
if($collection instanceof \Tainacan\Entities\Collection) {
|
||||
$collection_metadata_sections_id = array_filter(
|
||||
array_map(function($el) {return $el->get_id();} , \tainacan_metadata_sections()->fetch_by_collection($collection)),
|
||||
function($el) {return $el != \Tainacan\Entities\Metadata_Section::$default_section_slug;}
|
||||
);
|
||||
$old_value = get_post_meta($metadatum->get_id(), 'metadata_section_id');
|
||||
$new_value = array_diff($old_value, $collection_metadata_sections_id);
|
||||
$new_value[] = (string)$new_metadata_section_id;
|
||||
$metadatum->set_metadata_section_id($new_value);
|
||||
if(!$metadatum->validate()) {
|
||||
throw new \Exception( $metadatum->get_errors() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $metadatum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @param $new_values
|
||||
|
@ -751,6 +775,7 @@ class Metadata extends Repository {
|
|||
* @throws \Exception
|
||||
*/
|
||||
public function update( $object, $new_values = null ) {
|
||||
$object = $this->pre_update_metadata_repository_level($object, $new_values);
|
||||
return $this->insert( $object );
|
||||
}
|
||||
|
||||
|
|
|
@ -937,7 +937,9 @@ class Theme_Helper {
|
|||
'auto_play_speed' => 3,
|
||||
'loop_slides' => false,
|
||||
'hide_title' => false,
|
||||
'image_size' => 'tainacan-medium',
|
||||
'image_size' => ( isset($args['crop_images_to_square']) && !$args['crop_images_to_square'] )
|
||||
? 'tainacan-medium-full'
|
||||
: 'tainacan-medium',
|
||||
'show_collection_header' => false,
|
||||
'show_collection_label' => false,
|
||||
'collection_background_color' => '#454647',
|
||||
|
@ -947,12 +949,6 @@ class Theme_Helper {
|
|||
'class_name' => ''
|
||||
);
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
|
||||
/* Compatibility with previous version */
|
||||
if ( isset($args['crop_images_to_square ']) && !$args['crop_images_to_square'] ) {
|
||||
$args['image_size'] = 'tainacan-medium-full';
|
||||
}
|
||||
|
||||
$props = ' ';
|
||||
|
||||
// Always pass the class needed by Vue to mount the component;
|
||||
|
@ -960,22 +956,15 @@ class Theme_Helper {
|
|||
unset($args['class_name']);
|
||||
|
||||
// Builds parameters to the html div rendered by Vue
|
||||
$allowed_html = [
|
||||
'div' => [
|
||||
'data-module' => true,
|
||||
'id' => true
|
||||
]
|
||||
];
|
||||
foreach ($args as $key => $value) {
|
||||
if (is_bool($value))
|
||||
$value = $value ? 'true' : 'false';
|
||||
// Changes from PHP '_' notation to HTML '-' notation
|
||||
$key_attr = str_replace('_', '-', $key);
|
||||
$props .= "$key_attr='$value' ";
|
||||
$allowed_html['div'][$key_attr] = true;
|
||||
$props .= sprintf("%s='%s' ", $key_attr, esc_attr($value));
|
||||
}
|
||||
|
||||
return wp_kses( "<div data-module='carousel-items-list' id='tainacan-items-carousel-shortcode_" . uniqid() . "' $props ></div>", $allowed_html);
|
||||
return "<div data-module='carousel-items-list' id='tainacan-items-carousel-shortcode_" . uniqid() . "' $props ></div>";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1020,7 +1009,9 @@ class Theme_Helper {
|
|||
'show_name' => true,
|
||||
'show_image' => true,
|
||||
'layout' => 'grid',
|
||||
'image_size' => 'tainacan-medium',
|
||||
'image_size' => ( isset($args['crop_images_to_square']) && !$args['crop_images_to_square'] )
|
||||
? 'tainacan-medium-full'
|
||||
: 'tainacan-medium',
|
||||
'show_collection_header' => false,
|
||||
'show_collection_label' => false,
|
||||
'collection_background_color' => '#454647',
|
||||
|
@ -1036,36 +1027,22 @@ class Theme_Helper {
|
|||
'mosaic_item_focal_point_y' => 0.5
|
||||
);
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
|
||||
/* Compatibility with previous version */
|
||||
if ( isset($args['crop_images_to_square ']) && !$args['crop_images_to_square'] ) {
|
||||
$args['image_size'] = 'tainacan-medium-full';
|
||||
}
|
||||
|
||||
$props = ' ';
|
||||
|
||||
// Always pass the class needed by Vue to mount the component;
|
||||
$args['class'] = $args['class_name'] . ' wp-block-tainacan-dynamic-items-list';
|
||||
unset($args['class_name']);
|
||||
|
||||
// Builds parameters to the html div rendered by Vue
|
||||
$allowed_html = [
|
||||
'div' => [
|
||||
'data-module' => true,
|
||||
"id" => true
|
||||
]
|
||||
];
|
||||
// Builds parameters to the html div rendered by Vue
|
||||
foreach ($args as $key => $value) {
|
||||
if (is_bool($value))
|
||||
$value = $value ? 'true' : 'false';
|
||||
// Changes from PHP '_' notation to HTML '-' notation
|
||||
$key_attr = str_replace('_', '-', $key);
|
||||
$props .= "$key_attr='$value' ";
|
||||
$allowed_html['div'][$key_attr] = true;
|
||||
$props .= sprintf("%s='%s' ", $key_attr, esc_attr($value));
|
||||
}
|
||||
|
||||
return wp_kses("<div data-module='dynamic-items-list' id='tainacan-dynamic-items-list-shortcode_" . uniqid(). "' $props ></div>", $allowed_html);
|
||||
return "<div data-module='dynamic-items-list' id='tainacan-dynamic-items-list-shortcode_" . uniqid(). "' $props ></div>";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1104,7 +1081,7 @@ class Theme_Helper {
|
|||
return;
|
||||
|
||||
// Then fetches related ones
|
||||
$related_items = $item->get_related_items();
|
||||
$related_items = $item->get_related_items();
|
||||
if (!count($related_items))
|
||||
return;
|
||||
|
||||
|
@ -1125,18 +1102,37 @@ class Theme_Helper {
|
|||
if ( isset($related_group['metadata_name']) ) {
|
||||
$metadata_label = wp_kses_post('<' . $args['metadata_label_tag'] . ' class="' . $args['metadata_label_class_name'] . '">' . $related_group['metadata_name'] . '</' . $args['metadata_label_tag'] . '>');
|
||||
}
|
||||
|
||||
|
||||
// Sets the carousel, from the items carousel template tag.
|
||||
$items_list_div = '';
|
||||
if ( isset($related_group['collection_id']) ) {
|
||||
|
||||
|
||||
$block_args = (isset($args['items_list_layout']) && $args['items_list_layout'] !== 'carousel' )
|
||||
? $args['dynamic_items_args']
|
||||
: $args['carousel_args'];
|
||||
|
||||
$no_crop_images_to_square = isset($block_args['crop_images_to_square']) && !$block_args['crop_images_to_square'];
|
||||
$image_size = isset($block_args['image_size'])
|
||||
? $block_args['image_size']
|
||||
: ($no_crop_images_to_square ? 'tainacan-medium-full' : 'tainacan-medium');
|
||||
// remove attribute description and unused thumbnails image sizes, to avoid poluting HTML
|
||||
$related_group['items'] = array_map(
|
||||
function($el) use ($image_size) {
|
||||
$el['thumbnail'] = array_filter($el['thumbnail'], function($key) use ($image_size) {
|
||||
return $key == $image_size;
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
unset($el['description']);
|
||||
return $el;
|
||||
}, $related_group['items']
|
||||
);
|
||||
|
||||
if ( isset($args['items_list_layout']) && $args['items_list_layout'] !== 'carousel' ) {
|
||||
$items_list_args = wp_parse_args([
|
||||
'collection_id' => $related_group['collection_id'],
|
||||
'load_strategy' => 'parent',
|
||||
'selected_items' => json_encode($related_group['items']),
|
||||
'layout' => $args['items_list_layout']
|
||||
], $args['dynamic_items_args']);
|
||||
], $block_args);
|
||||
|
||||
$items_list_div = $this->get_tainacan_dynamic_items_list($items_list_args);
|
||||
} else {
|
||||
|
@ -1144,10 +1140,10 @@ class Theme_Helper {
|
|||
'collection_id' => $related_group['collection_id'],
|
||||
'load_strategy' => 'parent',
|
||||
'selected_items' => json_encode($related_group['items'])
|
||||
], $args['carousel_args']);
|
||||
], $block_args);
|
||||
|
||||
$items_list_div = $this->get_tainacan_items_carousel($items_list_args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output .= '<div class="wp-block-group">
|
||||
|
|
|
@ -4,7 +4,7 @@ Tags: museums, libraries, archives, GLAM, collections, repository
|
|||
Requires at least: 5.0
|
||||
Tested up to: 6.0
|
||||
Requires PHP: 5.6
|
||||
Stable tag: 0.19
|
||||
Stable tag: 0.19.1
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
|
|
|
@ -4,17 +4,17 @@ Plugin Name: Tainacan
|
|||
Plugin URI: https://tainacan.org/
|
||||
Description: Open source, powerful and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional repository platform.
|
||||
Author: Tainacan.org
|
||||
Version: 0.19
|
||||
Version: 0.19.1
|
||||
Requires at least: 5.0
|
||||
Tested up to: 6.0
|
||||
Requires PHP: 5.6
|
||||
Stable tag: 0.19
|
||||
Stable tag: 0.19.1
|
||||
Text Domain: tainacan
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
const TAINACAN_VERSION = '0.19';
|
||||
const TAINACAN_VERSION = '0.19.1';
|
||||
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
$TAINACAN_BASE_URL = plugins_url('', __FILE__);
|
||||
|
|
|
@ -269,12 +269,10 @@ export default {
|
|||
'updateFilter'
|
||||
]),
|
||||
saveEdition(filter) {
|
||||
|
||||
if ((filter.filter_type_object && filter.filter_type_object.form_component) || filter.edit_form == '') {
|
||||
|
||||
this.isLoading = true;
|
||||
|
||||
for (let [key, value] of this.form) {
|
||||
for (let [key, value] of Object.entries(this.form)) {
|
||||
if (key === 'begin_with_filter_collapsed')
|
||||
this.form[key] = (value == 'yes' || value == true) ? 'yes' : 'no';
|
||||
}
|
||||
|
|
|
@ -1250,7 +1250,7 @@ export default {
|
|||
|
||||
if (this.isOnSequenceEdit && this.$route.query.collapses) {
|
||||
for (let i = 0; i < metadata.length; i++) {
|
||||
this.metadataCollapses.push(this.$route.query.collapses[i] != undefined ? this.$route.query.collapses[i] : true);
|
||||
this.metadataCollapses.push(this.$route.query.collapses[i] != undefined ? (this.$route.query.collapses[i] == 'true' || this.$route.query.collapses[i] === true) : true);
|
||||
}
|
||||
} else if (this.isOnSequenceEdit && !this.$route.query.collapses) {
|
||||
for (let i = 0; i < metadata.length; i++) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<b-select
|
||||
name="step_options"
|
||||
v-model="step"
|
||||
@input="onUpdate">
|
||||
@input="onUpdateStep">
|
||||
<option value="0.001">0.001</option>
|
||||
<option value="0.01">0.01</option>
|
||||
<option value="0.1">0.1</option>
|
||||
|
@ -50,7 +50,7 @@
|
|||
<b-input
|
||||
name="max_options"
|
||||
v-model="step"
|
||||
@input="onUpdate"
|
||||
@input="onUpdateStep"
|
||||
type="number"
|
||||
step="1" />
|
||||
<button
|
||||
|
@ -77,11 +77,7 @@
|
|||
|
||||
export default {
|
||||
props: {
|
||||
filter: {
|
||||
type: Object
|
||||
},
|
||||
value: [String, Number, Array],
|
||||
disabled: false,
|
||||
value: [String, Number, Array]
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -93,12 +89,9 @@
|
|||
this.step = this.value && this.value.step ? this.value.step : 1;
|
||||
},
|
||||
methods: {
|
||||
onUpdate() {
|
||||
this.$emit('input', {
|
||||
step: this.step
|
||||
});
|
||||
onUpdateStep(value) {
|
||||
this.$emit('input', { step: value });
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -90,7 +90,7 @@
|
|||
methods: {
|
||||
onUpdateStep(value) {
|
||||
this.$emit('input', { step: value });
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -636,7 +636,7 @@ export default {
|
|||
this.updateMetadatum({
|
||||
collectionId: this.collectionId,
|
||||
metadatumId: event.added.element.id,
|
||||
isRepositoryLevel: false,
|
||||
isRepositoryLevel: event.added.element.collection_id === 'default',
|
||||
index: event.added.newIndex,
|
||||
options: {},
|
||||
includeOptionsAsHtml: true,
|
||||
|
|
|
@ -891,6 +891,8 @@
|
|||
class="column-default-width"
|
||||
:class="{
|
||||
'thumbnail-cell': column.metadatum == 'row_thumbnail',
|
||||
'column-needed-width column-align-right' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'float' ||
|
||||
column.metadata_type_object.primitive_type == 'int' ) : false,
|
||||
'column-small-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'date' ||
|
||||
column.metadata_type_object.primitive_type == 'float' ||
|
||||
column.metadata_type_object.primitive_type == 'int') : false,
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
</b-taginput>
|
||||
</b-tab-item>
|
||||
<b-tab-item
|
||||
v-if="itemMetadatum"
|
||||
v-if="itemMetadatum && itemMetadatum.value !== undefined"
|
||||
style="min-height: 56px;"
|
||||
:label="( itemMetadatum.value.length == 1 || itemMetadatum.metadatum.multiple != 'yes' ) ? $i18n.get('label_selected_item') : ( $i18n.get('label_selected_items') + ' (' + itemMetadatum.value.length + ')' )">
|
||||
<div class="tainacan-relationship-results-container">
|
||||
|
|
|
@ -240,7 +240,7 @@ class Relationship extends Metadata_Type {
|
|||
is_user_logged_in() ||
|
||||
(
|
||||
\is_post_status_viewable( $item->get_status() ) &&
|
||||
\is_post_status_viewable( $item->get_collection()->get_status() )
|
||||
($item->get_collection() != null && \is_post_status_viewable( $item->get_collection()->get_status() ))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
</span>
|
||||
<transition name="filter-item">
|
||||
<div
|
||||
v-show="hideCollapses || (isCollapsed || errorMessage)"
|
||||
v-show="hideCollapses || isCollapsed || !!errorMessage"
|
||||
v-if="isTextInputComponent">
|
||||
<p
|
||||
class="metadatum-description-help-info"
|
||||
|
@ -111,13 +111,11 @@
|
|||
</a>
|
||||
</template>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<!-- Non-textual metadata such as taxonomy, relationship and compound manage multiple state in different ways -->
|
||||
<transition name="filter-item">
|
||||
<!-- Non-textual metadata such as taxonomy, relationship and compound manage multiple state in different ways -->
|
||||
<div
|
||||
v-show="hideCollapses || isCollapsed"
|
||||
v-if="!isTextInputComponent">
|
||||
v-else>
|
||||
<p
|
||||
class="metadatum-description-help-info"
|
||||
v-if="itemMetadatum.metadatum &&
|
||||
|
|
|
@ -331,7 +331,7 @@ class Taxonomy extends Metadata_Type {
|
|||
* @return string The HTML representation of the value, containing one or multiple terms, separated by comma, linked to term page
|
||||
*/
|
||||
public function get_value_as_html(Item_Metadata_Entity $item_metadata) {
|
||||
$value = $item_metadata->get_value();
|
||||
$value = $item_metadata->get_value();
|
||||
$return = '';
|
||||
|
||||
if ( $item_metadata->is_multiple() ) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<transition name="filter-item">
|
||||
<div v-if="filterTags != undefined && filterTags.length > 0">
|
||||
<div v-show="filterTags != undefined && filterTags.length > 0">
|
||||
<p class="filter-tags-info">
|
||||
<span
|
||||
style="margin-right: 1em"
|
||||
|
|
|
@ -111,10 +111,12 @@ export const updateMetadatum = ({commit}, {collectionId, metadatumId, isReposito
|
|||
return new Promise((resolve, reject) => {
|
||||
let endpoint = '';
|
||||
|
||||
if (!isRepositoryLevel)
|
||||
if (!isRepositoryLevel) {
|
||||
endpoint = '/collection/' + collectionId + '/metadata/' + metadatumId;
|
||||
else
|
||||
} else {
|
||||
endpoint = '/metadata/' + metadatumId;
|
||||
options['target_collection_id'] = collectionId;
|
||||
}
|
||||
|
||||
endpoint += '?context=edit';
|
||||
|
||||
|
@ -295,16 +297,20 @@ export const updateMetadatumMappers = ({commit}, metadatumMappers) => {
|
|||
// METADATA SECTIONS
|
||||
export const fetchMetadataSections = ({commit}, { collectionId, isContextEdit, includeDisabled }) => {
|
||||
|
||||
let endpoint = '/collection/' + collectionId + '/metadata-sections?';
|
||||
let endpoint = '/collection/' + collectionId + '/metadata-sections';
|
||||
|
||||
let params = {
|
||||
nopaging: 1
|
||||
};
|
||||
|
||||
if (isContextEdit)
|
||||
endpoint += 'context=edit&'
|
||||
params['context'] = 'edit';
|
||||
|
||||
if (includeDisabled)
|
||||
endpoint += 'include_disabled=true'
|
||||
params['include_disabled'] = true;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.get(endpoint)
|
||||
axios.tainacan.get(endpoint + '?' + qs.stringify(params) )
|
||||
.then((res) => {
|
||||
let metadataSections = res.data;
|
||||
commit('setMetadataSections', metadataSections);
|
||||
|
|
|
@ -102,30 +102,32 @@
|
|||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)"
|
||||
:key="index"
|
||||
class="field">
|
||||
<label class="label">{{ itemMetadatum.metadatum.name }}</label>
|
||||
<template v-if="metadatumList && Array.isArray(metadatumList)">
|
||||
<div
|
||||
:class="{
|
||||
'metadata-type-textarea': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-textarea',
|
||||
'metadata-type-compound': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound',
|
||||
'metadata-type-relationship': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-relationship'
|
||||
}"
|
||||
class="content">
|
||||
<component
|
||||
:is="
|
||||
itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound' ||
|
||||
(itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-relationship' &&
|
||||
itemMetadatum.metadatum.metadata_type_object.options &&
|
||||
itemMetadatum.metadatum.metadata_type_object.options.display_related_item_metadata &&
|
||||
itemMetadatum.metadatum.metadata_type_object.options.display_related_item_metadata.length > 1
|
||||
) ? 'div' : 'p'"
|
||||
v-html="itemMetadatum.value_as_html != '' ? itemMetadatum.value_as_html : `<p><span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_provided') + `</span></p>`"/>
|
||||
v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)"
|
||||
:key="index"
|
||||
class="field">
|
||||
<label class="label">{{ itemMetadatum.metadatum.name }}</label>
|
||||
<div
|
||||
:class="{
|
||||
'metadata-type-textarea': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-textarea',
|
||||
'metadata-type-compound': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound',
|
||||
'metadata-type-relationship': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-relationship'
|
||||
}"
|
||||
class="content">
|
||||
<component
|
||||
:is="
|
||||
itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound' ||
|
||||
(itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-relationship' &&
|
||||
itemMetadatum.metadatum.metadata_type_object.options &&
|
||||
itemMetadatum.metadatum.metadata_type_object.options.display_related_item_metadata &&
|
||||
itemMetadatum.metadatum.metadata_type_object.options.display_related_item_metadata.length > 1
|
||||
) ? 'div' : 'p'"
|
||||
v-html="itemMetadatum.value_as_html != '' ? itemMetadatum.value_as_html : `<p><span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_provided') + `</span></p>`"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -68,6 +68,8 @@
|
|||
class="column-default-width"
|
||||
:class="{
|
||||
'thumbnail-cell': column.metadatum == 'row_thumbnail',
|
||||
'column-needed-width column-align-right' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'float' ||
|
||||
column.metadata_type_object.primitive_type == 'int' ) : false,
|
||||
'column-small-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'date' ||
|
||||
column.metadata_type_object.primitive_type == 'float' ||
|
||||
column.metadata_type_object.primitive_type == 'int') : false,
|
||||
|
|
|
@ -463,32 +463,32 @@
|
|||
v-if="metadataSection.description && (!hideHelpButtons && helpInfoBellowLabel)">
|
||||
{{ metadataSection.description }}
|
||||
</p>
|
||||
<template v-if="metadatumList && Array.isArray(metadatumList)">
|
||||
<template v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)">
|
||||
|
||||
<!-- JS-side hook for extra content -->
|
||||
<div
|
||||
:key="index"
|
||||
v-if="hasBeforeHook('metadatum')"
|
||||
class="item-submission-hook item-submission-hook-metadatum-before"
|
||||
v-html="getBeforeHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
|
||||
|
||||
<template v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)">
|
||||
<tainacan-form-item
|
||||
:key="index"
|
||||
v-if="enabledMetadata[index] == 'true'"
|
||||
:item-metadatum="itemMetadatum"
|
||||
:hide-collapses="hideCollapses"
|
||||
:is-collapsed="metadataCollapses[index]"
|
||||
@changeCollapse="onChangeCollapse($event, index)"/>
|
||||
|
||||
<!-- JS-side hook for extra content -->
|
||||
<div
|
||||
:key="index"
|
||||
v-if="hasBeforeHook('metadatum')"
|
||||
class="item-submission-hook item-submission-hook-metadatum-before"
|
||||
v-html="getBeforeHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
|
||||
|
||||
<tainacan-form-item
|
||||
:key="index"
|
||||
v-if="enabledMetadata[index] == 'true'"
|
||||
:item-metadatum="itemMetadatum"
|
||||
:hide-collapses="hideCollapses"
|
||||
:is-collapsed="metadataCollapses[index]"
|
||||
@changeCollapse="onChangeCollapse($event, index)"/>
|
||||
|
||||
<!-- JS-side hook for extra content -->
|
||||
<div
|
||||
:key="index"
|
||||
v-if="hasAfterHook('metadatum')"
|
||||
class="item-submission-hook item-submission-hook-metadatum-after"
|
||||
v-html="getAfterHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
|
||||
<!-- JS-side hook for extra content -->
|
||||
<div
|
||||
:key="index"
|
||||
v-if="hasAfterHook('metadatum')"
|
||||
class="item-submission-hook item-submission-hook-metadatum-after"
|
||||
v-html="getAfterHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- JS-side hook for extra content -->
|
||||
<div
|
||||
v-if="hasAfterHook('metadata_section')"
|
||||
|
|
|
@ -354,7 +354,7 @@ class TAINACAN_REST_Metadata_Sections_Controller extends TAINACAN_UnitApiTestCas
|
|||
$section1 = $this->tainacan_entity_factory->create_entity(
|
||||
'Metadata_Section',
|
||||
array(
|
||||
'name' => 'Section',
|
||||
'name' => 'Section-1',
|
||||
'description' => 'Section Description',
|
||||
'collection' => $collection,
|
||||
// 'metadata_list' => [$metadatum_1->get_id(), $metadatum_2->get_id()]
|
||||
|
@ -366,7 +366,7 @@ class TAINACAN_REST_Metadata_Sections_Controller extends TAINACAN_UnitApiTestCas
|
|||
$section2 = $this->tainacan_entity_factory->create_entity(
|
||||
'Metadata_Section',
|
||||
array(
|
||||
'name' => 'Section',
|
||||
'name' => 'Section-2',
|
||||
'description' => 'Section Description',
|
||||
'collection' => $collection,
|
||||
// 'metadata_list' => [$metadatum_3->get_id(), $metadatum_4->get_id()]
|
||||
|
@ -428,6 +428,21 @@ class TAINACAN_REST_Metadata_Sections_Controller extends TAINACAN_UnitApiTestCas
|
|||
true
|
||||
);
|
||||
|
||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||
$collection->set_metadata_section_order(
|
||||
[
|
||||
array( 'id' => $section1->get_id(), 'enabled' => true, 'metadata_order' => [
|
||||
array( 'id' => $metadatum_1->get_id(), 'enabled' => true ),
|
||||
array( 'id' => $metadatum_2->get_id(), 'enabled' => true )
|
||||
] ),
|
||||
array( 'id' => $section2->get_id(), 'enabled' => true, 'metadata_order' => [
|
||||
array( 'id' => $metadatum_3->get_id(), 'enabled' => true ),
|
||||
array( 'id' => $metadatum_4->get_id(), 'enabled' => true )
|
||||
])
|
||||
]
|
||||
);
|
||||
$Tainacan_Collections->update( $collection );
|
||||
|
||||
$request = new \WP_REST_Request(
|
||||
'GET',
|
||||
$this->namespace . '/collection/' . $collection->get_id() . '/metadata-sections'
|
||||
|
|
Loading…
Reference in New Issue