Merge branch 'develop' into feature/456

This commit is contained in:
mateuswetah 2021-02-08 11:38:02 -03:00
commit 7162c3eb4a
24 changed files with 249 additions and 107 deletions

44
package-lock.json generated
View File

@ -1895,29 +1895,11 @@
"integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug=="
},
"axios": {
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz",
"integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==",
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
"requires": {
"follow-redirects": "1.5.10"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"follow-redirects": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
"requires": {
"debug": "=3.1.0"
}
}
"follow-redirects": "^1.10.0"
}
},
"babel-code-frame": {
@ -4472,8 +4454,7 @@
"follow-redirects": {
"version": "1.12.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.12.1.tgz",
"integrity": "sha512-tmRv0AVuR7ZyouUHLeNSiO6pqulF7dYa3s19c6t+wz9LD69/uSzdMxJ2S91nTI9U3rt/IldxpzMOFejp6f0hjg==",
"dev": true
"integrity": "sha512-tmRv0AVuR7ZyouUHLeNSiO6pqulF7dYa3s19c6t+wz9LD69/uSzdMxJ2S91nTI9U3rt/IldxpzMOFejp6f0hjg=="
},
"for-in": {
"version": "1.0.2",
@ -4751,12 +4732,6 @@
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
"bundled": true,
"dev": true,
"optional": true
},
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
@ -5785,9 +5760,15 @@
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"ini": {
<<<<<<< HEAD
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
=======
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz",
"integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==",
>>>>>>> develop
"dev": true
},
"inquirer": {
@ -6846,7 +6827,8 @@
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
},
"multicast-dns": {
"version": "6.2.3",

View File

@ -8,8 +8,8 @@
"build-prod": "cross-env NODE_ENV=production webpack --config webpack.prod.js --display-error-details --progress --hide-modules"
},
"dependencies": {
"axios": "^0.19.2",
"blurhash": "^1.1.3",
"axios": "^0.21.1",
"buefy": "^0.9.4",
"bulma": "^0.9.1",
"css-vars-ponyfill": "^2.3.1",

View File

@ -0,0 +1,36 @@
body:not([class]){
margin: auto;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
body:not([class]) > img {
width: auto;
}
body:not([class]) > iframe {
width: 100%;
height: 100%;
min-height: 80vh;
border: none;
}
body:not([class]) > audio,
body:not([class]) > video {
width: 100%;
height: auto;
min-height: 54px;
max-height: 100%;
}
body:not([class]) > audio {
width: 100%;
}
body:not([class]) > a,
body:not([class]) > p {
z-index: 99;
padding: 1rem 4.33337vw;
background: white;
border-radius: 3px;
word-wrap: break-word;
}

View File

@ -145,7 +145,7 @@ class REST_Items_Controller extends REST_Controller {
)
);
register_rest_route(
$this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base . '/submission/(?P<submission_id>[\d]+)/finish',
$this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base . '/submission/(?P<submission_id>[a-z0-9]+)/finish',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
@ -987,12 +987,16 @@ class REST_Items_Controller extends REST_Controller {
if ($item->validate()) {
$item = $this->items_repository->insert( $item );
$fake_id = \hexdec(\uniqid());
$fake_id = md5(uniqid(mt_rand(), true));
$id = $item->get_id();
set_transient('tnc_transient_submission_' . $fake_id, $id, 300);
$response_item = $this->prepare_item_for_response($item, $request);
$response_item['id'] = $fake_id;
return new \WP_REST_Response($response_item, 201 );
if (set_transient('tnc_transient_submission_' . $fake_id, $id, 300) == true) {
$response_item = $this->prepare_item_for_response($item, $request);
$response_item['id'] = $fake_id;
return new \WP_REST_Response($response_item, 201 );
} else return new \WP_REST_Response([
'error_message' => __('unable create submission ID.', 'tainacan'),
], 400);
} else {
return new \WP_REST_Response([
'error_message' => __('One or more values are invalid.', 'tainacan'),

View File

@ -151,6 +151,7 @@ class REST_Roles_Controller extends REST_Controller {
if ( isset($request['capabilities']) && is_array($request['capabilities']) ) {
$this->handle_capabilities_for_role($role_slug, $request['capabilities']);
$this->handle_capabilites_default_for_role($role_slug);
}
if ($new_role instanceof \WP_Role) {
@ -262,6 +263,7 @@ class REST_Roles_Controller extends REST_Controller {
if ( is_array($request['capabilities']) ) {
$this->handle_capabilities_for_role($role_slug, $request['capabilities']);
$this->handle_capabilites_default_for_role($role_slug);
} elseif ( isset($request['add_cap']) ) {
// validate that we only deal with tainacan capabilities
@ -317,6 +319,13 @@ class REST_Roles_Controller extends REST_Controller {
}
private function handle_capabilites_default_for_role($role_slug) {
if ( !isset( \wp_roles()->roles[$role_slug] ) ) {
return false;
}
\wp_roles()->add_cap($role_slug, 'read', true);
}
/**
* @param \WP_REST_Request $request
*

View File

@ -21,6 +21,9 @@ class Media {
protected function __construct() {
add_action( 'init', [$this, 'add_attachment_page_rewrite_rule'] );
add_action( 'admin_enqueue_scripts', array( &$this, 'add_css' ) );
add_action( 'wp_enqueue_scripts', array( &$this, 'add_css' ) );
add_filter( 'query_vars', [$this, 'attachment_page_add_var'] );
add_action( 'template_redirect', [$this, 'attachment_page'] );
}
@ -33,6 +36,11 @@ class Media {
);
}
public function add_css() {
global $TAINACAN_BASE_URL;
wp_enqueue_style( 'tainacan-media-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-media-page.css', [], TAINACAN_VERSION );
}
public function attachment_page_add_var($vars) {
$vars[] = 'tainacan_attachment_page';
return $vars;
@ -320,11 +328,11 @@ class Media {
public function attachment_page() {
$att_id = get_query_var('tainacan_attachment_page');
if ( ! $att_id ) {
return; // continue normal execution
}
$attachment = get_post($att_id);
if ( $attachment instanceof \WP_Post && $attachment->post_type == 'attachment' ) {
@ -359,7 +367,7 @@ class Media {
$output .= $img;
} else {
wp_print_styles('tainacan-media-page');
global $wp_embed;
$url = wp_get_attachment_url($att_id);

View File

@ -24,6 +24,9 @@ class Roles {
*/
private function __construct() {
$this->meta_caps = (new \Tainacan\Entities\Metadatum())->get_capabilities();
$this->filters_caps = (new \Tainacan\Entities\Filter())->get_capabilities();
$this->capabilities = [
'manage_tainacan' => [
'display_name' => __('Manage Tainacan', 'tainacan'),
@ -172,6 +175,10 @@ class Roles {
'display_name' => __('Manage Collection', 'tainacan'),
'description' => __('Manage all collection settings, items, metadata, filters, etc.', 'tainacan'),
'scope' => 'collection',
'dependencies' => [
$this->meta_caps->read_private_posts,
$this->filters_caps->read_private_posts
],
'supercaps' => [
'manage_tainacan',
'manage_tainacan_collection_all'
@ -247,6 +254,9 @@ class Roles {
'display_name' => __('View private metadata', 'tainacan'),
'description' => __('Access private metadata in this collection', 'tainacan'),
'scope' => 'collection',
'dependencies' => [
$this->meta_caps->read_private_posts, // e.g.: 'read_private_tainacan-metadata'
],
'supercaps' => [
'manage_tainacan',
'manage_tainacan_collection_all',
@ -258,6 +268,9 @@ class Roles {
'display_name' => __('View private filters', 'tainacan'),
'description' => __('Access private filters in this collection', 'tainacan'),
'scope' => 'collection',
'dependencies' => [
$this->filters_caps->read_private_posts, // e.g.: 'read_private_tainacan-filters'
],
'supercaps' => [
'manage_tainacan',
'manage_tainacan_collection_all',
@ -392,7 +405,8 @@ class Roles {
'slug' => 'tainacan-administrator',
'display_name' => 'Tainacan Administrator',
'caps' => [
'manage_tainacan' => true
'manage_tainacan' => true,
'read' => true
]
],
'tainacan-editor' => [
@ -414,7 +428,8 @@ class Roles {
'tnc_rep_read_private_metadata' => true,
'tnc_rep_read_private_filters' => true,
'tnc_rep_read_logs' => true,
'manage_tainacan_collection_all' => true
'manage_tainacan_collection_all' => true,
'read' => true
]
],
'tainacan-author' => [
@ -427,6 +442,7 @@ class Roles {
'tnc_rep_read_private_taxonomies' => true,
'tnc_rep_read_private_metadata' => true,
'tnc_rep_read_private_filters' => true,
'read' => true
]
],
];
@ -534,6 +550,17 @@ class Roles {
continue;
}
if( in_array($requested_cap, [
$this->meta_caps->read_private_posts,
$this->filters_caps->read_private_posts]
) && (
$user->has_cap('manage_tainacan') ||
$user->has_cap('manage_tainacan_collection_all')
)
) {
$allcaps = array_merge($allcaps, [ $requested_cap => true ]);
}
if ( \strpos($cap, 'tnc_') === 0 ) {
if ( $user->has_cap('manage_tainacan') ) {

View File

@ -544,6 +544,8 @@ class Item extends Entity {
*
* @type bool $hide_empty Wether to hide or not metadata the item has no value to
* Default: true
* @type bool $display_slug_as_class Show metadata slug as a class in the div before the metadata block
* Default: false
* @type string $before String to be added before each metadata block
* Default '<div class="metadata-type-$type">' where $type is the metadata type slug
* @type string $after String to be added after each metadata block
@ -576,7 +578,8 @@ class Item extends Entity {
'exclude_description' => false,
'exclude_core' => false,
'hide_empty' => true,
'before' => '<div class="metadata-type-$type">',
'display_slug_as_class' => false,
'before' => '<div class="metadata-type-$type $id">',
'after' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
@ -616,6 +619,12 @@ class Item extends Entity {
$item_meta = new \Tainacan\Entities\Item_Metadata_Entity($this, $metadatum_object);
if ($item_meta->has_value() || !$args['hide_empty']) {
$before = str_replace('$type', $mto->get_slug(), $args['before']);
if ($args['display_slug_as_class']) {
$before = str_replace('$id', 'metadata-slug-'.$item_meta->get_metadatum()->get_slug() , $before);
}
else {
$before = str_replace(' $id', '', $before);
}
$return .= $before;
$return .= $args['before_title'] . $metadatum_object->get_name() . $args['after_title'];
$return .= $args['before_value'] . $item_meta->get_value_as_html() . $args['after_value'];
@ -681,6 +690,12 @@ class Item extends Entity {
if ($item_meta->has_value() || !$args['hide_empty']) {
$before = str_replace('$type', $fto->get_slug(), $args['before']);
if ($args['display_slug_as_class']) {
$before = str_replace('$id', 'metadata-slug-'.$item_meta->get_metadatum()->get_slug() , $before);
}
else {
$before = str_replace(' $id', '', $before);
}
$return .= $before;
$return .= $args['before_title'] . $item_meta->get_metadatum()->get_name() . $args['after_title'];
$return .= $args['before_value'] . $item_meta->get_value_as_html() . $args['after_value'];

View File

@ -57,14 +57,14 @@ class Csv extends Exposer {
return $a['name'];
}, $items[0]['metadata']);
fputcsv($csv, $headers, ';', '"' );
fputcsv($csv, $headers, ',', '"' );
foreach ($items as $item) {
$values = array_map(function($a) {
return $a['value_as_string'];
}, $item['metadata']);
fputcsv($csv, $values, ';', '"' );
fputcsv($csv, $values, ',', '"' );
}
rewind($csv);

View File

@ -35,7 +35,7 @@ class Theme_Helper {
// Redirect to post type archive if no cover page is set
add_action('wp', array($this, 'collection_single_redirect'));
add_action('wp_print_scripts', array($this, 'enqueue_scripts'));
add_action('wp_print_scripts', array($this, 'enqueue_scripts'), 90);
// make archive for terms work with items
add_action('pre_get_posts', array($this, 'tax_archive_pre_get_posts'));
@ -62,6 +62,7 @@ class Theme_Helper {
$this->register_view_mode('table', [
'label' => __('Table', 'tainacan'),
'description' => 'The classic table display.',
'dynamic_metadata' => true,
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewtable tainacan-icon-1-25em"></i></span>',
'type' => 'component',
@ -71,7 +72,7 @@ class Theme_Helper {
$this->register_view_mode('cards', [
'label' => __('Cards', 'tainacan'),
'dynamic_metadata' => false,
'description' => 'A cards view, displaying title, description, author name and creation date.',
'description' => 'A cards view, displaying cropped thumbnails, title and description.',
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewcards tainacan-icon-1-25em"></i></span>',
'type' => 'component',
'implements_skeleton' => true,
@ -80,7 +81,7 @@ class Theme_Helper {
$this->register_view_mode('records', [
'label' => __('Records', 'tainacan'),
'dynamic_metadata' => true,
'description' => 'A records view, similiar to cards, but flexible for metadata',
'description' => 'A records view, similiar to cards, but flexible for metadata.',
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewrecords tainacan-icon-1-25em"></i></span>',
'type' => 'component',
'implements_skeleton' => true,
@ -97,7 +98,7 @@ class Theme_Helper {
$this->register_view_mode('slideshow', [
'label' => __('Slideshow', 'tainacan'),
'dynamic_metadata' => false,
'description' => 'A fullscreen slideshow view.',
'description' => 'A fullscreen slideshow view, that shows the item document instead of just thumbnails.',
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewgallery tainacan-icon-1-25em"></i></span>',
'type' => 'component',
'show_pagination' => false,
@ -106,7 +107,7 @@ class Theme_Helper {
$this->register_view_mode('list', [
'label' => __('List', 'tainacan'),
'dynamic_metadata' => true,
'description' => 'A list view, similiar to the records, but full width',
'description' => 'A list view, similiar to the records, but full width.',
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewlist tainacan-icon-1-25em"></i></span>',
'type' => 'component',
'implements_skeleton' => true,

View File

@ -4,7 +4,7 @@ Tags: museums, libraries, archives, GLAM, collections, repository
Requires at least: 4.8
Tested up to: 5.6
Requires PHP: 5.6
Stable tag: 0.17.2
Stable tag: 0.17.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

View File

@ -4,13 +4,13 @@ Plugin Name: Tainacan
Plugin URI: https://tainacan.org/
Description: Open source, powerfull 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 respository platform.
Author: Tainacan.org
Version: 0.17.2
Version: 0.17.3
Text Domain: tainacan
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
const TAINACAN_VERSION = '0.17.2';
const TAINACAN_VERSION = '0.17.3';
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
$TAINACAN_BASE_URL = plugins_url('', __FILE__);

View File

@ -221,7 +221,7 @@
:message="$i18n.getHelperMessage('collections', 'enabled_view_modes')"/>
<div class="control">
<b-dropdown
class="two-columns-dropdown"
class="two-columns-dropdown enabled-view-modes-dropdown"
ref="enabledViewModesDropdown"
:mobile-modal="true"
:disabled="Object.keys(registeredViewModes).length < 0"
@ -247,14 +247,19 @@
@input="updateViewModeslist(viewMode)"
:value="checkIfViewModeEnabled(viewMode)"
:disabled="checkIfViewModeEnabled(viewMode) && form.enabled_view_modes.filter((aViewMode) => (registeredViewModes[aViewMode] && registeredViewModes[aViewMode].full_screen != true)).length <= 1">
<span
class="gray-icon"
:class="{
'has-text-secondary' : checkIfViewModeEnabled(viewMode),
'has-text-gray4' : !checkIfViewModeEnabled(viewMode)
}"
v-html="registeredViewModes[viewMode].icon"/>
<span>{{ registeredViewModes[viewMode].label }}</span>
<p>
<strong>
<span
class="gray-icon"
:class="{
'has-text-secondary' : checkIfViewModeEnabled(viewMode),
'has-text-gray4' : !checkIfViewModeEnabled(viewMode)
}"
v-html="registeredViewModes[viewMode].icon"/>
&nbsp;{{ registeredViewModes[viewMode].label }}
</strong>
</p>
<p v-if="registeredViewModes[viewMode].description">{{ registeredViewModes[viewMode].description }}</p>
</b-checkbox>
</b-dropdown-item>
</b-dropdown>
@ -1248,6 +1253,19 @@ export default {
margin-top: -1.5em;
border-left: 1px solid var(--tainacan-gray2);
}
.enabled-view-modes-dropdown {
/deep/ .dropdown-item {
display: flex !important;
}
p {
white-space: normal;
}
/deep/ svg {
margin-left: -2px;
overflow: hidden;
vertical-align: middle;
}
}
</style>

View File

@ -632,7 +632,7 @@
v-if="collection && collection.current_user_can_publish_items"
@click="onSubmit(visibility)"
type="button"
class="button is-success">{{ $i18n.get('label_publish') }}</button>
class="button is-success">{{ $i18n.get('label_verb_publish') }}</button>
</div>
<div
class="form-submission-footer"
@ -677,13 +677,13 @@
v-if="!isOnSequenceEdit || (group != null && group.items_count != undefined && group.items_count == itemPosition)"
@click="onSubmit(visibility)"
type="button"
class="button is-success">{{ $i18n.get('label_publish') }}</button>
class="button is-success">{{ $i18n.get('label_verb_publish') }}</button>
<button
v-else
@click="onSubmit(visibility, 'next')"
type="button"
class="button is-success">
<span>{{ $i18n.get('label_publish') }}</span>
<span>{{ $i18n.get('label_verb_publish') }}</span>
<span class="icon is-large">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-next"/>
</span>

View File

@ -276,7 +276,7 @@ export default {
return this.selectedItems && this.selectedItems.length ? 1 : Math.ceil(Number(this.totalItems)/Number(this.maxItemsPerPage));
},
exposerBaseURL() {
let baseURL = this.collectionId != undefined ? '/collection/' + this.collectionId + '/items/' : '/items/';
let baseURL = this.collectionId ? '/collection/' + this.collectionId + '/items/' : '/items/';
let currentParams = JSON.parse(JSON.stringify(this.$route.query));
// Removes Fetch Only

View File

@ -109,7 +109,11 @@
</div>
</div>
</template>
<template slot="empty">{{ $i18n.get('info_no_user_found') }}</template>
<template
v-if="!isFetchingUsers"
slot="empty">
{{ $i18n.get('info_no_user_found') }}
</template>
</b-autocomplete>
</b-field>

View File

@ -948,12 +948,14 @@
let descriptionMetadatum = this.localDisplayedMetadata.find(metadatum => metadatum.metadata_type_object != undefined ? metadatum.metadata_type_object.related_mapped_prop == 'description' : false);
// Updates Search
this.$eventBusSearch.addFetchOnly(
((thumbnailMetadatum != undefined && thumbnailMetadatum.display) ? 'thumbnail' : null) + ',' +
((creationDateMetadatum != undefined && creationDateMetadatum.display) ? 'creation_date' : null) + ',' +
((authorNameMetadatum != undefined && authorNameMetadatum.display) ? 'author_name': null) + ',' +
(this.isRepositoryLevel ? 'title' : null) + ',' +
(this.isRepositoryLevel && descriptionMetadatum.display ? 'description' : null), false, fetchOnlyMetadatumIds.toString());
let fetchOnlyArray = [
((thumbnailMetadatum != undefined && thumbnailMetadatum.display) ? 'thumbnail' : null),
((creationDateMetadatum != undefined && creationDateMetadatum.display) ? 'creation_date' : null),
((authorNameMetadatum != undefined && authorNameMetadatum.display) ? 'author_name': null),
(this.isRepositoryLevel ? 'title' : null),
(this.isRepositoryLevel && descriptionMetadatum.display ? 'description' : null)
];
this.$eventBusSearch.addFetchOnly(fetchOnlyArray.filter((fetchOnly) => fetchOnly != null).toString() , false, fetchOnlyMetadatumIds.toString());
// Closes dropdown
this.$refs.displayedMetadataDropdown.toggle();
@ -1098,13 +1100,14 @@
display: authorNameMetadatumDisplay
});
this.$eventBusSearch.addFetchOnly(
(thumbnailMetadatumDisplay ? 'thumbnail' : null) +','+
(creationDateMetadatumDisplay ? 'creation_date' : null) +','+
(authorNameMetadatumDisplay ? 'author_name' : null) +','+
(this.isRepositoryLevel ? 'title' : null) +','+
let fetchOnlyArray = [
(thumbnailMetadatumDisplay ? 'thumbnail' : null),
(creationDateMetadatumDisplay ? 'creation_date' : null),
(authorNameMetadatumDisplay ? 'author_name' : null),
(this.isRepositoryLevel ? 'title' : null),
(this.isRepositoryLevel ? 'description' : null)
, false, fetchOnlyMetadatumIds.toString());
];
this.$eventBusSearch.addFetchOnly(fetchOnlyArray.filter((fetchOnly) => fetchOnly != null).toString() , false, fetchOnlyMetadatumIds.toString());
// Sorting metadata
if (this.isRepositoryLevel) {

View File

@ -6,6 +6,11 @@
.icon {
color: var(--tainacan-secondary);
align-items: center;
svg {
fill: var(--tainacan-secondary);
overflow: hidden;
vertical-align: middle;
}
}
.gray-icon {
padding-right: 0 !important;
@ -54,7 +59,10 @@
&:hover { background-color: var(--tainacan-input-border-color); }
.is-small { color: var(--tainacan-info-color); }
&.is-active { background-color: var(--tainacan-primary); }
svg {
overflow: hidden;
vertical-align: middle;
}
.media {
display: flex;
align-items: center;

View File

@ -254,7 +254,7 @@ class Admin {
'wp_elasticpress' => \Tainacan\Elastic_Press::get_instance()->is_active(),
'item_submission_captcha_site_key' => get_option("tnc_option_recaptch_site_key")
];
$maps = [
'collections' => $Tainacan_Collections->get_map(),
'metadata' => $Tainacan_Metadata->get_map(),

View File

@ -31,13 +31,21 @@ class Component_Hooks {
private function init() {
// the priority should see less than on function
// `load_admin_page()` of class `Admin` in file /src/views/class-tainacan-admin.php
add_action( 'admin_enqueue_scripts', array( &$this, 'register_component' ), 80 );
add_action( 'init', array( &$this, 'register_component' ), 80 );
}
public function register_component() {
do_action('tainacan-register-vuejs-component', $this);
foreach($this->registered_component as $handle => $component) {
wp_enqueue_script($handle, $component['script_path']);
$deps = isset($component['args']['deps']) ? $component['args']['deps'] : [];
if ( is_admin() ) {
wp_enqueue_script($handle, $component['script_path'], $deps);
} else {
if (isset($component['args']['public']) == true && $component['args']['public'] != false) {
wp_enqueue_script($handle, $component['script_path'], $deps);
}
}
}
}

View File

@ -28,7 +28,8 @@ function tainacan_blocks_add_gutenberg_blocks_actions() {
add_action('init', 'tainacan_blocks_register_tainacan_facets_list');
add_action('init', 'tainacan_blocks_register_tainacan_item_submission_form');
add_action('init', 'tainacan_blocks_add_plugin_settings');
add_action('init', 'tainacan_blocks_add_plugin_settings', 90);
add_action('init', 'tainacan_blocks_add_plugin_admin_settings', 90);
add_filter('block_categories', 'tainacan_blocks_register_categories', 10, 2);
add_action('init', 'tainacan_blocks_register_category_icon');
@ -403,14 +404,13 @@ function tainacan_blocks_get_plugin_js_settings(){
'base_url' => $TAINACAN_BASE_URL,
'admin_url' => admin_url(),
'site_url' => site_url(),
'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug(),
'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug()
];
return $settings;
}
function tainacan_blocks_add_plugin_settings() {
$settings = tainacan_blocks_get_plugin_js_settings();
wp_localize_script( 'terms-list', 'tainacan_blocks', $settings );
@ -423,6 +423,9 @@ function tainacan_blocks_add_plugin_settings() {
wp_localize_script( 'collections-list', 'tainacan_blocks', $settings );
wp_localize_script( 'carousel-collections-list', 'tainacan_blocks', $settings );
wp_localize_script( 'facets-list', 'tainacan_blocks', $settings );
}
function tainacan_blocks_add_plugin_admin_settings() {
// The faceded search block uses a different settings object, the same used on the theme items list
wp_localize_script( 'tainacan-search', 'tainacan_plugin', \Tainacan\Admin::get_instance()->get_admin_js_localization_params() );

View File

@ -327,7 +327,10 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_save_as_draft' => __( 'Save as draft', 'tainacan' ),
'label_update_draft' => __( 'Update draft', 'tainacan' ),
'label_return_to_draft' => __( 'Return to draft', 'tainacan' ),
'label_publish' => __( 'Publish', 'tainacan' ),
/* translators: The verb 'to publish' not the 'publish' status */
'label_verb_publish' => _x( 'Publish', 'verb', 'tainacan' ),
/* translators: The status 'publish' not the verb 'to publish' */
'label_publish' => _x( 'Publish', 'noun', 'tainacan' ),
'label_update' => __( 'Update', 'tainacan' ),
'label_mapper_metadata' => __( 'Mapper Metadata', 'tainacan' ),
'label_add_more_mapper_metadata' => __( 'Add more mapper\'s metadata', 'tainacan' ),

View File

@ -31,7 +31,7 @@ export const viewModesMixin = {
}
},
mounted() {
this.isSlideshowViewModeEnabled = this.enabledViewModes.findIndex((viewMode) => viewMode == 'slideshow') >= 0;
this.isSlideshowViewModeEnabled = (this.enabledViewModes && Array.isArray(this.enabledViewModes)) ? (this.enabledViewModes.findIndex((viewMode) => viewMode == 'slideshow') >= 0) : false;
},
methods: {
getItemLink(itemUrl, index) {

View File

@ -411,7 +411,7 @@
:trap-focus="filtersAsModal"
full-screen
:custom-class="'tainacan-form filters-menu' + (filtersAsModal ? ' filters-menu-modal' : '')"
:can-cancel="hideHideFiltersButton ? ['x', 'outside'] : ['x', 'escape', 'outside']">
:can-cancel="hideHideFiltersButton || !filtersAsModal ? ['x', 'outside'] : ['x', 'escape', 'outside']">
<filters-items-list
:is-loading-items="isLoadingItems"
:autofocus="filtersAsModal"
@ -467,18 +467,18 @@
class="loading-container">
<!-- Default loading, to be used view modes without any skeleton-->
<b-loading
<b-loading
v-if="!(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].skeleton_template != undefined)"
:is-full-page="false"
:active="showLoading"/>
:active.sync="showLoading"/>
<!-- Custom skeleton templates used by some view modes -->
<!-- Custom skeleton templates used by some view modes -->
<div
v-if="(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].skeleton_template != undefined)"
v-html="registeredViewModes[viewMode].skeleton_template"/>
</div>
<!-- Alert if custom metada is being used for sorting -->
<!-- Alert if custom metadata is being used for sorting -->
<div
v-if="hasAnOpenAlert &&
isSortingByCustomMetadata &&
@ -509,7 +509,7 @@
<!-- Theme View Modes -->
<div
v-if="((openAdvancedSearch && advancedSearchResults) || !openAdvancedSearch) &&
!isLoadingItems &&
!showLoading &&
registeredViewModes[viewMode] != undefined &&
registeredViewModes[viewMode].type == 'template'"
v-html="itemsListTemplate"/>
@ -775,7 +775,7 @@
const userPrefViewMode = this.$userPrefs.get(prefsViewMode);
let existingViewModeIndex = Object.keys(this.registeredViewModes).findIndex(viewMode => viewMode == userPrefViewMode);
let enabledViewModeIndex = this.enabledViewModes.findIndex((viewMode) => viewMode == userPrefViewMode);
let enabledViewModeIndex = (this.enabledViewModes && Array.isArray(this.enabledViewModes)) ? this.enabledViewModes.findIndex((viewMode) => viewMode == userPrefViewMode) : -1;
if (existingViewModeIndex >= 0 && enabledViewModeIndex >= 0)
this.$eventBusSearch.setInitialViewMode(userPrefViewMode);
else
@ -933,11 +933,13 @@
let descriptionMetadatum = this.localDisplayedMetadata.find(metadatum => metadatum.metadata_type_object != undefined ? metadatum.metadata_type_object.related_mapped_prop == 'description' : false);
// Updates Search
this.$eventBusSearch.addFetchOnly(
((thumbnailMetadatum != undefined && thumbnailMetadatum.display) ? 'thumbnail' : null) + ',' +
((creationDateMetadatum != undefined && creationDateMetadatum.display) ? 'creation_date' : null) + ',' +
(this.isRepositoryLevel ? 'title' : null) + ',' +
(this.isRepositoryLevel && descriptionMetadatum.display ? 'description' : null), false, fetchOnlyMetadatumIds.toString());
let fetchOnlyArray = [
((thumbnailMetadatum != undefined && thumbnailMetadatum.display) ? 'thumbnail' : null),
((creationDateMetadatum != undefined && creationDateMetadatum.display) ? 'creation_date' : null),
(this.isRepositoryLevel ? 'title' : null),
(this.isRepositoryLevel && descriptionMetadatum.display ? 'description' : null)
];
this.$eventBusSearch.addFetchOnly(fetchOnlyArray.filter((fetchOnly) => fetchOnly != null).toString(), false, fetchOnlyMetadatumIds.toString());
// Closes dropdown
this.$refs.displayedMetadataDropdown.toggle();
@ -1064,12 +1066,13 @@
let creationDateMetadatumDisplay = prefsFetchOnlyObject ? (prefsFetchOnlyObject[1] != 'null') : true;
this.$eventBusSearch.addFetchOnly(
(thumbnailMetadatumDisplay ? 'thumbnail' : null) +','+
(creationDateMetadatumDisplay ? 'creation_date' : null) +','+
(this.isRepositoryLevel ? 'title' : null) +','+
let fetchOnlyArray = [
(thumbnailMetadatumDisplay ? 'thumbnail' : null),
(creationDateMetadatumDisplay ? 'creation_date' : null),
(this.isRepositoryLevel ? 'title' : null),
(this.isRepositoryLevel ? 'description' : null)
, false, fetchOnlyMetadatumIds.toString());
];
this.$eventBusSearch.addFetchOnly(fetchOnlyArray.filter((fetchOnly) => fetchOnly != null).toString(), false, fetchOnlyMetadatumIds.toString());
// Sorting metadata
if (this.isRepositoryLevel) {
@ -1450,10 +1453,20 @@
font-size: 1.3125em !important;
color: var(--tainacan-info-color) !important;
max-width: 1.25em;
svg {
color: var(--tainacan-info-color) !important;
overflow: hidden;
vertical-align: middle;
}
}
.has-text-secondary.gray-icon .icon i::before,
.has-text-secondary.gray-icon i::before {
color: var(--tainacan-secondary) !important;
svg {
fill: var(--tainacan-secondary) !important;
overflow: hidden;
vertical-align: middle;
}
}
.dropdown-menu {