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 npm ci
fi 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) new_md5_composer=$(<last-composer-build.md5)
if [ "$current_md5_composer" != "$new_md5_composer" ] if [ "$current_md5_composer" != "$new_md5_composer" ]
then then
## Install composer dependencies ## Install composer dependencies
composer install if [ "$is_prod_build" == false ]
then
composer install
else
composer install --no-dev
fi
fi fi
new_md5_sass=$(<last-sass-build.md5) new_md5_sass=$(<last-sass-build.md5)
@ -47,24 +62,15 @@ fi
new_md5_js=$(<last-js-build.md5) new_md5_js=$(<last-js-build.md5)
is_prod_build=false
if [ "$current_md5_js" != "$new_md5_js" ] if [ "$current_md5_js" != "$new_md5_js" ]
then 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 ] if [ "$is_prod_build" == false ]
then 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)" 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 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
fi fi

View File

@ -5,11 +5,12 @@
"require": { "require": {
"respect/validation": "^1.1", "respect/validation": "^1.1",
"smalot/pdfparser": "*", "smalot/pdfparser": "*",
"kornrunner/blurhash": "^1.1" "kornrunner/blurhash": "^1.1",
"symfony/polyfill-mbstring": "1.20.0",
"phpcompatibility/php-compatibility": "*"
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "^2.2 || ^3.0.2", "squizlabs/php_codesniffer": "^2.2 || ^3.0.2",
"phpcompatibility/php-compatibility": "*",
"yoast/phpunit-polyfills": "^1.0.1" "yoast/phpunit-polyfills": "^1.0.1"
}, },
"prefer-stable" : true, "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", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "33ed3955dccb57a048e54eec04c20205", "content-hash": "9a50d78655731555071e552968158d04",
"packages": [ "packages": [
{ {
"name": "kornrunner/blurhash", "name": "kornrunner/blurhash",
@ -47,8 +47,74 @@
], ],
"description": "Pure PHP implementation of Blurhash", "description": "Pure PHP implementation of Blurhash",
"homepage": "https://github.com/kornrunner/php-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" "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", "name": "respect/validation",
"version": "1.1.31", "version": "1.1.31",
@ -110,31 +176,31 @@
"validation", "validation",
"validator" "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" "time": "2019-05-28T06:10:06+00:00"
}, },
{ {
"name": "smalot/pdfparser", "name": "smalot/pdfparser",
"version": "v0.18.1", "version": "v2.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/smalot/pdfparser.git", "url": "https://github.com/smalot/pdfparser.git",
"reference": "b47f26425e32a814dc1ee55e3ce669b9e73b8458" "reference": "768d1d6859bdf9ef0da44724ac84079f920b7599"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/smalot/pdfparser/zipball/b47f26425e32a814dc1ee55e3ce669b9e73b8458", "url": "https://api.github.com/repos/smalot/pdfparser/zipball/768d1d6859bdf9ef0da44724ac84079f920b7599",
"reference": "b47f26425e32a814dc1ee55e3ce669b9e73b8458", "reference": "768d1d6859bdf9ef0da44724ac84079f920b7599",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-zlib": "*", "ext-zlib": "*",
"php": ">=5.6", "php": ">=7.1",
"symfony/polyfill-mbstring": "^1.18" "symfony/polyfill-mbstring": "^1.18"
}, },
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"symfony/phpunit-bridge": "^5.2"
},
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-0": { "psr-0": {
@ -160,7 +226,67 @@
"pdf", "pdf",
"text" "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", "name": "symfony/polyfill-mbstring",
@ -482,64 +608,6 @@
}, },
"time": "2021-02-23T14:00:09+00:00" "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", "name": "phpdocumentor/reflection-common",
"version": "2.2.0", "version": "2.2.0",
@ -842,16 +910,16 @@
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
"version": "2.0.4", "version": "2.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "28af674ff175d0768a5a978e6de83f697d4a7f05" "reference": "42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/28af674ff175d0768a5a978e6de83f697d4a7f05", "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5",
"reference": "28af674ff175d0768a5a978e6de83f697d4a7f05", "reference": "42c5ba5220e6904cbfe8b1a1bda7c0cfdc8c12f5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -890,7 +958,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", "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": [ "funding": [
{ {
@ -898,7 +966,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-07-19T06:46:01+00:00" "time": "2021-12-02T12:42:26+00:00"
}, },
{ {
"name": "phpunit/php-text-template", "name": "phpunit/php-text-template",
@ -1890,57 +1958,6 @@
}, },
"time": "2016-10-03T07:35:21+00:00" "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", "name": "symfony/polyfill-ctype",
"version": "v1.23.0", "version": "v1.23.0",
@ -2130,16 +2147,16 @@
}, },
{ {
"name": "yoast/phpunit-polyfills", "name": "yoast/phpunit-polyfills",
"version": "1.0.2", "version": "1.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Yoast/PHPUnit-Polyfills.git", "url": "https://github.com/Yoast/PHPUnit-Polyfills.git",
"reference": "1a582ab1d91e86aa450340c4d35631a85314ff9f" "reference": "5ea3536428944955f969bc764bbe09738e151ada"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/1a582ab1d91e86aa450340c4d35631a85314ff9f", "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/5ea3536428944955f969bc764bbe09738e151ada",
"reference": "1a582ab1d91e86aa450340c4d35631a85314ff9f", "reference": "5ea3536428944955f969bc764bbe09738e151ada",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2187,7 +2204,7 @@
"issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues", "issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues",
"source": "https://github.com/Yoast/PHPUnit-Polyfills" "source": "https://github.com/Yoast/PHPUnit-Polyfills"
}, },
"time": "2021-10-03T08:40:26+00:00" "time": "2021-11-23T01:37:03+00:00"
} }
], ],
"aliases": [], "aliases": [],

View File

@ -514,7 +514,8 @@
margin-right: 20px; margin-right: 20px;
display: block; display: block;
height: 54px; 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.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 { .wp-block-tainacan-dynamic-items-list ul.items-list-edit.items-layout-list li.item-list-item img {
height: auto; 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; $collection_id = ( isset($request['collection_id']) ) ? $request['collection_id'] : null;
$last_term = ( isset($request['last_term']) ) ? $request['last_term'] : ''; $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); $query_args = $this->prepare_filters($query_args);
if ( isset($request['hideempty']) && $request['hideempty'] == 0 ) { if ( isset($request['hideempty']) && $request['hideempty'] == 0 ) {

View File

@ -145,7 +145,7 @@ class Embed {
$width = false; $width = false;
$dom = new \DOMDocument(); $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 we have a fixed aspect iframe, and it's a responsive embed content.
if ($dom) { if ($dom) {

View File

@ -828,9 +828,10 @@ class CSV extends Importer {
if($itemMetadata instanceof Entities\Item_Metadata_Entity ) { if($itemMetadata instanceof Entities\Item_Metadata_Entity ) {
$itemMetadata->set_item( $insertedItem ); // *I told you $itemMetadata->set_item( $insertedItem ); // *I told you
if( $itemMetadata->validate() ) { if( $itemMetadata->validate() ) {
$result = $Tainacan_Item_Metadata->insert( $itemMetadata ); $Tainacan_Item_Metadata->insert( $itemMetadata );
} else { } 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()); $this->add_error_log($itemMetadata->get_errors());
continue; continue;
} }

View File

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

View File

@ -423,15 +423,15 @@ class Theme_Helper {
// Loads info related to view modes // Loads info related to view modes
$view_modes = tainacan_get_the_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']; $default_view_mode = $args['default_view_mode'];
unset($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']; $enabled_view_modes = $args['enabled_view_modes'];
if ( !in_array($default_view_mode, $enabled_view_modes) ) { if ( !in_array($default_view_mode, $enabled_view_modes) ) {
$default_view_mode = $enabled_view_modes[0]; $default_view_mode = $enabled_view_modes[0];
@ -439,12 +439,27 @@ class Theme_Helper {
unset($args['enabled_view_modes']); 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 // If in a collection page
$collection = tainacan_get_collection($args); $collection = tainacan_get_collection($args);
if ($collection) { if ($collection) {
$props .= 'collection-id="' . $collection->get_id() . '" '; $props .= "collection-id='" . $collection->get_id() . "' ";
$default_view_mode = $collection->get_default_view_mode(); $default_view_mode = $collection->get_default_view_mode();
$enabled_view_modes = $collection->get_enabled_view_modes(); $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 // Gets hideItemsThumbnail info from collection setting
$args['hide-items-thumbnail'] = $collection->get_hide_items_thumbnail_on_lists() == 'yes' ? true : false; $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 // If in a tainacan taxonomy
$term = tainacan_get_term($args); $term = tainacan_get_term($args);
if ($term) { if ($term) {
$props .= 'term-id="' . $term->term_id . '" '; $props .= "term-id='" . $term->term_id . "' ";
$props .= 'taxonomy="' . $term->taxonomy . '" '; $props .= "taxonomy='" . $term->taxonomy . "' ";
} }
$props .= 'default-view-mode="' . $default_view_mode . '" '; $props .= "default-view-mode='" . $default_view_mode . "' ";
$props .= 'enabled-view-modes="' . implode(',', $enabled_view_modes) . '" '; $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 // Passes arguments to custom props
foreach ($args as $key => $value) { foreach ($args as $key => $value) {
if ($value == true || $value == 'true') { 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 Requires at least: 5.0
Tested up to: 5.8 Tested up to: 5.8
Requires PHP: 5.6 Requires PHP: 5.6
Stable tag: 0.18.6 Stable tag: 0.18.7
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html 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/ 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. 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 Author: Tainacan.org
Version: 0.18.6 Version: 0.18.7
Requires at least: 5.0 Requires at least: 5.0
Tested up to: 5.8 Tested up to: 5.8
Requires PHP: 5.6 Requires PHP: 5.6
Stable tag: 0.18.6 Stable tag: 0.18.7
Text Domain: tainacan Text Domain: tainacan
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html 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!' ); defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
$TAINACAN_BASE_URL = plugins_url('', __FILE__); $TAINACAN_BASE_URL = plugins_url('', __FILE__);

View File

@ -198,6 +198,53 @@
{{ $i18n.get('label_create_new_page') }}</a> {{ $i18n.get('label_create_new_page') }}</a>
</b-field> </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 ------------------------ --> <!-- Hide Items Thumbnail on Lists ------------------------ -->
<b-field <b-field
:addons="false" :addons="false"
@ -332,7 +379,7 @@
</div> </div>
</b-field> </b-field>
<!-- Header Page -------------------------------- --> <!-- Header Image -------------------------------- -->
<b-field :addons="false"> <b-field :addons="false">
<label class="label">{{ $i18n.get('label_header_image') }}</label> <label class="label">{{ $i18n.get('label_header_image') }}</label>
<div class="header-field"> <div class="header-field">
@ -628,7 +675,7 @@
</template> </template>
<script> <script>
import { mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import wpMediaFrames from '../../js/wp-media-frames'; import wpMediaFrames from '../../js/wp-media-frames';
import FileItem from '../other/file-item.vue'; import FileItem from '../other/file-item.vue';
import { wpAjax, formHooks } from '../../js/mixins'; import { wpAjax, formHooks } from '../../js/mixins';
@ -655,6 +702,8 @@ export default {
files:[], files:[],
enabled_view_modes: [], enabled_view_modes: [],
default_view_mode: [], default_view_mode: [],
default_order: 'ASC',
default_orderby: 'creation_date',
allow_comments: 'closed', allow_comments: 'closed',
allows_submission: 'no', allows_submission: 'no',
submission_default_status: 'draft', submission_default_status: 'draft',
@ -687,9 +736,18 @@ export default {
reCAPTCHASettingsPagePath: tainacan_plugin.admin_url + 'admin.php?page=tainacan_item_submission', reCAPTCHASettingsPagePath: tainacan_plugin.admin_url + 'admin.php?page=tainacan_item_submission',
newPagePath: tainacan_plugin.admin_url + 'post-new.php?post_type=page', newPagePath: tainacan_plugin.admin_url + 'post-new.php?post_type=page',
isUpdatingSlug: false, isUpdatingSlug: false,
entityName: 'collection' entityName: 'collection',
metadataSearchCancel: undefined,
isLoadingMetadata: true,
sortingMetadata: [],
localDefaultOrderBy: 'creation_date'
} }
}, },
computed: {
...mapGetters('metadata', {
'metadata': 'getMetadata'
})
},
watch: { watch: {
'form.hide_items_thumbnail_on_lists' (newValue) { 'form.hide_items_thumbnail_on_lists' (newValue) {
if (newValue == 'yes') { if (newValue == 'yes') {
@ -711,11 +769,19 @@ export default {
} else { } else {
this.registeredViewModes = tainacan_plugin.registered_view_modes; 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(){ mounted(){
this.$root.$emit('onCollectionBreadCrumbUpdate', [{ path: '', label: this.$i18n.get('settings') }]); this.$root.$emit('onCollectionBreadCrumbUpdate', [{ path: '', label: this.$i18n.get('settings') }]);
if (this.$route.query.fromImporter != undefined) if (this.$route.query.fromImporter != undefined)
this.fromImporter = this.$route.query.fromImporter; this.fromImporter = this.$route.query.fromImporter;
@ -753,6 +819,8 @@ export default {
this.form.parent = this.collection.parent; this.form.parent = this.collection.parent;
this.form.default_view_mode = this.collection.default_view_mode; 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.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.allow_comments = this.collection.allow_comments;
this.form.allows_submission = this.collection.allows_submission; this.form.allows_submission = this.collection.allows_submission;
this.form.submission_anonymous_user = this.collection.submission_anonymous_user; this.form.submission_anonymous_user = this.collection.submission_anonymous_user;
@ -796,6 +864,9 @@ export default {
// this.isFetchingCollections = false; // this.isFetchingCollections = false;
// }); // });
// Prepares list of metadata available for sorting
this.getMetadataForSorting();
this.isLoading = false; this.isLoading = false;
}); });
} else { } else {
@ -821,6 +892,9 @@ export default {
'fetchPage', 'fetchPage',
'fetchAllCollectionNames' 'fetchAllCollectionNames'
]), ]),
...mapActions('metadata', [
'fetchMetadata'
]),
updateSlug: _.debounce(function() { updateSlug: _.debounce(function() {
if (!this.form.name || this.form.name.length <= 0) if (!this.form.name || this.form.name.length <= 0)
return; return;
@ -856,6 +930,8 @@ export default {
parent: this.form.parent, parent: this.form.parent,
enabled_view_modes: this.form.enabled_view_modes, enabled_view_modes: this.form.enabled_view_modes,
default_view_mode: this.form.default_view_mode, 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, allows_submission: this.form.allows_submission,
submission_anonymous_user: this.form.submission_anonymous_user, submission_anonymous_user: this.form.submission_anonymous_user,
submission_default_status: this.form.submission_default_status, 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.enable_cover_page = this.collection.enable_cover_page;
this.form.enabled_view_modes = this.collection.enabled_view_modes.map((viewMode) => viewMode.viewMode); 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_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.allow_comments = this.collection.allow_comments;
this.form.allows_submission = this.collection.allows_submission; this.form.allows_submission = this.collection.allows_submission;
this.form.submission_anonymous_user = this.collection.submission_anonymous_user; this.form.submission_anonymous_user = this.collection.submission_anonymous_user;
@ -939,6 +1017,8 @@ export default {
this.form.slug = this.collection.slug; this.form.slug = this.collection.slug;
this.form.parent = this.collection.parent; this.form.parent = this.collection.parent;
this.form.default_view_mode = this.collection.default_view_mode; 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.enabled_view_modes = [];
this.form.allow_comments = this.collection.allow_comments; this.form.allow_comments = this.collection.allow_comments;
this.form.allows_submission = this.collection.allows_submission; this.form.allows_submission = this.collection.allows_submission;
@ -969,6 +1049,9 @@ export default {
// this.isFetchingCollections = false; // this.isFetchingCollections = false;
// }); // });
// Prepares list of metadata available for sorting
this.getMetadataForSorting();
this.isLoading = false; this.isLoading = false;
}) })
@ -1063,12 +1146,12 @@ export default {
deleteThumbnail() { deleteThumbnail() {
this.updateThumbnail({collectionId: this.collectionId, thumbnailId: 0}) this.updateThumbnail({collectionId: this.collectionId, thumbnailId: 0})
.then(() => { .then(() => {
this.collection.thumbnail = false; this.collection.thumbnail = false;
}) })
.catch((error) => { .catch((error) => {
this.$console.error(error); this.$console.error(error);
}); });
}, },
deleteHeaderImage() { 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); } .icon { color: var(--tainacan-gray2); }
} }
} }
.sorting-options {
display: flex;
align-items: center;
.label {
font-weight: normal;
margin-bottom: 0;
}
}
.status-radios { .status-radios {
display: flex; display: flex;

View File

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

View File

@ -26,7 +26,7 @@
<span <span
class="selected-items-info" class="selected-items-info"
v-if="selectedItems.length && items.length > 1 && !isAllItemsSelected"> 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 <button
class="link-style" class="link-style"
@click="cleanSelectedItems()"> @click="cleanSelectedItems()">
@ -559,7 +559,7 @@
@click.left="onClickItem($event, item)" @click.left="onClickItem($event, item)"
@click.right="onRightClickItem($event, item)"> @click.right="onRightClickItem($event, item)">
<div <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"> class="card-thumbnail">
<blur-hash-image <blur-hash-image
v-if="item.thumbnail != undefined" v-if="item.thumbnail != undefined"

View File

@ -9,32 +9,47 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
*/ */
class Numeric extends Metadata_Type { class Numeric extends Metadata_Type {
function __construct(){ function __construct(){
// call metadatum type constructor // call metadatum type constructor
parent::__construct(); parent::__construct();
$this->set_name( __('Numeric', 'tainacan') ); $this->set_name( __('Numeric', 'tainacan') );
$this->set_primitive_type('float'); $this->set_primitive_type('float');
$this->set_component('tainacan-numeric'); $this->set_component('tainacan-numeric');
$this->set_form_component('tainacan-form-numeric'); $this->set_form_component('tainacan-form-numeric');
$this->set_description( __('A numeric value, integer or float', 'tainacan') ); $this->set_description( __('A numeric value, integer or float', 'tainacan') );
$this->set_preview_template(' $this->set_preview_template('
<div> <div>
<div class="control is-clearfix"> <div class="control is-clearfix">
<input type="number" placeholder="3,1415" class="input"> <input type="number" placeholder="3,1415" class="input">
</div> </div>
</div> </div>
'); ');
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function get_form_labels(){ public function get_form_labels(){
return [ return [
'step' => [ 'step' => [
'title' => __( 'Step', 'tainacan' ), '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' ), '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 { .b-checkbox.checkbox {
margin-top: 12px; margin-top: 12px;
width: auto !important;
} }
</style> </style>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -159,10 +159,6 @@ export const setAdminViewMode = ( state, adminViewMode ) => {
state.postquery.admin_view_mode = adminViewMode; state.postquery.admin_view_mode = adminViewMode;
}; };
export const setOrderByName = ( state, orderByName ) => {
state.orderByName = orderByName;
};
export const addFilterTag = ( state, filterTag ) => { export const addFilterTag = ( state, filterTag ) => {
state.filter_tags = ( ! state.filter_tags) ? [] : state.filter_tags; state.filter_tags = ( ! state.filter_tags) ? [] : state.filter_tags;
let index = state.filter_tags.findIndex( tag => tag.filterId == filterTag.filterId); 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 = {}) { ThumbnailHelperPlugin.install = function (Vue, options = {}) {
Vue.prototype.$thumbHelper = ThumbnailHelperFunctions(); 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> <span>{{ $i18n.get('label_cards') }}</span>
</b-dropdown-item> </b-dropdown-item>
<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" aria-controls="items-list-results"
role="button" role="button"
:class="{ 'is-active': adminViewMode == 'grid' }" :class="{ 'is-active': adminViewMode == 'grid' }"
@ -385,7 +385,7 @@
<span>{{ $i18n.get('label_records') }}</span> <span>{{ $i18n.get('label_records') }}</span>
</b-dropdown-item> </b-dropdown-item>
<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" aria-controls="items-list-results"
role="button" role="button"
:class="{ 'is-active': adminViewMode == 'masonry' }" :class="{ 'is-active': adminViewMode == 'masonry' }"
@ -471,7 +471,7 @@
:is-repository-level="isRepositoryLevel" :is-repository-level="isRepositoryLevel"
:advanced-search-results="advancedSearchResults" :advanced-search-results="advancedSearchResults"
:open-form-advanced-search="openFormAdvancedSearch" :open-form-advanced-search="openFormAdvancedSearch"
:is-do-search="isDoSearch"/> :is-doing-search="isDoingSearch"/>
<div class="advanced-search-form-submit"> <div class="advanced-search-form-submit">
<p <p
@ -487,7 +487,7 @@
class="control"> class="control">
<button <button
aria-controls="items-list-results" aria-controls="items-list-results"
@click="isDoSearch = !isDoSearch" @click="isDoingSearch = !isDoingSearch"
class="button is-success">{{ $i18n.get('search') }}</button> class="button is-success">{{ $i18n.get('search') }}</button>
</p> </p>
</div> </div>
@ -664,7 +664,7 @@
openAdvancedSearch: false, openAdvancedSearch: false,
openFormAdvancedSearch: false, openFormAdvancedSearch: false,
advancedSearchResults: false, advancedSearchResults: false,
isDoSearch: false, isDoingSearch: false,
sortingMetadata: [], sortingMetadata: [],
isFiltersModalActive: false, isFiltersModalActive: false,
hasAnOpenModal: false, hasAnOpenModal: false,
@ -715,24 +715,11 @@
return this.getMetaKey(); return this.getMetaKey();
}, },
orderByName() { orderByName() {
const metadatumName = this.$orderByHelper.getOrderByMetadatumName({
if (this.getOrderByName() != null && this.getOrderByName() != undefined && this.getOrderByName() != '') { orderby: this.$route.query.orderby,
return this.getOrderByName(); metakey: this.$route.query.metakey
} else { }, this.sortingMetadata);
return this.$route.query.metakey ? metadatumName : this.$i18n.get(metadatumName);
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 '';
}, },
isReadMode () { isReadMode () {
return this.$route && this.$route.query && this.$route.query.readmode; return this.$route && this.$route.query && this.$route.query.readmode;
@ -795,13 +782,8 @@
this.advancedSearchResults = advancedSearchResults; this.advancedSearchResults = advancedSearchResults;
}); });
this.$eventBusSearch.$on('hasToPrepareMetadataAndFilters', (to) => { this.$eventBusSearch.$on('hasToPrepareMetadataAndFilters', () => {
/* This condition is to prevent an incorrect fetch by filter or metadata when we coming from items this.prepareMetadata();
* at collection level to items page at repository level
*/
if (this.collectionId == to.params.collectionId || to.query.fromBreadcrumb) {
this.prepareMetadata();
}
}); });
if (this.$route.query && this.$route.query.advancedSearch) { if (this.$route.query && this.$route.query.advancedSearch) {
@ -884,7 +866,6 @@
'getSearchQuery', 'getSearchQuery',
'getStatus', 'getStatus',
'getOrderBy', 'getOrderBy',
'getOrderByName',
'getOrder', 'getOrder',
'getTotalItems', 'getTotalItems',
'getAdminViewMode', 'getAdminViewMode',
@ -933,7 +914,7 @@
this.$eventBusSearch.setSearchQuery(this.futureSearchQuery); this.$eventBusSearch.setSearchQuery(this.futureSearchQuery);
}, },
onChangeOrderBy(metadatum) { onChangeOrderBy(metadatum) {
this.$eventBusSearch.setOrderBy(metadatum); this.$eventBusSearch.setOrderBy(this.$orderByHelper.getOrderByForMetadatum(metadatum));
this.showItemsHiddingDueSortingDialog(); this.showItemsHiddingDueSortingDialog();
}, },
onChangeOrder(newOrder) { onChangeOrder(newOrder) {
@ -979,7 +960,6 @@
this.$refs.displayedMetadataDropdown.toggle(); this.$refs.displayedMetadataDropdown.toggle();
}, },
prepareMetadata() { prepareMetadata() {
// Cancels previous Request // Cancels previous Request
if (this.metadataSearchCancel != undefined) if (this.metadataSearchCancel != undefined)
this.metadataSearchCancel.cancel('Metadata search Canceled.'); this.metadataSearchCancel.cancel('Metadata search Canceled.');
@ -1178,7 +1158,7 @@
// Loads only basic attributes necessary to view modes that do not allow custom meta // Loads only basic attributes necessary to view modes that do not allow custom meta
} else { } 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, ''); this.$eventBusSearch.addFetchOnly(basicAttributes, true, '');
if (this.isRepositoryLevel) { if (this.isRepositoryLevel) {

View File

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

View File

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

View File

@ -38,7 +38,7 @@
:collection-id="collectionId" :collection-id="collectionId"
:advanced-search-results="advancedSearchResults" :advanced-search-results="advancedSearchResults"
:open-form-advanced-search="openFormAdvancedSearch" :open-form-advanced-search="openFormAdvancedSearch"
:is-do-search="isDoSearch"/> :is-doing-search="isDoingSearch"/>
<div class="advanced-search-form-submit"> <div class="advanced-search-form-submit">
<p <p
@ -54,7 +54,7 @@
class="control"> class="control">
<button <button
aria-controls="items-list-results" aria-controls="items-list-results"
@click="isDoSearch = !isDoSearch" @click="isDoingSearch = !isDoingSearch"
class="button is-success">{{ $i18n.get('search') }}</button> class="button is-success">{{ $i18n.get('search') }}</button>
</p> </p>
</div> </div>
@ -592,6 +592,8 @@
hideGoToPageButton: false, hideGoToPageButton: false,
hidePaginationArea: false, hidePaginationArea: false,
// Other Tweaks // Other Tweaks
defaultOrder: 'ASC',
defaultOrderBy: 'date',
defaultItemsPerPage: Number, defaultItemsPerPage: Number,
showFiltersButtonInsideSearchControl: false, showFiltersButtonInsideSearchControl: false,
startWithFiltersHidden: false, startWithFiltersHidden: false,
@ -613,7 +615,7 @@
openAdvancedSearch: false, openAdvancedSearch: false,
openFormAdvancedSearch: false, openFormAdvancedSearch: false,
advancedSearchResults: false, advancedSearchResults: false,
isDoSearch: false, isDoingSearch: false,
sortingMetadata: [], sortingMetadata: [],
isFiltersModalActive: false, isFiltersModalActive: false,
hasAnOpenModal: false, hasAnOpenModal: false,
@ -665,21 +667,11 @@
return this.getMetaKey(); return this.getMetaKey();
}, },
orderByName() { orderByName() {
const metadatumName = this.$orderByHelper.getOrderByMetadatumName({
if (this.getOrderByName() != null && this.getOrderByName() != undefined && this.getOrderByName() != '') { orderby: this.$route.query.orderby,
return this.getOrderByName(); metakey: this.$route.query.metakey
} else { }, this.sortingMetadata);
for (let metadatum of this.sortingMetadata) { return this.$route.query.metakey ? metadatumName : (metadatumName ? this.$i18n.get(metadatumName) : '');
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 '';
} }
}, },
watch: { watch: {
@ -715,11 +707,16 @@
created() { created() {
this.isRepositoryLevel = (this.collectionId == undefined || this.collectionId == '' || this.collectionId == null); this.isRepositoryLevel = (this.collectionId == undefined || this.collectionId == '' || this.collectionId == null);
// Sets initial variables important to searchbus
if (this.collectionId != undefined) if (this.collectionId != undefined)
this.$eventBusSearch.setCollectionId(this.collectionId); this.$eventBusSearch.setCollectionId(this.collectionId);
if (this.termId != undefined && this.termId != null) if (this.termId != undefined && this.termId != null)
this.$eventBusSearch.setTerm(this.termId, this.taxonomy); 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(); this.$eventBusSearch.updateStoreFromURL();
@ -756,9 +753,6 @@
} }
this.$eventBusSearch.$on('hasToPrepareMetadataAndFilters', () => { 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(); this.prepareMetadata();
}); });
@ -874,7 +868,6 @@
...mapGetters('search', [ ...mapGetters('search', [
'getSearchQuery', 'getSearchQuery',
'getOrderBy', 'getOrderBy',
'getOrderByName',
'getOrder', 'getOrder',
'getViewMode', 'getViewMode',
'getTotalItems', 'getTotalItems',
@ -900,7 +893,7 @@
this.$eventBusSearch.setSearchQuery(this.futureSearchQuery); this.$eventBusSearch.setSearchQuery(this.futureSearchQuery);
}, },
onChangeOrderBy(metadatum) { onChangeOrderBy(metadatum) {
this.$eventBusSearch.setOrderBy(metadatum); this.$eventBusSearch.setOrderBy(this.$orderByHelper.getOrderByForMetadatum(metadatum));
this.showItemsHiddingDueSortingDialog(); this.showItemsHiddingDueSortingDialog();
}, },
onChangeOrder(newOrder) { onChangeOrder(newOrder) {

View File

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

View File

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

View File

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

View File

@ -415,8 +415,10 @@ return apply_filters( 'tainacan-i18n', [
'label_all_terms' => __( 'All terms', 'tainacan' ), 'label_all_terms' => __( 'All terms', 'tainacan' ),
'label_selected_terms' => __( 'Selected terms', 'tainacan' ), 'label_selected_terms' => __( 'Selected terms', 'tainacan' ),
'label_selected_term' => __( 'Selected term', '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_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' ), 'label_all_items_selected' => __( 'All items selected', 'tainacan' ),
/* translators: Here there is a number of items that are selected in this listing */ /* translators: Here there is a number of items that are selected in this listing */
'label_%s_on_this_page' => __( '%s on this page', 'tainacan' ), '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_document_option_is_image' => __( 'Is link to external image', 'tainacan' ),
'label_limit_max_values' => __( 'Limit the amount of multiple values', 'tainacan'), 'label_limit_max_values' => __( 'Limit the amount of multiple values', 'tainacan'),
'label_items_selection' => __( 'Items selection', 'tainacan'), 'label_items_selection' => __( 'Items selection', 'tainacan'),
'label_default_orderby' => __( 'Initial default sorting', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders // Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ), 'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
@ -898,12 +901,13 @@ 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_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_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_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_%s_applied_filters' => __( '<strong>%s</strong> filters applied', 'tainacan'),
'info_items_found' => __( 'items found', 'tainacan'), 'info_items_%s_found' => __( '<strong>%s</strong> items found', 'tainacan'),
'info_applied_filter' => __( 'filter applied', 'tainacan'), 'info_%s_applied_filter' => __( '<strong>%s</strong> filter applied', 'tainacan'),
'info_item_found' => __( 'item found', '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_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_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 */ /* Activity actions */
'action_update-metadata-value' => __( 'Item Metadata Value Updates', 'tainacan'), 'action_update-metadata-value' => __( 'Item Metadata Value Updates', 'tainacan'),