Merge tag '0.20.0' into develop

release 0.20.0
This commit is contained in:
vnmedeiros 2023-03-09 10:56:38 -03:00
commit 2493505d7e
67 changed files with 1689 additions and 723 deletions

48
package-lock.json generated
View File

@ -2031,9 +2031,9 @@
}
},
"apexcharts": {
"version": "3.36.3",
"resolved": "https://registry.npmjs.org/apexcharts/-/apexcharts-3.36.3.tgz",
"integrity": "sha512-8/FXEs0ohXMff07Gv28XjhPwEJphIUdq2/wii/pcvi54Tw6z1mjrV8ydN8rlWi/ve8BAPBefJkLmRWv7UOBsLw==",
"version": "3.37.1",
"resolved": "https://registry.npmjs.org/apexcharts/-/apexcharts-3.37.1.tgz",
"integrity": "sha512-fmQ5Updeb/LASl+S1+mIxXUFxzY0Fa7gexfCs4o+OPP9f2NEBNjvybOtPrah44N4roK7U5o5Jis906QeEQu0cA==",
"requires": {
"svg.draggable.js": "^2.2.2",
"svg.easing.js": "^2.0.0",
@ -2270,9 +2270,9 @@
"dev": true
},
"blurhash": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/blurhash/-/blurhash-2.0.4.tgz",
"integrity": "sha512-r/As72u2FbucLoK5NTegM/GucxJc3d8GvHc4ngo13IO/nt2HU4gONxNLq1XPN6EM/V8Y9URIa7PcSz2RZu553A=="
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/blurhash/-/blurhash-2.0.5.tgz",
"integrity": "sha512-cRygWd7kGBQO3VEhPiTgq4Wc43ctsM+o46urrmPOiuAe+07fzlSB9OJVdpgDL0jPqXUVQ9ht7aq7kxOeJHRK+w=="
},
"body-parser": {
"version": "1.20.0",
@ -2745,9 +2745,9 @@
}
},
"countup.js": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/countup.js/-/countup.js-2.3.2.tgz",
"integrity": "sha512-dQ7F/CmKGjaO6cDfhtEXwsKVlXIpJ89dFs8PvkaZH9jBVJ2Z8GU4iwG/qP7MgY8qwr+1skbwR6qecWWQLUzB8Q=="
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/countup.js/-/countup.js-2.5.0.tgz",
"integrity": "sha512-/59H8Q6wzu6VfHeqGUgXoyh6kgboGr5mALmRKi8YA11DlcaXSnT1PZG6mTyBRLco4ZjExKlmfNHeMbQgZvis9Q=="
},
"cross-env": {
"version": "7.0.3",
@ -3570,9 +3570,9 @@
"dev": true
},
"floating-vue": {
"version": "1.0.0-beta.18",
"resolved": "https://registry.npmjs.org/floating-vue/-/floating-vue-1.0.0-beta.18.tgz",
"integrity": "sha512-mRFc78szc1BTbhlCa4okb7wAGPuH/IID+yqJ+yrTMQ038H8WIAsPV/WFgWCaXqe8d1Z12LkMqiHDVorCJy8M2A==",
"version": "1.0.0-beta.19",
"resolved": "https://registry.npmjs.org/floating-vue/-/floating-vue-1.0.0-beta.19.tgz",
"integrity": "sha512-OcM7z5Ua4XAykqolmvPj3l1s+KqUKj6Xz2t66eqjgaWfNBjtuifmxO5+4rRXakIch/Crt8IH+vKdKcR3jOUaoQ==",
"requires": {
"@floating-ui/dom": "^0.1.10",
"vue-resize": "^1.0.0"
@ -3896,9 +3896,9 @@
"dev": true
},
"http-cache-semantics": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
"integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ=="
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
"integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ=="
},
"http-deceiver": {
"version": "1.2.7",
@ -5133,9 +5133,9 @@
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="
},
"photoswipe": {
"version": "5.3.4",
"resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-5.3.4.tgz",
"integrity": "sha512-SN+RWHqxJvdwzXJsh8KrG+ajjPpdTX5HpKglEd0k9o6o5fW+QHPkW8//Bo11MB+NQwTa/hFw8BDv2EdxiDXjNw=="
"version": "5.3.6",
"resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-5.3.6.tgz",
"integrity": "sha512-v7e8iMfaPUujTACYsK5HBCCtFoW9n2dMZmjIlbvFS2oSpTQmPrfc3PrWnGx8OGY3jNOKho8JC8L277+m+9ag9Q=="
},
"picocolors": {
"version": "1.0.0",
@ -6637,9 +6637,9 @@
},
"dependencies": {
"json5": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
@ -6682,9 +6682,9 @@
},
"dependencies": {
"json5": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"requires": {
"minimist": "^1.2.0"

View File

@ -8,21 +8,21 @@
"build-prod": "cross-env NODE_ENV=production webpack --config webpack.prod.js --progress --mode production"
},
"dependencies": {
"apexcharts": "^3.36.3",
"apexcharts": "^3.37.1",
"axios": "^1.1.3",
"blurhash": "^2.0.4",
"blurhash": "^2.0.5",
"buefy": "^0.9.22",
"bulma": "^0.9.4",
"conditioner-core": "^2.3.3",
"countup.js": "^2.3.2",
"countup.js": "^2.5.0",
"css-vars-ponyfill": "^2.4.8",
"floating-vue": "^1.0.0-beta.18",
"floating-vue": "^1.0.0-beta.19",
"leaflet": "^1.9.3",
"leaflet-active-area": "^1.2.1",
"masonry-layout": "^4.2.2",
"moment": "^2.29.4",
"node-sass": "^7.0.3",
"photoswipe": "^5.3.4",
"photoswipe": "^5.3.6",
"qs": "^6.11.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",

View File

@ -31,7 +31,8 @@
flex-direction: column;
border-radius: 4px;
border: 1px solid rgba(200, 200, 200, 0.3);
overflow: hidden; }
overflow: hidden;
box-sizing: border-box; }
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-text {
background-color: var(--tainacan-label-color, rgba(200, 200, 200, 0.3));
height: 0.25em;
@ -239,12 +240,29 @@
display: flex;
flex-wrap: wrap;
justify-content: flex-start; }
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-steps {
margin-top: 1em;
display: flex;
justify-content: space-evenly;
align-items: center; }
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-steps .fake-step {
width: 1em;
height: 1em;
border-radius: 100%;
background-color: var(--tainacan-input-border-color, rgba(200, 200, 200, 0.3)); }
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-steps .fake-step:first-of-type {
background-color: var(--tainacan-secondary, rgba(200, 200, 200, 0.3)); }
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-steps + .metadata-section {
margin-top: -0.5em;
border: 1px solid var(--tainacan-input-border-color, rgba(200, 200, 200, 0.3));
padding: 2em; }
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .metadata-section {
width: 100%;
padding: 0.5em 1em;
display: flex;
flex-wrap: nowrap;
flex-direction: column; }
flex-direction: column;
box-sizing: border-box; }
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .metadata-section .fake-metadata {
display: flex;
flex-direction: column;

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View File

@ -26,6 +26,10 @@ class REST_Exporters_Controller extends REST_Controller {
add_action('init', array(&$this, 'init_objects'), 11);
}
public function __destruct() {
session_write_close();
}
/**
* Initialize objects after post_type register
*/

View File

@ -11,124 +11,126 @@ use Tainacan\Entities;
*
* */
class REST_Importers_Controller extends REST_Controller {
private $collections_repository;
private $collection;
private $collections_repository;
private $collection;
/**
* REST_Importers_Controller constructor.
* Define the namespace, rest base and instantiate your attributes.
*/
public function __construct(){
$this->rest_base = 'importers';
if (session_status() == PHP_SESSION_NONE) {
@session_start(); // @ avoids Warnings when running phpunit tests
}
$this->rest_base = 'importers';
if (session_status() == PHP_SESSION_NONE) {
@session_start(); // @ avoids Warnings when running phpunit tests
}
parent::__construct();
}
}
public function __destruct() {
session_write_close();
}
/**
* Register the collections route and their endpoints
*/
public function register_routes(){
register_rest_route($this->namespace, '/' . $this->rest_base . '/session', array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array($this, 'create_item'),
'permission_callback' => array($this, 'import_permissions_check'),
'args' => [
'importer_slug' => [
'type' => 'string',
'description' => __( 'The slug of the importer to be initialized', 'tainacan' ),
]
],
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)', array(
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => array($this, 'update_item'),
'permission_callback' => array($this, 'import_permissions_check'),
'args' => [
'url' => [
'type' => 'string',
'description' => __( 'The URL to be used by the importer', 'tainacan' ),
],
'collection' => [
'type' => ['array','object'],
'description' => __( 'The array describing the destination collection as expected by the importer', 'tainacan' ),
],
'options' => [
'type' => ['array', 'object'],
'description' => __( 'The importer options', 'tainacan' ),
]
],
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session', array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array($this, 'create_item'),
'permission_callback' => array($this, 'import_permissions_check'),
'args' => [
'importer_slug' => [
'type' => 'string',
'description' => __( 'The slug of the importer to be initialized', 'tainacan' ),
]
],
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)', array(
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => array($this, 'update_item'),
'permission_callback' => array($this, 'import_permissions_check'),
'args' => [
'url' => [
'type' => 'string',
'description' => __( 'The URL to be used by the importer', 'tainacan' ),
],
'collection' => [
'type' => ['array','object'],
'description' => __( 'The array describing the destination collection as expected by the importer', 'tainacan' ),
],
'options' => [
'type' => ['array', 'object'],
'description' => __( 'The importer options', 'tainacan' ),
]
],
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)/file', array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array($this, 'add_file'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)/source_info', array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'source_info'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)/file', array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array($this, 'add_file'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)/source_info', array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'source_info'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)/get_mapping/(?P<collection_id>[0-9a-f]+)', array(
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)/get_mapping/(?P<collection_id>[0-9a-f]+)', array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_saved_mapping'),
'permission_callback' => array($this, 'import_permissions_check'),
),
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_saved_mapping'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)', array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_item'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)', array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_item'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)/run', array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array($this, 'run'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/session/(?P<session_id>[0-9a-f]+)/run', array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array($this, 'run'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/available', array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_registered_importers'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
register_rest_route($this->namespace, '/' . $this->rest_base . '/available', array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_registered_importers'),
'permission_callback' => array($this, 'import_permissions_check'),
),
));
}
}
/**
@ -139,8 +141,8 @@ class REST_Importers_Controller extends REST_Controller {
* @throws \Exception
*/
public function import_permissions_check($request){
// TODO
return true;
// TODO
return true;
}
/**
@ -159,21 +161,21 @@ class REST_Importers_Controller extends REST_Controller {
], 400);
}
$slug = $body['importer_slug'];
$slug = $body['importer_slug'];
global $Tainacan_Importer_Handler;
global $Tainacan_Importer_Handler;
if ($object = $Tainacan_Importer_Handler->initialize_importer($slug)) {
$response = $object->_to_Array();
if ($object = $Tainacan_Importer_Handler->initialize_importer($slug)) {
$response = $object->_to_Array();
$Tainacan_Importer_Handler->save_importer_instance($object);
return new \WP_REST_Response($response, 201);
} else {
return new \WP_REST_Response([
return new \WP_REST_Response($response, 201);
} else {
return new \WP_REST_Response([
'error_message' => __('Importer not found', 'tainacan'),
], 400);
}
}
}
}
/**
* Update a collection
@ -183,202 +185,202 @@ class REST_Importers_Controller extends REST_Controller {
* @return string|\WP_Error|\WP_REST_Response
*/
public function update_item( $request ) {
$session_id = $request['session_id'];
$body = json_decode($request->get_body(), true);
$session_id = $request['session_id'];
$body = json_decode($request->get_body(), true);
if (!empty($body)) {
$attributes = [];
if (!empty($body)) {
$attributes = [];
foreach ($body as $att => $value){
$attributes[$att] = $value;
}
foreach ($body as $att => $value){
$attributes[$att] = $value;
}
global $Tainacan_Importer_Handler;
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
if ($importer) {
foreach ($body as $att => $value) {
if ($att == 'collection') {
if (is_array($value) && isset($value['id'])) {
if ($importer->add_collection($value) === false ) {
return new \WP_REST_Response([
'error_message' => __('Error while creating metadatum, please review the metadatum description.', 'tainacan' ),
'session_id' => $session_id
], 400);
}
continue;
} else {
return new \WP_REST_Response([
'error_message' => __('Invalid collection', 'tainacan' ),
'session_id' => $session_id
], 400);
}
}
$method = 'set_' . $att;
if (method_exists($importer, $method)) {
$importer->$method($value);
}
}
if ($importer) {
foreach ($body as $att => $value) {
if ($att == 'collection') {
if (is_array($value) && isset($value['id'])) {
if ($importer->add_collection($value) === false ) {
return new \WP_REST_Response([
'error_message' => __('Error while creating metadatum, please review the metadatum description.', 'tainacan' ),
'session_id' => $session_id
], 400);
}
continue;
} else {
return new \WP_REST_Response([
'error_message' => __('Invalid collection', 'tainacan' ),
'session_id' => $session_id
], 400);
}
}
$method = 'set_' . $att;
if (method_exists($importer, $method)) {
$importer->$method($value);
}
}
$response = $importer->_to_Array();
$response = $importer->_to_Array();
$Tainacan_Importer_Handler->save_importer_instance($importer);
return new \WP_REST_Response( $response, 200 );
return new \WP_REST_Response( $response, 200 );
}
}
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
return new \WP_REST_Response([
'error_message' => __('The body cannot be empty', 'tainacan'),
'body' => $body
], 400);
}
return new \WP_REST_Response([
'error_message' => __('The body cannot be empty', 'tainacan'),
'body' => $body
], 400);
}
public function source_info( $request ) {
$session_id = $request['session_id'];
public function source_info( $request ) {
$session_id = $request['session_id'];
global $Tainacan_Importer_Handler;
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
if(!$importer) {
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
if(!$importer) {
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
$response = [
'source_metadata' => false,
'source_total_items' => false,
'source_special_fields' => false
];
$response = [
'source_metadata' => false,
'source_total_items' => false,
'source_special_fields' => false
];
if ( method_exists($importer, 'get_source_metadata') ) {
$response['source_metadata'] = $importer->get_source_metadata();
}
if ( method_exists($importer, 'get_source_metadata') ) {
$response['source_metadata'] = $importer->get_source_metadata();
}
if ( method_exists($importer, 'get_source_number_of_items') ) {
$response['source_total_items'] = $importer->get_source_number_of_items();
}
if ( method_exists($importer, 'get_source_number_of_items') ) {
$response['source_total_items'] = $importer->get_source_number_of_items();
}
if ( method_exists($importer, 'get_source_special_fields') ) {
$response['source_special_fields'] = $importer->get_source_special_fields();
}
$Tainacan_Importer_Handler->save_importer_instance($importer);
return new \WP_REST_Response( $response, 200 );
if ( method_exists($importer, 'get_source_special_fields') ) {
$response['source_special_fields'] = $importer->get_source_special_fields();
}
$Tainacan_Importer_Handler->save_importer_instance($importer);
return new \WP_REST_Response( $response, 200 );
}
}
public function get_saved_mapping( $request ){
$session_id = $request['session_id'];
$collection_id = $request['collection_id'];
public function get_saved_mapping( $request ){
$session_id = $request['session_id'];
$collection_id = $request['collection_id'];
global $Tainacan_Importer_Handler;
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
$response = false;
$response = false;
if(!$importer) {
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
if(!$importer) {
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
if ( method_exists($importer, 'get_mapping') ) {
$response = $importer->get_mapping($collection_id);
}
if ( method_exists($importer, 'get_mapping') ) {
$response = $importer->get_mapping($collection_id);
}
return new \WP_REST_Response( $response, 200 );
}
return new \WP_REST_Response( $response, 200 );
}
public function get_item( $request ) {
$session_id = $request['session_id'];
public function get_item( $request ) {
$session_id = $request['session_id'];
global $Tainacan_Importer_Handler;
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
if(!$importer) {
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
if(!$importer) {
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
$response = $importer->_to_Array();
return new \WP_REST_Response( $response, 200 );
$response = $importer->_to_Array();
return new \WP_REST_Response( $response, 200 );
}
}
public function add_file( $request ) {
$session_id = $request['session_id'];
public function add_file( $request ) {
$session_id = $request['session_id'];
global $Tainacan_Importer_Handler;
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
if(!$importer) {
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
if(!$importer) {
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
$files = $request->get_file_params();
$headers = $request->get_headers();
$files = $request->get_file_params();
$headers = $request->get_headers();
if ( isset($files['file']) && $importer->add_file($files['file']) ) {
$response = $importer->_to_Array();
if ( isset($files['file']) && $importer->add_file($files['file']) ) {
$response = $importer->_to_Array();
$Tainacan_Importer_Handler->save_importer_instance($importer);
return new \WP_REST_Response( $response, 200 );
} else {
return new \WP_REST_Response([
'error_message' => __('Failed to upload file', 'tainacan' ),
'session_id' => $session_id
], 400);
}
return new \WP_REST_Response( $response, 200 );
} else {
return new \WP_REST_Response([
'error_message' => __('Failed to upload file', 'tainacan' ),
'session_id' => $session_id
], 400);
}
}
}
public function run($request) {
$session_id = $request['session_id'];
public function run($request) {
$session_id = $request['session_id'];
global $Tainacan_Importer_Handler;
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
if(!$importer) {
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
if(!$importer) {
return new \WP_REST_Response([
'error_message' => __('Importer Session not found', 'tainacan' ),
'session_id' => $session_id
], 400);
}
global $Tainacan_Importer_Handler;
global $Tainacan_Importer_Handler;
$process = $Tainacan_Importer_Handler->add_to_queue($importer);
$process = $Tainacan_Importer_Handler->add_to_queue($importer);
if (false === $process) {
return new \WP_REST_Response([
'error_message' => __('Error starting importer', 'tainacan' ),
'session_id' => $session_id
], 400);
}
if (false === $process) {
return new \WP_REST_Response([
'error_message' => __('Error starting importer', 'tainacan' ),
'session_id' => $session_id
], 400);
}
$response = [
'bg_process_id' => $process->ID
];
$response = [
'bg_process_id' => $process->ID
];
$Tainacan_Importer_Handler->delete_importer_instance($importer);
return new \WP_REST_Response( $response, 200 );
return new \WP_REST_Response( $response, 200 );
}
}
public function get_registered_importers() {
global $Tainacan_Importer_Handler;
$importers = $Tainacan_Importer_Handler->get_registered_importers();
return new \WP_REST_Response( $importers, 200 );
}
public function get_registered_importers() {
global $Tainacan_Importer_Handler;
$importers = $Tainacan_Importer_Handler->get_registered_importers();
return new \WP_REST_Response( $importers, 200 );
}
}

View File

@ -1388,6 +1388,7 @@ class REST_Items_Controller extends REST_Controller {
if (empty($entities_erros) & $item->validate()) {
$item = $this->items_repository->insert( $item );
delete_transient('tnc_transient_submission_' . $submission_id);
do_action('tainacan-submission-item-finish', $item, $request);
return new \WP_REST_Response($this->prepare_item_for_response($item, $request), 201 );
} else {
$this->submission_rollback_new_terms();

View File

@ -354,37 +354,42 @@ class Media {
}
public function get_image_blurhash($file_path, $width, $height) {
if (
!(version_compare(PHP_VERSION, '7.2.0') >= 0) ||
!$image = @imagecreatefromstring(file_get_contents($file_path))
) {
return $this->get_default_image_blurhash();
}
if($image == false) {
return $this->get_default_image_blurhash();
}
$max_width = 90;
if( $width > $max_width ) {
$image = imagescale($image, $max_width);
$width = imagesx($image);
$height = imagesy($image);
}
$pixels = [];
for ($y = 0; $y < $height; ++$y) {
$row = [];
for ($x = 0; $x < $width; ++$x) {
$index = imagecolorat($image, $x, $y);
$colors = imagecolorsforindex($image, $index);
$row[] = [$colors['red'], $colors['green'], $colors['blue']];
try {
if (
!function_exists('imagecreatefromstring') ||
!(version_compare(PHP_VERSION, '7.2.0') >= 0) ||
!$image = @imagecreatefromstring(file_get_contents($file_path))
) {
return $this->get_default_image_blurhash();
}
$pixels[] = $row;
if($image == false) {
return $this->get_default_image_blurhash();
}
$max_width = 90;
if( $width > $max_width ) {
$image = imagescale($image, $max_width);
$width = imagesx($image);
$height = imagesy($image);
}
$pixels = [];
for ($y = 0; $y < $height; ++$y) {
$row = [];
for ($x = 0; $x < $width; ++$x) {
$index = imagecolorat($image, $x, $y);
$colors = imagecolorsforindex($image, $index);
$row[] = [$colors['red'], $colors['green'], $colors['blue']];
}
$pixels[] = $row;
}
$components_x = 5;
$components_y = 4;
$blurhash = \kornrunner\Blurhash\Blurhash::encode($pixels, $components_x, $components_y);
return $blurhash;
} catch (\Exception $e) {
return $this->get_default_image_blurhash();
}
$components_x = 5;
$components_y = 4;
$blurhash = \kornrunner\Blurhash\Blurhash::encode($pixels, $components_x, $components_y);
return $blurhash;
}
}

View File

@ -182,6 +182,15 @@ class Item_Metadata_Entity extends Entity {
* @return string
*/
public function get_value_as_string() {
$metadatum = $this->get_metadatum();
if (is_object($metadatum)) {
$fto = $metadatum->get_metadata_type_object();
if (is_object($fto)) {
if ( method_exists($fto, 'get_value_as_string') ) {
return $fto->get_value_as_string($this);
}
}
}
return strip_tags($this->get_value_as_html());
}

View File

@ -1130,7 +1130,7 @@ class Item extends Entity {
*
* This function expects a $metadata_section object. For a more generic approach, check the get_metadata_sections_as_html function
*
* @param object $metadata_section The Metadata Section object
* @param \Tainacan\Entities\Metadata_Section $metadata_section The Metadata Section object
* @param array|string $args {
* Optional. Array or string of arguments.
*
@ -1169,6 +1169,17 @@ class Item extends Entity {
$return = '';
if($metadata_section->is_conditional_section()) {
$rules = $metadata_section->get_conditional_section_rules();
$item_id = $this->get_id();
foreach($rules as $meta_id => $meta_values_conditional) {
$meta_values = get_post_meta( $item_id, $meta_id );
if (!array_intersect($meta_values, $meta_values_conditional)) {
return $return;
}
}
}
$defaults = array(
'hide_name' => false,
'hide_description' => true,

View File

@ -18,7 +18,9 @@ class Metadata_Section extends Entity {
$name,
$slug,
$description,
$description_bellow_name;
$description_bellow_name,
$is_conditional_section,
$conditional_section_rules;
/**
* {@inheritDoc}
@ -94,6 +96,34 @@ class Metadata_Section extends Entity {
return $tainacan_metadata_sections->get_metadata_object_list($this->get_id(), $args);
}
/**
* Get if section is conditional.
*
* @return string "yes"|"no"
*/
function get_is_conditional_section() {
return $this->get_mapped_property( 'is_conditional_section' );
}
/**
* get the rules of the conditional section
*
* @return array|object
*/
function get_conditional_section_rules() {
return $this->get_mapped_property( 'conditional_section_rules' );
}
/**
* Checks if section is conditional
*
* @return boolean
*/
function is_conditional_section() {
return $this->get_is_conditional_section() == 'yes';
}
/**
* Set the metadata section name
*
@ -141,6 +171,25 @@ class Metadata_Section extends Entity {
}
/**
* set if section is conditional.
*
* @return void
*/
function set_is_conditional_section($value) {
return $this->set_mapped_property( 'is_conditional_section', $value );
}
/**
* set the rules of the conditional section
*
* @return void
*/
function set_conditional_section_rules($value) {
return $this->set_mapped_property( 'conditional_section_rules', $value );
}
/**
* Transient property used to store the status of the metadatum section for a particular collection
*
@ -168,6 +217,25 @@ class Metadata_Section extends Entity {
$name = $this->get_name();
$collection = $this->get_collection();
if ($this->is_conditional_section()) {
$metadata_section_id = $this->get_id();
if ($metadata_section_id == static::$default_section_slug) {
$this->add_error($this->get_id(), __("conditional section cannot be enabled in default section", 'tainacan'));
$no_errors = false;
} else {
$metadata_list = $this->get_metadata_object_list();
$required_metadata_list = array_filter($metadata_list, function($m) {
return $m->is_required();
});
if ( count($required_metadata_list) ) {
$no_errors = false;
foreach($required_metadata_list as $metadata) {
$this->add_error($metadata->get_id(), __("metadata cannot be required", 'tainacan'));
}
}
}
}
if( empty($collection) ) {
$this->add_error($this->get_id(), __("collection is required", 'tainacan'));
$no_errors = false;

View File

@ -533,6 +533,17 @@ class Metadatum extends Entity {
return false;
}
}
if( $this->is_required() ) {
$meta_section_id = $this->get_metadata_section_id();
if($meta_section_id != \Tainacan\Entities\Metadata_Section::$default_section_slug) {
$meta_section = new \Tainacan\Entities\Metadata_Section($meta_section_id);
if($meta_section->is_conditional_section()) {
$this->add_error($this->get_id(), __('Metadata cannot be required into conditional section', 'tainacan'));
return false;
}
}
}
// You cant have a taxonomy metadatum inside a multiple compound metadatum
if ( $this->get_parent() > 0 && $this->get_metadata_type_object()->get_primitive_type() == 'term' ) {

View File

@ -410,6 +410,9 @@ class Flickr_Importer extends Importer {
case 'type':
$value = $this->get_image_mime_type( $url_image );
break;
default:
continue 2;
}
$metadatum = new \Tainacan\Entities\Metadatum($metadatum_id);
@ -543,8 +546,8 @@ class Flickr_Importer extends Importer {
IMAGETYPE_ICO => "image/ico");
if (function_exists('exif_imagetype')) {
if ( $image_type = exif_imagetype($image_path)
&& array_key_exists($image_type ,$mimes) ) {
$image_type = exif_imagetype($image_path);
if ( $image_type && array_key_exists($image_type ,$mimes) ) {
return $mimes[$image_type];
}
}

View File

@ -933,18 +933,19 @@ abstract class Importer {
$type = $properties[1];
$supported_types = \Tainacan\Repositories\Metadata::get_instance()->fetch_metadata_types('NAME');
$supported_types = array_map('strtolower', $supported_types);
$supported_types_index_of = array_search(strtolower($type), array_map('strtolower', $supported_types));
if ( ! \in_array($type, $supported_types) ) {
if ( $supported_types_index_of === false ) {
// translators: Warning on import logs. Invalid metadata type passed, using text type as fallback. 1 is the invalid type; 2 the name of the metadata. Ex: Unknown Metadata type "Hexadecimal" for Color. Considering text type.
$this->add_log( sprintf(__('Unknown Metadata type "%1$s" for %2$s. Considering text type.', 'tainacan'), $type, $name) );
$type = 'text';
} else {
$type = $supported_types[$supported_types_index_of];
}
$newMetadatum = new Entities\Metadatum();
$newMetadatum->set_name($name);
$type = ucfirst($type);
$newMetadatum->set_metadata_type('Tainacan\Metadata_Types\\'.$type);
$newMetadatum->set_collection_id( (isset($collection_id)) ? $collection_id : 'default');
$newMetadatum->set_status('auto-draft');

View File

@ -94,7 +94,7 @@ class Collections extends Repository {
'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',
'default' => 'date',
//'validation' => v::stringType(),
],
'default_order' => [

View File

@ -76,6 +76,21 @@ class Metadata_Sections extends Repository {
'title' => __( 'Collection', 'tainacan' ),
'type' => ['integer', 'string'],
'description' => __( 'The collection ID', 'tainacan' ),
],
'is_conditional_section' => [
'map' => 'meta',
'title' => __( 'Enable conditional section', 'tainacan' ),
'type' => 'string',
'description' => __( 'Binds this section visibility to a set of rules related to some metadata values.', 'tainacan' ),
'on_error' => __( 'Value should be "yes" or "no"', 'tainacan' ),
'validation' => v::stringType()->in( [ 'yes', 'no' ] ),
'default' => 'no'
],
'conditional_section_rules' => [
'map' => 'meta',
'title' => __( 'Conditional section rules', 'tainacan' ),
'type' => ['object', 'array'],
'description' => __( 'The conditions that will allow this section to be displayed, based on metadata values.', 'tainacan' ),
]
] );
}
@ -378,62 +393,21 @@ class Metadata_Sections extends Repository {
return false;
}
public function get_default_section_metadata_object_list (Entities\Collection $collection, $args = []) {
public function get_default_section_metadata_object_list(Entities\Collection $collection, $args = []) {
$metadata_repository = \Tainacan\Repositories\Metadata::get_instance();
$metadata_sections_ids = $this->fetch_ids();
$collection_metadata_sections_id = array_diff(array_map(function($el) {return $el->get_id();} , $this->fetch_by_collection($collection)), [\Tainacan\Entities\Metadata_Section::$default_section_slug]);
if ( empty($collection_metadata_sections_id) ) {
$not_post_ids = [];
} else {
$args_exclude = array(
'meta_query' => array(
'relation' => 'AND',
array(
array(
'key' => 'collection_id',
'value' => 'default',
'compare' => '='
),
array(
'key' => 'metadata_section_id',
'value' => $collection_metadata_sections_id,
'compare' => 'IN'
)
)
)
);
$list_exclude = $metadata_repository->fetch_by_collection($collection, $args_exclude);
$not_post_ids = array_map(function($el) { return $el->get_id(); }, $list_exclude);
}
$args = array_merge(
$args,
array(
'post__not_in' => $not_post_ids,
'meta_query' => array(
array(
'relation' => 'OR',
array(
'key' => 'metadata_section_id',
'value' => \Tainacan\Entities\Metadata_Section::$default_section_slug,
'compare' => '='
),
array(
'key' => 'metadata_section_id',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'metadata_section_id',
'value' => $metadata_sections_ids,
'compare' => 'NOT IN'
)
)
)
)
);
$metadata_list = $metadata_repository->fetch_by_collection($collection, $args);
$list_all_metadatas = $metadata_repository->fetch_by_collection($collection, $args);
$sections_ids = array_map(function($el) {return $el->get_id();} , $this->fetch_by_collection($collection, ['posts_per_page' => - 1]));
$metadata_list = array_filter($list_all_metadatas, function($meta) use ($sections_ids) {
$metadata_section_id = $meta->get_metadata_section_id();
if( !isset($metadata_section_id) ) return true;
if( !is_array($metadata_section_id) ) {
return $metadata_section_id == \Tainacan\Entities\Metadata_Section::$default_section_slug;
}
$diff = array_filter(array_intersect($sections_ids, $metadata_section_id), function($el) {
return $el != \Tainacan\Entities\Metadata_Section::$default_section_slug;
});
return count( $diff ) == 0;
});
return $metadata_list;
}

View File

@ -25,7 +25,9 @@ class Theme_Helper {
private function __construct() {
add_filter( 'the_content', [$this, 'the_content_filter'] );
if ( !defined('TAINACAN_DISABLE_ITEM_THE_CONTENT_FILTER') || true !== TAINACAN_DISABLE_ITEM_THE_CONTENT_FILTER ) {
add_filter( 'the_content', [$this, 'the_content_filter'] );
}
// Replace collections permalink to post type archive if cover not enabled
add_filter('post_type_link', array($this, 'permalink_filter'), 10, 3);
@ -507,7 +509,7 @@ class Theme_Helper {
$default_order = $args['default_order'];
unset($args['default_order']);
}
$default_orderby = 'date';
if ( isset($args['default_orderby']) ) {
$default_orderby = $args['default_orderby'];
@ -526,7 +528,7 @@ class Theme_Helper {
// Gets hideItemsThumbnail info from collection setting
$args['hide-items-thumbnail'] = $collection->get_hide_items_thumbnail_on_lists() == 'yes' ? true : false;
}
// If in a tainacan taxonomy
$term = tainacan_get_term($args);
if ($term) {

View File

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

View File

@ -4,7 +4,7 @@ Plugin Name: Tainacan
Plugin URI: https://tainacan.org/
Description: Open source, powerful and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional repository platform.
Author: Tainacan.org
Version: 0.19.3
Version: 0.20.0
Requires at least: 5.0
Tested up to: 6.1
Requires PHP: 5.6
@ -14,7 +14,7 @@ License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
const TAINACAN_VERSION = '0.19.3';
const TAINACAN_VERSION = '0.20.0';
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
$TAINACAN_BASE_URL = plugins_url('', __FILE__);

View File

@ -719,7 +719,7 @@ export default {
enabled_view_modes: [],
default_view_mode: [],
default_order: 'ASC',
default_orderby: 'creation_date',
default_orderby: 'date',
allow_comments: 'closed',
allows_submission: 'no',
submission_default_status: 'draft',
@ -756,7 +756,7 @@ export default {
metadataSearchCancel: undefined,
isLoadingMetadata: true,
sortingMetadata: [],
localDefaultOrderBy: 'creation_date'
localDefaultOrderBy: 'date'
}
},
computed: {
@ -1238,7 +1238,8 @@ export default {
'Tainacan\\Metadata_Types\\Taxonomy',
'Tainacan\\Metadata_Types\\Relationship',
'Tainacan\\Metadata_Types\\Compound',
'Tainacan\\Metadata_Types\\User'
'Tainacan\\Metadata_Types\\User',
'Tainacan\\Metadata_Types\\GeoCoordinate'
]
}]
}).then((resp) => {
@ -1251,8 +1252,8 @@ export default {
this.sortingMetadata.push({
name: this.$i18n.get('label_creation_date'),
metadata_type: undefined,
slug: 'creation_date',
id: 'creation_date'
slug: 'date',
id: 'date'
});
// Updates localDefaultOrder variable that needs only the ID of the metadata

View File

@ -372,19 +372,25 @@
<div
v-for="(metadataSection, sectionIndex) of metadataSections"
:key="sectionIndex"
:class="'metadata-section-slug-' + metadataSection.slug"
:id="'metadata-section-id-' + metadataSection.id">
:class="'metadata-section-slug-' + metadataSection.slug + (isSectionHidden(metadataSection.id) ? ' metadata-section-hidden' : '')"
:id="'metadata-section-id-' + metadataSection.id"
v-tooltip="{
content: isSectionHidden(metadataSection.id) ? $i18n.get('info_metadata_section_hidden_conditional') : false,
autoHide: true,
placement: 'auto',
popperClass: ['tainacan-tooltip', 'tooltip']
}">
<div class="metadata-section-header section-label">
<span
class="collapse-handle"
@click="(isMetadataNavigation || $adminOptions.hideItemEditionCollapses) ? null : toggleMetadataSectionCollapse(sectionIndex)">
@click="(isMetadataNavigation || $adminOptions.hideItemEditionCollapses || isSectionHidden(metadataSection.id)) ? null : toggleMetadataSectionCollapse(sectionIndex)">
<span
v-if="!$adminOptions.hideItemEditionCollapses && !isMetadataNavigation"
class="icon">
<i
:class="{
'tainacan-icon-arrowdown' : metadataSectionCollapses[sectionIndex] || errorMessage,
'tainacan-icon-arrowright' : !(metadataSectionCollapses[sectionIndex] || errorMessage)
'tainacan-icon-arrowdown' : (metadataSectionCollapses[sectionIndex] || errorMessage) && !isSectionHidden(metadataSection.id),
'tainacan-icon-arrowright' : !(metadataSectionCollapses[sectionIndex] || errorMessage) || isSectionHidden(metadataSection.id)
}"
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
@ -409,7 +415,7 @@
<transition name="filter-item">
<div
class="metadata-section-metadata-list"
v-show="metadataSectionCollapses[sectionIndex] || isMetadataNavigation">
v-show="(metadataSectionCollapses[sectionIndex] || isMetadataNavigation) && !isSectionHidden(metadataSection.id)">
<p
class="metadatum-description-help-info"
v-if="metadataSection.description && metadataSection.description_bellow_name == 'yes'">
@ -852,6 +858,9 @@ export default {
formErrors() {
return eventBusItemMetadata && eventBusItemMetadata.errors && eventBusItemMetadata.errors.length ? eventBusItemMetadata.errors : []
},
conditionalSections() {
return eventBusItemMetadata && eventBusItemMetadata.conditionalSections ? eventBusItemMetadata.conditionalSections : [];
},
isEditingItemMetadataInsideIframe() {
return this.$route.query && this.$route.query.editingmetadata;
},
@ -1016,6 +1025,25 @@ export default {
.then((metadataSections) => {
this.metadataSectionCollapses = Array(metadataSections.length).fill(true)
this.isLoadingMetadataSections = false;
/**
* Creates the conditional metadata set to later watch values
* of certain metadata that control sections visibility.
*/
eventBusItemMetadata.conditionalSections = {};
for (let metadataSection of metadataSections) {
if ( metadataSection.is_conditional_section == 'yes') {
const conditionalSectionId = Object.keys(metadataSection.conditional_section_rules);
if ( conditionalSectionId.length ) {
eventBusItemMetadata.conditionalSections[metadataSection.id] = {
sectionId: metadataSection.id,
metadatumId: conditionalSectionId[0],
metadatumValues: metadataSection.conditional_section_rules[conditionalSectionId[0]],
hide: true
};
}
}
}
})
.catch((error) => {
this.isLoadingMetadataSections = false;
@ -1284,6 +1312,16 @@ export default {
this.metadataCollapses[i] = true;
}
}
/* Sets initial state for conditional sections based on metadatum values */
for (let conditionalSectionId in this.conditionalSections) {
const currentItemMetadatum = metadata.find(anItemMetadatum => anItemMetadatum.metadatum.id == this.conditionalSections[conditionalSectionId].metadatumId);
if (currentItemMetadatum) {
const itemMetadatumValues = Array.isArray(currentItemMetadatum.value) ? currentItemMetadatum.value : [ currentItemMetadatum.value ];
const conditionalValues = Array.isArray(eventBusItemMetadata.conditionalSections[conditionalSectionId].metadatumValues) ? eventBusItemMetadata.conditionalSections[conditionalSectionId].metadatumValues : [eventBusItemMetadata.conditionalSections[conditionalSectionId].metadatumValues];
eventBusItemMetadata.conditionalSections[conditionalSectionId].hide = itemMetadatumValues.every(aValue => conditionalValues.indexOf(aValue) < 0);
}
}
this.isLoading = false;
});
@ -1591,6 +1629,9 @@ export default {
},
onChangeCollapse(event, index) {
if (event && !this.metadataCollapses[index] && this.itemMetadata[index].metadatum && this.itemMetadata[index].metadatum['metadata_type'] === "Tainacan\\Metadata_Types\\GeoCoordinate")
eventBusItemMetadata.$emit('itemEditionFormResize');
this.metadataCollapses.splice(index, 1, event);
},
toggleMetadataSectionCollapse(sectionIndex) {
@ -1800,6 +1841,9 @@ export default {
webkit.messageHandlers.cordova_iab
)
webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify({ 'type': 'exited_from_navigation', 'item': this.item }));
},
isSectionHidden(sectionId) {
return this.conditionalSections[sectionId] && this.conditionalSections[sectionId].hide;
}
}
}
@ -2122,6 +2166,15 @@ export default {
border-bottom: 1px solid var(--tainacan-input-border-color);
}
.metadata-section-hidden {
opacity: 0.5;
filter: grayscale(1.0);
& > {
pointer-events: none;
}
}
.item-edition-tab-content {
border-top: 1px solid var(--tainacan-input-border-color);
}

View File

@ -122,6 +122,93 @@
</b-field>
</div>
<div
@click="hideConditionalSectionSettings = !hideConditionalSectionSettings;"
class="metadata-form-section">
<span class="icon">
<i
class="tainacan-icon"
:class="!hideConditionalSectionSettings ? 'tainacan-icon-arrowdown' : 'tainacan-icon-arrowright'" />
</span>
<strong>{{ $i18n.get('label_advanced_metadata_options') }}</strong>
<hr>
</div>
<transition name="filter-item">
<div
v-show="!hideConditionalSectionSettings"
class="options-columns">
<b-field
:addons="false"
:label="$i18n.getHelperTitle('metadata-sections', 'is_conditional_section')"
:type="formErrors['is_conditional_section'] != undefined ? 'is-danger' : ''"
:message="formErrors['is_conditional_section'] != undefined ? formErrors['is_conditional_section'] : ''">
&nbsp;
<b-switch
size="is-small"
@input="clearErrors('is_conditional_section')"
v-model="form.is_conditional_section"
true-value="yes"
false-value="no"
name="is_conditional_section">
<help-button
:title="$i18n.getHelperTitle('metadata-sections', 'is_conditional_section')"
:message="$i18n.getHelperMessage('metadata-sections', 'is_conditional_section')"
:extra-classes="isRepositoryLevel ? 'tainacan-repository-tooltip' : ''" />
</b-switch>
</b-field>
<div v-if="isConditionalSection && !availableConditionalMetadata.length">
<p style="break-inside: avoid;">{{ $i18n.get('info_create_select_metadatum_for_conditional_section') }}</p>
</div>
<transition name="filter-item">
<b-field
v-if="isConditionalSection && availableConditionalMetadata.length"
:addons="false"
:type="formErrors['conditional_section_rules'] != undefined ? 'is-danger' : ''"
:message="formErrors['conditional_section_rules'] != undefined ? formErrors['conditional_section_rules'] : ''">
<label class="label is-inline">
{{ $i18n.getHelperTitle('metadata-sections', 'conditional_section_rules') }}
<help-button
:title="$i18n.getHelperTitle('metadata-sections', 'conditional_section_rules')"
:message="$i18n.getHelperMessage('metadata-sections', 'conditional_section_rules')"
:extra-classes="isRepositoryLevel ? 'tainacan-repository-tooltip' : ''" />
</label>
<b-select
v-model="selectedConditionalMetadatum"
:placeholder="$i18n.get('label_select_metadatum')">
<option
v-for="conditionalMetadatum of availableConditionalMetadata"
:key="conditionalMetadatum.id"
:value="conditionalMetadatum.id">
{{ conditionalMetadatum.name }}
</option>
</b-select>
</b-field>
</transition>
<transition name="filter-item">
<b-field
v-if="isConditionalSection && selectedConditionalMetadatum"
:addons="false"
:type="formErrors['conditional_section_rules'] != undefined ? 'is-danger' : ''"
:message="formErrors['conditional_section_rules'] != undefined ? formErrors['conditional_section_rules'] : ''">
<label class="label is-inline">
{{ availableConditionalMetadata.find((availableMetadatum) => availableMetadatum.id == selectedConditionalMetadatum).name }}
</label>
<div style="overflow-y: auto; overflow-x: hidden; max-height: 100px;">
<b-checkbox
v-model="selectedConditionalValue"
v-for="(conditionalValue, conditionalValueIndex) of availableConditionalMetadata.find((availableMetadatum) => availableMetadatum.id == selectedConditionalMetadatum).metadata_type_object.options.options.split('\n')"
:key="conditionalValueIndex"
:native-value="conditionalValue">
{{ conditionalValue }}
</b-checkbox>
</div>
</b-field>
</transition>
</div>
</transition>
<!-- Hook for extra Form options -->
<template v-if="hasEndLeftForm" >
@ -156,7 +243,7 @@
</template>
<script>
import { mapActions } from 'vuex';
import { mapActions, mapGetters } from 'vuex';
import { formHooks } from "../../js/mixins";
export default {
@ -166,7 +253,7 @@
index: '',
originalMetadataSection: Object,
collectionId: '',
isInsideImporterFlow: false
isInsideImporterFlow: false,
},
data() {
return {
@ -175,7 +262,28 @@
formErrorMessage: '',
closedByForm: false,
entityName: 'metadataSection',
isUpdating: false
isUpdating: false,
selectedConditionalMetadatum: undefined,
selectedConditionalValue: [],
hideConditionalSectionSettings: false
}
},
computed: {
...mapGetters('metadata', [
'getMetadataSections'
]),
availableConditionalMetadata() {
if (this.getMetadataSections.length) {
const otherMetadataSections = this.getMetadataSections.filter(aMetadataSection => aMetadataSection.id != this.form.id);
const availableMetadata = [];
for (let aMetadataSection of otherMetadataSections)
availableMetadata.push.apply(availableMetadata, aMetadataSection.metadata_object_list);
return availableMetadata.filter(aMetadatum => aMetadatum.metadata_type === 'Tainacan\\Metadata_Types\\Selectbox');
}
return {};
},
isConditionalSection() {
return this.form.is_conditional_section == 'yes';
}
},
created() {
@ -184,6 +292,12 @@
if (this.form.status == 'auto-draft')
this.form.status = 'publish';
if ( this.form.is_conditional_section == 'yes' && Object.keys(this.form.conditional_section_rules).length ) {
const conditionalMetadatum = Object.keys(this.form.conditional_section_rules)[0];
this.selectedConditionalMetadatum = conditionalMetadatum;
this.selectedConditionalValue = this.form.conditional_section_rules[conditionalMetadatum];
}
this.formErrors = this.form.formErrors != undefined ? this.form.formErrors : {};
this.formErrorMessage = this.form.formErrors != undefined ? this.form.formErrorMessage : '';
},
@ -200,79 +314,40 @@
]),
saveEdition(metadataSection) {
if ( (metadataSection.metadata_type_object && metadataSection.metadata_type_object.form_component) || metadataSection.edit_form == '') {
if ( this.form.is_conditional_section == 'yes' && this.selectedConditionalMetadatum && this.selectedConditionalValue ) {
this.form.conditional_section_rules = {}
this.form.conditional_section_rules[this.selectedConditionalMetadatum] = this.selectedConditionalValue;
} else
this.form.conditional_section_rules = null;
this.fillExtraFormData(this.form);
this.isUpdating = true;
this.updateMetadataSection({
collectionId: this.collectionId,
metadataSectionId: metadataSection.id,
index: this.index,
options: this.form
this.fillExtraFormData(this.form);
this.isUpdating = true;
this.updateMetadataSection({
collectionId: this.collectionId,
metadataSectionId: metadataSection.id,
index: this.index,
options: this.form
})
.then(() => {
this.form = {};
this.formErrors = {};
this.formErrorMessage = '';
this.isUpdating = false;
this.closedByForm = true;
this.$emit('onEditionFinished');
})
.then(() => {
this.form = {};
this.formErrors = {};
this.formErrorMessage = '';
this.isUpdating = false;
this.closedByForm = true;
.catch((errors) => {
this.isUpdating = false;
for (let error of errors.errors) {
for (let attribute of Object.keys(error))
this.formErrors[attribute] = error[attribute];
}
this.formErrorMessage = errors.error_message;
this.$emit('onEditionFinished');
})
.catch((errors) => {
this.isUpdating = false;
for (let error of errors.errors) {
for (let attribute of Object.keys(error))
this.formErrors[attribute] = error[attribute];
}
this.formErrorMessage = errors.error_message;
this.form.formErrors = this.formErrors;
this.form.formErrorMessage = this.formErrorMessage;
});
} else {
let formElement = document.getElementById('metadataSectionEditForm');
let formData = new FormData(formElement);
let formObj = {};
for (let [key, value] of formData.entries()) {
if (key === 'description_bellow_name')
formObj[key] = value ? 'yes' : 'no';
else
formObj[key] = value;
}
this.fillExtraFormData(formObj);
this.isUpdating = true;
this.updateMetadataSection({
collectionId: this.collectionId,
metadataSectionId: metadataSection.id,
index: this.index,
options: formObj
})
.then(() => {
this.form = {};
this.formErrors = {};
this.formErrorMessage = '';
this.isUpdating = false;
this.closedByForm = true;
this.$emit('onEditionFinished');
})
.catch((errors) => {
this.isUpdating = false;
for (let error of errors.errors) {
for (let attribute of Object.keys(error))
this.formErrors[attribute] = error[attribute];
}
this.formErrorMessage = errors.error_message;
this.$emit('onErrorFound');
this.form.formErrors = this.formErrors;
this.form.formErrorMessage = this.formErrorMessage;
});
}
this.form.formErrors = this.formErrors;
this.form.formErrorMessage = this.formErrorMessage;
});
},
clearErrors(attribute) {
this.formErrors[attribute] = undefined;

View File

@ -416,7 +416,7 @@
},
watch: {
showCardinalityOptions() {
this.form.cardinality = !this.showCardinalityOptions ? 1 : 2;
this.form.cardinality = !this.showCardinalityOptions ? 1 : Number(this.form.cardinality);
}
},
created() {
@ -425,7 +425,7 @@
if (this.form.status == 'auto-draft')
this.form.status = 'publish';
if (this.form.cardinality && this.form.cardinality > 1)
if (this.form.cardinality && Number(this.form.cardinality) > 1)
this.showCardinalityOptions = true;
this.formErrors = this.form.formErrors != undefined ? this.form.formErrors : {};

View File

@ -1585,6 +1585,27 @@
</option>
</b-select>
</div>
<section
v-else
class="section">
<div class="content has-text-grey has-text-centered">
<p style="margin-bottom: 0px">
<span class="icon is-large">
<i>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="var(--tainacan-info-color, #555758)"
width="2.875em"
height="2.875em">
<path d="M15,19L9,16.89V5L15,7.11M20.5,3C20.44,3 20.39,3 20.34,3L15,5.1L9,3L3.36,4.9C3.15,4.97 3,5.15 3,5.38V20.5A0.5,0.5 0 0,0 3.5,21C3.55,21 3.61,21 3.66,20.97L9,18.9L15,21L20.64,19.1C20.85,19 21,18.85 21,18.62V3.5A0.5,0.5 0 0,0 20.5,3Z" />
</svg>
</i>
</span>
</p>
<p>{{ $i18n.get('info_empty_geocoordinate_metadata_list') }}</p>
</div>
</section>
</div>
</l-control>
<l-control
@ -1784,7 +1805,11 @@
v-for="(column, metadatumIndex) in displayedMetadata"
:key="metadatumIndex"
:class="{ 'metadata-type-textarea': column.metadata_type_object != undefined && column.metadata_type_object.component == 'tainacan-textarea' }"
v-if="renderMetadata(item.metadata, column) != '' && column.display && column.slug != 'thumbnail' && column.metadata_type_object != undefined && (column.metadata_type_object.related_mapped_prop != 'title')">
v-if="renderMetadata(item.metadata, column) != '' &&
column.display && column.slug != 'thumbnail' &&
column.metadata_type_object != undefined &&
(column.metadata_type_object.related_mapped_prop != 'title') &&
(column.metadata_type != 'Tainacan\\Metadata_Types\\GeoCoordinate')">
<h3 class="metadata-label">{{ column.name }}</h3>
<p
v-html="renderMetadata(item.metadata, column)"

View File

@ -342,7 +342,7 @@
this.sendMetadatum({
collectionId: this.collectionId,
name: newMetadatum.name,
metadatumType: newMetadatum.className,
metadatumType: newMetadatum.className ? newMetadatum.className : newMetadatum.metadata_type,
status: 'auto-draft',
isRepositoryLevel: this.isRepositoryLevel,
newIndex: newIndex,
@ -417,6 +417,9 @@
this.updateMetadataOrder();
},
isAvailableChildMetadata(to, from, item) {
if (from.el && from.el.className === 'active-metadata-area')
return false;
return !['tainacan-compound', 'tainacan-taxonomy'].includes(item.id);
},
isCollapseOpen(metadatumId) {

View File

@ -234,7 +234,7 @@ class Compound extends Metadata_Type {
if ($meta instanceof Item_Metadata_Entity && !empty($meta->get_value_as_html())) {
ob_start();
?>
<div class="tainacan-metadatum">
<div class="tainacan-metadatum metadata-type-<?php echo $meta->get_metadatum()->get_metadata_type_object()->get_slug() ?>">
<h4 class="label">
<?php echo esc_html($meta->get_metadatum()->get_name()); ?>
</h4>

View File

@ -3,7 +3,7 @@
<b-input
:id="'tainacan-item-metadatum_id-' + itemMetadatum.metadatum.id + (itemMetadatum.parent_meta_id ? ('_parent_meta_id-' + itemMetadatum.parent_meta_id) : '')"
:disabled="disabled"
:class="{'is-danger': isInvalidDate && dateValue}"
:custom-class="{ 'is-danger': isInvalidDate && dateValue }"
type="text"
v-mask="dateMask"
v-model="dateValue"
@ -51,6 +51,11 @@
isInvalidDate: false,
}
},
computed: {
isOnItemSubmissionForm() {
return !this.itemMetadatum.item || !this.itemMetadatum.item.id;
},
},
created() {
if (this.value)
this.dateValue = this.parseDateToNavigatorLanguage(this.value);
@ -66,14 +71,20 @@
else if ($event.target.value && $event.target.value.length === this.dateMask.length)
dateISO = moment($event.target.value, this.dateFormat).toISOString(true) ? moment($event.target.value, this.dateFormat).toISOString(true).split('T')[0] : false;
if (dateISO == false){
if (dateISO == false) {
this.isInvalidDate = true;
return;
if (!this.isOnItemSubmissionForm)
this.$emit('input', false);
else
this.$emit('input', this.dateValue) // On item submission form we keep the error here to allow the server to return the correct format.
} else {
this.isInvalidDate = false;
this.$emit('input', dateISO);
}
this.$emit('input', dateISO);
} else {
this.$emit('input', '');
}

View File

@ -46,7 +46,7 @@
v-model="initialZoom"
@input="emitValues()"
:step="1"
:max="21"
:max="19"
:min="1" />
</b-field>
@ -64,7 +64,7 @@
v-model="maximumZoom"
@input="emitValues()"
:step="1"
:max="21"
:max="19"
:min="1" />
</b-field>

View File

@ -175,19 +175,16 @@
}
},
watch: {
selectedLatLng: {
handler() {
this.$nextTick(() => {
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
if ( this.selectedLatLng.length && this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject ) {
if (this.selectedLatLng.length == 1)
this.$refs[mapComponentRef].mapObject.panInsideBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
else
this.$refs[mapComponentRef].mapObject.flyToBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
}
});
},
immediate: true
selectedLatLng() {
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
this.$nextTick(() => {
if ( this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject && this.selectedLatLng.length != undefined) {
if (this.selectedLatLng.length == 1)
this.$refs[mapComponentRef].mapObject.panInsideBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
else
this.$refs[mapComponentRef].mapObject.flyToBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
}
});
}
},
created() {
@ -201,12 +198,10 @@
eventBusItemMetadata.$on('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef));
},
mounted() {
setTimeout(() => {
this.$nextTick(() => {
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
this.handleWindowResize(mapComponentRef);
});
}, 500);
this.$nextTick(() => {
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
this.handleWindowResize(mapComponentRef);
});
},
beforeDestroy() {
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
@ -318,8 +313,18 @@
this.$emit('input', this.selected);
},
handleWindowResize(mapComponentRef) {
if ( this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject )
this.$refs[mapComponentRef].mapObject.invalidateSize(true);
setTimeout(() => {
if ( this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject ) {
this.$refs[mapComponentRef].mapObject.invalidateSize(true);
if ( this.selectedLatLng.length != undefined) {
if (this.selectedLatLng.length == 1)
this.$refs[mapComponentRef].mapObject.panInsideBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
else
this.$refs[mapComponentRef].mapObject.flyToBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
}
}
}, 500);
}
}
}
@ -366,7 +371,7 @@
border-radius: 0px !important;
height: 100% !important;
line-height: 1.7rem;
background-color: var(--tainacan-background-color, #fff) !important;
background-color: var(--tainacan-input-background-color, #fff) !important;
}
}
}

View File

@ -31,7 +31,7 @@ class GeoCoordinate extends Metadata_Type {
$this->set_preview_template('
<div>
<div class="control">
!!POINT IN MAP!!
<img src="' . plugin_dir_url( __FILE__ ) . '/../../../../../../assets/images/geocoordinate_preview.png" alt="' . __('Image of a marker in a map.' , 'tainacan' ) . '" />
</div>
</div>
');
@ -89,6 +89,36 @@ class GeoCoordinate extends Metadata_Type {
}
return true;
}
/**
* Return the value of an Item_Metadata_Entity using a metadatum of this metadatum type as a string
* @param Item_Metadata_Entity $item_metadata
* @return string The String representation of the value, containing one or multiple items names, linked to the item page
*/
public function get_value_as_string(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
$return = '';
if ( $item_metadata->is_multiple() ) {
$prefix = $item_metadata->get_multivalue_prefix();
$suffix = $item_metadata->get_multivalue_suffix();
$separator = $item_metadata->get_multivalue_separator();
$total = count($value);
$count = 0;
foreach ($value as $v) {
$return .= $prefix;
$return .= (string) $v;
$return .= $suffix;
$count ++;
if ($count < $total)
$return .= $separator;
}
} else {
$return = (string) $value;
}
return $return;
}
/**
* Get the value as a HTML string with proper date format set in admin
@ -107,7 +137,7 @@ class GeoCoordinate extends Metadata_Type {
$metadatum = $item_metadata->get_metadatum();
$item_metadatum_id = $metadatum->get_id();
$item_metadatum_id .= $metadatum->get_parent() ? ( $metadatum->get_parent() . '_parent_meta_id-') : '';
$item_metadatum_id .= ( $metadatum->get_parent() && $item_metadata->get_parent_meta_id() ) ? ( '_parent_meta_id-' . $item_metadata->get_parent_meta_id() ) : '';
$zoom_geo_query = isset($options['initial_zoom']) ? ('z=' . $options['initial_zoom'] ) : '' ;
$return = '';

View File

@ -201,7 +201,7 @@ export default {
li {
height: $subheader-height;
a {
color: var(--tainacan-white);
color: var(--tainacan-white) !important;
white-space: nowrap;
overflow: hidden;
padding: 8px 15px;

View File

@ -233,7 +233,7 @@ export default {
a {
background-color: var(--tainacan-turquoise4);
transition: color 0.2s ease;
color: var(--tainacan-white);
color: var(--tainacan-white) !important;
text-decoration: none;
}
svg {
@ -249,7 +249,7 @@ export default {
}
}
a {
color: var(--tainacan-white);
color: var(--tainacan-white) !important;;
text-align: center;
white-space: nowrap;
padding: 6px 11px;

View File

@ -10,7 +10,6 @@ const i18nGet = function (key) {
};
export const tainacanErrorHandler = function(error) {
console.error(error)
if (error.response && error.response.status) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx

View File

@ -4,7 +4,8 @@ import store from './store/store'
export const eventBusItemMetadata = new Vue({
store,
data: {
errors : []
errors : [],
conditionalSections: {}
},
watch: {
errors() {
@ -72,7 +73,7 @@ export const eventBusItemMetadata = new Vue({
} else {
if (values.length > 0 && values[0] != undefined && values[0].value) {
let onlyValues = values.map((aValueObject) => aValueObject.value);
const onlyValues = values.map((aValueObject) => aValueObject.value);
values = JSON.parse(JSON.stringify(onlyValues));
}
@ -83,19 +84,24 @@ export const eventBusItemMetadata = new Vue({
parent_id: parentId
});
let index = this.errors.findIndex( errorItem => errorItem.metadatum_id == metadatumId && (parentMetaId ? errorItem.parent_meta_id == parentMetaId : true ));
let messages = [];
if ( index >= 0) {
Vue.set( this.errors, index, { metadatum_id: metadatumId, parent_meta_id: parentMetaId, errors: messages });
this.$emit('updateErrorMessageOf#' + (parentMetaId ? metadatumId + '-' + parentMetaId : metadatumId), this.errors[index]);
} else {
this.errors.push( { metadatum_id: metadatumId, parent_meta_id: parentMetaId, errors: messages } );
this.$emit('updateErrorMessageOf#' + (parentMetaId ? metadatumId + '-' + parentMetaId : metadatumId), this.errors[0]);
}
// In the item submission, we don't want to block submission or clear errors before a re-submission is performed,
// as the validation depends on a single server-side request. Thus, we do not update error arary here.
this.$emit('isUpdatingValue', false);
}
/**
* Updates conditionalSections set values if this is one of the
* metadata with values that affect the sections visibility.
*/
let updatedConditionalSections = JSON.parse(JSON.stringify(this.conditionalSections));
for (let conditionalSectionId in updatedConditionalSections) {
if ( updatedConditionalSections[conditionalSectionId].metadatumId == metadatumId ) {
const conditionalValues = Array.isArray(updatedConditionalSections[conditionalSectionId].metadatumValues) ? updatedConditionalSections[conditionalSectionId].metadatumValues : [ this.conditionalSections[conditionalSectionId].metadatumValues ];
updatedConditionalSections[conditionalSectionId].hide = values.every(aValue => conditionalValues.indexOf(aValue) < 0);
}
}
this.conditionalSections = updatedConditionalSections;
},
removeItemMetadataGroup({ itemId, metadatumId, parentMetaId, parentMetadatum }) {

View File

@ -75,14 +75,14 @@ export default {
this.$userPrefs.set(orderKey, 'DESC');
}
}
// 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 orderBy = this.$userPrefs.get(orderByKey) ? this.$userPrefs.get(orderByKey) : this.defaultOrderBy;
if (orderBy && orderBy != 'name') {
// Previously was stored as a metadata object, now it is a orderby object
if (orderBy.slug || typeof orderBy == 'string')
orderBy = this.$orderByHelper.getOrderByForMetadatum(orderBy);
@ -101,6 +101,8 @@ export default {
name: this.$i18n.get('label_creation_date')
}).catch(() => { });
}
} else if ( this.$route.query.orderby == 'creation_date' ) { // Fixes old usage of creation_date
this.$route.query.orderby = 'date'
}
// Theme View Modes

View File

@ -390,7 +390,7 @@ export const submitItemSubmission = ({ commit }, { itemSubmission, itemSubmissio
export const finishItemSubmission = ({ commit }, { itemSubmission, fakeItemId }) => {
return new Promise((resolve, reject) => {
let config = {
headers: { 'content-type': 'multipart/form-data' }
headers: { 'Content-Type': 'multipart/form-data' }
}
const formData = new FormData();

View File

@ -707,7 +707,7 @@ export default {
}
}
this.availableMetadata = availableMetadata.filter((aMetadatum) => aMetadatum.metadata_type_object.component != 'tainacan-compound');
this.availableMetadata = availableMetadata.filter((aMetadatum) => aMetadatum.metadata_type_object.component != 'tainacan-compound' && aMetadatum.metadata_type_object.component != 'tainacan-geocoordinate');
},
onChangeEnable($event, index) {
let filtersOrder = [];

View File

@ -1099,7 +1099,7 @@
display = true;
// Deciding display based on user prefs
if (prefsFetchOnlyMetaObject.length) {
if (prefsFetchOnlyMetaObject.length && metadatum.display != 'yes') {
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
display = index >= 0;

View File

@ -162,10 +162,10 @@
color: transparent !important;
}
a,
a:hover,
a:focus,
a:hover:not([href]) {
a:not(.wp-element-button),
a:not(.wp-element-button):hover,
a:not(.wp-element-button):focus,
a:not(.wp-element-button):hover:not([href]) {
color: var(--tainacan-secondary);
}
a:not([href])

View File

@ -30,7 +30,7 @@
/deep/ .leaflet-marker-pane {
filter: hue-rotate(-22deg);
}
/deep/ div.tainacan-metadatum.metadata-type-geocoordinate,
/deep/ span[data-module="geocoordinate-item-metadatum"],
/deep/ span[data-module="geocoordinate-item-metadatum"]+br {
display: none;
@ -54,6 +54,7 @@
}
.geocoordinate-panel--input {
color: var(--tainacan-label-color);
display: flex;
align-items: center;
flex-wrap: wrap;

View File

@ -1,14 +1,12 @@
const { SVG, Path } = wp.components;
const { SVG, Path } = wp.components;
export default (
export default (
<SVG
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
height="24px"
width="24px">
<Path
fill="#298596"
d="M21.43,14.64,19.32,17a2.57,2.57,0,0,1-2,1H12.05a6,6,0,0,0-6-6H6V10.64A2.59,2.59,0,0,1,8.59,8H17.3a2.57,2.57,0,0,1,2,1l2.11,2.38A2.59,2.59,0,0,1,21.43,14.64ZM4,4A2,2,0,0,0,2,6v7.63a5.74,5.74,0,0,1,2-1.2V6H16V4ZM7,15.05v6.06l3.06-3.06ZM5,21.11V15.05L1.94,18.11Z"/>
<Path d="M21.43,14.64,19.32,17a2.57,2.57,0,0,1-2,1H12.05a6,6,0,0,0-6-6H6V10.64A2.59,2.59,0,0,1,8.59,8H17.3a2.57,2.57,0,0,1,2,1l2.11,2.38A2.59,2.59,0,0,1,21.43,14.64ZM4,4A2,2,0,0,0,2,6v7.63a5.74,5.74,0,0,1,2-1.2V6H16V4ZM7,15.05v6.06l3.06-3.06ZM5,21.11V15.05L1.94,18.11Z"/>
</SVG>
);
);

View File

@ -6,9 +6,7 @@
viewBox="0 0 24 24"
height="24px"
width="24px">
<Path
fill="#298596"
d="M14,2V4H7v7.24A5.33,5.33,0,0,0,5.5,11a4.07,4.07,0,0,0-.5,0V4A2,2,0,0,1,7,2Zm7,10v8a2,2,0,0,1-2,2H12l1-1-2.41-2.41A5.56,5.56,0,0,0,11,16.53a5.48,5.48,0,0,0-2-4.24V8a2,2,0,0,1,2-2h4Zm-2.52,0L14,7.5V12ZM11,21l-1,1L8.86,20.89,8,20H8l-.57-.57A3.42,3.42,0,0,1,5.5,20a3.5,3.5,0,0,1-.5-7,2.74,2.74,0,0,1,.5,0,3.41,3.41,0,0,1,1.5.34,3.5,3.5,0,0,1,2,3.16,3.42,3.42,0,0,1-.58,1.92L9,19H9l.85.85Zm-4-4.5A1.5,1.5,0,0,0,5.5,15a1.39,1.39,0,0,0-.5.09A1.5,1.5,0,0,0,5.5,18a1.48,1.48,0,0,0,1.42-1A1.5,1.5,0,0,0,7,16.53Z"/>
<Path d="M14,2V4H7v7.24A5.33,5.33,0,0,0,5.5,11a4.07,4.07,0,0,0-.5,0V4A2,2,0,0,1,7,2Zm7,10v8a2,2,0,0,1-2,2H12l1-1-2.41-2.41A5.56,5.56,0,0,0,11,16.53a5.48,5.48,0,0,0-2-4.24V8a2,2,0,0,1,2-2h4Zm-2.52,0L14,7.5V12ZM11,21l-1,1L8.86,20.89,8,20H8l-.57-.57A3.42,3.42,0,0,1,5.5,20a3.5,3.5,0,0,1-.5-7,2.74,2.74,0,0,1,.5,0,3.41,3.41,0,0,1,1.5.34,3.5,3.5,0,0,1,2,3.16,3.42,3.42,0,0,1-.58,1.92L9,19H9l.85.85Zm-4-4.5A1.5,1.5,0,0,0,5.5,15a1.39,1.39,0,0,0-.5.09A1.5,1.5,0,0,0,5.5,18a1.48,1.48,0,0,0,1.42-1A1.5,1.5,0,0,0,7,16.53Z"/>
</SVG>
);

View File

@ -9,7 +9,6 @@ export default (
<G transform="matrix(0.2891908,0,0,0.2891908,-30.465367,-38.43427)">
<Path
transform="matrix(0.26458333,0,0,0.26458333,104.32258,131.88168)"
fill="#298596"
d="M 16.662109,14.712891 V 24.927734 H 84.753906 V 14.712891 Z m 6.810547,17.021484 v 9.748047 c 6.857764,2.272819 11.798639,8.605281 11.798828,16.078125 -7.56e-4,2.313298 -0.496344,4.586348 -1.421875,6.693359 l 8.375,8.375 -3.365234,3.367188 H 77.945312 V 31.734375 Z m 17.019532,10.216797 h 20.429687 v 10.21289 H 40.492188 Z m -22.835938,3.84375 a 9.1779065,9.1779065 0 0 0 -0.916016,0.03906 11.753475,11.753475 0 0 0 1.671875,23.445313 11.455635,11.455635 0 0 0 6.466797,-1.910156 l 1.908203,1.910156 2.88086,2.982422 3.820312,3.716797 3.347657,-3.347657 -3.851563,-3.855468 -2.847656,-2.845703 -1.941407,-1.941407 a 11.455635,11.455635 0 0 0 1.941407,-6.433593 11.723603,11.723603 0 0 0 -6.697266,-10.583985 11.422139,11.422139 0 0 0 -5.027344,-1.136719 9.1779065,9.1779065 0 0 0 -0.755859,-0.03906 z m 0.755859,6.736328 a 5.0244015,5.0244015 0 0 1 5.027344,5.025391 v 0.101562 a 5.0244015,5.0244015 0 0 1 -0.269531,1.570313 4.9574094,4.9574094 0 0 1 -4.757813,3.351562 5.0244015,5.0244015 0 0 1 -1.671875,-9.746094 4.6559456,4.6559456 0 0 1 1.671875,-0.302734 z m 6.376953,20.601562 c -0.431168,0.183308 -0.872311,0.335613 -1.316406,0.484376 v 2.378906 h 4.179688 z "/>
</G>
</SVG>

View File

@ -154,9 +154,18 @@
v-else
class="section">
<div class="content has-text-grey has-text-centered">
<p>
<p style="margin-bottom: 0px">
<span class="icon is-large">
<i class="tainacan-icon tainacan-icon-30px tainacan-icon-public" />
<i>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="var(--tainacan-info-color, #555758)"
width="2.875em"
height="2.875em">
<path d="M15,19L9,16.89V5L15,7.11M20.5,3C20.44,3 20.39,3 20.34,3L15,5.1L9,3L3.36,4.9C3.15,4.97 3,5.15 3,5.38V20.5A0.5,0.5 0 0,0 3.5,21C3.55,21 3.61,21 3.66,20.97L9,18.9L15,21L20.64,19.1C20.85,19 21,18.85 21,18.62V3.5A0.5,0.5 0 0,0 20.5,3Z" />
</svg>
</i>
</span>
</p>
<p>{{ $i18n.get('info_empty_geocoordinate_metadata_list') }}</p>
@ -291,7 +300,11 @@
v-for="(column, metadatumIndex) in displayedMetadata"
:key="metadatumIndex"
:class="{ 'metadata-type-textarea': column.metadata_type_object.component == 'tainacan-textarea' }"
v-if="renderMetadata(item, column) != '' && column.display && column.slug != 'thumbnail' && column.metadata_type_object != undefined && (column.metadata_type_object.related_mapped_prop != 'title')">
v-if="renderMetadata(item, column) != '' &&
column.display && column.slug != 'thumbnail' &&
column.metadata_type_object != undefined &&
(column.metadata_type_object.related_mapped_prop != 'title') &&
(column.metadata_type != 'Tainacan\\Metadata_Types\\GeoCoordinate') ">
<h3 class="metadata-label">{{ column.name }}</h3>
<p
v-html="renderMetadata(item, column)"

View File

@ -769,7 +769,7 @@
},
computed: {
isSortingByCustomMetadata() {
return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'date' && this.orderBy != 'modified');
return (this.orderBy != undefined && this.orderBy != '' && this.orderBy != 'title' && this.orderBy != 'creation_date' && this.orderBy != 'date' && this.orderBy != 'modified');
},
items() {
return this.getItems();
@ -863,6 +863,7 @@
this.$eventBusSearch.setOrder(this.defaultOrder);
}
if (this.defaultOrderBy != undefined) {
if (this.defaultOrderByMeta || this.defaultOrderByType) {
let orderByObject = { orderby: this.defaultOrderBy }
@ -1278,7 +1279,7 @@
display = true;
// Deciding display based on user prefs
if (prefsFetchOnlyMetaObject.length) {
if (prefsFetchOnlyMetaObject.length && metadatum.display != 'yes') {
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
display = index >= 0;

View File

@ -226,12 +226,14 @@ 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)
if (this.$el.attributes['default-orderby'] != undefined) {
this.defaultOrderBy = this.maybeConvertFromJSON(this.$el.attributes['default-orderby'].value);
this.defaultOrderBy === 'creation_date' ? 'date' : this.defaultOrderBy;
}
if (this.$el.attributes['default-orderby-meta'] != undefined)
this.defaultOrderByMeta = this.$el.attributes['default-orderby-meta'].value;
if (this.$el.attributes['default-orderby-type'] != undefined)

View File

@ -6,9 +6,7 @@
viewBox="0 0 24 24"
height="24px"
width="24px">
<Path
fill="#298596"
d="M21.43,13.64,19.32,16a2.57,2.57,0,0,1-2,1H11a3.91,3.91,0,0,0,0-.49,5.49,5.49,0,0,0-5-5.47V9.64A2.59,2.59,0,0,1,8.59,7H17.3a2.57,2.57,0,0,1,2,1l2.11,2.38A2.59,2.59,0,0,1,21.43,13.64ZM4,3A2,2,0,0,0,2,5v7.3a5.32,5.32,0,0,1,2-1V5H16V3ZM11,21l-1,1L8.86,20.89,8,20H8l-.57-.57A3.42,3.42,0,0,1,5.5,20a3.5,3.5,0,0,1,0-7,2.74,2.74,0,0,1,.5,0A3.5,3.5,0,0,1,9,16a2.92,2.92,0,0,1,0,.51,3.42,3.42,0,0,1-.58,1.92L9,19H9l.85.85Zm-4-4.5A1.5,1.5,0,1,0,5.5,18,1.5,1.5,0,0,0,7,16.53Z"/>
<Path d="M21.43,13.64,19.32,16a2.57,2.57,0,0,1-2,1H11a3.91,3.91,0,0,0,0-.49,5.49,5.49,0,0,0-5-5.47V9.64A2.59,2.59,0,0,1,8.59,7H17.3a2.57,2.57,0,0,1,2,1l2.11,2.38A2.59,2.59,0,0,1,21.43,13.64ZM4,3A2,2,0,0,0,2,5v7.3a5.32,5.32,0,0,1,2-1V5H16V3ZM11,21l-1,1L8.86,20.89,8,20H8l-.57-.57A3.42,3.42,0,0,1,5.5,20a3.5,3.5,0,0,1,0-7,2.74,2.74,0,0,1,.5,0A3.5,3.5,0,0,1,9,16a2.92,2.92,0,0,1,0,.51,3.42,3.42,0,0,1-.58,1.92L9,19H9l.85.85Zm-4-4.5A1.5,1.5,0,1,0,5.5,18,1.5,1.5,0,0,0,7,16.53Z"/>
</SVG>
);

View File

@ -6,9 +6,7 @@
viewBox="0 0 24 24"
height="24px"
width="24px">
<Path
d="m 6,3.9960001 h 5.016 c 0.544,0 1.008,0.192 1.392,0.576 L 19.416,11.58 c 0.384,0.384 0.576,0.856 0.576,1.416 0,0.56 -0.192,1.032 -0.576,1.416 l -4.992,4.992 c -0.176,0.176 -0.392,0.32 -0.648,0.432 -0.24,0.112 -0.496,0.168 -0.768,0.168 -0.272,0 -0.536,-0.056 -0.792,-0.168 -0.24,-0.112 -0.448,-0.256 -0.624,-0.432 L 4.608,12.42 c -0.4,-0.4 -0.6,-0.872 -0.6,-1.416 V 5.988 C 4.008,5.428 4.2,4.956 4.584,4.572 4.968,4.188 5.44,3.996 6,3.9960001 Z m 1.512,4.992 c 0.416,0 0.768,-0.144 1.056,-0.432 C 8.856,8.2680001 9,7.916 9,7.5 9,7.084 8.856,6.732 8.568,6.444 8.28,6.14 7.928,5.988 7.512,5.988 7.096,5.988 6.736,6.14 6.432,6.444 6.144,6.732 6,7.084 6,7.5 c 0,0.416 0.144,0.7680001 0.432,1.0560001 0.304,0.288 0.664,0.432 1.08,0.432 z"
/>
<Path d="m 6,3.9960001 h 5.016 c 0.544,0 1.008,0.192 1.392,0.576 L 19.416,11.58 c 0.384,0.384 0.576,0.856 0.576,1.416 0,0.56 -0.192,1.032 -0.576,1.416 l -4.992,4.992 c -0.176,0.176 -0.392,0.32 -0.648,0.432 -0.24,0.112 -0.496,0.168 -0.768,0.168 -0.272,0 -0.536,-0.056 -0.792,-0.168 -0.24,-0.112 -0.448,-0.256 -0.624,-0.432 L 4.608,12.42 c -0.4,-0.4 -0.6,-0.872 -0.6,-1.416 V 5.988 C 4.008,5.428 4.2,4.956 4.584,4.572 4.968,4.188 5.44,3.996 6,3.9960001 Z m 1.512,4.992 c 0.416,0 0.768,-0.144 1.056,-0.432 C 8.856,8.2680001 9,7.916 9,7.5 9,7.084 8.856,6.732 8.568,6.444 8.28,6.14 7.928,5.988 7.512,5.988 7.096,5.988 6.736,6.14 6.432,6.444 6.144,6.732 6,7.084 6,7.5 c 0,0.416 0.144,0.7680001 0.432,1.0560001 0.304,0.288 0.664,0.432 1.08,0.432 z" />
</SVG>
);

View File

@ -43,7 +43,7 @@ export default (element) => {
const attribution = element.hasAttribute('data-attribution') ? element.getAttribute('data-attribution') : '&copy; <a target="_blank" href="http://osm.org/copyright">OpenStreetMap</a> contributors';
const initial_zoom = element.hasAttribute('data-initial_zoom') ? element.getAttribute('data-initial_zoom') : 5;
const maximum_zoom = element.hasAttribute('data-maximum_zoom') ? element.getAttribute('data-maximum_zoom') : 12;
TainacanLeaflet.tileLayer(map_provider, {
attribution: attribution,
zoom: initial_zoom,

View File

@ -13,140 +13,144 @@
},
"attributes": {
"collectionId": {
"type": "String",
"type": "string",
"default": ""
},
"isCollectionModalOpen": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideFileModalButton": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideTextModalButton": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideLinkModalButton": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideThumbnailSection": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideAttachmentsSection": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideHelpButtons": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideMetadataTypes": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"showAllowCommentsSection": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"hideCollapses": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"backgroundColor": {
"type": "String",
"type": "string",
"default": "rgba(255,255,255,0)"
},
"baseFontSize": {
"type": "Number",
"type": "number",
"default": 16
},
"inputColor": {
"type": "String",
"type": "string",
"default": "#1d1d1d"
},
"inputBackgroundColor": {
"type": "String",
"type": "string",
"default": "#ffffff"
},
"inputBorderColor": {
"type": "String",
"type": "string",
"default": "#dbdbdb"
},
"labelColor": {
"type": "String",
"type": "string",
"default": "#454647"
},
"infoColor": {
"type": "String",
"type": "string",
"default": "#555758"
},
"primaryColor": {
"type": "String",
"type": "string",
"default": "#d9eced"
},
"secondaryColor": {
"type": "String",
"type": "string",
"default": "#298596"
},
"enabledMetadata": {
"type": "Array",
"type": "array",
"default": []
},
"collectionMetadata": {
"type": "Array",
"type": "array",
"default": []
},
"isLoadingCollectionMetadata": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"sentFormHeading": {
"type": "String",
"type": "string",
"default": "Form submitted!"
},
"sentFormMessage": {
"type": "String",
"type": "string",
"default": "Thank you. Your item was submitted to the collection."
},
"documentSectionLabel": {
"type": "String",
"type": "string",
"default": "Document"
},
"attachmentsSectionLabel": {
"type": "String",
"type": "string",
"default": "Attachments"
},
"thumbnailSectionLabel": {
"type": "String",
"type": "string",
"default": "Thumbnail"
},
"metadataSectionLabel": {
"type": "String",
"type": "string",
"default": "Metadata"
},
"showItemLinkButton": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"itemLinkButtonLabel": {
"type": "String",
"type": "string",
"default": "Go to the item page"
},
"helpInfoBellowLabel": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"showTermsAgreementCheckbox": {
"type": "Boolean",
"type": "boolean",
"default": false
},
"termsAgreementMessage": {
"type": "String",
"type": "string",
"default": "I agree to submit this item information."
},
"isLayoutSteps": {
"type": "boolean",
"default": false
}
},
"supports": {

View File

@ -2,6 +2,235 @@ const { __ } = wp.i18n;
const { RichText, useBlockProps } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
export default [
/* Deprecated on Tainacan 0.20.0, due to isLayoutSteps */
{
"attributes": {
"collectionId": {
"type": "String",
"default": ""
},
"isCollectionModalOpen": {
"type": "Boolean",
"default": false
},
"hideFileModalButton": {
"type": "Boolean",
"default": false
},
"hideTextModalButton": {
"type": "Boolean",
"default": false
},
"hideLinkModalButton": {
"type": "Boolean",
"default": false
},
"hideThumbnailSection": {
"type": "Boolean",
"default": false
},
"hideAttachmentsSection": {
"type": "Boolean",
"default": false
},
"hideHelpButtons": {
"type": "Boolean",
"default": false
},
"hideMetadataTypes": {
"type": "Boolean",
"default": false
},
"showAllowCommentsSection": {
"type": "Boolean",
"default": false
},
"hideCollapses": {
"type": "Boolean",
"default": false
},
"backgroundColor": {
"type": "String",
"default": "rgba(255,255,255,0)"
},
"baseFontSize": {
"type": "Number",
"default": 16
},
"inputColor": {
"type": "String",
"default": "#1d1d1d"
},
"inputBackgroundColor": {
"type": "String",
"default": "#ffffff"
},
"inputBorderColor": {
"type": "String",
"default": "#dbdbdb"
},
"labelColor": {
"type": "String",
"default": "#454647"
},
"infoColor": {
"type": "String",
"default": "#555758"
},
"primaryColor": {
"type": "String",
"default": "#d9eced"
},
"secondaryColor": {
"type": "String",
"default": "#298596"
},
"enabledMetadata": {
"type": "Array",
"default": []
},
"collectionMetadata": {
"type": "Array",
"default": []
},
"isLoadingCollectionMetadata": {
"type": "Boolean",
"default": false
},
"sentFormHeading": {
"type": "String",
"default": "Form submitted!"
},
"sentFormMessage": {
"type": "String",
"default": "Thank you. Your item was submitted to the collection."
},
"documentSectionLabel": {
"type": "String",
"default": "Document"
},
"attachmentsSectionLabel": {
"type": "String",
"default": "Attachments"
},
"thumbnailSectionLabel": {
"type": "String",
"default": "Thumbnail"
},
"metadataSectionLabel": {
"type": "String",
"default": "Metadata"
},
"showItemLinkButton": {
"type": "Boolean",
"default": false
},
"itemLinkButtonLabel": {
"type": "String",
"default": "Go to the item page"
},
"helpInfoBellowLabel": {
"type": "Boolean",
"default": false
},
"showTermsAgreementCheckbox": {
"type": "Boolean",
"default": false
},
"termsAgreementMessage": {
"type": "String",
"default": "I agree to submit this item information."
}
},
save({ attributes, className }) {
const {
collectionId,
backgroundColor,
hideFileModalButton,
hideTextModalButton,
hideLinkModalButton,
hideThumbnailSection,
hideAttachmentsSection,
showAllowCommentsSection,
hideHelpButtons,
hideMetadataTypes,
hideCollapses,
documentSectionLabel,
thumbnailSectionLabel,
attachmentsSectionLabel,
metadataSectionLabel,
baseFontSize,
inputColor,
inputBackgroundColor,
inputBorderColor,
labelColor,
infoColor,
primaryColor,
secondaryColor,
enabledMetadata,
sentFormHeading,
sentFormMessage,
showItemLinkButton,
itemLinkButtonLabel,
helpInfoBellowLabel,
showTermsAgreementCheckbox,
termsAgreementMessage
} = attributes;
const blockProps = useBlockProps.save();
let termsAgreementMessageHTML = <RichText.Content { ...blockProps } tagName="p" value={ termsAgreementMessage } />;
termsAgreementMessageHTML = (termsAgreementMessageHTML && termsAgreementMessageHTML.props && termsAgreementMessageHTML.props.value) ? termsAgreementMessageHTML.props.value : '';
if (backgroundColor.rgb != undefined) {
if (backgroundColor.rgb.a)
backgroundColor = 'rgba(' + backgroundColor.rgb.r + ',' + backgroundColor.rgb.g + ',' + backgroundColor.rgb.b + ',' + backgroundColor.rgb.a + ')';
else
backgroundColor = 'rgb(' + backgroundColor.rgb.r + ',' + backgroundColor.rgb.g + ',' + backgroundColor.rgb.b + ')';
}
return <div
style={{
'font-size': baseFontSize + 'px',
'--tainacan-base-font-size': baseFontSize + 'px',
'--tainacan-background-color': backgroundColor,
'--tainacan-input-color': inputColor,
'--tainacan-input-background-color': inputBackgroundColor,
'--tainacan-input-border-color': inputBorderColor,
'--tainacan-label-color': labelColor,
'--tainacan-info-color': infoColor,
'--tainacan-primary': primaryColor,
'--tainacan-secondary': secondaryColor
}}
className={ className }>
<div
id="tainacan-item-submission-form"
data-module="item-submission-form"
collection-id={ collectionId }
hide-file-modal-button={ hideFileModalButton.toString() }
hide-text-modal-button={ hideTextModalButton.toString() }
hide-link-modal-button={ hideLinkModalButton.toString() }
hide-thumbnail-section={ hideThumbnailSection.toString() }
hide-attachments-section={ hideAttachmentsSection.toString() }
show-allow-comments-section={ showAllowCommentsSection.toString() }
hide-help-buttons={ hideHelpButtons.toString() }
hide-metadata-types={ hideMetadataTypes.toString() }
hide-collapses={ hideCollapses.toString() }
enabled-metadata={ enabledMetadata.toString() }
sent-form-heading={ sentFormHeading }
sent-form-message={ sentFormMessage }
document-section-label={ documentSectionLabel }
thumbnail-section-label={ thumbnailSectionLabel }
attachments-section-label={ attachmentsSectionLabel }
metadata-section-label={ metadataSectionLabel }
show-item-link-button={ showItemLinkButton ? showItemLinkButton.toString() : 'false' }
show-terms-agreement-checkbox={ showTermsAgreementCheckbox ? showTermsAgreementCheckbox.toString() : 'false' }
terms-agreement-message={ termsAgreementMessageHTML }
item-link-button-label={ itemLinkButtonLabel ? itemLinkButtonLabel : __( 'Go to the item page', 'tainacan' ) }
help-info-bellow-label={ helpInfoBellowLabel ? helpInfoBellowLabel.toString() : 'false' } >
</div>
</div>
}
},
/* Deprecated on Tainacan 0.18.8, due to the backgroundColor being a string instead of object */
{
"attributes": {

View File

@ -56,7 +56,8 @@ export default function ({ attributes, setAttributes, className }) {
itemLinkButtonLabel,
helpInfoBellowLabel,
showTermsAgreementCheckbox,
termsAgreementMessage
termsAgreementMessage,
isLayoutSteps
} = attributes;
const blockProps = useBlockProps();
@ -280,6 +281,16 @@ export default function ({ attributes, setAttributes, className }) {
<PanelBody
title={__('Form elements', 'tainacan')}
initialOpen={ true } >
<ToggleControl
label={__('Show metadata sections as steps on the form.', 'tainacan')}
help={ isLayoutSteps ? __('Do not show the metadata sections as separate steps of the form.', 'tainacan') : __('Toggle to show the metadata sections as steps of the form.', 'tainacan')}
checked={ isLayoutSteps }
onChange={ ( isChecked ) => {
isLayoutSteps = isChecked;
setAttributes({ isLayoutSteps: isChecked });
}
}
/>
<ToggleControl
label={__('Hide the Document type file button', 'tainacan')}
help={ hideFileModalButton ? __('Do not show the button for uploading a file document', 'tainacan') : __('Toggle to show the button to upload a file document.', 'tainacan')}
@ -646,8 +657,17 @@ export default function ({ attributes, setAttributes, className }) {
<div style={{ flexGrow: '1' }}>
{ metadataSectionLabel ?
<div class="fake-text section-label"></div>
:null }
{ !hideCollapses ? <div class="fake-link"></div> : null }
: null }
{ !hideCollapses && !isLayoutSteps ?
<div class="fake-link"></div>
: null }
{ isLayoutSteps ?
<div class="fake-steps">
<div class="fake-step"/>
<div class="fake-step"/>
<div class="fake-step"/>
</div>
: null }
<div class="metadata-section">
{ enabledMetadata.length ?
enabledMetadata.map( (isEnabled) => {

View File

@ -4,6 +4,7 @@
:is-full-page="false"
:active.sync="isLoading"
:can-cancel="false"/>
<template v-if="couldLoadCollection && collecionAllowsItemSubmission">
<form
v-if="!hasSentForm"
@ -400,7 +401,7 @@
</div>
<a
v-if="!hideCollapses"
v-if="!showSteppedLayout && !hideCollapses"
class="collapse-all"
@click="toggleCollapseAll()">
{{ collapseAll ? $i18n.get('label_collapse_all') : $i18n.get('label_expand_all') }}
@ -416,89 +417,111 @@
v-if="hasBeforeHook('metadata')"
class="item-submission-hook item-submission-hook-metadata-before"
v-html="getBeforeHook('metadata')" />
<div
v-for="(metadataSection, sectionIndex) of metadataSections"
:key="sectionIndex"
:class="'metadata-section-slug-' + metadataSection.slug"
:id="'metadata-section-id-' + metadataSection.id">
<div class="metadata-section-header section-label">
<span
class="collapse-handle"
@click="!hideCollapses ? toggleMetadataSectionCollapse(sectionIndex) : ''">
<span
v-if="!hideCollapses"
class="icon"
@click="toggleMetadataSectionCollapse(sectionIndex)">
<i
:class="{
'tainacan-icon-arrowdown' : metadataSectionCollapses[sectionIndex] || formErrorMessage,
'tainacan-icon-arrowright' : !(metadataSectionCollapses[sectionIndex] || formErrorMessage)
}"
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
<label>{{ metadataSection.name }}</label>
<help-button
v-if="!hideHelpButtons &&
!helpInfoBellowLabel &&
metadataSection.description"
:title="metadataSection.name"
:message="metadataSection.description" />
</span>
</div>
<transition name="filter-item">
<component
v-if="metadataSections.length"
:is="showSteppedLayout ? 'b-steps' : 'div'"
v-model="activeSectionStep"
:has-navigation="false"
type="is-secondary"
mobile-mode="compact"
size="is-small"
ref="item-submission-steps-layout">
<component
:is="showSteppedLayout ? 'b-step-item' : 'div'"
v-for="(metadataSection, sectionIndex) of metadataSections"
:key="sectionIndex"
:step="sectionIndex + 1"
:label="metadataSection.name"
:label-position="'right'"
:clickable="true"
:class="'metadata-section-slug-' + metadataSection.slug + (!showSteppedLayout && isSectionHidden(metadataSection.id) ? ' metadata-section-hidden' : '')"
:id="'metadata-section-id-' + metadataSection.id"
v-tooltip="{
content: !showSteppedLayout && isSectionHidden(metadataSection.id) ? $i18n.get('info_metadata_section_hidden_conditional') : false,
autoHide: true,
placement: 'auto',
popperClass: ['tainacan-tooltip', 'tooltip']
}">
<div
class="metadata-section-metadata-list"
v-show="metadataSectionCollapses[sectionIndex]">
<!-- JS-side hook for extra content -->
<div
v-if="hasBeforeHook('metadata_section')"
class="item-submission-hook item-submission-hook-metadata-section-before"
v-html="getBeforeHook('metadata_section', { metadataSection: metadataSection, sectionIndex: sectionIndex })" />
<p
class="metadatum-description-help-info"
v-if="metadataSection.description && (!hideHelpButtons && helpInfoBellowLabel)">
{{ metadataSection.description }}
</p>
<template v-if="itemMetadata && Array.isArray(itemMetadata)">
<template v-for="(itemMetadatum, index) of itemMetadata.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)">
<!-- JS-side hook for extra content -->
<div
:key="index"
v-if="hasBeforeHook('metadatum')"
class="item-submission-hook item-submission-hook-metadatum-before"
v-html="getBeforeHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
<tainacan-form-item
:key="index"
v-if="enabledMetadata[index] == 'true'"
:item-metadatum="itemMetadatum"
:hide-collapses="hideCollapses"
:is-collapsed="metadataCollapses[index]"
@changeCollapse="onChangeCollapse($event, index)"/>
<!-- JS-side hook for extra content -->
<div
:key="index"
v-if="hasAfterHook('metadatum')"
class="item-submission-hook item-submission-hook-metadatum-after"
v-html="getAfterHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
</template>
</template>
<!-- JS-side hook for extra content -->
<div
v-if="hasAfterHook('metadata_section')"
class="item-submission-hook item-submission-hook-metadata-section-after"
v-html="getAfterHook('metadata_section', { metadataSection: metadataSection, sectionIndex: sectionIndex })" />
v-if="!showSteppedLayout"
class="metadata-section-header section-label">
<span
class="collapse-handle"
@click="!hideCollapses && !isSectionHidden(metadataSection.id) ? toggleMetadataSectionCollapse(sectionIndex) : ''">
<span
v-if="!hideCollapses"
class="icon"
@click="toggleMetadataSectionCollapse(sectionIndex)">
<i
:class="{
'tainacan-icon-arrowdown' : (metadataSectionCollapses[sectionIndex] || formErrorMessage) && !isSectionHidden(metadataSection.id),
'tainacan-icon-arrowright' : !(metadataSectionCollapses[sectionIndex] || formErrorMessage) || isSectionHidden(metadataSection.id)
}"
class="has-text-secondary tainacan-icon tainacan-icon-1-25em"/>
</span>
<label>{{ metadataSection.name }}</label>
<help-button
v-if="!hideHelpButtons &&
!helpInfoBellowLabel &&
metadataSection.description"
:title="metadataSection.name"
:message="metadataSection.description" />
</span>
</div>
</transition>
<transition name="filter-item">
<div
class="metadata-section-metadata-list"
v-show="metadataSectionCollapses[sectionIndex] && (showSteppedLayout || !isSectionHidden(metadataSection.id))">
</div>
<!-- JS-side hook for extra content -->
<div
v-if="hasBeforeHook('metadata_section')"
class="item-submission-hook item-submission-hook-metadata-section-before"
v-html="getBeforeHook('metadata_section', { metadataSection: metadataSection, sectionIndex: sectionIndex })" />
<p
class="metadatum-description-help-info"
v-if="metadataSection.description && (!hideHelpButtons && helpInfoBellowLabel)">
{{ metadataSection.description }}
</p>
<template v-if="itemMetadata && Array.isArray(itemMetadata)">
<template v-for="(itemMetadatum, index) of itemMetadata.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)">
<!-- JS-side hook for extra content -->
<div
:key="index"
v-if="hasBeforeHook('metadatum')"
class="item-submission-hook item-submission-hook-metadatum-before"
v-html="getBeforeHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
<tainacan-form-item
:key="index"
v-if="enabledMetadata[index] == 'true'"
:item-metadatum="itemMetadatum"
:hide-collapses="hideCollapses"
:is-collapsed="metadataCollapses[index]"
@changeCollapse="onChangeCollapse($event, index)"/>
<!-- JS-side hook for extra content -->
<div
:key="index"
v-if="hasAfterHook('metadatum')"
class="item-submission-hook item-submission-hook-metadatum-after"
v-html="getAfterHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
</template>
</template>
<!-- JS-side hook for extra content -->
<div
v-if="hasAfterHook('metadata_section')"
class="item-submission-hook item-submission-hook-metadata-section-after"
v-html="getAfterHook('metadata_section', { metadataSection: metadataSection, sectionIndex: sectionIndex })" />
</div>
</transition>
</component>
</component>
<!-- JS-side hook for extra content -->
<div
@ -514,6 +537,41 @@
v-html="getEndRightForm"/>
</template>
<!-- Form errors area -->
<div
v-if="formErrorMessage"
class="form-error-area is-danger">
<div class="form-error-area-icon">
<a class="help-button has-text-danger">
<span class="icon">
<i class="tainacan-icon tainacan-icon-alertcircle" />
</span>
</a>
</div>
<div class="form-error-area-messages">
<strong>{{ formErrorMessage }}</strong>
<template v-if="formErrors.length && formErrors[0].errors && formErrors[0].errors.length">
<p>{{ $i18n.get('instruction_click_error_to_go_to_metadata') }}</p>
<ol>
<template v-for="(error, index) of formErrors">
<li
v-if="error.errors.length"
:key="index">
<a
v-if="['thumbnail', 'attachments', 'document'].includes(error.metadatum_id) || metadataElements[error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : '')]"
class="has-text-danger"
@click="goToErrorMetadatum(error)">
{{ getErrorMessage(error.errors) }}
</a>
<p v-else>{{ getErrorMessage(error.errors) }}</p>
</li>
</template>
</ol>
</template>
</div>
</div>
<!-- Google reCAPTCHA -->
<template v-if="useCaptcha == 'yes'">
<div
@ -543,30 +601,52 @@
class="item-submission-hook item-submission-hook-footer-before"
v-html="getBeforeHook('footer')" />
<button
@click="onDiscard()"
type="button"
class="button is-outlined">{{ $i18n.get('cancel') }}</button>
<!-- Updated and Error Info -->
<div class="update-info-section">
<p class="footer-message">
<span class="help is-danger">
{{ formErrorMessage }}
<item-metadatum-errors-tooltip
v-if="formErrors.length && formErrors[0].errors && formErrors[0].errors.length"
:form-errors="formErrors" />
</span>
</p>
<div
class="wp-block-buttons"
style="gap: 1rem;">
<div
class="wp-block-button is-style-outline"
style="margin-right: auto;">
<button
@click="onDiscard()"
type="button"
class="wp-block-button__link wp-element-button">
{{ $i18n.get('cancel') }}
</button>
</div>
<div
v-if="showSteppedLayout && activeSectionStep > 0"
class="wp-block-button">
<button
@click="onPreviousStep()"
type="button"
class="wp-block-button__link wp-element-button">
{{ $i18n.get('previous') }}
</button>
</div>
<div
v-if="showSteppedLayout && activeSectionStep < metadataSections.length - 1"
class="wp-block-button">
<button
@click="onNextStep()"
type="button"
class="wp-block-button__link wp-element-button">
{{ $i18n.get('next') }}
</button>
</div>
<div
v-if="!showSteppedLayout || activeSectionStep == metadataSections.length - 1"
class="wp-block-button">
<button
:disabled="showTermsAgreementCheckbox && !userHasAgreedToTerms"
@click="onSubmit()"
type="button"
class="wp-block-button__link wp-element-button">
{{ $i18n.get('label_submit') }}
</button>
</div>
</div>
<button
:disabled="showTermsAgreementCheckbox && !userHasAgreedToTerms"
@click="onSubmit()"
type="button"
class="button is-secondary">{{ $i18n.get('label_submit') }}</button>
<!-- JS-side hook for extra content -->
<div
v-if="hasAfterHook('footer')"
@ -661,13 +741,9 @@
import { mapActions, mapGetters } from 'vuex';
import { eventBusItemMetadata } from '../../../../admin/js/event-bus-item-metadata';
import { formHooks } from '../../../../admin/js/mixins';
import ItemMetadatumErrorsTooltip from '../../../../admin/components/other/item-metadatum-errors-tooltip.vue';
export default {
name: 'ItemSubmissionForm',
components: {
ItemMetadatumErrorsTooltip,
},
mixins: [ formHooks ],
props: {
collectionId: String,
@ -691,7 +767,8 @@ export default {
itemLinkButtonLabel: String,
helpInfoBellowLabel: Boolean,
showTermsAgreementCheckbox: Boolean,
termsAgreementMessage: String
termsAgreementMessage: String,
isLayoutSteps: Boolean
},
data(){
return {
@ -724,10 +801,15 @@ export default {
useCaptcha: 'no',
captchaSiteKey: tainacan_plugin['item_submission_captcha_site_key'],
linkToCreatedItem: '',
userHasAgreedToTerms: false
userHasAgreedToTerms: false,
metadataElements: {},
activeSectionStep: 0,
}
},
computed: {
showSteppedLayout() {
return this.isLayoutSteps;
},
itemSubmission() {
return this.getItemSubmission();
},
@ -757,9 +839,9 @@ export default {
// To find which is the section of this metadatum, we look for an intersection of the existeing sections
// in this collection and the list of section ids in the repository metadata
const intersectionOfSections = this.metadataSections.filter(
(aMetadataSection) => metadatumSectionId.includes("" + aMetadataSection.id) && aMetadataSection.id !== 'default_section'
);
const intersectionOfSections = this.getMetadataSections() // We do not use the computed metadataSections here as we want to include every section, even those hidden by stepped layout
.filter((aMetadataSection) => metadatumSectionId.includes("" + aMetadataSection.id) && aMetadataSection.id !== 'default_section');
if (intersectionOfSections.length === 1)
metadatum.metadata_section_id = intersectionOfSections[0].id;
@ -773,7 +855,7 @@ export default {
return tweakedItemMetadata;
},
metadataSections() {
return this.getMetadataSections();
return this.showSteppedLayout ? this.getMetadataSections().filter(aMetadataSection => !this.isSectionHidden(aMetadataSection.id)) : this.getMetadataSections();
},
formErrors() {
return eventBusItemMetadata && eventBusItemMetadata.errors && eventBusItemMetadata.errors.length ? eventBusItemMetadata.errors : []
@ -792,7 +874,10 @@ export default {
thumbnailErrorMessage() {
const existingError = this.formErrors.find(error => error.metadatum_id == 'thumbnail');
return existingError ? existingError.errors : '';
}
},
conditionalSections() {
return eventBusItemMetadata && eventBusItemMetadata.conditionalSections ? eventBusItemMetadata.conditionalSections : [];
},
},
created() {
@ -824,6 +909,7 @@ export default {
this.$set(this.metadataSectionCollapses, i, true);
}
this.formErrorMessage = this.formErrorMessage ? this.formErrorMessage : this.$i18n.get('info_errors_in_form');
this.loadMetadataElements();
} else
this.formErrorMessage = '';
});
@ -841,6 +927,25 @@ export default {
.then((metadataSections) => {
this.metadataSectionCollapses = Array(metadataSections.length).fill(true);
this.isLoadingMetadataSections = false;
/**
* Creates the conditional metadata set to later watch values
* of certain metadata that control sections visibility.
*/
eventBusItemMetadata.conditionalSections = {};
for (let metadataSection of metadataSections) {
if ( metadataSection.is_conditional_section == 'yes') {
const conditionalSectionId = Object.keys(metadataSection.conditional_section_rules);
if ( conditionalSectionId.length ) {
eventBusItemMetadata.conditionalSections[metadataSection.id] = {
sectionId: metadataSection.id,
metadatumId: conditionalSectionId[0],
metadatumValues: metadataSection.conditional_section_rules[conditionalSectionId[0]],
hide: true
};
}
}
}
})
.catch((error) => {
this.isLoadingMetadataSections = false;
@ -1011,7 +1116,6 @@ export default {
}
this.setItemSubmissionMetadata( metadata.map((metadatum) => { return { metadatum_id: metadatum.id, value: null } }) );
this.couldLoadCollection = true;
this.isLoading = false;
// Mounts grecapcha
if (this.useCaptcha == 'yes') {
@ -1021,6 +1125,8 @@ export default {
this.$console.log(error);
}
}
this.isLoading = false;
})
.catch(() => {
this.couldLoadCollection = false;
@ -1042,6 +1148,48 @@ export default {
},
toggleMetadataSectionCollapse(sectionIndex) {
this.$set(this.metadataSectionCollapses, sectionIndex, (this.formErrorMessage ? true : !this.metadataSectionCollapses[sectionIndex]));
},
getErrorMessage(errors) {
let metadatumErrorMessage = '';
for (let singleError of errors) {
if (typeof singleError != 'string') {
for (let index of Object.keys(singleError))
metadatumErrorMessage += singleError[index] + '\n';
} else {
metadatumErrorMessage += singleError;
}
}
return metadatumErrorMessage;
},
loadMetadataElements() {
this.metadataElements = {};
this.formErrors.map((error) => {
this.metadataElements[error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : '')] = document.getElementById('tainacan-item-metadatum_id-' + error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : ''));
});
},
goToErrorMetadatum(error) {
if ( ['thumbnail', 'attachments', 'document'].includes(error.metadatum_id) )
this.metadataElements[error.metadatum_id].scrollIntoView({ behavior: 'smooth', block: 'center' });
else if ( this.metadataElements[error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : '')] ) {
if ( this.showSteppedLayout ) {
const stepWhereTheErrorIs = this.metadataSections.findIndex((aMetadataSection) => aMetadataSection.metadata_object_list.findIndex((aMetadatatum) => aMetadatatum.id == error.metadatum_id || aMetadatatum.id == error.parent_meta_id) >= 0);
if (stepWhereTheErrorIs >= 0)
this.activeSectionStep = stepWhereTheErrorIs;
}
this.metadataElements[error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : '')].scrollIntoView({ behavior: 'smooth', block: 'center' });
}
},
onPreviousStep() {
if ( this.$refs['item-submission-steps-layout'] && typeof this.$refs['item-submission-steps-layout'].prev == 'function' )
this.$refs['item-submission-steps-layout'].prev();
},
onNextStep() {
if ( this.$refs['item-submission-steps-layout'] && typeof this.$refs['item-submission-steps-layout'].next == 'function' )
this.$refs['item-submission-steps-layout'].next();
},
isSectionHidden(sectionId) {
return this.conditionalSections[sectionId] && this.conditionalSections[sectionId].hide;
}
}
}
@ -1067,9 +1215,11 @@ export default {
.field {
padding: 12px 0px 12px 34px;
margin-left: 16px;
}
.columns {
/deep/ input {
box-sizing: border-box;
}
.columns {
flex-wrap: wrap;
justify-content: space-between;
@ -1086,6 +1236,14 @@ export default {
}
}
.metadata-section-hidden {
opacity: 0.5;
filter: grayscale(1.0);
& > {
pointer-events: none;
}
}
.section-label {
position: relative;
@ -1168,6 +1326,8 @@ export default {
margin-top: 1.25em;
.field {
margin-left: 0;
margin-right: 0;
padding: 0.75em 0.75em 0.5em 0.75em;
border: 1px dashed var(--tainacan-input-border-color);
@ -1180,6 +1340,35 @@ export default {
overflow: visible;
}
}
.form-error-area {
font-size: 0.9375em;
margin-top: 1rem;
margin-bottom: 1.125rem;
padding: 0.875em;
display: flex;
flex-wrap: nowrap;
border: 1px solid var(--tainacan-red-2, #a23939);
color: var(--tainacan-red-2, #a23939);
background: var(--tainacan-red-1, #eadadc);
.form-error-area-icon {
font-size: 2rem;
padding-right: 0.75rem;
}
.form-error-area-messages > p {
margin-top: 0.25rem;
margin-bottom: 0.25rem;
}
/deep/ ol {
margin-top: 0;
margin-bottom: 0;
padding-top: 0;
padding-bottom: 0;
}
}
.metadata-section-header {
padding-bottom: 7px;
@ -1198,6 +1387,13 @@ export default {
align-items: center;
font-size: 1em;
.wp-block-buttons {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
}
@keyframes blink {
from { color: var(--tainacan-blue5); }
to { color: var(--tainacan-info-color); }
@ -1222,5 +1418,29 @@ export default {
}
}
.b-steps {
border: 1px solid var(--tainacan-input-border-color);
border-radius: 2px;
margin-top: 1em;
/deep/ .steps {
.step-items {
margin-top: -1em;
padding-right: 0px;
margin-right: 0px;
padding-left: 0px;
margin-left: 0px;
.step-item.is-active .step-title {
color: var(--tainacan-secondary);
}
.step-item:not(.is-active) .step-title {
color: var(--tainacan-label-color);
}
}
}
}
}
</style>

View File

@ -11,4 +11,7 @@
@import "../../../../../../../node_modules/bulma/sass/elements/button.sass"
@import "../../../../../../../node_modules/bulma/sass/grid/columns.sass"
@import "../../../../../../../node_modules/bulma/sass/components/dropdown.sass"
@import "../../../../../../../node_modules/bulma/sass/components/modal.sass"
@import "../../../../../../../node_modules/bulma/sass/components/modal.sass"
$body-background-color: #fff;
$body-color: #fff;

View File

@ -32,7 +32,8 @@ export default function({ attributes, className }) {
itemLinkButtonLabel,
helpInfoBellowLabel,
showTermsAgreementCheckbox,
termsAgreementMessage
termsAgreementMessage,
isLayoutSteps
} = attributes;
const blockProps = useBlockProps.save();
@ -84,7 +85,8 @@ export default function({ attributes, className }) {
show-terms-agreement-checkbox={ showTermsAgreementCheckbox ? showTermsAgreementCheckbox.toString() : 'false' }
terms-agreement-message={ termsAgreementMessageHTML }
item-link-button-label={ itemLinkButtonLabel ? itemLinkButtonLabel : __( 'Go to the item page', 'tainacan' ) }
help-info-bellow-label={ helpInfoBellowLabel ? helpInfoBellowLabel.toString() : 'false' } >
help-info-bellow-label={ helpInfoBellowLabel ? helpInfoBellowLabel.toString() : 'false' }
is-layout-steps={ isLayoutSteps.toString() } >
</div>
</div>
};

View File

@ -41,6 +41,7 @@
border-radius: 4px;
border: 1px solid rgba(200,200,200, 0.3);
overflow: hidden;
box-sizing: border-box;
.fake-text {
background-color: var(--tainacan-label-color, rgba(200,200,200, 0.3));
@ -302,12 +303,34 @@
flex-wrap: wrap;
justify-content: flex-start;
}
.fake-steps {
margin-top: 1em;
display: flex;
justify-content: space-evenly;
align-items: center;
.fake-step {
width: 1em;
height: 1em;
border-radius: 100%;
background-color: var(--tainacan-input-border-color, rgba(200,200,200, 0.3));
}
.fake-step:first-of-type {
background-color: var(--tainacan-secondary, rgba(200,200,200, 0.3));
}
}
.fake-steps+.metadata-section {
margin-top: -0.5em;
border: 1px solid var(--tainacan-input-border-color, rgba(200,200,200, 0.3));
padding: 2em;
}
.metadata-section {
width: 100%;
padding: 0.5em 1em;
display: flex;
flex-wrap: nowrap;
flex-direction: column;
box-sizing: border-box;
.fake-metadata {
display: flex;

View File

@ -6,6 +6,7 @@ import {
Switch,
Tabs,
Tag,
Modal,
Checkbox,
Collapse,
Radio,
@ -18,7 +19,8 @@ import {
Input,
Select,
Taginput,
Snackbar
Snackbar,
Steps
} from 'buefy';
import VTooltip from 'floating-vue';
import cssVars from 'css-vars-ponyfill';
@ -34,6 +36,7 @@ import Relationship from '../../../admin/components/metadata-types/relationship/
import Taxonomy from '../../../admin/components/metadata-types/taxonomy/Taxonomy.vue';
import Compound from '../../../admin/components/metadata-types/compound/Compound.vue';
import User from '../../../admin/components/metadata-types/user/User.vue';
import GeoCoordinate from '../../../admin/components/metadata-types/geocoordinate/GeoCoordinate.vue';
// Main components
import ItemSubmissionForm from './item-submission/item-submission-form.vue';
@ -83,7 +86,9 @@ export default (element) => {
Vue.use(Autocomplete);
Vue.use(Collapse);
Vue.use(Snackbar);
Vue.use(Modal);
Vue.use(Input);
Vue.use(Steps);
Vue.use(VTooltip, {
popperTriggers: ['hover'],
themes: {
@ -128,6 +133,7 @@ export default (element) => {
Vue.component('tainacan-taxonomy', Taxonomy);
Vue.component('tainacan-compound', Compound);
Vue.component('tainacan-user', User);
Vue.component('tainacan-geocoordinate', GeoCoordinate);
/* Main page component */
Vue.component('item-submission-form', ItemSubmissionForm);
@ -162,7 +168,8 @@ export default (element) => {
itemLinkButtonLabel: '',
helpInfoBellowLabel: false,
showItemLinkButton: false,
termsAgreementMessage: ''
termsAgreementMessage: '',
isLayoutSteps: false
},
beforeMount () {
// Collection source settings
@ -190,6 +197,8 @@ export default (element) => {
this.hideMetadataTypes = this.isParameterTrue('hide-metadata-types');
if (this.$el.attributes['help-info-bellow-label'] != undefined)
this.helpInfoBellowLabel = this.isParameterTrue('help-info-bellow-label');
if (this.$el.attributes['is-layout-steps'] != undefined)
this.isLayoutSteps = this.isParameterTrue('is-layout-steps');
// Form sections labels
if (this.$el.attributes['document-section-label'] != undefined)

View File

@ -23,6 +23,7 @@
:help-info-bellow-label="$root.helpInfoBellowLabel ? $root.helpInfoBellowLabel : false"
:show-terms-agreement-checkbox="$root.showTermsAgreementCheckbox ? $root.showTermsAgreementCheckbox : false"
:terms-agreement-message="$root.termsAgreementMessage"
:is-layout-steps="$root.isLayoutSteps"
/>
</template>
@ -55,6 +56,7 @@ export default {
@import "../../../../../node_modules/buefy/src/scss/components/_dialog.scss";
@import "../../../../../node_modules/buefy/src/scss/components/_notices.scss";
@import "../../../../../node_modules/buefy/src/scss/components/_numberinput.scss";
@import "../../../../../node_modules/buefy/src/scss/components/_steps.scss";
// Block level custom variables
@import "../../../admin/scss/_custom_variables.scss";
@ -84,11 +86,12 @@ export default {
@import "../../../admin/scss/_control.scss";
@import "../../../admin/scss/_upload.scss";
a, a:not([href]) {
a:not(.wp-element-button),
a:not(.wp-element-button):not([href]) {
color: var(--tainacan-secondary);
}
a:hover,
a:hover:not([href]) {
a:not(.wp-element-button):hover,
a:not(.wp-element-button):hover:not([href]) {
cursor: pointer;
color: var(--tainacan-secondary);
text-decoration: underline;

View File

@ -2,8 +2,7 @@ const { SVG, Path } = wp.components;
export default (
<SVG width="24" height="24" viewBox="0 -2 12 16">
<Path
fill="#298596"
<Path
d="M8.8,1.2H1.2V10H0V1.2C0,0.6,0.6,0,1.2,0h7.5V1.2z M3.8,2.5c-0.7,0-1.2,0.6-1.2,1.3v8.8c0,0.7,0.6,1.2,1.2,1.2h6.9
c0.7,0,1.2-0.6,1.2-1.2V6.3L8.1,2.5H3.8z M7.5,3.4L11,6.9H7.5V3.4z"/>
</SVG>

View File

@ -7,7 +7,6 @@
height="24px"
width="24px">
<Path
fill="#298596"
d="M0,5.8C0,5,0.2,4.2,0.5,3.5s0.7-1.3,1.2-1.8s1.1-0.9,1.8-1.2C4.2,0.1,5,0,5.8,0S7.3,0.1,8,0.5
c0.7,0.3,1.3,0.7,1.8,1.2s0.9,1.1,1.2,1.8c0.5,1.2,0.5,2.5,0.2,3.7c0,0.2-0.1,0.4-0.2,0.6c0,0.1-0.2,0.6-0.2,0.6
c0.6,0.6,1.3,1.3,1.9,1.9c0.7,0.7,1.3,1.3,2,2c0,0,0.3,0.2,0.3,0.3c0,0.3-0.1,0.7-0.3,1c-0.2,0.6-0.8,1-1.4,1.2

View File

@ -2,8 +2,6 @@ const { SVG, Path } = wp.components;
export default (
<SVG width="24" height="24" viewBox="0 -2 12 16">
<Path
fill="#298596"
d="M 4.4,2.5 H 0 V 0 h 4.4 l 1.2,1.3 z m -1.9,5 v 3.1 H 5 v 1.2 H 1.3 v -8 H 2.5 V 6.3 H 5 V 7.6 H 2.5 Z m 8.2,0.7 H 6.3 V 5.7 h 4.4 l 1.2,1.2 z M 11.9,11.3 10.7,10 H 6.3 v 2.5 h 4.4 z"/>
<Path d="M 4.4,2.5 H 0 V 0 h 4.4 l 1.2,1.3 z m -1.9,5 v 3.1 H 5 v 1.2 H 1.3 v -8 H 2.5 V 6.3 H 5 V 7.6 H 2.5 Z m 8.2,0.7 H 6.3 V 5.7 h 4.4 l 1.2,1.2 z M 11.9,11.3 10.7,10 H 6.3 v 2.5 h 4.4 z"/>
</SVG>
);

View File

@ -67,7 +67,11 @@ function tainacan_blocks_register_categories($categories, $editor_context) {
array(
array(
'slug' => 'tainacan-blocks',
'title' => __( 'Tainacan', 'tainacan' ),
'title' => __( 'Tainacan Blocks', 'tainacan' ),
),
array(
'slug' => 'tainacan-blocks-variations',
'title' => __( 'Tainacan Query Loop Variations', 'tainacan' ),
),
)
);
@ -82,6 +86,7 @@ function tainacan_blocks_register_and_enqueue_all_blocks() {
if ( is_admin() ) {
tainacan_blocks_get_category_icon_script();
tainacan_blocks_get_common_editor_styles();
tainacan_blocks_get_variations_script();
}
// May be needed outside the editor, if server side render is used
foreach(TAINACAN_BLOCKS as $block_slug => $block_options) {
@ -212,6 +217,13 @@ function tainacan_blocks_get_plugin_js_settings(){
global $TAINACAN_BASE_URL;
global $wp_version;
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$collections = $Tainacan_Collections->fetch( [], 'OBJECT' );
$cpts = [];
foreach ( $collections as $col ) {
$cpts[$col->get_db_identifier()] = $col->get_name();
}
$settings = [
'wp_version' => $wp_version,
'root' => esc_url_raw( rest_url() ) . 'tainacan/v2',
@ -219,7 +231,8 @@ function tainacan_blocks_get_plugin_js_settings(){
'base_url' => $TAINACAN_BASE_URL,
'admin_url' => admin_url(),
'site_url' => site_url(),
'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug()
'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug(),
'collections_post_types' => $cpts
];
return $settings;
@ -286,3 +299,22 @@ function tainacan_blocks_get_category_icon_script() {
$TAINACAN_VERSION
);
}
/**
* Registers the script that inserts the Query Loop Block variations
*/
function tainacan_blocks_get_variations_script() {
global $TAINACAN_BASE_URL;
global $TAINACAN_VERSION;
wp_enqueue_script(
'tainacan-blocks-query-variations',
$TAINACAN_BASE_URL . '/assets/js/tainacan_blocks_query_variations.js',
array('wp-blocks', 'wp-components'),
$TAINACAN_VERSION
);
$block_settings = tainacan_blocks_get_plugin_js_settings();
wp_localize_script( 'tainacan-blocks-query-variations', 'tainacan_blocks', $block_settings );
}

View File

@ -49,6 +49,8 @@
var g2 = el('g', { transform: 'translate(-85.490815,-209.14412)' });
var svgIcon = el( 'svg', { width: 20, height: 20, viewBox: '0 0 20 20'}, path4, path6, path8, path10, path12, path14, path16, path18, path20, g1, g2);
if (wp.blocks.updateCategory)
if (wp.blocks.updateCategory) {
wp.blocks.updateCategory( 'tainacan-blocks', { icon: svgIcon } );
wp.blocks.updateCategory( 'tainacan-blocks-variations', { icon: svgIcon } );
}
} )();

View File

@ -0,0 +1,93 @@
const { registerBlockVariation } = wp.blocks;
const { __ } = wp.i18n;
import itemsIcon from '../blocks/items-list/icon';
import collectionsIcon from '../blocks/collections-list/icon';
/**
* Adds Tainacan Collections as a query loop variation
*/
registerBlockVariation( 'core/query', {
name: 'tainacan-collection',
title: __( 'Tainacan collections', 'tainacan'),
icon: collectionsIcon,
category: 'tainacan-blocks-variations',
description: __('Displays a list of Tainacan collections', 'tainacan'),
isActive: ( { namespace, query } ) => {
return (
namespace === 'tainacan-collection'
&& query.postType === 'tainacan-collection'
);
},
attributes: {
namespace: 'tainacan-collection',
query: {
postType: 'tainacan-collection',
perPage: 12,
offset: 0
},
align: 'wide',
displayLayout: {
type: 'flex',
columns: 4
}
},
allowedControls: [ 'inherit', 'order', 'taxQuery', 'search' ],
innerBlocks: [
[
'core/post-template',
{},
[
[ 'core/post-featured-image' ],
[ 'core/post-title' ]
],
]
]
} );
/**
* Loops on Tainacan Collections post types to create items list variations
*/
const POST_TYPES = tainacan_blocks.collections_post_types;
Object.keys(POST_TYPES).forEach((postType) => {
const postName = POST_TYPES[postType];
const VARIATION_NAME = 'tainacan-items-' + postType;
registerBlockVariation( 'core/query', {
name: VARIATION_NAME,
title: postName,
icon: itemsIcon,
category: 'tainacan-blocks-variations',
description: __('Displays a list of Tainacan itens from a collection', 'tainacan'),
isActive: ( { namespace, query } ) => {
return (
namespace === VARIATION_NAME
&& query.postType === postType
);
},
attributes: {
namespace: VARIATION_NAME,
query: {
postType: postType,
perPage: 12,
offset: 0
},
align: 'wide',
displayLayout: {
type: 'flex',
columns: 4
}
},
allowedControls: [ 'inherit', 'order', 'taxQuery', 'search' ],
innerBlocks: [
[
'core/post-template',
{},
[
[ 'core/post-featured-image' ],
[ 'core/post-title' ]
],
]
]
} );
});

View File

@ -1004,6 +1004,8 @@ return apply_filters( 'tainacan-i18n', [
'info_item_submission_draft_status' => __( 'Warning: draft items may be submitted even without filling all required metadata.', 'tainacan' ),
'info_empty_geocoordinate_metadata_list' => __( 'No geocoordinate metadata was found. Try enabling it in the "displayed metadata" dropdown.', 'tainacan' ),
'info_non_located_item' => __( 'This item does not have any location based on this metadata.', 'tainacan' ),
'info_metadata_section_hidden_conditional' => __( 'Section disabled due to a conditional metadatum value.', 'tainacan' ),
'info_create_select_metadatum_for_conditional_section' => __( 'For configuring conditional sections, first create one select type metadatum to use its values as rules for displaing this section. The metadatum should be inside another metadatum section.', 'tainacan' ),
/* Activity actions */
'action_update-metadata-value' => __( 'Item Metadata Value Updates', 'tainacan'),

View File

@ -9,6 +9,7 @@ module.exports = {
tainacan_pages_common_scripts: './src/views/tainacan-pages-common-scripts.js',
tainacan_blocks_common_scripts: './src/views/gutenberg-blocks/tainacan-blocks-common-scripts.js',
tainacan_blocks_category_icon: './src/views/gutenberg-blocks/js/tainacan-blocks-category-icon.js',
tainacan_blocks_query_variations: './src/views/gutenberg-blocks/js/tainacan-blocks-query-variations.js',
block_terms_list: './src/views/gutenberg-blocks/blocks/terms-list/index.js',
block_items_list: './src/views/gutenberg-blocks/blocks/items-list/index.js',