Merges conflicts from develop.
This commit is contained in:
commit
c136f375c0
|
@ -63,6 +63,9 @@ $repos = [
|
|||
[
|
||||
'name' => 'get_core_description_metadatum',
|
||||
],
|
||||
[
|
||||
'name' => 'get_core_author_metadatum',
|
||||
],
|
||||
[
|
||||
'name' => 'fetch_all_metadatum_values',
|
||||
],
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
list-style-type: none;
|
||||
margin: 10px;
|
||||
padding: 2px;
|
||||
max-height: 50vh;
|
||||
max-height: 39vh;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden; }
|
||||
.wp-block-tainacan-modal .modal-checkbox-list .components-base-control,
|
||||
|
|
|
@ -137,6 +137,7 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
|||
*/
|
||||
$item_arr['collections'] = [];
|
||||
$item_arr['collections_ids'] = [];
|
||||
$item_arr['metadata_by_collection'] = [];
|
||||
|
||||
$taxonomy = get_taxonomy( $item->get_db_identifier() );
|
||||
if (is_object($taxonomy) && isset($taxonomy->object_type) && is_array($taxonomy->object_type)) {
|
||||
|
@ -146,6 +147,7 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
|||
if ( $tax_collection instanceof \Tainacan\Entities\Collection ) {
|
||||
$item_arr['collections'][] = $tax_collection->_toArray();
|
||||
$item_arr['collections_ids'][] = $tax_collection->get_id();
|
||||
$item_arr['metadata_by_collection'][$tax_collection->get_id()] = $this->get_metadata_taxonomy_in_collection($item->get_id(), $tax_collection->get_id());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -178,6 +180,28 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
|||
return $item;
|
||||
}
|
||||
|
||||
function get_metadata_taxonomy_in_collection($taxonomy_id, $collection_id) {
|
||||
$args = [
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
|
||||
'meta_query' => [
|
||||
[
|
||||
'key' => '_option_taxonomy_id',
|
||||
'value' => $taxonomy_id
|
||||
],
|
||||
[
|
||||
'compare' => 'IN',
|
||||
'key' => 'collection_id',
|
||||
'value' => "$collection_id, default"
|
||||
]
|
||||
]
|
||||
];
|
||||
$metadata = Repositories\Metadata::get_instance()->fetch($args, 'OBJECT');
|
||||
if (is_array($metadata) && !empty($metadata)) {
|
||||
return $metadata[0]->_toArray();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \WP_REST_Request $request
|
||||
*
|
||||
|
|
|
@ -494,7 +494,7 @@ class Collection extends Entity {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the two core metadata of the collection (title and description)
|
||||
* Get the two core metadata of the collection (title, description and author)
|
||||
*
|
||||
* @return array[\Tainacan\Entities\Metadatum]
|
||||
*/
|
||||
|
@ -527,6 +527,17 @@ class Collection extends Entity {
|
|||
return $repo->get_core_description_metadatum($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Core Author Metadatum of the collection
|
||||
*
|
||||
* @return array[\Tainacan\Entities\Metadatum]
|
||||
*/
|
||||
function get_core_author_metadatum() {
|
||||
$repo = \Tainacan\Repositories\Metadata::get_instance();
|
||||
|
||||
return $repo->get_core_author_metadatum($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if comments are allowed for the current Collection.
|
||||
* @return string "open"|"closed"
|
||||
|
|
|
@ -384,6 +384,17 @@ class Item extends Entity {
|
|||
$this->set_mapped_property('comment_status', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the author id
|
||||
*
|
||||
* @param [integer] $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function set_author_id( $value ) {
|
||||
$this->set_mapped_property( 'author_id', $value );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -688,8 +699,6 @@ class Item extends Entity {
|
|||
} else {
|
||||
$output .= $embed;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -698,6 +707,43 @@ class Item extends Entity {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attachment as a html, can be iframe, image, audio...
|
||||
*/
|
||||
public function get_attachment_as_html($attachment, $img_size = 'large') {
|
||||
|
||||
$output = '';
|
||||
|
||||
if ( wp_attachment_is_image($attachment) ) {
|
||||
|
||||
$img = wp_get_attachment_image($attachment, $img_size);
|
||||
$img_full = wp_get_attachment_url($attachment);
|
||||
|
||||
$image_attributes = wp_get_attachment_image_src($attachment, $img_size );
|
||||
$img = "<img style='max-width: 100%;' src='" . $image_attributes[0] . "' />";
|
||||
|
||||
$output .= sprintf("<a href='%s' target='blank'>%s</a>", $img_full, $img);
|
||||
|
||||
} else {
|
||||
|
||||
global $wp_embed;
|
||||
|
||||
$url = wp_get_attachment_url($attachment);
|
||||
|
||||
$embed = $wp_embed->autoembed($url);
|
||||
|
||||
if ( $embed == $url ) {
|
||||
$output .= sprintf("<a href='%s' target='blank'>%s</a>", $url, $url);
|
||||
} else {
|
||||
$output .= $embed;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the url to the edit page for this item
|
||||
*/
|
||||
|
@ -706,4 +752,27 @@ class Item extends Entity {
|
|||
$id = $this->get_id();
|
||||
return admin_url("?page=tainacan_admin#/collections/$collection_id/items/$id/edit");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Document url of this item
|
||||
*/
|
||||
public function get_document_download_url() {
|
||||
$type = $this->get_document_type();
|
||||
|
||||
$link = null;
|
||||
|
||||
if ( $type == 'url' ) {
|
||||
$link = $this->get_document();
|
||||
} elseif ( $type == 'text' ) {
|
||||
$link = $this->get_document();
|
||||
} elseif ( $type == 'attachment' ) {
|
||||
if ( wp_attachment_is_image($this->get_document()) ) {
|
||||
$link = wp_get_attachment_url($this->get_document());
|
||||
} else {
|
||||
$link = wp_get_attachment_url($this->get_document());
|
||||
}
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,9 @@ class CSV extends Exporter {
|
|||
$line[] = implode( $this->get_option('multivalued_delimiter'), $rel );
|
||||
else
|
||||
$line[] = $rel;
|
||||
} else
|
||||
} else {
|
||||
$line[] = $meta->get_value_as_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -66,6 +67,14 @@ class CSV extends Exporter {
|
|||
$line[] = $this->get_attachments_cell($item);
|
||||
|
||||
$line[] = $item->get_comment_status();
|
||||
|
||||
$line[] = $item->get_author_name();
|
||||
|
||||
$line[] = $item->get_creation_date();
|
||||
|
||||
$line[] = $this->get_author_name_last_modification($item->get_id());
|
||||
|
||||
$line[] = $item->get_modification_date();
|
||||
|
||||
$line_string = $this->str_putcsv($line, $this->get_option('delimiter'), $this->get_option('enclosure'));
|
||||
|
||||
|
@ -99,6 +108,26 @@ class CSV extends Exporter {
|
|||
return implode( $this->get_option('multivalued_delimiter'), $attachments_urls );
|
||||
}
|
||||
|
||||
function get_author_name_last_modification($item_id) {
|
||||
$logs = \Tainacan\Repositories\Logs::get_instance()->fetch([
|
||||
'item_id'=>$item_id,
|
||||
'paged'=>1,
|
||||
'posts_per_page'=>1
|
||||
]);
|
||||
$response;
|
||||
|
||||
if($logs->have_posts()){
|
||||
while ($logs->have_posts()){
|
||||
$logs->the_post();
|
||||
|
||||
$log = new Entities\Log($logs->post);
|
||||
$response = $log->get_user_name();
|
||||
}
|
||||
wp_reset_postdata();
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function output_header() {
|
||||
|
||||
$mapper = $this->get_current_mapper();
|
||||
|
@ -136,6 +165,10 @@ class CSV extends Exporter {
|
|||
$line[] = 'special_document';
|
||||
$line[] = 'special_attachments';
|
||||
$line[] = 'special_comment_status';
|
||||
$line[] = 'author_name';
|
||||
$line[] = 'creation_date';
|
||||
$line[] = 'user_last_modified';
|
||||
$line[] = 'modification_date';
|
||||
|
||||
$line_string = $this->str_putcsv($line, $this->get_option('delimiter'), $this->get_option('enclosure'));
|
||||
|
||||
|
|
|
@ -24,15 +24,16 @@ class Dublin_Core extends Mapper {
|
|||
'label' => 'Coverage'
|
||||
],
|
||||
'dc:creator' => [
|
||||
'label' => 'Creator'
|
||||
'label' => 'Creator',
|
||||
'core_metadatum' => 'author'
|
||||
],
|
||||
'dc:date' => [
|
||||
'label' => 'Date',
|
||||
'metadata_type' => 'date'
|
||||
'metadata_type' => 'date'
|
||||
],
|
||||
'dc:description' => [
|
||||
'label' => 'Description',
|
||||
'core_metadatum' => 'description'
|
||||
'core_metadatum' => 'description'
|
||||
],
|
||||
'dc:format' => [
|
||||
'label' => 'Format',
|
||||
|
@ -60,7 +61,7 @@ class Dublin_Core extends Mapper {
|
|||
],
|
||||
'dc:title' => [
|
||||
'label' => 'Title',
|
||||
'core_metadatum' => 'title'
|
||||
'core_metadatum' => 'title'
|
||||
],
|
||||
'dc:type' => [
|
||||
'label' => 'Type'
|
||||
|
|
|
@ -348,6 +348,7 @@ class Collections extends Repository {
|
|||
$this->old_collection = $this->fetch( $collection->get_id() );
|
||||
$this->old_core_title = $collection->get_core_title_metadatum();
|
||||
$this->old_core_description = $collection->get_core_description_metadatum();
|
||||
$this->old_core_author = $collection->get_core_author_metadatum();
|
||||
|
||||
|
||||
}
|
||||
|
@ -360,9 +361,10 @@ class Collections extends Repository {
|
|||
if ( $this->old_collection instanceof Entities\Collection &&
|
||||
$this->old_collection->get_parent() != $collection->get_parent() &&
|
||||
$this->old_core_title instanceof Entities\Metadatum &&
|
||||
$this->old_core_description instanceof Entities\Metadatum
|
||||
$this->old_core_description instanceof Entities\Metadatum &&
|
||||
$this->old_core_author instanceof Entities\Metadatum
|
||||
) {
|
||||
$Tainacan_Metadata->maybe_update_core_metadata_meta_keys( $collection, $this->old_collection, $this->old_core_title, $this->old_core_description );
|
||||
$Tainacan_Metadata->maybe_update_core_metadata_meta_keys( $collection, $this->old_collection, $this->old_core_title, $this->old_core_description, $this->old_core_author);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ class Metadata extends Repository {
|
|||
|
||||
public $core_metadata = [
|
||||
'Tainacan\Metadata_Types\Core_Title',
|
||||
'Tainacan\Metadata_Types\Core_Description'
|
||||
'Tainacan\Metadata_Types\Core_Description',
|
||||
'Tainacan\Metadata_Types\Core_Author'
|
||||
];
|
||||
|
||||
private static $instance = null;
|
||||
|
@ -665,7 +666,7 @@ class Metadata extends Repository {
|
|||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function maybe_update_core_metadata_meta_keys( Entities\Collection $collection_new, Entities\Collection $collection_old, Entities\Metadatum $old_title_metadatum, Entities\Metadatum $old_description_metadatum ) {
|
||||
public function maybe_update_core_metadata_meta_keys( Entities\Collection $collection_new, Entities\Collection $collection_old, Entities\Metadatum $old_title_metadatum, Entities\Metadatum $old_description_metadatum, Entities\Metadatum $old_author_metadatum ) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
|
@ -677,10 +678,13 @@ class Metadata extends Repository {
|
|||
wp_delete_post( $old_description_metadatum->get_id(), true );
|
||||
update_post_meta( $old_title_metadatum->get_id(), 'metadata_type', 'to_delete', $old_title_metadatum->get_metadata_type() );
|
||||
wp_delete_post( $old_title_metadatum->get_id(), true );
|
||||
update_post_meta( $old_author_metadatum->get_id(), 'metadata_type', 'to_delete', $old_author_metadatum->get_metadata_type() );
|
||||
wp_delete_post( $old_author_metadatum->get_id(), true );
|
||||
}
|
||||
|
||||
$new_title_metadatum = $collection_new->get_core_title_metadatum();
|
||||
$new_description_metadatum = $collection_new->get_core_description_metadatum();
|
||||
$new_author_metadatum = $collection_new->get_core_author_metadatum();
|
||||
|
||||
$sql_statement = $wpdb->prepare(
|
||||
"UPDATE $wpdb->postmeta
|
||||
|
@ -706,6 +710,18 @@ class Metadata extends Repository {
|
|||
|
||||
$res = $wpdb->query( $sql_statement );
|
||||
|
||||
$sql_statement = $wpdb->prepare(
|
||||
"UPDATE $wpdb->postmeta
|
||||
SET meta_key = %s
|
||||
WHERE meta_key = %s AND post_id IN (
|
||||
SELECT ID
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s
|
||||
)", $new_author_metadatum->get_id(), $old_author_metadatum->get_id(), $item_post_type
|
||||
);
|
||||
|
||||
$res = $wpdb->query( $sql_statement );
|
||||
|
||||
wp_cache_flush();
|
||||
|
||||
}
|
||||
|
@ -732,6 +748,14 @@ class Metadata extends Repository {
|
|||
'metadata_type' => 'Tainacan\Metadata_Types\Core_Title',
|
||||
'status' => 'publish',
|
||||
'display' => 'yes',
|
||||
],
|
||||
'core_author' => [
|
||||
'name' => 'Author',
|
||||
'description' => 'Author',
|
||||
'collection_id' => $collection->get_id(),
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Core_Author',
|
||||
'status' => 'private',
|
||||
'display' => 'no',
|
||||
]
|
||||
];
|
||||
|
||||
|
@ -896,6 +920,33 @@ class Metadata extends Repository {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Core Author Metadatum for a collection
|
||||
*
|
||||
* @param Entities\Collection $collection
|
||||
*
|
||||
* @return \Tainacan\Entities\Metadatum The Core Author Metadatum
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function get_core_author_metadatum( Entities\Collection $collection ) {
|
||||
|
||||
$results = $this->fetch_by_collection( $collection, [
|
||||
'meta_query' => [
|
||||
[
|
||||
'key' => 'metadata_type',
|
||||
'value' => 'Tainacan\Metadata_Types\Core_Author',
|
||||
]
|
||||
],
|
||||
'posts_per_page' => 1
|
||||
] );
|
||||
|
||||
if ( is_array( $results ) && sizeof( $results ) == 1 && $results[0] instanceof \Tainacan\Entities\Metadatum ) {
|
||||
return $results[0];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* create a metadatum entity and insert by an associative array ( attribute => value )
|
||||
*
|
||||
|
|
|
@ -75,13 +75,40 @@ function tainacan_get_the_document() {
|
|||
return;
|
||||
|
||||
return apply_filters('tainacan-get-the-document', $item->get_document_as_html(), $item);
|
||||
}
|
||||
|
||||
function tainacan_the_item_document_download_link() {
|
||||
$item = tainacan_get_item();
|
||||
|
||||
if (!$item)
|
||||
return;
|
||||
|
||||
$link = $item->get_document_download_url();
|
||||
|
||||
if (!$link || $item->get_document_type() == 'text')
|
||||
return;
|
||||
|
||||
return '<a name="' . __('Download the item document', 'tainacan') . '" download="'. $link . '" href="' . $link . '">' . __('Download', 'tainacan') . '</a>';
|
||||
}
|
||||
|
||||
function tainacan_the_document() {
|
||||
echo tainacan_get_the_document();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTML display-ready version of an attachment
|
||||
*/
|
||||
function tainacan_get_single_attachment_as_html($attachment_id) {
|
||||
|
||||
$item = tainacan_get_item();
|
||||
|
||||
if (!$attachment_id) {
|
||||
return '';
|
||||
}
|
||||
|
||||
echo $item->get_attachment_as_html($attachment_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* To be used inside The Loop
|
||||
*
|
||||
|
@ -141,7 +168,7 @@ function tainacan_get_the_collection_name() {
|
|||
$name = $collection->get_name();
|
||||
}
|
||||
return apply_filters('tainacan-get-collection-name', $name, $collection);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When visiting a collection archive or single, prints the collection name
|
||||
|
@ -175,6 +202,32 @@ function tainacan_the_collection_description() {
|
|||
echo tainacan_get_the_collection_description();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* When visiting a collection archive or single, returns the collection url link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function tainacan_get_the_collection_url() {
|
||||
$collection = tainacan_get_collection();
|
||||
$url = '';
|
||||
|
||||
if ( $collection ) {
|
||||
$url = $collection->get_url();
|
||||
}
|
||||
return apply_filters('tainacan-get-collection-url', $url, $collection);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* When visiting a collection archive or single, prints the collection url link
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function tainacan_the_collection_url() {
|
||||
echo tainacan_get_the_collection_url();
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the div used by Vue to render the Items List with a powerful faceted search
|
||||
*
|
||||
|
@ -330,7 +383,7 @@ function tainacan_get_the_attachments($exclude = null) {
|
|||
if (!$item)
|
||||
return [];
|
||||
|
||||
return apply_filters('tainacan-get-the-attachments', $item->get_attachments(), $item);
|
||||
return apply_filters('tainacan-get-the-attachments', $item->get_attachments($exclude), $item);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Tainacan\Filter_Types;
|
|||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
* Class TainacanFilterType
|
||||
*/
|
||||
class Autocomplete extends Filter_Type {
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Tainacan\Filter_Types;
|
|||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
* Class TainacanFilterType
|
||||
*/
|
||||
class Checkbox extends Filter_Type {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Tainacan\Filter_Types;
|
|||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
* Class TainacanFilterType
|
||||
*/
|
||||
class Date_Interval extends Filter_Type {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Tainacan\Filter_Types;
|
|||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
* Class TainacanFilterType
|
||||
*/
|
||||
class Numeric_Interval extends Filter_Type {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Tainacan\Filter_Types;
|
|||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
* Class TainacanFilterType
|
||||
*/
|
||||
class Numeric_List_Interval extends Filter_Type {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Tainacan\Filter_Types;
|
|||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
* Class TainacanFilterType
|
||||
*/
|
||||
class Numeric extends Filter_Type {
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Tainacan\Filter_Types;
|
|||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
* Class TainacanFilterType
|
||||
*/
|
||||
class Selectbox extends Filter_Type {
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
@typing="search"
|
||||
:aria-close-label="$i18n.get('remove_value')"
|
||||
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||
:placeholder="(metadatumType == 'Tainacan\\Metadata_Types\\Relationship') ? $i18n.get('info_type_to_add_items') : $i18n.get('info_type_to_add_metadata')"
|
||||
:placeholder="getInputPlaceholder"
|
||||
check-infinite-scroll
|
||||
@infinite-scroll="searchMore">
|
||||
<template slot-scope="props">
|
||||
|
@ -46,13 +46,13 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { tainacan as axios, isCancel } from '../../../js/axios';
|
||||
import { tainacan as axios, isCancel, wp as wpAxios } from '../../../js/axios';
|
||||
import { filterTypeMixin, dynamicFilterTypeMixin } from '../../../js/filter-types-mixin';
|
||||
import qs from 'qs';
|
||||
|
||||
export default {
|
||||
mixins: [filterTypeMixin, dynamicFilterTypeMixin],
|
||||
data(){
|
||||
data() {
|
||||
return {
|
||||
results:'',
|
||||
selected:[],
|
||||
|
@ -64,6 +64,16 @@
|
|||
totalFacets: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
getInputPlaceholder() {
|
||||
if (this.metadatumType == 'Tainacan\\Metadata_Types\\Relationship')
|
||||
return this.$i18n.get('info_type_to_add_items');
|
||||
else if (this.metadatumType == 'Tainacan\\Metadata_Types\\Core_Author')
|
||||
return this.$i18n.get('info_type_to_add_users');
|
||||
else
|
||||
return this.$i18n.get('info_type_to_add_metadata');
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'query.metaquery'() {
|
||||
this.updateSelectedValues();
|
||||
|
@ -115,7 +125,7 @@
|
|||
if (this.getOptionsValuesCancel != undefined)
|
||||
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
||||
|
||||
if ( this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' )
|
||||
if ( this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' || this.metadatumType === 'Tainacan\\Metadata_Types\\Core_Author' )
|
||||
promise = this.getValuesRelationship( this.searchQuery, this.isRepositoryLevel, valuesToIgnore, this.searchOffset, this.searchNumber );
|
||||
else
|
||||
promise = this.getValuesPlainText( this.metadatumId, this.searchQuery, this.isRepositoryLevel, valuesToIgnore, this.searchOffset, this.searchNumber );
|
||||
|
@ -149,7 +159,7 @@
|
|||
if (index >= 0) {
|
||||
let metadata = this.query.metaquery[ index ];
|
||||
|
||||
if ( this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' ) {
|
||||
if (this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship') {
|
||||
let query = qs.stringify({ postin: metadata.value, fetch_only: 'title,thumbnail', fetch_only_meta: '' });
|
||||
let endpoint = '/items/';
|
||||
|
||||
|
@ -179,6 +189,33 @@
|
|||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
} else if (this.metadatumType === 'Tainacan\\Metadata_Types\\Core_Author') {
|
||||
let query = qs.stringify({ include: metadata.value });
|
||||
let endpoint = '/users/';
|
||||
|
||||
wpAxios.get(endpoint + '?' + query)
|
||||
.then( res => {
|
||||
if (res.data) {
|
||||
this.selected = [];
|
||||
for (let user of res.data) {
|
||||
let existingUser = this.selected.findIndex((anUser) => user.id == anUser.id);
|
||||
if (existingUser < 0) {
|
||||
this.selected.push({
|
||||
label: user.name,
|
||||
value: user.id,
|
||||
img: user.avatar_urls && user.avatar_urls['24'] ? user.avatar_urls['24'] : null
|
||||
});
|
||||
}
|
||||
}
|
||||
this.$emit( 'sendValuesToTags', {
|
||||
label: this.selected.map((option) => option.label),
|
||||
value: this.selected.map((option) => option.value)
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
} else {
|
||||
this.selected = [];
|
||||
for (let item of metadata.value)
|
||||
|
|
|
@ -4,13 +4,13 @@ namespace Tainacan\Filter_Types;
|
|||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
* Class TainacanFilterType
|
||||
*/
|
||||
class Taginput extends Filter_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->set_name( __('Tag Input', 'tainacan') );
|
||||
$this->set_supported_types(['string','long_string','item']);
|
||||
$this->set_supported_types(['string','long_string','item','user']);
|
||||
$this->set_component('tainacan-filter-taginput');
|
||||
$this->set_use_max_options(false);
|
||||
$this->set_preview_template('
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Tainacan\Filter_Types;
|
|||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
* Class TainacanFilterType
|
||||
*/
|
||||
class TaxonomyCheckbox extends Filter_Type {
|
||||
|
||||
|
|
|
@ -135,11 +135,11 @@
|
|||
show: 500,
|
||||
hide: 300,
|
||||
},
|
||||
content: (taxonomy.collections != undefined && taxonomy.collections.length != undefined && taxonomy.collections.length > 0) ? renderListOfCollections(taxonomy.collections) : $i18n.get('label_no_collections_using_taxonomy'),
|
||||
content: (taxonomy.collections != undefined && taxonomy.collections.length != undefined && taxonomy.collections.length > 0) ? renderListOfCollections(taxonomy.collections, taxonomy.metadata_by_collection) : $i18n.get('label_no_collections_using_taxonomy'),
|
||||
autoHide: false,
|
||||
placement: 'auto-start'
|
||||
}"
|
||||
v-html="(taxonomy.collections != undefined && taxonomy.collections.length != undefined && taxonomy.collections.length > 0) ? renderListOfCollections(taxonomy.collections) : $i18n.get('label_no_collections_using_taxonomy')" />
|
||||
v-html="(taxonomy.collections != undefined && taxonomy.collections.length != undefined && taxonomy.collections.length > 0) ? renderListOfCollections(taxonomy.collections, taxonomy.metadata_by_collection) : $i18n.get('label_no_collections_using_taxonomy')" />
|
||||
</td>
|
||||
<!-- Actions -->
|
||||
<td
|
||||
|
@ -325,11 +325,11 @@
|
|||
this.$router.push(this.$routerHelper.getTaxonomyEditPath(taxonomyId));
|
||||
}
|
||||
},
|
||||
renderListOfCollections(collections) {
|
||||
renderListOfCollections(collections, metadata) {
|
||||
let htmlList = '';
|
||||
|
||||
for (let i = 0; i < collections.length; i++) {
|
||||
htmlList += `<a target="_blank" href=${ this.adminUrl + 'admin.php?page=tainacan_admin#' + this.$routerHelper.getCollectionPath(collections[i].id)}>${collections[i].name}</a>`;
|
||||
htmlList += `<a target="_blank" href=${ this.adminUrl + 'admin.php?page=tainacan_admin#' + this.$routerHelper.getCollectionPath(collections[i].id)}>${collections[i].name}(${metadata[collections[i].id].name})</a>`;
|
||||
if (collections.length > 2 && i < collections.length - 1) {
|
||||
if (i < collections.length - 2)
|
||||
htmlList += ', '
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
<template>
|
||||
<b-autocomplete
|
||||
clearable
|
||||
:disabled="disabled"
|
||||
:value="currentUser && currentUser.name ? currentUser.name : null"
|
||||
:data="users"
|
||||
:placeholder="$i18n.get('instruction_type_search_users')"
|
||||
keep-first
|
||||
open-on-focus
|
||||
@input="loadUsers"
|
||||
@focus.once="($event) => loadUsers($event.target.value)"
|
||||
@select="onSelect"
|
||||
:loading="isFetchingUsers || isLoadingCurrentUser"
|
||||
field="name"
|
||||
icon="account"
|
||||
check-infinite-scroll
|
||||
@infinite-scroll="fetchMoreUsers">
|
||||
<template slot-scope="props">
|
||||
<div class="media">
|
||||
<div
|
||||
v-if="props.option.avatar_urls && props.option.avatar_urls['24']"
|
||||
class="media-left">
|
||||
<img
|
||||
width="24"
|
||||
:src="props.option.avatar_urls['24']">
|
||||
</div>
|
||||
<div class="media-content">
|
||||
{{ props.option.name }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template slot="empty">{{ $i18n.get('info_no_user_found') }}</template>
|
||||
</b-autocomplete>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
metadatum: Object,
|
||||
value: [String, Number, Array],
|
||||
disabled: false
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
users: [],
|
||||
isLoadingCurrentUser: false,
|
||||
isFetchingUsers: false,
|
||||
userId: null,
|
||||
usersSearchQuery: '',
|
||||
usersSearchPage: 1,
|
||||
totalUsers: 0,
|
||||
currentUser: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loadCurrentUser();
|
||||
},
|
||||
methods: {
|
||||
onSelect(value) {
|
||||
this.$emit('input', value.id);
|
||||
},
|
||||
...mapActions('activity', [
|
||||
'fetchUsers',
|
||||
'fetchUser'
|
||||
]),
|
||||
loadCurrentUser() {
|
||||
this.isLoadingCurrentUser = true;
|
||||
this.fetchUser(this.value)
|
||||
.then((res) => {
|
||||
this.currentUser = res.user;
|
||||
this.isLoadingCurrentUser = false;
|
||||
})
|
||||
.catch(() => this.isLoadingCurrentUser = false );
|
||||
},
|
||||
loadUsers: _.debounce(function (search) {
|
||||
|
||||
// String update
|
||||
if (search != this.usersSearchQuery) {
|
||||
this.usersSearchQuery = search;
|
||||
this.users = [];
|
||||
this.usersSearchPage = 1;
|
||||
}
|
||||
|
||||
// String cleared
|
||||
if (!search.length) {
|
||||
this.usersSearchQuery = search;
|
||||
this.users = [];
|
||||
this.usersSearchPage = 1;
|
||||
}
|
||||
|
||||
// No need to load more
|
||||
if (this.usersSearchPage > 1 && this.users.length > this.totalUsers)
|
||||
return;
|
||||
|
||||
this.isFetchingUsers = true;
|
||||
|
||||
this.fetchUsers({ search: this.usersSearchQuery, page: this.usersSearchPage })
|
||||
.then((res) => {
|
||||
if (res.users) {
|
||||
for (let user of res.users)
|
||||
this.users.push(user);
|
||||
}
|
||||
|
||||
if (res.totalUsers)
|
||||
this.totalUsers = res.totalUsers;
|
||||
|
||||
this.usersSearchPage++;
|
||||
|
||||
this.isFetchingUsers = false;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
this.isFetchingPages = false;
|
||||
});
|
||||
}, 500),
|
||||
fetchMoreUsers: _.debounce(function () {
|
||||
this.loadUsers(this.usersSearchQuery)
|
||||
}, 250),
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Metadata_Types;
|
||||
|
||||
use Tainacan\Entities\Metadatum;
|
||||
|
||||
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
*/
|
||||
class Core_Author extends Metadata_Type {
|
||||
|
||||
function __construct(){
|
||||
// call metadatum type constructor
|
||||
parent::__construct();
|
||||
$this->set_primitive_type('user');
|
||||
$this->set_core(true);
|
||||
$this->set_related_mapped_prop('author_id');
|
||||
$this->set_component('tainacan-author');
|
||||
$this->set_name( __('Core Author', 'tainacan') );
|
||||
$this->set_description( __('The "Core Author" is a compulsory metadata automatically created for all collections by default.', 'tainacan') );
|
||||
}
|
||||
|
||||
/**
|
||||
* generate the metadata for this metadatum type
|
||||
*/
|
||||
public function form(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Core author metadatum type is stored as the item author
|
||||
*
|
||||
* Lets validate it as the item title
|
||||
*
|
||||
* @param TainacanEntitiesItem_Metadata_Entity $item_metadata
|
||||
* @return bool Valid or not
|
||||
*
|
||||
* Quarantine - Core metadata should be validated as any other metadata
|
||||
* and item title is no longer mandatory
|
||||
* public function validate(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) { }
|
||||
*/
|
||||
|
||||
public function validate_options( Metadatum $metadatum ) {
|
||||
if ( !in_array($metadatum->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
|
||||
return true;
|
||||
|
||||
if ( $metadatum->get_multiple() != 'no') {
|
||||
return ['multiple' => __('Core Metadata can not accept multiple values', 'tainacan')];
|
||||
}
|
||||
|
||||
if ($metadatum->get_required() != 'no') {
|
||||
return ['multiple' => __('Core Author Metadata is required', 'tainacan')];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value as a HTML string
|
||||
* @return string
|
||||
*/
|
||||
public function get_value_as_html(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
|
||||
$value = $item_metadata->get_value();
|
||||
$name = get_the_author_meta( 'display_name', $value );
|
||||
return apply_filters("tainacan-item-get-author-name", $name, $this);
|
||||
}
|
||||
|
||||
}
|
|
@ -50,7 +50,7 @@ abstract class Metadata_Type {
|
|||
/**
|
||||
* Indicates whether this is a core Metadatum Type or not
|
||||
*
|
||||
* Core metadatum types are used by Title and description metadata. These metadata:
|
||||
* Core metadatum types are used by Title, Description and Author metadata. These metadata:
|
||||
* * Can only be used once, they belong to the repository and can not be deleted
|
||||
* * Its values are saved in th wp_post table, and not as post_meta
|
||||
*
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
props: {
|
||||
itemMetadatum: Object,
|
||||
|
|
|
@ -535,9 +535,14 @@
|
|||
getValidEditionActions(metadatumID) {
|
||||
const isMultiple = this.getMetadataByID(metadatumID).multiple == 'yes';
|
||||
let validEditionActions = {};
|
||||
|
||||
|
||||
for (let [actionKey, action] of Object.entries(isMultiple ? this.editionActionsForMultiple : this.editionActionsForNotMultiple)) {
|
||||
if ((metadatumID != 'status' && metadatumID != 'comments') || actionKey != 'clear')
|
||||
if ( (metadatumID != 'status' &&
|
||||
metadatumID != 'comments' &&
|
||||
(this.getMetadataByID(metadatumID) && this.getMetadataByID(metadatumID).metadata_type_object && this.getMetadataByID(metadatumID).metadata_type_object.component !== 'tainacan-author')
|
||||
) ||
|
||||
actionKey != 'clear'
|
||||
)
|
||||
validEditionActions[actionKey] = action;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ export default {
|
|||
this.$route.query.metakey = orderBy.id;
|
||||
this.$route.query.metatype = 'DATETIME';
|
||||
} else if (orderBy.metadata_type_object.core) {
|
||||
this.$route.query.orderby = orderBy.metadata_type_object.related_mapped_prop;
|
||||
this.$route.query.orderby = orderBy.metadata_type_object.related_mapped_prop == 'author_id' ? 'author' : orderBy.metadata_type_object.related_mapped_prop;
|
||||
} else {
|
||||
this.$route.query.orderby = 'meta_value';
|
||||
this.$route.query.metakey = orderBy.id;
|
||||
|
|
|
@ -178,7 +178,7 @@ export const dynamicFilterTypeMixin = {
|
|||
return new Object ({
|
||||
request:
|
||||
new Promise((resolve, reject) => {
|
||||
axios.tainacan.get(url + '&fetch_only=thumbnail,title,id&' + qs.stringify(query_items))
|
||||
axios.tainacan.get(url + '&' + qs.stringify(query_items))
|
||||
.then(res => {
|
||||
|
||||
this.isLoadingOptions = false;
|
||||
|
|
|
@ -20,6 +20,7 @@ import Date from '../components/metadata-types/date/Date.vue';
|
|||
import Relationship from '../components/metadata-types/relationship/Relationship.vue';
|
||||
import Taxonomy from '../components/metadata-types/taxonomy/Taxonomy.vue';
|
||||
import Compound from '../components/metadata-types/compound/Compound.vue';
|
||||
import Author from '../components/metadata-types/core-author/Author.vue';
|
||||
|
||||
import FormRelationship from '../components/metadata-types/relationship/FormRelationship.vue';
|
||||
import FormTaxonomy from '../components/metadata-types/taxonomy/FormTaxonomy.vue';
|
||||
|
@ -94,6 +95,7 @@ Vue.component('tainacan-date', Date);
|
|||
Vue.component('tainacan-relationship', Relationship);
|
||||
Vue.component('tainacan-taxonomy', Taxonomy);
|
||||
Vue.component('tainacan-compound', Compound);
|
||||
Vue.component('tainacan-author', Author);
|
||||
|
||||
/* Metadata Option forms */
|
||||
Vue.component('tainacan-form-relationship', FormRelationship);
|
||||
|
|
|
@ -165,7 +165,7 @@ export const notApprove = ({commit}, activityId) => {
|
|||
|
||||
};
|
||||
|
||||
// Users for filtering
|
||||
// Users for filtering and core author metadata
|
||||
export const fetchUsers = ({ commit }, { search, page }) => {
|
||||
let endpoint = '/users?search=' + search;
|
||||
|
||||
|
@ -174,11 +174,24 @@ export const fetchUsers = ({ commit }, { search, page }) => {
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.wp.get(endpoint)
|
||||
.then(res => {
|
||||
resolve({ users: res.data, totalUsers: res.headers['x-wp-total'] } );
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
.then(res => {
|
||||
resolve({ users: res.data, totalUsers: res.headers['x-wp-total'] } );
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Single user for core author metadata
|
||||
export const fetchUser = ({ commit }, userId) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.wp.get('/users/' + userId)
|
||||
.then(res => {
|
||||
resolve({ user: res.data });
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
|
@ -107,7 +107,7 @@ export const setOrderBy = ({ state, commit }, orderBy ) => {
|
|||
commit('setPostQueryAttribute', { attr: 'metakey', value: orderBy.id } );
|
||||
commit('setPostQueryAttribute', { attr: 'metatype', value: 'DATETIME' } );
|
||||
} else if (orderBy.metadata_type_object.core) {
|
||||
commit('setPostQueryAttribute', { attr: 'orderby', value: orderBy.metadata_type_object.related_mapped_prop } );
|
||||
commit('setPostQueryAttribute', { attr: 'orderby', value: orderBy.metadata_type_object.related_mapped_prop == 'author_id' ? 'author' : orderBy.metadata_type_object.related_mapped_prop } );
|
||||
commit('removePostQueryAttribute', 'metakey');
|
||||
commit('removePostQueryAttribute', 'metatype');
|
||||
} else {
|
||||
|
|
|
@ -272,7 +272,7 @@
|
|||
ProcessesList,
|
||||
},
|
||||
mixins: [ dateInter ],
|
||||
data(){
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
totalActivities: 0,
|
||||
|
@ -524,7 +524,7 @@
|
|||
}
|
||||
|
||||
// No need to load more
|
||||
if (this.usersForFilteringSearchPage > 1 && this.users.length > this.totalPages*12)
|
||||
if (this.usersForFilteringSearchPage > 1 && this.users.length > this.totalUsers)
|
||||
return;
|
||||
|
||||
this.isFetchingUsers = true;
|
||||
|
|
|
@ -704,7 +704,7 @@
|
|||
|
||||
if (
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug == 'creation_date' && (!metadatum.metadata_type_object || !metadatum.metadata_type_object.core)) && this.orderBy == 'date') ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (metadatum.metadata_type_object != undefined && metadatum.metadata_type_object.core)) && this.orderBy == metadatum.metadata_type_object.related_mapped_prop) ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (metadatum.metadata_type_object != undefined && metadatum.metadata_type_object.core)) && this.orderBy == (metadatum.metadata_type_object.related_mapped_prop == 'author_id' ? 'author' : metadatum.metadata_type_object.related_mapped_prop)) ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (!metadatum.metadata_type_object || !metadatum.metadata_type_object.core)) && this.orderBy == metadatum.slug) ||
|
||||
((this.orderBy == 'meta_value' || this.orderBy == 'meta_value_num') && this.getMetaKey() == metadatum.id)
|
||||
)
|
||||
|
@ -1002,6 +1002,15 @@
|
|||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_author'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'author_id'},
|
||||
metadata_type: undefined,
|
||||
slug: 'author',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
let fetchOnlyMetadatumIds = [];
|
||||
|
|
|
@ -243,7 +243,7 @@ class Admin {
|
|||
|
||||
$maps = [
|
||||
'collections' => $Tainacan_Collections->get_map(),
|
||||
'metadata' => $Tainacan_Metadata->get_map(),
|
||||
'metadata' => $Tainacan_Metadata->get_map(),
|
||||
'filters' => $Tainacan_Filters->get_map(),
|
||||
'items' => $Tainacan_Items->get_map(),
|
||||
'taxonomies' => $Tainacan_Taxonomies->get_map(),
|
||||
|
|
|
@ -185,7 +185,7 @@
|
|||
list-style-type: none;
|
||||
margin: 10px;
|
||||
padding: 2px;
|
||||
max-height: 50vh;
|
||||
max-height: 39vh;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
|
||||
|
|
|
@ -231,8 +231,9 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_inherited' => __( 'Inherited', 'tainacan' ),
|
||||
'label_core_title' => __( 'Core Title', 'tainacan' ),
|
||||
'label_core_description' => __( 'Core Description', 'tainacan' ),
|
||||
'label_core_author' => __( 'Core Author', 'tainacan' ),
|
||||
'label_sorting' => __( 'Sorting', 'tainacan' ),
|
||||
'label_sorting_direction' => __( 'Sorting direction', 'tainacan' ),
|
||||
'label_sorting_direction' => __( 'Sorting direction', 'tainacan' ),
|
||||
'label_sort' => __( 'Sort', 'tainacan' ),
|
||||
'label_activity_date' => __( 'Activity date', 'tainacan' ),
|
||||
'label_activity_title' => __( 'Activity', 'tainacan' ),
|
||||
|
@ -472,7 +473,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'instruction_select_a_parent_term' => __( 'Select a parent term:', 'tainacan' ),
|
||||
'instruction_select_a_metadatum' => __( 'Select a metadatum', 'tainacan' ),
|
||||
'instruction_cover_page' => __( 'Type to search a Page to choose.', 'tainacan' ),
|
||||
'instruction_moderators' => __( 'Type to search a User to add.', 'tainacan' ),
|
||||
'instruction_type_search_users' => __( 'Type to search users...', 'tainacan' ),
|
||||
'instruction_type_search_users_filter' => __( 'Type to search users to filter...', 'tainacan' ),
|
||||
'instruction_type_search_roles_filter' => __( 'Type to search roles to filter...', 'tainacan' ),
|
||||
'instruction_select_a_parent_collection' => __( 'Select a parent collection.', 'tainacan' ),
|
||||
|
@ -645,6 +646,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'info_updated_at' => __( 'Updated at', 'tainacan' ),
|
||||
'info_editing_metadata_values' => __( 'Editing metadata values...', 'tainacan' ),
|
||||
'info_updating_metadata_values' => __( 'Updating metadata values...', 'tainacan' ),
|
||||
'info_type_to_add_users' => __( 'Add users to filter...', 'tainacan' ),
|
||||
'info_type_to_add_items' => __( 'Add items to filter...', 'tainacan' ),
|
||||
'info_type_to_search_items' => __( 'Search items...', 'tainacan' ),
|
||||
'info_type_to_add_terms' => __( 'Add terms to filter...', 'tainacan' ),
|
||||
|
|
|
@ -153,33 +153,39 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
// Options related to hidding elements
|
||||
if (this.$el.attributes['hide-filters'] != undefined)
|
||||
this.hideFilters = this.$el.attributes['hide-filters'].value == 'true' ? true : false;
|
||||
this.hideFilters = this.isParameterTrue('hide-filters');
|
||||
if (this.$el.attributes['hide-hide-filters-button'] != undefined)
|
||||
this.hideHideFiltersButton = this.$el.attributes['hide-hide-filters-button'].value == 'true' ? true : false;
|
||||
this.hideHideFiltersButton = this.isParameterTrue('hide-hide-filters-button');
|
||||
if (this.$el.attributes['hide-search'] != undefined)
|
||||
this.hideSearch = this.$el.attributes['hide-search'].value == 'true' ? true : false;
|
||||
this.hideSearch = this.isParameterTrue('hide-search');
|
||||
if (this.$el.attributes['hide-advanced-search'] != undefined)
|
||||
this.hideAdvancedSearch = this.$el.attributes['hide-advanced-search'].value == 'true' ? true : false;
|
||||
this.hideAdvancedSearch = this.isParameterTrue('hide-advanced-search');
|
||||
if (this.$el.attributes['hide-sort-by-button'] != undefined)
|
||||
this.hideSortByButton = this.$el.attributes['hide-sort-by-button'].value == 'true' ? true : false;
|
||||
this.hideSortByButton = this.isParameterTrue('hide-sort-by-button');
|
||||
if (this.$el.attributes['hide-exposers-button'] != undefined)
|
||||
this.hideExposersButton = this.$el.attributes['hide-exposers-button'].value == 'true' ? true : false
|
||||
this.hideExposersButton = this.isParameterTrue('hide-exposers-button');
|
||||
if (this.$el.attributes['hide-items-per-page-button'] != undefined)
|
||||
this.hideItemsPerPageButton = this.$el.attributes['hide-items-per-page-button'].value == 'true' ? true : false;
|
||||
this.hideItemsPerPageButton = this.isParameterTrue('hide-items-per-page-button');
|
||||
if (this.$el.attributes['hide-go-to-page-button'] != undefined)
|
||||
this.hideGoToPageButton = this.$el.attributes['hide-go-to-page-button'].value == 'true' ? true : false;
|
||||
this.hideGoToPageButton = this.isParameterTrue('hide-go-to-page-button');
|
||||
|
||||
// Other Tweaks
|
||||
if (this.$el.attributes['show-filters-button-inside-search-control'] != undefined)
|
||||
this.showFiltersButtonInsideSearchControl = this.$el.attributes['show-filters-button-inside-search-control'].value == 'true' ? true : false;
|
||||
this.showFiltersButtonInsideSearchControl = this.isParameterTrue('show-filters-button-inside-search-control');
|
||||
if (this.$el.attributes['start-with-filters-hidden'] != undefined)
|
||||
this.startWithFiltersHidden = this.$el.attributes['start-with-filters-hidden'].value == 'true' ? true : false;
|
||||
this.startWithFiltersHidden = this.isParameterTrue('start-with-filters-hidden');
|
||||
if (this.$el.attributes['filters-as-modal'] != undefined)
|
||||
this.filtersAsModal = this.$el.attributes['filters-as-modal'].value == 'true' ? true : false;
|
||||
this.filtersAsModal = this.isParameterTrue('filters-as-modal');
|
||||
if (this.$el.attributes['show-inline-view-mode-options'] != undefined)
|
||||
this.showInlineViewModeOptions = this.$el.attributes['show-inline-view-mode-options'].value == 'true' ? true : false;
|
||||
this.showInlineViewModeOptions = this.isParameterTrue('show-inline-view-mode-options');
|
||||
if (this.$el.attributes['show-fullscreen-with-view-modes'] != undefined)
|
||||
this.showFullscreenWithViewModes = this.$el.attributes['show-fullscreen-with-view-modes'].value == 'true' ? true : false;
|
||||
this.showFullscreenWithViewModes = this.isParameterTrue('show-fullscreen-with-view-modes');
|
||||
},
|
||||
methods: {
|
||||
isParameterTrue(parameter) {
|
||||
const value = this.$el.attributes[parameter].value;
|
||||
return (value == true || value == 'true' || value == '1' || value == 1) ? true : false;
|
||||
}
|
||||
},
|
||||
render: h => h(ThemeSearch)
|
||||
});
|
||||
|
|
|
@ -622,7 +622,7 @@
|
|||
for (let metadatum of this.sortingMetadata) {
|
||||
if (
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug == 'creation_date' && (!metadatum.metadata_type_object || !metadatum.metadata_type_object.core)) && this.orderBy == 'date') ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (metadatum.metadata_type_object != undefined && metadatum.metadata_type_object.core)) && this.orderBy == metadatum.metadata_type_object.related_mapped_prop) ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (metadatum.metadata_type_object != undefined && metadatum.metadata_type_object.core)) && this.orderBy == (metadatum.metadata_type_object.related_mapped_prop == 'author_id' ? 'author' : metadatum.metadata_type_object.related_mapped_prop)) ||
|
||||
((this.orderBy != 'meta_value' && this.orderBy != 'meta_value_num' && metadatum.slug != 'creation_date' && (!metadatum.metadata_type_object || !metadatum.metadata_type_object.core)) && this.orderBy == metadatum.slug) ||
|
||||
((this.orderBy == 'meta_value' || this.orderBy == 'meta_value_num') && this.getMetaKey() == metadatum.id)
|
||||
)
|
||||
|
@ -895,6 +895,15 @@
|
|||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
metadata.push({
|
||||
name: this.$i18n.get('label_author'),
|
||||
metadatum: 'row_author',
|
||||
metadata_type_object: {core: true, related_mapped_prop: 'author_id'},
|
||||
metadata_type: undefined,
|
||||
slug: 'author',
|
||||
id: undefined,
|
||||
display: true
|
||||
});
|
||||
}
|
||||
|
||||
let fetchOnlyMetadatumIds = [];
|
||||
|
|
|
@ -380,7 +380,7 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$data = $response->get_data()['items'];
|
||||
|
||||
$this->assertEquals( 2, sizeof($data) );
|
||||
$this->assertEquals( 5, sizeof($data[0]['metadata']) );
|
||||
$this->assertEquals( 6, sizeof($data[0]['metadata']) );
|
||||
|
||||
// Fetch only as admin
|
||||
$request = new \WP_REST_Request(
|
||||
|
|
|
@ -825,7 +825,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$response = $this->server->dispatch($request);
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals(4, count($data['metadata_order']));
|
||||
$this->assertEquals(5, count($data['metadata_order']));
|
||||
|
||||
wp_logout();
|
||||
wp_set_current_user(0);
|
||||
|
|
|
@ -205,13 +205,13 @@ class TAINACAN_REST_Metadatum_Mappers_Controller extends TAINACAN_UnitApiTestCas
|
|||
$dc = new \Tainacan\Mappers\Dublin_Core();
|
||||
|
||||
$metadatum_mapper_request = new \WP_REST_Request('POST', $this->namespace . '/collections');
|
||||
$metadatum_mapper_request->set_body(json_encode([
|
||||
$metadatum_mapper_request->set_body(json_encode([
|
||||
\Tainacan\Mappers_Handler::MAPPER_PARAM => $dc->slug,
|
||||
'name' => 'Test Collection'
|
||||
]));
|
||||
$metadatum_mapper_response = $this->server->dispatch($metadatum_mapper_request);
|
||||
$this->assertEquals(201, $metadatum_mapper_response->get_status());
|
||||
$data = $metadatum_mapper_response->get_data();
|
||||
$metadatum_mapper_response = $this->server->dispatch($metadatum_mapper_request);
|
||||
$this->assertEquals(201, $metadatum_mapper_response->get_status());
|
||||
$data = $metadatum_mapper_response->get_data();
|
||||
|
||||
$collection = \Tainacan\Repositories\Collections::get_instance()->fetch( $data['id'] );
|
||||
|
||||
|
|
|
@ -510,17 +510,17 @@ class Capabilities extends TAINACAN_UnitTestCase {
|
|||
$current_user = $this->subscriber2; // force update current user object with new capabilities
|
||||
|
||||
$meta = tainacan_metadata()->fetch_by_collection($this->public_collection);
|
||||
$this->AssertEquals(5, sizeof($meta));
|
||||
$this->AssertEquals(6, sizeof($meta));
|
||||
$meta = tainacan_metadata()->fetch_ids_by_collection($this->public_collection);
|
||||
$this->AssertEquals(5, sizeof($meta));
|
||||
$this->AssertEquals(6, sizeof($meta));
|
||||
|
||||
$this->subscriber2->add_cap( 'tnc_rep_read_private_metadata' );
|
||||
$current_user = $this->subscriber2; // force update current user object with new capabilities
|
||||
|
||||
$meta = tainacan_metadata()->fetch_by_collection($this->public_collection);
|
||||
$this->AssertEquals(6, sizeof($meta));
|
||||
$this->AssertEquals(7, sizeof($meta));
|
||||
$meta = tainacan_metadata()->fetch_ids_by_collection($this->public_collection);
|
||||
$this->AssertEquals(6, sizeof($meta));
|
||||
$this->AssertEquals(7, sizeof($meta));
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
$metadatum = $collection->get_core_title_metadatum();
|
||||
|
||||
$metadatumDescription = $collection->get_core_description_metadatum();
|
||||
|
||||
$metadatumAuthor = $collection->get_core_author_metadatum();
|
||||
|
||||
|
||||
$i = $this->tainacan_entity_factory->create_entity(
|
||||
|
@ -56,7 +58,7 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
$checkItem = $Tainacan_Items->fetch($i->get_id());
|
||||
|
||||
$this->assertEquals('changed title', $checkItem->get_title());
|
||||
|
||||
|
||||
$check_item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($checkItem, $metadatum);
|
||||
$this->assertEquals('changed title', $check_item_metadata->get_value());
|
||||
|
||||
|
@ -87,6 +89,10 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
$this->assertEquals(1, sizeof($checkMeta));
|
||||
$this->assertEquals('changed description', $checkMeta[0]->get_description());
|
||||
|
||||
|
||||
// author
|
||||
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($i, $metadatumAuthor);
|
||||
|
||||
}
|
||||
|
||||
|
@ -194,7 +200,7 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
$core_metadata = $collection->get_core_metadata();
|
||||
|
||||
$this->assertEquals(2, sizeof($core_metadata));
|
||||
$this->assertEquals(3, sizeof($core_metadata));
|
||||
|
||||
$this->assertNotEquals('Tainacan\Metadata_Types\Text', $core_metadata[0]->get_metadata_type());
|
||||
$this->assertNotEquals('Tainacan\Metadata_Types\Text', $core_metadata[1]->get_metadata_type());
|
||||
|
@ -253,17 +259,30 @@ class CoreMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
array(
|
||||
'title' => 'Son of son',
|
||||
'description' => 'Desc of son of son',
|
||||
'collection' => $collection_son,
|
||||
'collection' => $collection_son,
|
||||
'author_id' => get_current_user_id(),
|
||||
'status' => 'publish'
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$item_metadatum_title = $this->tainacan_item_metadata_factory->create_item_metadata($collection_son_item,
|
||||
$core_metadata_son[1], 'Son of son');
|
||||
$item_metadatum_title = $this->tainacan_item_metadata_factory->create_item_metadata(
|
||||
$collection_son_item,
|
||||
$core_metadata_son[1],
|
||||
'Son of son'
|
||||
);
|
||||
|
||||
$item_metadatum_desc = $this->tainacan_item_metadata_factory->create_item_metadata($collection_son_item, $core_metadata_son[0],
|
||||
'Desc of son of son');
|
||||
$item_metadatum_desc = $this->tainacan_item_metadata_factory->create_item_metadata(
|
||||
$collection_son_item,
|
||||
$core_metadata_son[0],
|
||||
'Desc of son of son'
|
||||
);
|
||||
|
||||
$item_metadatum_author = $this->tainacan_item_metadata_factory->create_item_metadata(
|
||||
$collection_son_item,
|
||||
$core_metadata_son[2],
|
||||
get_current_user_id()
|
||||
);
|
||||
|
||||
$this->assertEquals($core_metadata_son[0]->get_id(), $item_metadatum_desc->get_metadatum()->get_id());
|
||||
$this->assertEquals($core_metadata_son[1]->get_id(), $item_metadatum_title->get_metadatum()->get_id());
|
||||
|
|
|
@ -263,19 +263,19 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
$file = fopen($file_name, 'w');
|
||||
|
||||
// save the column headers
|
||||
fputcsv($file, array('Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));
|
||||
fputcsv($file, array('author', 'Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));
|
||||
|
||||
// Sample data
|
||||
$data = array(
|
||||
array('Data 11', 'Data 12', 'Data 13||TESTE', 'Data 14', 'Data 15>>DATA 151'),
|
||||
array('Data 21', 'Data 22', 'this
|
||||
array(get_current_user_id(), 'Data 11', 'Data 12', 'Data 13||TESTE', 'Data 14', 'Data 15>>DATA 151'),
|
||||
array(get_current_user_id(), 'Data 21', 'Data 22', 'this
|
||||
is
|
||||
having
|
||||
multiple
|
||||
lines', 'Data 24', 'Data 25'),
|
||||
array('Data 31', 'Data 32', utf8_decode( 'Data 33||Rééço' ), 'Data 34', 'Data 35'),
|
||||
array('Data 41', 'Data 42', 'Data 43||limbbo', 'Data 44', 'Data 45'),
|
||||
array('Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55>>DATA551')
|
||||
array(get_current_user_id(), 'Data 31', 'Data 32', utf8_decode( 'Data 33||Rééço' ), 'Data 34', 'Data 35'),
|
||||
array(get_current_user_id(), 'Data 41', 'Data 42', 'Data 43||limbbo', 'Data 44', 'Data 45'),
|
||||
array(get_current_user_id(), 'Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55>>DATA551')
|
||||
);
|
||||
|
||||
// save each row of the data
|
||||
|
@ -296,7 +296,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
|
||||
// get metadata to mapping
|
||||
$headers = $importer_instance->get_source_metadata();
|
||||
$this->assertEquals( $headers[4], 'Column 5' );
|
||||
$this->assertEquals( $headers[5], 'Column 5' );
|
||||
|
||||
// inserting the collection
|
||||
$collection = $this->tainacan_entity_factory->create_entity(
|
||||
|
@ -368,13 +368,18 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
|
||||
//create a random mapping
|
||||
$map = [];
|
||||
foreach ( $metadata as $index => $metadatum ){
|
||||
if( $index === 0){
|
||||
$index = 1;
|
||||
foreach ( $metadata as $metadatum ){
|
||||
if ($metadatum->get_metadata_type() == 'Tainacan\Metadata_Types\Core_Author') {
|
||||
$map[$metadatum->get_id()] = $headers[0];
|
||||
continue;
|
||||
}
|
||||
if( $index === 1){
|
||||
$map['create_metadata'] = $headers[$index];
|
||||
} else {
|
||||
$map[$metadatum->get_id()] = $headers[$index];
|
||||
}
|
||||
|
||||
$index++;
|
||||
}
|
||||
|
||||
$collection_definition['mapping'] = $map;
|
||||
|
|
|
@ -240,7 +240,7 @@ class Item_Metadata extends TAINACAN_UnitTestCase {
|
|||
$this->assertTrue(is_array($item_metadatas));
|
||||
|
||||
// notice for repository metadata
|
||||
$this->assertEquals(3, sizeof($item_metadatas));
|
||||
$this->assertEquals(4, sizeof($item_metadatas));
|
||||
//first 2 metadata are repository metadata
|
||||
$this->assertTrue( in_array('metadado', $names) );
|
||||
|
||||
|
|
|
@ -165,8 +165,8 @@ class Metadata extends TAINACAN_UnitTestCase {
|
|||
$retrieve_metadata_ids = $Tainacan_Metadata->fetch_ids_by_collection( $collection_son, [] );
|
||||
|
||||
// should return 6
|
||||
$this->assertEquals( 6, sizeof( $retrieve_metadata ) );
|
||||
$this->assertEquals( 6, sizeof( $retrieve_metadata_ids ) );
|
||||
$this->assertEquals( 7, sizeof( $retrieve_metadata ) );
|
||||
$this->assertEquals( 7, sizeof( $retrieve_metadata_ids ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue