Merge tag '0.18.7' into develop

release 0.18.7
This commit is contained in:
vnmedeiros 2021-12-07 17:15:29 -03:00
commit e4999f1743
36 changed files with 688 additions and 392 deletions

View File

@ -31,11 +31,26 @@ then
npm ci
fi
is_prod_build=false
for i in "$@"
do
case $i in
--prod)
is_prod_build=true
;;
esac
done
new_md5_composer=$(<last-composer-build.md5)
if [ "$current_md5_composer" != "$new_md5_composer" ]
then
## Install composer dependencies
composer install
if [ "$is_prod_build" == false ]
then
composer install
else
composer install --no-dev
fi
fi
new_md5_sass=$(<last-sass-build.md5)
@ -47,24 +62,15 @@ fi
new_md5_js=$(<last-js-build.md5)
is_prod_build=false
if [ "$current_md5_js" != "$new_md5_js" ]
then
for i in "$@"
do
case $i in
--prod)
is_prod_build=true
echo "$(tput setab 4) $(tput sgr 0) $(tput setab 4) $(tput sgr 0) Building in production mode $(tput setab 4) $(tput sgr 0) $(tput setab 4) $(tput sgr 0)"
npm run build-prod
;;
esac
done
if [ "$is_prod_build" == false ]
then
echo "$(tput setab 2) $(tput sgr 0) $(tput setab 2) $(tput sgr 0) Building in development mode $(tput setab 2) $(tput sgr 0) $(tput setab 2) $(tput sgr 0)"
npm run build
else
echo "$(tput setab 4) $(tput sgr 0) $(tput setab 4) $(tput sgr 0) Building in production mode $(tput setab 4) $(tput sgr 0) $(tput setab 4) $(tput sgr 0)"
npm run build-prod
fi
fi

View File

@ -5,11 +5,12 @@
"require": {
"respect/validation": "^1.1",
"smalot/pdfparser": "*",
"kornrunner/blurhash": "^1.1"
"kornrunner/blurhash": "^1.1",
"symfony/polyfill-mbstring": "1.20.0",
"phpcompatibility/php-compatibility": "*"
},
"require-dev": {
"squizlabs/php_codesniffer": "^2.2 || ^3.0.2",
"phpcompatibility/php-compatibility": "*",
"yoast/phpunit-polyfills": "^1.0.1"
},
"prefer-stable" : true,

279
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "33ed3955dccb57a048e54eec04c20205",
"content-hash": "9a50d78655731555071e552968158d04",
"packages": [
{
"name": "kornrunner/blurhash",
@ -47,8 +47,74 @@
],
"description": "Pure PHP implementation of Blurhash",
"homepage": "https://github.com/kornrunner/php-blurhash",
"support": {
"issues": "https://github.com/kornrunner/php-blurhash/issues",
"source": "https://github.com/kornrunner/php-blurhash.git"
},
"time": "2020-04-15T22:06:04+00:00"
},
{
"name": "phpcompatibility/php-compatibility",
"version": "9.3.5",
"source": {
"type": "git",
"url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
"reference": "9fb324479acf6f39452e0655d2429cc0d3914243"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243",
"reference": "9fb324479acf6f39452e0655d2429cc0d3914243",
"shasum": ""
},
"require": {
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
},
"conflict": {
"squizlabs/php_codesniffer": "2.6.2"
},
"require-dev": {
"phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-or-later"
],
"authors": [
{
"name": "Wim Godden",
"homepage": "https://github.com/wimg",
"role": "lead"
},
{
"name": "Juliette Reinders Folmer",
"homepage": "https://github.com/jrfnl",
"role": "lead"
},
{
"name": "Contributors",
"homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
}
],
"description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
"homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
"keywords": [
"compatibility",
"phpcs",
"standards"
],
"support": {
"issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues",
"source": "https://github.com/PHPCompatibility/PHPCompatibility"
},
"time": "2019-12-27T09:44:58+00:00"
},
{
"name": "respect/validation",
"version": "1.1.31",
@ -110,31 +176,31 @@
"validation",
"validator"
],
"support": {
"issues": "https://github.com/Respect/Validation/issues",
"source": "https://github.com/Respect/Validation/tree/1.1.31"
},
"time": "2019-05-28T06:10:06+00:00"
},
{
"name": "smalot/pdfparser",
"version": "v0.18.1",
"version": "v2.0.1",
"source": {
"type": "git",
"url": "https://github.com/smalot/pdfparser.git",
"reference": "b47f26425e32a814dc1ee55e3ce669b9e73b8458"
"reference": "768d1d6859bdf9ef0da44724ac84079f920b7599"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/smalot/pdfparser/zipball/b47f26425e32a814dc1ee55e3ce669b9e73b8458",
"reference": "b47f26425e32a814dc1ee55e3ce669b9e73b8458",
"url": "https://api.github.com/repos/smalot/pdfparser/zipball/768d1d6859bdf9ef0da44724ac84079f920b7599",
"reference": "768d1d6859bdf9ef0da44724ac84079f920b7599",
"shasum": ""
},
"require": {
"ext-zlib": "*",
"php": ">=5.6",
"php": ">=7.1",
"symfony/polyfill-mbstring": "^1.18"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"symfony/phpunit-bridge": "^5.2"
},
"type": "library",
"autoload": {
"psr-0": {
@ -160,7 +226,67 @@
"pdf",
"text"
],
"time": "2021-01-05T08:52:07+00:00"
"support": {
"issues": "https://github.com/smalot/pdfparser/issues",
"source": "https://github.com/smalot/pdfparser/tree/v2.0.1"
},
"time": "2021-11-22T11:57:24+00:00"
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.6.1",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "f268ca40d54617c6e06757f83f699775c9b3ff2e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/f268ca40d54617c6e06757f83f699775c9b3ff2e",
"reference": "f268ca40d54617c6e06757f83f699775c9b3ff2e",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"bin": [
"bin/phpcs",
"bin/phpcbf"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Greg Sherwood",
"role": "lead"
}
],
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
"keywords": [
"phpcs",
"standards"
],
"support": {
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
},
"time": "2021-10-11T04:00:11+00:00"
},
{
"name": "symfony/polyfill-mbstring",
@ -482,64 +608,6 @@
},
"time": "2021-02-23T14:00:09+00:00"
},
{
"name": "phpcompatibility/php-compatibility",
"version": "9.3.5",
"source": {
"type": "git",
"url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
"reference": "9fb324479acf6f39452e0655d2429cc0d3914243"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243",
"reference": "9fb324479acf6f39452e0655d2429cc0d3914243",
"shasum": ""
},
"require": {
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
},
"conflict": {
"squizlabs/php_codesniffer": "2.6.2"
},
"require-dev": {
"phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-or-later"
],
"authors": [
{
"name": "Wim Godden",
"homepage": "https://github.com/wimg",
"role": "lead"
},
{
"name": "Juliette Reinders Folmer",
"homepage": "https://github.com/jrfnl",
"role": "lead"
},
{
"name": "Contributors",
"homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
}
],
"description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
"homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
"keywords": [
"compatibility",
"phpcs",
"standards"
],
"time": "2019-12-27T09:44:58+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "2.2.0",
@ -842,16 +910,16 @@
},
{
"name": "phpunit/php-file-iterator",
"version": "2.0.4",
"version": "2.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "28af674ff175d0768a5a978e6de83f697d4a7f05"
"reference": "42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/28af674ff175d0768a5a978e6de83f697d4a7f05",
"reference": "28af674ff175d0768a5a978e6de83f697d4a7f05",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5",
"reference": "42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5",
"shasum": ""
},
"require": {
@ -890,7 +958,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.4"
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.5"
},
"funding": [
{
@ -898,7 +966,7 @@
"type": "github"
}
],
"time": "2021-07-19T06:46:01+00:00"
"time": "2021-12-02T12:42:26+00:00"
},
{
"name": "phpunit/php-text-template",
@ -1890,57 +1958,6 @@
},
"time": "2016-10-03T07:35:21+00:00"
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.5.8",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4",
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"bin": [
"bin/phpcs",
"bin/phpcbf"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Greg Sherwood",
"role": "lead"
}
],
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
"keywords": [
"phpcs",
"standards"
],
"time": "2020-10-23T02:01:07+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.23.0",
@ -2130,16 +2147,16 @@
},
{
"name": "yoast/phpunit-polyfills",
"version": "1.0.2",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/Yoast/PHPUnit-Polyfills.git",
"reference": "1a582ab1d91e86aa450340c4d35631a85314ff9f"
"reference": "5ea3536428944955f969bc764bbe09738e151ada"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/1a582ab1d91e86aa450340c4d35631a85314ff9f",
"reference": "1a582ab1d91e86aa450340c4d35631a85314ff9f",
"url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/5ea3536428944955f969bc764bbe09738e151ada",
"reference": "5ea3536428944955f969bc764bbe09738e151ada",
"shasum": ""
},
"require": {
@ -2187,7 +2204,7 @@
"issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues",
"source": "https://github.com/Yoast/PHPUnit-Polyfills"
},
"time": "2021-10-03T08:40:26+00:00"
"time": "2021-11-23T01:37:03+00:00"
}
],
"aliases": [],

View File

@ -514,7 +514,8 @@
margin-right: 20px;
display: block;
height: 54px;
width: 54px; }
width: 54px;
min-width: 54px; }
.wp-block-tainacan-dynamic-items-list ul.items-list.items-layout-list li.item-list-item img,
.wp-block-tainacan-dynamic-items-list ul.items-list-edit.items-layout-list li.item-list-item img {
height: auto;

File diff suppressed because one or more lines are too long

View File

@ -71,7 +71,10 @@ class REST_Facets_Controller extends REST_Controller {
$collection_id = ( isset($request['collection_id']) ) ? $request['collection_id'] : null;
$last_term = ( isset($request['last_term']) ) ? $request['last_term'] : '';
$query_args = defined('TAINACAN_FACETS_DISABLE_FILTER_ITEMS') && true === TAINACAN_FACETS_DISABLE_FILTER_ITEMS ? [] : $request['current_query'];
$query_args = $request['current_query'];
if(defined('TAINACAN_FACETS_DISABLE_FILTER_ITEMS') && true === TAINACAN_FACETS_DISABLE_FILTER_ITEMS) {
$query_args = is_user_logged_in() && is_admin() ? ["status" => ["publish", "private", "draft"]] : [];
}
$query_args = $this->prepare_filters($query_args);
if ( isset($request['hideempty']) && $request['hideempty'] == 0 ) {

View File

@ -145,7 +145,7 @@ class Embed {
$width = false;
$dom = new \DOMDocument();
$dom->loadHTML($html);
$dom->loadHTML(htmlentities($html));
// If we have a fixed aspect iframe, and it's a responsive embed content.
if ($dom) {

View File

@ -828,9 +828,10 @@ class CSV extends Importer {
if($itemMetadata instanceof Entities\Item_Metadata_Entity ) {
$itemMetadata->set_item( $insertedItem ); // *I told you
if( $itemMetadata->validate() ) {
$result = $Tainacan_Item_Metadata->insert( $itemMetadata );
$Tainacan_Item_Metadata->insert( $itemMetadata );
} else {
$this->add_error_log('Error saving value for ' . $itemMetadata->get_metadatum()->get_name() . " in item " . $insertedItem->get_title());
$insertedItemId = $updating_item == true ? ' (special_item_id: ' . $insertedItem->get_id() . ')' : '';
$this->add_error_log('Error saving value for ' . $itemMetadata->get_metadatum()->get_name() . " in item " . $insertedItem->get_title() . $insertedItemId);
$this->add_error_log($itemMetadata->get_errors());
continue;
}

View File

@ -91,10 +91,10 @@ class Collections extends Repository {
],
'default_orderby' => [
'map' => 'meta',
'title' => __( 'Default Order metadata', 'tainacan' ),
'type' => 'string',
'description' => __( 'Default property items in this collections will be ordered by', 'tainacan' ),
'default' => 'name',
'title' => __( 'Default order metadata', 'tainacan' ),
'type' => ['string', 'array', 'object'],
'description' => __( 'Default property that items in this collections will be ordered by', 'tainacan' ),
'default' => 'creation_date',
//'validation' => v::stringType(),
],
'default_order' => [

View File

@ -423,15 +423,15 @@ class Theme_Helper {
// Loads info related to view modes
$view_modes = tainacan_get_the_view_modes();
$default_view_mode = $view_modes['default_view_mode'];
$enabled_view_modes = $view_modes['enabled_view_modes'];
if( isset($args['default_view_mode']) ) {
$enabled_view_modes = $view_modes['enabled_view_modes'];
if ( isset($args['default_view_mode']) ) {
$default_view_mode = $args['default_view_mode'];
unset($args['default_view_mode']);
}
if( isset($args['enabled_view_modes']) ) {
$default_view_mode = $view_modes['default_view_mode'];
if ( isset($args['enabled_view_modes']) ) {
$enabled_view_modes = $args['enabled_view_modes'];
if ( !in_array($default_view_mode, $enabled_view_modes) ) {
$default_view_mode = $enabled_view_modes[0];
@ -439,13 +439,28 @@ class Theme_Helper {
unset($args['enabled_view_modes']);
}
// Loads info related to sorting
$default_order = 'ASC';
if ( isset($args['default_order']) ) {
$default_order = $args['default_order'];
unset($args['default_order']);
}
$default_orderby = 'date';
if ( isset($args['default_orderby']) ) {
$default_orderby = $args['default_orderby'];
unset($args['default_orderby']);
}
// If in a collection page
$collection = tainacan_get_collection($args);
if ($collection) {
$props .= 'collection-id="' . $collection->get_id() . '" ';
$props .= "collection-id='" . $collection->get_id() . "' ";
$default_view_mode = $collection->get_default_view_mode();
$enabled_view_modes = $collection->get_enabled_view_modes();
$default_order = $collection->get_default_order();
$default_orderby = $collection->get_default_orderby();
// Gets hideItemsThumbnail info from collection setting
$args['hide-items-thumbnail'] = $collection->get_hide_items_thumbnail_on_lists() == 'yes' ? true : false;
}
@ -453,17 +468,19 @@ class Theme_Helper {
// If in a tainacan taxonomy
$term = tainacan_get_term($args);
if ($term) {
$props .= 'term-id="' . $term->term_id . '" ';
$props .= 'taxonomy="' . $term->taxonomy . '" ';
$props .= "term-id='" . $term->term_id . "' ";
$props .= "taxonomy='" . $term->taxonomy . "' ";
}
$props .= 'default-view-mode="' . $default_view_mode . '" ';
$props .= 'enabled-view-modes="' . implode(',', $enabled_view_modes) . '" ';
$props .= "default-view-mode='" . $default_view_mode . "' ";
$props .= "enabled-view-modes='" . implode(',', $enabled_view_modes) . "' ";
$props .= "default-order='" . $default_order . "' ";
$props .= "default-orderby='" . (is_array($default_orderby) ? json_encode($default_orderby) : $default_orderby) . "' ";
// Passes arguments to custom props
foreach ($args as $key => $value) {
if ($value == true || $value == 'true') {
$props .= str_replace('_', '-', $key) . '="' . $value . '" ';
$props .= str_replace("_", "-", $key) . "='" . $value . "' ";
}
}

View File

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

View File

@ -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.18.6
Version: 0.18.7
Requires at least: 5.0
Tested up to: 5.8
Requires PHP: 5.6
Stable tag: 0.18.6
Stable tag: 0.18.7
Text Domain: tainacan
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
const TAINACAN_VERSION = '0.18.6';
const TAINACAN_VERSION = '0.18.7';
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
$TAINACAN_BASE_URL = plugins_url('', __FILE__);

View File

@ -198,6 +198,53 @@
{{ $i18n.get('label_create_new_page') }}</a>
</b-field>
<!-- Change Default OrderBy Select and Order Button-->
<b-field
:addons="false"
:label="$i18n.get('label_default_orderby')"
:type="editFormErrors['default_orderby'] != undefined ? 'is-danger' : ''"
:message="editFormErrors['default_orderby'] != undefined ? editFormErrors['default_orderby'] : $i18n.get('info_default_orderby')">
<help-button
:title="$i18n.getHelperTitle('collections', 'default_orderby')"
:message="$i18n.getHelperMessage('collections', 'default_orderby')"/>
<div class="control sorting-options">
<label class="label">{{ $i18n.get('label_sort') }}&nbsp;</label>
<b-select
id="tainacan-select-default_order"
v-model="form.default_order">
<option
role="button"
:class="{ 'is-active': form.default_order == 'DESC' }"
:value="'DESC'">
{{ $i18n.get('label_descending') }}
</option>
<option
role="button"
:class="{ 'is-active': form.default_order == 'ASC' }"
:value="'ASC'">
{{ $i18n.get('label_ascending') }}
</option>
</b-select>
<span
class="label"
style="padding: 0 0.65em;">
{{ $i18n.get('info_by_inner') }}
</span>
<b-select
expanded
:loading="isLoadingMetadata"
v-model="localDefaultOrderBy"
id="tainacan-select-default_orderby">
<option
v-for="metadatum of sortingMetadata"
:value="metadatum.id"
:key="metadatum.id">
{{ metadatum.name }}
</option>
</b-select>
</div>
</b-field>
<!-- Hide Items Thumbnail on Lists ------------------------ -->
<b-field
:addons="false"
@ -332,7 +379,7 @@
</div>
</b-field>
<!-- Header Page -------------------------------- -->
<!-- Header Image -------------------------------- -->
<b-field :addons="false">
<label class="label">{{ $i18n.get('label_header_image') }}</label>
<div class="header-field">
@ -628,7 +675,7 @@
</template>
<script>
import { mapActions } from 'vuex';
import { mapGetters, mapActions } from 'vuex';
import wpMediaFrames from '../../js/wp-media-frames';
import FileItem from '../other/file-item.vue';
import { wpAjax, formHooks } from '../../js/mixins';
@ -655,6 +702,8 @@ export default {
files:[],
enabled_view_modes: [],
default_view_mode: [],
default_order: 'ASC',
default_orderby: 'creation_date',
allow_comments: 'closed',
allows_submission: 'no',
submission_default_status: 'draft',
@ -687,9 +736,18 @@ export default {
reCAPTCHASettingsPagePath: tainacan_plugin.admin_url + 'admin.php?page=tainacan_item_submission',
newPagePath: tainacan_plugin.admin_url + 'post-new.php?post_type=page',
isUpdatingSlug: false,
entityName: 'collection'
entityName: 'collection',
metadataSearchCancel: undefined,
isLoadingMetadata: true,
sortingMetadata: [],
localDefaultOrderBy: 'creation_date'
}
},
computed: {
...mapGetters('metadata', {
'metadata': 'getMetadata'
})
},
watch: {
'form.hide_items_thumbnail_on_lists' (newValue) {
if (newValue == 'yes') {
@ -711,11 +769,19 @@ export default {
} else {
this.registeredViewModes = tainacan_plugin.registered_view_modes;
}
},
localDefaultOrderBy(newValue) {
if (this.sortingMetadata && this.sortingMetadata.length && newValue) {
let sortingMetadatumIndex = this.sortingMetadata.findIndex(aMetadatum => aMetadatum.id == newValue);
if (sortingMetadatumIndex >= 0)
this.form.default_orderby = this.$orderByHelper.getOrderByForMetadatum(this.sortingMetadata[sortingMetadatumIndex].metadata_type ? this.sortingMetadata[sortingMetadatumIndex] : this.sortingMetadata[sortingMetadatumIndex].id);
}
}
},
mounted(){
this.$root.$emit('onCollectionBreadCrumbUpdate', [{ path: '', label: this.$i18n.get('settings') }]);
if (this.$route.query.fromImporter != undefined)
this.fromImporter = this.$route.query.fromImporter;
@ -753,6 +819,8 @@ export default {
this.form.parent = this.collection.parent;
this.form.default_view_mode = this.collection.default_view_mode;
this.form.enabled_view_modes = JSON.parse(JSON.stringify(this.collection.enabled_view_modes.reduce((result, viewMode) => { typeof viewMode == 'string' ? result.push(viewMode) : null; return result }, [])));
this.form.default_order = this.collection.default_order;
this.form.default_orderby = this.collection.default_orderby;
this.form.allow_comments = this.collection.allow_comments;
this.form.allows_submission = this.collection.allows_submission;
this.form.submission_anonymous_user = this.collection.submission_anonymous_user;
@ -796,6 +864,9 @@ export default {
// this.isFetchingCollections = false;
// });
// Prepares list of metadata available for sorting
this.getMetadataForSorting();
this.isLoading = false;
});
} else {
@ -821,6 +892,9 @@ export default {
'fetchPage',
'fetchAllCollectionNames'
]),
...mapActions('metadata', [
'fetchMetadata'
]),
updateSlug: _.debounce(function() {
if (!this.form.name || this.form.name.length <= 0)
return;
@ -856,6 +930,8 @@ export default {
parent: this.form.parent,
enabled_view_modes: this.form.enabled_view_modes,
default_view_mode: this.form.default_view_mode,
default_order: this.form.default_order,
default_orderby: this.form.default_orderby,
allows_submission: this.form.allows_submission,
submission_anonymous_user: this.form.submission_anonymous_user,
submission_default_status: this.form.submission_default_status,
@ -882,6 +958,8 @@ export default {
this.form.enable_cover_page = this.collection.enable_cover_page;
this.form.enabled_view_modes = this.collection.enabled_view_modes.map((viewMode) => viewMode.viewMode);
this.form.default_view_mode = this.collection.default_view_mode;
this.form.default_order = this.collection.default_order;
this.form.default_orderby = this.collection.default_orderby;
this.form.allow_comments = this.collection.allow_comments;
this.form.allows_submission = this.collection.allows_submission;
this.form.submission_anonymous_user = this.collection.submission_anonymous_user;
@ -939,6 +1017,8 @@ export default {
this.form.slug = this.collection.slug;
this.form.parent = this.collection.parent;
this.form.default_view_mode = this.collection.default_view_mode;
this.form.default_order = this.collection.default_order;
this.form.default_orderby = this.collection.default_orderby;
this.form.enabled_view_modes = [];
this.form.allow_comments = this.collection.allow_comments;
this.form.allows_submission = this.collection.allows_submission;
@ -969,6 +1049,9 @@ export default {
// this.isFetchingCollections = false;
// });
// Prepares list of metadata available for sorting
this.getMetadataForSorting();
this.isLoading = false;
})
@ -1063,12 +1146,12 @@ export default {
deleteThumbnail() {
this.updateThumbnail({collectionId: this.collectionId, thumbnailId: 0})
.then(() => {
this.collection.thumbnail = false;
})
.catch((error) => {
this.$console.error(error);
});
.then(() => {
this.collection.thumbnail = false;
})
.catch((error) => {
this.$console.error(error);
});
},
deleteHeaderImage() {
@ -1117,6 +1200,69 @@ export default {
}
}
);
},
getMetadataForSorting() {
// Cancels previous Request
if (this.metadataSearchCancel != undefined)
this.metadataSearchCancel.cancel('Metadata search Canceled.');
this.isLoadingMetadata = true;
// Processing is done inside a local variable
this.fetchMetadata({
collectionId: this.collectionId,
isContextEdit: false,
includeControlMetadataTypes: true,
metaquery: [{
key: 'metadata_type',
compare: 'NOT IN',
value: [ // Not every metadata can be used for sorting
'Tainacan\\Metadata_Types\\Core_Description',
'Tainacan\\Metadata_Types\\Taxonomy',
'Tainacan\\Metadata_Types\\Relationship',
'Tainacan\\Metadata_Types\\Compound',
'Tainacan\\Metadata_Types\\User'
]
}]
}).then((resp) => {
resp.request
.then(() => {
// Not every metadata can be used for sorting
this.sortingMetadata = JSON.parse(JSON.stringify(this.metadata));
// Adds creation date as it is the default
this.sortingMetadata.push({
name: this.$i18n.get('label_creation_date'),
metadata_type: undefined,
slug: 'creation_date',
id: 'creation_date'
});
// Updates localDefaultOrder variable that needs only the ID of the metadata
if (this.form.default_orderby.metakey)
this.localDefaultOrderBy = this.form.default_orderby.metakey;
else {
if (this.form.default_orderby == 'title') {
const localDefaultOrderByIndex = this.sortingMetadata.findIndex((aMetadatum) => aMetadatum.metadata_type == 'Tainacan\\Metadata_Types\\Core_Title');
this.localDefaultOrderBy = localDefaultOrderByIndex >= 0 ? this.sortingMetadata[localDefaultOrderByIndex].id : 'title';
} else if (this.form.default_orderby == 'description') {
const localDefaultOrderByIndex = this.sortingMetadata.findIndex((aMetadatum) => aMetadatum.metadata_type == 'Tainacan\\Metadata_Types\\Core_Description');
this.localDefaultOrderBy = localDefaultOrderByIndex >= 0 ? this.sortingMetadata[localDefaultOrderByIndex].id : 'description';
} else {
this.localDefaultOrderBy = this.form.default_orderby;
}
}
this.isLoadingMetadata = false;
})
.catch(() => {
this.isLoadingMetadata = false;
})
// Search Request Token for cancelling
this.metadataSearchCancel = resp.source;
})
.catch(() => this.isLoadingMetadata = false);
}
}
}
@ -1243,6 +1389,15 @@ export default {
.icon { color: var(--tainacan-gray2); }
}
}
.sorting-options {
display: flex;
align-items: center;
.label {
font-weight: normal;
margin-bottom: 0;
}
}
.status-radios {
display: flex;

View File

@ -34,10 +34,10 @@
aria-role="listitem">
{{ $i18n.get('label_delete_selected_collections') }}
</b-dropdown-item>
<b-dropdown-item
<!-- <b-dropdown-item
disabled
aria-role="listitem">{{ $i18n.get('label_edit_selected_collections') + ' (Not ready)' }}
</b-dropdown-item>
</b-dropdown-item> -->
</b-dropdown>
</div>
</div>
@ -292,7 +292,7 @@
show: 500,
hide: 300,
},
content: getTotalItems(collection.total_items),
content: getTotalItemsDetailed(collection.total_items),
autoHide: false,
classes: ['tainacan-tooltip', 'tooltip', 'repository-tooltip'],
placement: 'auto-start'
@ -317,7 +317,8 @@
content: $i18n.get('edit'),
autoHide: true,
classes: ['tainacan-tooltip', 'tooltip', 'repository-tooltip'],
placement: 'auto'
placement: 'auto',
html: true
}"
class="icon">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-settings"/>
@ -414,6 +415,9 @@ export default {
getTotalItems(total_items) {
return Number(total_items['publish']) + Number(total_items['private']) + Number(total_items['draft']);
},
getTotalItemsDetailed(total_items) {
return this.$i18n.get('status_public') + ': ' + total_items['publish'] + '<br> ' + this.$i18n.get('status_private') + ': ' + total_items['private'] + '<br> ' + this.$i18n.get('status_draft') + ': ' + total_items['draft'];
},
deleteOneCollection(collectionId) {
this.$buefy.modal.open({
parent: this,

View File

@ -26,7 +26,7 @@
<span
class="selected-items-info"
v-if="selectedItems.length && items.length > 1 && !isAllItemsSelected">
{{ selectedItems.length != 1 ? (selectedItems.length + ' ' + $i18n.get('label_selected_items')) : ('1 ' + $i18n.get('label_selected_item')) }}<span v-if="selectedItems.length != amountOfSelectedItemsOnThisPage && amountOfSelectedItemsOnThisPage > 0">,&nbsp;({{ $i18n.getWithVariables('label_%s_on_this_page', [ amountOfSelectedItemsOnThisPage ]) }})</span>
{{ selectedItems.length != 1 ? $i18n.getWithVariables('label_%s_selected_items', [selectedItems.length]) : $i18n.get('label_one_selected_item') }}<span v-if="selectedItems.length != amountOfSelectedItemsOnThisPage && amountOfSelectedItemsOnThisPage > 0">&nbsp;({{ $i18n.getWithVariables('label_%s_on_this_page', [ amountOfSelectedItemsOnThisPage ]) }})</span>
<button
class="link-style"
@click="cleanSelectedItems()">
@ -559,7 +559,7 @@
@click.left="onClickItem($event, item)"
@click.right="onRightClickItem($event, item)">
<div
v-if="collection && collection.hide_items_thumbnail_on_lists != 'yes'"
v-if="!collection || (collection && collection.hide_items_thumbnail_on_lists != 'yes')"
class="card-thumbnail">
<blur-hash-image
v-if="item.thumbnail != undefined"

View File

@ -9,32 +9,47 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
*/
class Numeric extends Metadata_Type {
function __construct(){
// call metadatum type constructor
parent::__construct();
$this->set_name( __('Numeric', 'tainacan') );
$this->set_primitive_type('float');
$this->set_component('tainacan-numeric');
$this->set_form_component('tainacan-form-numeric');
$this->set_description( __('A numeric value, integer or float', 'tainacan') );
$this->set_preview_template('
<div>
<div class="control is-clearfix">
<input type="number" placeholder="3,1415" class="input">
</div>
</div>
');
}
function __construct(){
// call metadatum type constructor
parent::__construct();
$this->set_name( __('Numeric', 'tainacan') );
$this->set_primitive_type('float');
$this->set_component('tainacan-numeric');
$this->set_form_component('tainacan-form-numeric');
$this->set_description( __('A numeric value, integer or float', 'tainacan') );
$this->set_preview_template('
<div>
<div class="control is-clearfix">
<input type="number" placeholder="3,1415" class="input">
</div>
</div>
');
}
/**
* @inheritdoc
*/
public function get_form_labels(){
return [
'step' => [
'title' => __( 'Step', 'tainacan' ),
'description' => __( 'The amount to be increased or decreased when clicking on the metadatum control buttons. This also defines whether the input accepts decimal numbers.', 'tainacan' ),
]
];
}
/**
* @inheritdoc
*/
public function get_form_labels(){
return [
'step' => [
'title' => __( 'Step', 'tainacan' ),
'description' => __( 'The amount to be increased or decreased when clicking on the metadatum control buttons. This also defines whether the input accepts decimal numbers.', 'tainacan' ),
]
];
}
public function validate(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
$value = is_array($value) ? $value : [$value];
foreach ($value as $numeric_value) {
if( !empty($numeric_value) && !is_numeric($numeric_value) ) {
$this->add_error( sprintf(__('The value (%s) is not a valid number', 'tainacan'), $numeric_value ) );
return false;
}
}
return true;
}
}

View File

@ -110,6 +110,7 @@
.b-checkbox.checkbox {
margin-top: 12px;
width: auto !important;
}
</style>

View File

@ -239,7 +239,7 @@
isHeader: false,
advancedSearchResults: false,
openFormAdvancedSearch: false,
isDoSearch: false,
isDoingSearch: false,
collectionId: ''
},
data() {
@ -274,8 +274,8 @@
}
},
watch: {
isDoSearch() {
if (this.isDoSearch)
isDoingSearch() {
if (this.isDoingSearch)
this.searchAdvanced();
}
},

View File

@ -2,13 +2,11 @@
<transition name="filter-item">
<div v-if="filterTags != undefined && filterTags.length > 0">
<p class="filter-tags-info">
<span style="margin-right: 1em">
<strong>{{ totalItems }}</strong>
{{ ' ' + ( totalItems == 1 ? $i18n.get('info_item_found') : $i18n.get('info_items_found') ) }}
</span>
<span
style="margin-right: 1em"
v-html="totalItems == 1 ? $i18n.getWithVariables('info_item_%s_found', [totalItems]) : $i18n.getWithVariables('info_items_%s_found', [totalItems])" />
<span>
<strong>{{ filterTags.length }}</strong>
{{ ' ' + ( filterTags.length == 1 ? $i18n.get('info_applied_filter') : $i18n.get('info_applied_filters') ) }}
<span v-html="filterTags.length == 1 ? $i18n.getWithVariables('info_%s_applied_filter', [filterTags.length]) : $i18n.getWithVariables('info_%s_applied_filters', [filterTags.length])" />
&nbsp;
<a
@click="clearAllFilters()"

View File

@ -71,7 +71,8 @@ import {
CommentsStatusHelperPlugin
} from './admin-utilities';
import {
ThumbnailHelperPlugin
ThumbnailHelperPlugin,
OrderByHelperPlugin
} from './utilities';
export default (element) => {
@ -107,6 +108,7 @@ export default (element) => {
Vue.use(RouterHelperPlugin);
Vue.use(UserCapabilitiesPlugin);
Vue.use(ThumbnailHelperPlugin);
Vue.use(OrderByHelperPlugin);
Vue.use(StatusHelperPlugin);
Vue.use(ConsolePlugin, {visual: false});
Vue.use(VueTheMask);

View File

@ -133,10 +133,7 @@ UserPrefsPlugin.install = function (Vue, options = {}) {
'taxonomies_per_page': 12,
'activities_per_page': 12,
'order': 'DESC',
'order_by': {
slug: 'creation_date',
name: 'Creation Date'
},
'order_by': 'date',
'view_mode': undefined,
'admin_view_mode': 'cards',
'fetch_only': 'thumbnail,modification_date,creation_date,author_name',

View File

@ -9,6 +9,8 @@ export default {
errors : [],
query: {},
collectionId: undefined,
defaultOrder: 'ASC',
defaultOrderBy: 'date',
taxonomy: undefined,
termId: undefined,
searchCancel: undefined
@ -64,7 +66,7 @@ export default {
// Order (ASC, DESC)
if (this.$route.query.order == undefined || to.params.collectionId != from.params.collectionId) {
let orderKey = (this.collectionId != undefined ? 'order_' + this.collectionId : 'order');
let orderValue = this.$userPrefs.get(orderKey);
let orderValue = this.$userPrefs.get(orderKey) ? this.$userPrefs.get(orderKey) : this.defaultOrder;
if (orderValue)
this.$route.query.order = orderValue;
@ -77,31 +79,21 @@ export default {
// Order By (required extra work to deal with custom metadata ordering)
if (this.$route.query.orderby == undefined || to.params.collectionId != from.params.collectionId) {
let orderByKey = (this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by');
let orderBy = this.$userPrefs.get(orderByKey);
let orderBy = this.$userPrefs.get(orderByKey) ? this.$userPrefs.get(orderByKey) : this.defaultOrderBy;
if (orderBy) {
if (orderBy.slug == 'modification_date') {
this.$route.query.orderby = 'modified';
} else if (orderBy.slug == 'creation_date') {
this.$route.query.orderby = 'date';
} else if (orderBy.slug == 'author_name') {
this.$route.query.orderby = 'author_name';
} else if (orderBy.metadata_type_object.primitive_type == 'float' || orderBy.metadata_type_object.primitive_type == 'int') {
this.$route.query.orderby = 'meta_value_num';
this.$route.query.metakey = orderBy.id;
} else if (orderBy.metadata_type_object.primitive_type == 'date') {
this.$route.query.orderby = 'meta_value';
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 == 'author_id' ? 'author' : orderBy.metadata_type_object.related_mapped_prop;
// Previously was stored as a metadata object, now it is a orderby object
if (orderBy.slug)
orderBy = this.$orderByHelper.getOrderByForMetadatum(orderBy);
if (orderBy.orderby) {
Object.keys(orderBy).forEach((paramKey) => {
this.$route.query[paramKey] = orderBy[paramKey];
});
} else {
this.$route.query.orderby = 'meta_value';
this.$route.query.metakey = orderBy.id;
this.$route.query.orderby = orderBy;
}
// Sets orderByName as null so ItemsPage can take care of creating it
this.$store.dispatch('search/setOrderByName', null);
} else {
this.$route.query.orderby = 'date';
@ -109,9 +101,6 @@ export default {
slug: 'creation_date',
name: this.$i18n.get('label_creation_date')
}).catch(() => { });
// Sets orderByName as null so ItemsPage can take care of creating it
this.$store.dispatch('search/setOrderByName', null);
}
}
@ -181,11 +170,10 @@ export default {
) {
this.$emit('has-to-reload-facets', true);
}
// Finally, loads items
if (to.fullPath != from.fullPath) {
this.loadItems(to);
}
if (to.fullPath != from.fullPath)
this.loadItems();
}
}
},
@ -235,7 +223,7 @@ export default {
}
this.updateURLQueries();
},
addFetchOnly( metadatum, ignorePrefs, metadatumIDs ){
addFetchOnly( metadatum, ignorePrefs, metadatumIDs ) {
this.$store.dispatch('search/add_fetch_only', metadatum );
this.$store.dispatch('search/add_fetch_only_meta', metadatumIDs);
this.updateURLQueries();
@ -279,10 +267,15 @@ export default {
},
setOrderBy(orderBy) {
let prefsOrderBy = this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by';
if (this.$userPrefs.get(prefsOrderBy) != orderBy) {
this.$userPrefs.set(prefsOrderBy, orderBy)
.catch(() => {});
if (orderBy.metakey) {
if (!this.$userPrefs.get(prefsOrderBy) || orderBy.metakey != this.$userPrefs.get(prefsOrderBy).metakey)
this.$userPrefs.set(prefsOrderBy, orderBy).catch(() => {});
} else {
if (orderBy != this.$userPrefs.get(prefsOrderBy))
this.$userPrefs.set(prefsOrderBy, orderBy).catch(() => {});
}
this.$store.dispatch('search/setOrderBy', orderBy);
this.updateURLQueries();
},
@ -372,17 +365,16 @@ export default {
updateStoreFromURL() {
this.$store.dispatch('search/set_postquery', this.$route.query);
},
loadItems(to) {
loadItems() {
// Forces fetch_only to be filled before any search happens
if (this.$store.getters['search/getPostQuery']['fetch_only'] == undefined) {
this.$emit( 'hasToPrepareMetadataAndFilters', to);
this.$emit( 'hasToPrepareMetadataAndFilters');
} else {
this.$emit( 'isLoadingItems', true);
// Cancels previous Request
if (this.searchCancel != undefined)
this.searchCancel.cancel('Item search Canceled.');
this.$store.dispatch('collection/fetchItems', {
'collectionId': this.collectionId,
'isOnTheme': (this.$route.name == null),
@ -414,6 +406,12 @@ export default {
this.setTotalItems(null);
this.collectionId = collectionId;
},
setDefaultOrder(defaultOrder) {
this.defaultOrder = defaultOrder;
},
setDefaultOrderBy(defaultOrderBy) {
this.defaultOrderBy = defaultOrderBy;
},
setTerm(termId, taxonomy) {
this.termId = termId;
this.taxonomy = taxonomy;

View File

@ -1,6 +1,17 @@
import axios from '../../../axios';
import qs from 'qs';
export const fetchMetadata = ({commit}, { collectionId, isRepositoryLevel, isContextEdit, includeDisabled, isAdvancedSearch, parent, includeControlMetadataTypes, includeOptionsAsHtml }) => {
export const fetchMetadata = ({commit}, {
collectionId,
isRepositoryLevel,
isContextEdit,
includeDisabled,
isAdvancedSearch,
parent,
includeControlMetadataTypes,
includeOptionsAsHtml,
metaquery
}) => {
const source = axios.CancelToken.source();
@ -8,28 +19,33 @@ export const fetchMetadata = ({commit}, { collectionId, isRepositoryLevel, isCon
request: new Promise((resolve, reject) => {
let endpoint = '';
if (!isRepositoryLevel)
endpoint = '/collection/' + collectionId + '/metadata/';
endpoint = '/collection/' + collectionId + '/metadata/?';
else
endpoint = '/metadata/';
endpoint = '/metadata/?';
endpoint += '?nopaging=1';
let query = {
nopaging: 1
};
if (isContextEdit)
endpoint += '&context=edit';
query['context'] = 'edit';
if (includeDisabled)
endpoint += '&include_disabled=' + includeDisabled;
query['include_disabled'] = includeDisabled;
if (parent)
endpoint += '&parent=' + parent;
query['parent'] = parent;
if (includeControlMetadataTypes)
endpoint += '&include_control_metadata_types=true';
query['include_control_metadata_types'] = 'true';
if (includeOptionsAsHtml)
endpoint += '&include_options_as_html=yes';
query['include_options_as_html'] = 'yes';
axios.tainacan.get(endpoint, { cancelToken: source.token })
if (metaquery)
query['metaquery'] = metaquery;
axios.tainacan.get(endpoint + qs.stringify(query), { cancelToken: source.token })
.then((res) => {
let metadata = res.data;
if (!isAdvancedSearch) {

View File

@ -93,51 +93,22 @@ export const setStatus= ({ commit }, status ) => {
// Sorting queries
export const setOrderBy = ({ state, commit }, orderBy ) => {
commit('removePostQueryAttribute', 'orderby');
commit('removePostQueryAttribute', 'metakey');
commit('removePostQueryAttribute', 'metatype');
// Primitive Types: string, date, item, term, compound, float
if (orderBy.slug == 'modification_date') {
commit('setPostQueryAttribute', { attr: 'orderby', value: 'modified' } );
commit('removePostQueryAttribute', 'metakey');
commit('removePostQueryAttribute', 'metatype');
} else if (orderBy.slug == 'creation_date') {
commit('setPostQueryAttribute', { attr: 'orderby', value: 'date' } );
commit('removePostQueryAttribute', 'metakey');
commit('removePostQueryAttribute', 'metatype');
} else if (orderBy.slug == 'author_name') {
commit('setPostQueryAttribute', { attr: 'orderby', value: 'author_name' } );
commit('removePostQueryAttribute', 'metakey');
commit('removePostQueryAttribute', 'metatype');
} else if (orderBy.metadata_type_object.primitive_type == 'float' || orderBy.metadata_type_object.primitive_type == 'int') {
commit('setPostQueryAttribute', { attr: 'orderby', value: 'meta_value_num' } );
commit('setPostQueryAttribute', { attr: 'metakey', value: orderBy.id } );
commit('removePostQueryAttribute', 'metatype');
} else if (orderBy.metadata_type_object.primitive_type == 'date') {
commit('setPostQueryAttribute', { attr: 'orderby', value: 'meta_value' } );
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('removePostQueryAttribute', 'metakey');
commit('removePostQueryAttribute', 'metatype');
if (orderBy.metakey) {
Object.keys(orderBy).forEach((paramKey) => {
commit('setPostQueryAttribute', { attr: paramKey, value: orderBy[paramKey] });
});
} else {
commit('setPostQueryAttribute', { attr: 'orderby', value: 'meta_value' } );
commit('setPostQueryAttribute', { attr: 'metakey', value: orderBy.id } );
commit('removePostQueryAttribute', 'metatype');
commit('setPostQueryAttribute', { attr: 'orderby', value: orderBy } );
}
commit('setOrderByName', orderBy.name);
};
export const setOrder = ({ commit }, order ) => {
commit('setPostQueryAttribute', { attr: 'order', value: order } );
};
// Set orderByName
export const setOrderByName = ({ commit }, orderByName ) => {
commit('setOrderByName', orderByName );
};
// Set search query
export const setSearchQuery = ({ commit }, searchQuery ) => {
commit('setSearchQuery', searchQuery );

View File

@ -64,10 +64,6 @@ export const getFetchOnly = state => {
return state.postquery.fetch_only;
};
export const getOrderByName = state => {
return state.orderByName;
};
export const getMetaKey = state => {
return state.postquery.metakey;
};

View File

@ -4,8 +4,8 @@ import * as mutations from './mutations';
const state = {
postquery: {
orderby: 'date',
order: 'DESC',
orderby: '',
order: '',
paged: 1,
perpage: 12,
status: '',
@ -23,7 +23,6 @@ const state = {
totalPages: 0,
itemsPerPage: 12, // Not the same as postquery.perpage as API may have limited it's value
facets: {},
orderByName: '',
selecteditems: [],
highlightedItem: null
};

View File

@ -159,10 +159,6 @@ export const setAdminViewMode = ( state, adminViewMode ) => {
state.postquery.admin_view_mode = adminViewMode;
};
export const setOrderByName = ( state, orderByName ) => {
state.orderByName = orderByName;
};
export const addFilterTag = ( state, filterTag ) => {
state.filter_tags = ( ! state.filter_tags) ? [] : state.filter_tags;
let index = state.filter_tags.findIndex( tag => tag.filterId == filterTag.filterId);

View File

@ -107,3 +107,100 @@ export const ThumbnailHelperFunctions = () => {
ThumbnailHelperPlugin.install = function (Vue, options = {}) {
Vue.prototype.$thumbHelper = ThumbnailHelperFunctions();
};
// ORDERBY PLUGIN - Converts a metadatum information into appropriate orderby query for WP Query
export const OrderByHelperPlugin = {};
export const OrderByHelperFunctions = () => {
return {
getOrderByForMetadatum(metadatum) {
// If we are receiving a metadatum object, we can handle different orderby properties
if (metadatum.id !== undefined) {
if (metadatum.metadata_type_object && (metadatum.metadata_type_object.primitive_type == 'float' || metadatum.metadata_type_object.primitive_type == 'int')) {
return {
metakey: metadatum.id,
orderby: 'meta_value_num'
}
} else if (metadatum.metadata_type_object && metadatum.metadata_type_object.primitive_type == 'date') {
return {
orderby: 'meta_value',
metakey: metadatum.id,
metatype: 'DATETIME'
}
} else if (metadatum.metadata_type_object && metadatum.metadata_type_object.core) {
return metadatum.metadata_type_object.related_mapped_prop
} else {
return {
orderby: 'meta_value',
metakey: metadatum.id
}
}
// If it is just a string, we stick to the default
} else {
// We do this due to previous metadata that were saved as metadata object instead of orderby objects.
if (metadatum.slug) {
switch(metadatum.slug) {
case 'modification_date': return 'modified'
case 'creation_date': return 'date'
case 'author_name': return 'author_name'
case 'created_by': return 'author_name'
case 'title': return 'title'
case 'description': return 'description'
default: return metadatum;
}
} else {
switch(metadatum) {
case 'modification_date': return { orderby: 'modified' }
case 'creation_date': return { orderby: 'date' }
case 'author_name': return { orderby: 'author_name' }
case 'created_by': return { orderby: 'author_name' }
case 'title': return { orderby: 'title' }
case 'description': return { orderby: 'description' }
default: return metadatum;
}
}
}
},
getOrderByMetadatumName(orderBy, metadata) {
if (orderBy.metakey) {
let existingMetadataIndex = metadata.findIndex((aMetadatum) => aMetadatum.id == orderBy.metakey);
return existingMetadataIndex >= 0 ? metadata[existingMetadataIndex].name : '';
} else {
// We do this due to previous metadata that were saved as metadata object instead of orderby objects.
if (orderBy.slug) {
switch(orderBy.slug) {
case 'modification_date': return 'label_modification_date'
case 'modified': return 'label_modification_date'
case 'creation_date': return 'label_creation_date'
case 'date': return 'label_creation_date'
case 'author_name': return 'label_created_by'
case 'created_by': return 'label_created_by'
case 'title': return 'label_title'
case 'description': return 'label_description'
default: return orderBy.slug;
}
} else {
switch(orderBy.orderby) {
case 'modification_date': return 'label_modification_date'
case 'modified': return 'label_modification_date'
case 'creation_date': return 'label_creation_date'
case 'date': return 'label_creation_date'
case 'author_name': return 'label_created_by'
case 'created_by': return 'label_created_by'
case 'title': return 'label_title'
case 'description': return 'label_description'
default: return orderBy.orderby;
}
}
}
}
}
}
OrderByHelperPlugin.install = function (Vue, options = {}) {
Vue.prototype.$orderByHelper = OrderByHelperFunctions();
};

View File

@ -362,7 +362,7 @@
<span>{{ $i18n.get('label_cards') }}</span>
</b-dropdown-item>
<b-dropdown-item
v-if="collection && collection.hide_items_thumbnail_on_lists != 'yes'"
v-if="!collection || (collection && collection.hide_items_thumbnail_on_lists != 'yes')"
aria-controls="items-list-results"
role="button"
:class="{ 'is-active': adminViewMode == 'grid' }"
@ -385,7 +385,7 @@
<span>{{ $i18n.get('label_records') }}</span>
</b-dropdown-item>
<b-dropdown-item
v-if="collection && collection.hide_items_thumbnail_on_lists != 'yes'"
v-if="!collection || (collection && collection.hide_items_thumbnail_on_lists != 'yes')"
aria-controls="items-list-results"
role="button"
:class="{ 'is-active': adminViewMode == 'masonry' }"
@ -471,7 +471,7 @@
:is-repository-level="isRepositoryLevel"
:advanced-search-results="advancedSearchResults"
:open-form-advanced-search="openFormAdvancedSearch"
:is-do-search="isDoSearch"/>
:is-doing-search="isDoingSearch"/>
<div class="advanced-search-form-submit">
<p
@ -487,7 +487,7 @@
class="control">
<button
aria-controls="items-list-results"
@click="isDoSearch = !isDoSearch"
@click="isDoingSearch = !isDoingSearch"
class="button is-success">{{ $i18n.get('search') }}</button>
</p>
</div>
@ -664,7 +664,7 @@
openAdvancedSearch: false,
openFormAdvancedSearch: false,
advancedSearchResults: false,
isDoSearch: false,
isDoingSearch: false,
sortingMetadata: [],
isFiltersModalActive: false,
hasAnOpenModal: false,
@ -715,24 +715,11 @@
return this.getMetaKey();
},
orderByName() {
if (this.getOrderByName() != null && this.getOrderByName() != undefined && this.getOrderByName() != '') {
return this.getOrderByName();
} else {
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 == 'modification_date' && (!metadatum.metadata_type_object || !metadatum.metadata_type_object.core)) && this.orderBy == 'modified') ||
((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 || !metadatum.metadata_type_object.core)) && this.orderBy == metadatum.slug) ||
((this.orderBy == 'meta_value' || this.orderBy == 'meta_value_num') && this.getMetaKey() == metadatum.id)
)
return metadatum.name;
}
}
return '';
const metadatumName = this.$orderByHelper.getOrderByMetadatumName({
orderby: this.$route.query.orderby,
metakey: this.$route.query.metakey
}, this.sortingMetadata);
return this.$route.query.metakey ? metadatumName : this.$i18n.get(metadatumName);
},
isReadMode () {
return this.$route && this.$route.query && this.$route.query.readmode;
@ -795,13 +782,8 @@
this.advancedSearchResults = advancedSearchResults;
});
this.$eventBusSearch.$on('hasToPrepareMetadataAndFilters', (to) => {
/* This condition is to prevent an incorrect fetch by filter or metadata when we coming from items
* at collection level to items page at repository level
*/
if (this.collectionId == to.params.collectionId || to.query.fromBreadcrumb) {
this.prepareMetadata();
}
this.$eventBusSearch.$on('hasToPrepareMetadataAndFilters', () => {
this.prepareMetadata();
});
if (this.$route.query && this.$route.query.advancedSearch) {
@ -884,7 +866,6 @@
'getSearchQuery',
'getStatus',
'getOrderBy',
'getOrderByName',
'getOrder',
'getTotalItems',
'getAdminViewMode',
@ -933,7 +914,7 @@
this.$eventBusSearch.setSearchQuery(this.futureSearchQuery);
},
onChangeOrderBy(metadatum) {
this.$eventBusSearch.setOrderBy(metadatum);
this.$eventBusSearch.setOrderBy(this.$orderByHelper.getOrderByForMetadatum(metadatum));
this.showItemsHiddingDueSortingDialog();
},
onChangeOrder(newOrder) {
@ -979,7 +960,6 @@
this.$refs.displayedMetadataDropdown.toggle();
},
prepareMetadata() {
// Cancels previous Request
if (this.metadataSearchCancel != undefined)
this.metadataSearchCancel.cancel('Metadata search Canceled.');
@ -1177,8 +1157,8 @@
// Loads only basic attributes necessary to view modes that do not allow custom meta
} else {
const basicAttributes = this.collection.hide_items_thumbnail_on_lists == 'yes' ? 'modification_date,creation_date,author_name,title,description' : 'thumbnail,modification_date,creation_date,author_name,title,description';
const basicAttributes = (!this.isRepositoryLevel && this.collection.hide_items_thumbnail_on_lists == 'yes') ? 'modification_date,creation_date,author_name,title,description' : 'thumbnail,modification_date,creation_date,author_name,title,description';
this.$eventBusSearch.addFetchOnly(basicAttributes, true, '');
if (this.isRepositoryLevel) {
@ -1223,7 +1203,7 @@
})
}
this.isLoadingMetadata = false;
this.displayedMetadata = metadata;
})

View File

@ -54,6 +54,7 @@ input[type="week"].input {
font-size: 0.875em;
color: var(--tainacan-info-color) !important;
text-overflow: ellipsis;
opacity: 0.75;
}
&::-ms-input-placeholder {
font-size: 0.875em;

View File

@ -519,6 +519,7 @@
display: block;
height: 54px;
width: 54px;
min-width: 54px;
}
}

View File

@ -38,7 +38,7 @@
:collection-id="collectionId"
:advanced-search-results="advancedSearchResults"
:open-form-advanced-search="openFormAdvancedSearch"
:is-do-search="isDoSearch"/>
:is-doing-search="isDoingSearch"/>
<div class="advanced-search-form-submit">
<p
@ -54,7 +54,7 @@
class="control">
<button
aria-controls="items-list-results"
@click="isDoSearch = !isDoSearch"
@click="isDoingSearch = !isDoingSearch"
class="button is-success">{{ $i18n.get('search') }}</button>
</p>
</div>
@ -592,6 +592,8 @@
hideGoToPageButton: false,
hidePaginationArea: false,
// Other Tweaks
defaultOrder: 'ASC',
defaultOrderBy: 'date',
defaultItemsPerPage: Number,
showFiltersButtonInsideSearchControl: false,
startWithFiltersHidden: false,
@ -613,7 +615,7 @@
openAdvancedSearch: false,
openFormAdvancedSearch: false,
advancedSearchResults: false,
isDoSearch: false,
isDoingSearch: false,
sortingMetadata: [],
isFiltersModalActive: false,
hasAnOpenModal: false,
@ -665,21 +667,11 @@
return this.getMetaKey();
},
orderByName() {
if (this.getOrderByName() != null && this.getOrderByName() != undefined && this.getOrderByName() != '') {
return this.getOrderByName();
} else {
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 || !metadatum.metadata_type_object.core)) && this.orderBy == metadatum.slug) ||
((this.orderBy == 'meta_value' || this.orderBy == 'meta_value_num') && this.getMetaKey() == metadatum.id)
)
return metadatum.name;
}
}
return '';
const metadatumName = this.$orderByHelper.getOrderByMetadatumName({
orderby: this.$route.query.orderby,
metakey: this.$route.query.metakey
}, this.sortingMetadata);
return this.$route.query.metakey ? metadatumName : (metadatumName ? this.$i18n.get(metadatumName) : '');
}
},
watch: {
@ -714,12 +706,17 @@
},
created() {
this.isRepositoryLevel = (this.collectionId == undefined || this.collectionId == '' || this.collectionId == null);
// Sets initial variables important to searchbus
if (this.collectionId != undefined)
this.$eventBusSearch.setCollectionId(this.collectionId);
if (this.termId != undefined && this.termId != null)
this.$eventBusSearch.setTerm(this.termId, this.taxonomy);
if (this.defaultOrder != undefined)
this.$eventBusSearch.setDefaultOrder(this.defaultOrder);
if (this.defaultOrderBy != undefined) {
this.$eventBusSearch.setDefaultOrderBy(this.defaultOrderBy);
}
this.$eventBusSearch.updateStoreFromURL();
@ -756,9 +753,6 @@
}
this.$eventBusSearch.$on('hasToPrepareMetadataAndFilters', () => {
/* This condition is to prevent an incorrect fetch by filter or metadata when we come from items
* at collection level to items page at repository level
*/
this.prepareMetadata();
});
@ -874,7 +868,6 @@
...mapGetters('search', [
'getSearchQuery',
'getOrderBy',
'getOrderByName',
'getOrder',
'getViewMode',
'getTotalItems',
@ -900,7 +893,7 @@
this.$eventBusSearch.setSearchQuery(this.futureSearchQuery);
},
onChangeOrderBy(metadatum) {
this.$eventBusSearch.setOrderBy(metadatum);
this.$eventBusSearch.setOrderBy(this.$orderByHelper.getOrderByForMetadatum(metadatum));
this.showItemsHiddingDueSortingDialog();
},
onChangeOrder(newOrder) {
@ -959,7 +952,7 @@
this.$refs.displayedMetadataDropdown.toggle();
},
prepareMetadata() {
// Cancels previous Request
if (this.metadataSearchCancel != undefined)
this.metadataSearchCancel.cancel('Metadata search Canceled.');

View File

@ -42,7 +42,8 @@ import {
ConsolePlugin
} from '../../../admin/js/admin-utilities';
import {
ThumbnailHelperPlugin
ThumbnailHelperPlugin,
OrderByHelperPlugin
} from '../../../admin/js/utilities';
export default (element) => {
@ -77,6 +78,7 @@ export default (element) => {
Vue.use(I18NPlugin);
Vue.use(UserPrefsPlugin);
Vue.use(ThumbnailHelperPlugin);
Vue.use(OrderByHelperPlugin);
Vue.use(ConsolePlugin, {visual: false});
/* Registers Extra Vue Components passed to the window.tainacan_extra_components */
@ -123,6 +125,8 @@ export default (element) => {
taxonomy: '',
collectionId: '',
defaultViewMode: '',
defaultOrder: 'ASC',
defaultOrderBy: 'date',
isForcedViewMode: false,
enabledViewModes: {},
defaultItemsPerPage: '',
@ -143,7 +147,7 @@ export default (element) => {
showInlineViewModeOptions: false,
showFullscreenWithViewModes: false
},
beforeMount () {
beforeMount() {
// Loads params if passed previously
if (this.$route.hash && this.$route.hash.split('#/?') && this.$route.hash.split('#/?')[1]) {
@ -173,6 +177,12 @@ export default (element) => {
if (this.$el.attributes['enabled-view-modes'] != undefined)
this.enabledViewModes = this.$el.attributes['enabled-view-modes'].value.split(',');
// Sorting options
if (this.$el.attributes['default-order'] != undefined)
this.defaultOrder = this.$el.attributes['default-order'].value;
if (this.$el.attributes['default-orderby'] != undefined)
this.defaultOrderBy = this.maybeConvertFromJSON(this.$el.attributes['default-orderby'].value);
// Options related to hidding elements
if (this.$el.attributes['hide-filters'] != undefined)
this.hideFilters = this.isParameterTrue('hide-filters');
@ -217,6 +227,13 @@ export default (element) => {
isParameterTrue(parameter) {
const value = this.$el.attributes[parameter].value;
return (value == true || value == 'true' || value == '1' || value == 1) ? true : false;
},
maybeConvertFromJSON(someString) {
try {
return JSON.parse(someString);
} catch(error) {
return someString;
}
}
},
render: h => h(ThemeSearch)

View File

@ -7,6 +7,8 @@
:enabled-view-modes="$root.enabledViewModes"
:default-view-mode="$root.defaultViewMode"
:is-forced-view-mode="$root.isForcedViewMode"
:default-order="$root.defaultOrder"
:default-order-by="$root.defaultOrderBy"
:default-items-per-page="$root.defaultItemsPerPage"
:hide-filters="$root.hideFilters ? $root.hideFilters : false"
:hide-hide-filters-button="$root.hideHideFiltersButton ? $root.hideHideFiltersButton : false"

View File

@ -242,7 +242,7 @@ export default {
this.chartOptionsByUser.push({
...this.areaChartOptions,
title: {
text: ''
text: daysWithActivityByUser.user.name + ' (' + daysWithActivityByUser.total + ')'
},
chart: {
id: 'userschart-' + daysWithActivityByUser.user_id,
@ -297,6 +297,13 @@ export default {
order: 3;
padding: 12px;
@media only screen {
/deep/ .apexcharts-title-text {
display: none;
visibility: hidden;
}
}
.users-charts__card {
padding: 20px !important;
@ -305,7 +312,7 @@ export default {
align-items: center;
padding: 6px 12px 2px 12px;
position: absolute;
top: 4px;
top: 2px;
left: 26px;
img,

View File

@ -415,8 +415,10 @@ return apply_filters( 'tainacan-i18n', [
'label_all_terms' => __( 'All terms', 'tainacan' ),
'label_selected_terms' => __( 'Selected terms', 'tainacan' ),
'label_selected_term' => __( 'Selected term', 'tainacan' ),
'label_selected_items' => __( 'Selected items', 'tainacan' ),
'label_%s_selected_items' => __( '%s selected items', 'tainacan' ),
'label_selected_item' => __( 'Selected item', 'tainacan' ),
'label_selected_items' => __( 'Selected items', 'tainacan' ),
'label_one_selected_item' => __( 'One selected item', 'tainacan' ),
'label_all_items_selected' => __( 'All items selected', 'tainacan' ),
/* translators: Here there is a number of items that are selected in this listing */
'label_%s_on_this_page' => __( '%s on this page', 'tainacan' ),
@ -608,6 +610,7 @@ return apply_filters( 'tainacan-i18n', [
'label_document_option_is_image' => __( 'Is link to external image', 'tainacan' ),
'label_limit_max_values' => __( 'Limit the amount of multiple values', 'tainacan'),
'label_items_selection' => __( 'Items selection', 'tainacan'),
'label_default_orderby' => __( 'Initial default sorting', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
@ -898,13 +901,14 @@ return apply_filters( 'tainacan-i18n', [
'info_related_items' => __( 'These are items that are related to this item via their own relationship type metadata. You can edit such relation on their pages.', 'tainacan'),
'info_document_option_forced_iframe' => __( 'Attempt to use an iframe to embed url content on the item page. You may use this option if the autoembed does not work.', 'tainacan'),
'info_document_option_is_image' => __( 'If you are linking directly to an external image, use this option so it can be properly embedded.', 'tainacan' ),
'info_applied_filters' => __( 'filters applied', 'tainacan'),
'info_items_found' => __( 'items found', 'tainacan'),
'info_applied_filter' => __( 'filter applied', 'tainacan'),
'info_item_found' => __( 'item found', 'tainacan'),
'info_%s_applied_filters' => __( '<strong>%s</strong> filters applied', 'tainacan'),
'info_items_%s_found' => __( '<strong>%s</strong> items found', 'tainacan'),
'info_%s_applied_filter' => __( '<strong>%s</strong> filter applied', 'tainacan'),
'info_item_%s_found' => __( '<strong>%s</strong> item found', 'tainacan'),
'info_iframe_dimensions' => __( 'The dimension values will be passed to the iframe, but it\'s rendering may change according to the theme display settings. It is still important to keep an approximate aspect ratio to the inner content.', 'tainacan'),
'info_metadata_mapper_helper' => __( 'Select the corresponding metadata so they can be exposed according to the mapper', 'tainacan'),
'info_default_orderby' => __( 'These settings only affect the initial state of the items sorting. After changed, the value used will be the latest selected by the user.', 'tainacan' ),
/* Activity actions */
'action_update-metadata-value' => __( 'Item Metadata Value Updates', 'tainacan'),
'action_update' => __( 'General Updates', 'tainacan'),