Merge branch 'develop' into feature/794.
This commit is contained in:
commit
a2fd2f3dce
|
@ -922,7 +922,7 @@ class Item extends Entity {
|
||||||
$output .= $embed;
|
$output .= $embed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return wp_kses_tainacan($output);
|
return apply_filters("tainacan-item-get-attachment-as-html", wp_kses_tainacan($output), $img_size, $this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ Tags: museums, libraries, archives, GLAM, collections, repository
|
||||||
Requires at least: 5.9
|
Requires at least: 5.9
|
||||||
Tested up to: 6.4
|
Tested up to: 6.4
|
||||||
Requires PHP: 7.0
|
Requires PHP: 7.0
|
||||||
Stable tag: 0.20.5
|
Stable tag: 0.20.6
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ Tainacan is an open-source, powerful and flexible digital repository platform fo
|
||||||
|
|
||||||
[Tainacan](https://tainacan.org/) is an [open-source](https://github.com/tainacan/tainacan), powerful and flexible digital repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. It can be used for the creation of a digital collection, a digital library or a digital repository for your institutional or personal collection.
|
[Tainacan](https://tainacan.org/) is an [open-source](https://github.com/tainacan/tainacan), powerful and flexible digital repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. It can be used for the creation of a digital collection, a digital library or a digital repository for your institutional or personal collection.
|
||||||
|
|
||||||
Tainacan aims to facilitate the activities of organizing, documenting, disseminating and displaying digital objects based on simple and accessible principles of digital curation. The plugin integrates with the Wordpress block engine, making it easy to reuse objects for different and varied uses.
|
Tainacan aims to facilitate the activities of organizing, documenting, disseminating and displaying digital objects based on simple and accessible principles of digital curation. The plugin integrates with the WordPress block engine, making it easy to reuse objects for different and varied uses.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ Tainacan aims to facilitate the activities of organizing, documenting, dissemina
|
||||||
|
|
||||||
* "Manage Taxonomies": Manage vocabularies that can be used across all your collections.
|
* "Manage Taxonomies": Manage vocabularies that can be used across all your collections.
|
||||||
|
|
||||||
* "Themes": The Tainacan plugin has its own default theme, which helps you to showcase your collections in a beautiful and effective manner. But it can also work with any WordPress theme, so interface developers can easily add Tainacan specific features to an existing theme.
|
* "Themes": The Tainacan plugin has its own default theme, which helps you to showcase your collections beautifully and effectively. But it can also work with any WordPress theme, so interface developers can easily add Tainacan-specific features to an existing theme.
|
||||||
|
|
||||||
* "API and Interoperability": Tainacan implements a RESTful API (read and write) to allow other applications to interact with your repository. That way, you can expose your collection in different formats, such as JSON, JsonLD, OAI-PMH and others. If your collection has a specific set of metadata, you can map this metadata to match the patterns you want to use.
|
* "API and Interoperability": Tainacan implements a RESTful API (read and write) to allow other applications to interact with your repository. That way, you can expose your collection in different formats, such as JSON, CSV, HTML and others. If your collection has a specific set of metadata, you can map this metadata to match the patterns you want to use.
|
||||||
|
|
||||||
* "Gutenberg blocks": Tell stories with your collections. Tainacan offers you several Gutenberg blocks so you can present your collections to the public in many different ways!
|
* "Gutenberg blocks": Tell stories with your collections. Tainacan offers you several Gutenberg blocks so you can present your collections to the public in many different ways!
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ Back to the "Items" screen, click "Add new" to create a new item.
|
||||||
|
|
||||||
= Manage and browse your collection =
|
= Manage and browse your collection =
|
||||||
|
|
||||||
Through this admin interface you can manage your collection and browse its item using the faceted search interface or advanced search interface.
|
Through this admin interface, you can manage your collection and browse its items using the faceted search interface or advanced search interface.
|
||||||
|
|
||||||
If you want to visit your collections in the public side of your site, using your current theme, visit http://your-site/collections and you will get the list of your collections.
|
If you want to visit your collections on the public side of your site, using your current theme, visit http://your-site/collections and you will get the list of your collections.
|
||||||
|
|
||||||
= Set up Taxonomies =
|
= Set up Taxonomies =
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ You can also have metadata as taxonomies, which you can configure with a set of
|
||||||
|
|
||||||
Edit your menu and links directly to your collections. Click "Screen options" at the top of the Edit Menu page and enable "Collections".
|
Edit your menu and links directly to your collections. Click "Screen options" at the top of the Edit Menu page and enable "Collections".
|
||||||
|
|
||||||
If you want to add a link to the list of collections, click "View all" tab on the Collections box on the left, and then add the first item named "Collections" to the menu.
|
If you want to add a link to the list of collections, click the "View all" tab on the Collections box on the left, and then add the first item named "Collections" to the menu.
|
||||||
|
|
||||||
= Faceted search in your theme =
|
= Faceted search in your theme =
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ To have a fully-featured faceted search in your theme, you can either make it co
|
||||||
|
|
||||||
Upload the files to the plugins directory and activate it. You can also install and activate directly from the admin panel.
|
Upload the files to the plugins directory and activate it. You can also install and activate directly from the admin panel.
|
||||||
|
|
||||||
If you have Imagick installed in your server, Tainacan will be able to automatically generate a thumbnail from your PDF files. This is desired but not required.
|
If you have Imagick installed on your server, Tainacan will be able to automatically generate a thumbnail from your PDF files. This is desired but not required.
|
||||||
|
|
||||||
== Find out more ==
|
== Find out more ==
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ If you have Imagick installed in your server, Tainacan will be able to automatic
|
||||||
4. Add items described by your metadata
|
4. Add items described by your metadata
|
||||||
5. Set up your item as a file, link or text and attach many types of documents
|
5. Set up your item as a file, link or text and attach many types of documents
|
||||||
6. Browse your collections with a faceted search interface
|
6. Browse your collections with a faceted search interface
|
||||||
7. Navigate through rich filtering interface
|
7. Navigate through the rich filtering interface
|
||||||
8. Explore more with Advanced Search
|
8. Explore more with Advanced Search
|
||||||
9. Set up Taxonomies to be used across your repository
|
9. Set up Taxonomies to be used across your repository
|
||||||
10. Bulk edit as many items as you need quickly
|
10. Bulk edit as many items as you need quickly
|
||||||
|
|
|
@ -5,17 +5,17 @@ Plugin URI: https://tainacan.org/
|
||||||
Description: Open source, powerful and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional repository platform.
|
Description: Open source, powerful and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional repository platform.
|
||||||
Author: Tainacan.org
|
Author: Tainacan.org
|
||||||
Author URI: https://tainacan.org/
|
Author URI: https://tainacan.org/
|
||||||
Version: 0.20.5
|
Version: 0.20.6
|
||||||
Requires at least: 5.9
|
Requires at least: 5.9
|
||||||
Tested up to: 6.4
|
Tested up to: 6.4
|
||||||
Requires PHP: 7.0
|
Requires PHP: 7.0
|
||||||
Stable tag: 0.20.5
|
Stable tag: 0.20.6
|
||||||
Text Domain: tainacan
|
Text Domain: tainacan
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const TAINACAN_VERSION = '0.20.5';
|
const TAINACAN_VERSION = '0.20.6';
|
||||||
|
|
||||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||||
$TAINACAN_BASE_URL = plugins_url('', __FILE__);
|
$TAINACAN_BASE_URL = plugins_url('', __FILE__);
|
||||||
|
|
|
@ -94,8 +94,8 @@
|
||||||
"default": "#187181"
|
"default": "#187181"
|
||||||
},
|
},
|
||||||
"enabledMetadata": {
|
"enabledMetadata": {
|
||||||
"type": "array",
|
"type": "object",
|
||||||
"default": []
|
"default": {}
|
||||||
},
|
},
|
||||||
"collectionMetadata": {
|
"collectionMetadata": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|
|
@ -2,6 +2,253 @@ const { __ } = wp.i18n;
|
||||||
const { RichText, useBlockProps } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
|
const { RichText, useBlockProps } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
|
/* Deprecated in version 0.20.7 due to the change of enabledMetadata from array to object with IDs */
|
||||||
|
{
|
||||||
|
migrate( attributes ) {
|
||||||
|
if ( Array.isArray(attributes.enabledMetadata) ) {
|
||||||
|
attributes.enabledMetadata = {};
|
||||||
|
attributes.collectionMetadata.forEach( metadatum => {
|
||||||
|
attributes.enabledMetadata[ metadatum.id ] = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
console.log('migrated to ' + attributes.enabledMetadata)
|
||||||
|
return attributes;
|
||||||
|
},
|
||||||
|
"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": "#373839"
|
||||||
|
},
|
||||||
|
"infoColor": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "#505253"
|
||||||
|
},
|
||||||
|
"primaryColor": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "#d9eced"
|
||||||
|
},
|
||||||
|
"secondaryColor": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "#187181"
|
||||||
|
},
|
||||||
|
"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."
|
||||||
|
},
|
||||||
|
"isLayoutSteps": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
save: function({ attributes }) {
|
||||||
|
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,
|
||||||
|
isLayoutSteps
|
||||||
|
} = attributes;
|
||||||
|
|
||||||
|
const blockProps = useBlockProps.save();
|
||||||
|
const className = blockProps.className;
|
||||||
|
|
||||||
|
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' }
|
||||||
|
is-layout-steps={ isLayoutSteps !== undefined ? isLayoutSteps.toString() : 'false' } >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
},
|
||||||
/* Deprecated in version 0.20.4 due to changes on labelColor, infoColor and secondaryColor default values */
|
/* Deprecated in version 0.20.4 due to changes on labelColor, infoColor and secondaryColor default values */
|
||||||
{
|
{
|
||||||
"attributes": {
|
"attributes": {
|
||||||
|
|
|
@ -14,7 +14,7 @@ const {
|
||||||
Placeholder,
|
Placeholder,
|
||||||
PanelBody
|
PanelBody
|
||||||
} = wp.components;
|
} = wp.components;
|
||||||
|
const { useEffect } = wp.element;
|
||||||
const { InspectorControls, BlockControls, RichText, useBlockProps } = wp.blockEditor;
|
const { InspectorControls, BlockControls, RichText, useBlockProps } = wp.blockEditor;
|
||||||
|
|
||||||
import tainacan from '../../js/axios.js';
|
import tainacan from '../../js/axios.js';
|
||||||
|
@ -104,6 +104,12 @@ export default function ({ attributes, setAttributes }) {
|
||||||
setAttributes({ isLayoutSteps: isLayoutSteps });
|
setAttributes({ isLayoutSteps: isLayoutSteps });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fill the enabledMetadata object with the metadata that are enabled initially
|
||||||
|
useEffect(() => {
|
||||||
|
if ( collectionId && collectionId != 'preview' )
|
||||||
|
loadCollectionMetadata(collectionId)
|
||||||
|
}, []);
|
||||||
|
|
||||||
function openCollectionModal() {
|
function openCollectionModal() {
|
||||||
isCollectionModalOpen = true;
|
isCollectionModalOpen = true;
|
||||||
setAttributes( {
|
setAttributes( {
|
||||||
|
@ -111,10 +117,8 @@ export default function ({ attributes, setAttributes }) {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleIsEnabledMetadatum(isEnabled, index) {
|
function toggleIsEnabledMetadatum(isEnabled, metadatumId) {
|
||||||
|
enabledMetadata[metadatumId] = isEnabled;
|
||||||
enabledMetadata.splice(index, 1, isEnabled);
|
|
||||||
|
|
||||||
setAttributes({
|
setAttributes({
|
||||||
enabledMetadata: JSON.parse(JSON.stringify(enabledMetadata))
|
enabledMetadata: JSON.parse(JSON.stringify(enabledMetadata))
|
||||||
});
|
});
|
||||||
|
@ -127,10 +131,11 @@ export default function ({ attributes, setAttributes }) {
|
||||||
tainacan.get('/collection/' + selectedCollectionId + '/metadata/?nopaging=1&include_disabled=false&parent=0')
|
tainacan.get('/collection/' + selectedCollectionId + '/metadata/?nopaging=1&include_disabled=false&parent=0')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
collectionMetadata = response.data;
|
collectionMetadata = response.data;
|
||||||
enabledMetadata = new Array(response.data.length).fill(true);
|
collectionMetadata.forEach(aMetadatum => {
|
||||||
|
if ( enabledMetadata[aMetadatum.id] === undefined )
|
||||||
|
enabledMetadata[aMetadatum.id] = true;
|
||||||
|
});
|
||||||
isLoadingCollectionMetadata = false;
|
isLoadingCollectionMetadata = false;
|
||||||
|
|
||||||
setAttributes({
|
setAttributes({
|
||||||
isLoadingCollectionMetadata : isLoadingCollectionMetadata,
|
isLoadingCollectionMetadata : isLoadingCollectionMetadata,
|
||||||
collectionMetadata: collectionMetadata,
|
collectionMetadata: collectionMetadata,
|
||||||
|
@ -262,16 +267,17 @@ export default function ({ attributes, setAttributes }) {
|
||||||
help={ __('Uncheck the metadata that you do not want to be shown on the form', 'tainacan') }
|
help={ __('Uncheck the metadata that you do not want to be shown on the form', 'tainacan') }
|
||||||
>
|
>
|
||||||
<ul id="metadata-checkbox-list">
|
<ul id="metadata-checkbox-list">
|
||||||
{ enabledMetadata.length ?
|
{
|
||||||
enabledMetadata.map((isMetadatumEnabled, index) => {
|
collectionMetadata.length ?
|
||||||
|
collectionMetadata.map(metadatum => {
|
||||||
return (
|
return (
|
||||||
<li>
|
<li>
|
||||||
<CheckboxControl
|
<CheckboxControl
|
||||||
label={ collectionMetadata[index].name + (collectionMetadata[index].required == 'yes' ? ' *' : '') }
|
label={ metadatum.name + (metadatum.required == 'yes' ? ' *' : '') }
|
||||||
disabled={ collectionMetadata[index].required == 'yes' }
|
disabled={ metadatum.required == 'yes' }
|
||||||
checked={ isMetadatumEnabled ? true : false }
|
checked={ enabledMetadata[metadatum.id] ? true : false }
|
||||||
help={ collectionMetadata[index].metadata_type_object.name + (collectionMetadata[index].required == 'yes' ? (', ' + __('Required', 'tainacan')) : '' ) + (collectionMetadata[index].collection_id != collectionId ? (' (' + __('Inherited', 'tainacan') + ')' ) : '') }
|
help={ metadatum.metadata_type_object.name + (metadatum.required == 'yes' ? (', ' + __('Required', 'tainacan')) : '' ) + (metadatum.collection_id != collectionId ? (' (' + __('Inherited', 'tainacan') + ')' ) : '') }
|
||||||
onChange={ (isEnabled) => toggleIsEnabledMetadatum(isEnabled, index) }
|
onChange={ (isEnabled) => toggleIsEnabledMetadatum(isEnabled, metadatum.id) }
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
|
|
|
@ -506,7 +506,7 @@
|
||||||
v-html="getBeforeHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
|
v-html="getBeforeHook('metadatum', { metadatum: itemMetadatum.metadatum, index: index, metadataSection: metadataSection, sectionIndex: sectionIndex })" />
|
||||||
|
|
||||||
<tainacan-form-item
|
<tainacan-form-item
|
||||||
v-if="enabledMetadata[index] == 'true'"
|
v-if="Object.keys(enabledMetadata).length == 0 || enabledMetadata[itemMetadatum.metadatum.id]"
|
||||||
:item-metadatum="itemMetadatum"
|
:item-metadatum="itemMetadatum"
|
||||||
:hide-collapses="hideCollapses"
|
:hide-collapses="hideCollapses"
|
||||||
:hide-metadata-types="hideMetadataTypes"
|
:hide-metadata-types="hideMetadataTypes"
|
||||||
|
@ -774,7 +774,7 @@ export default {
|
||||||
hideCollapses: Boolean,
|
hideCollapses: Boolean,
|
||||||
hideHelpButtons: Boolean,
|
hideHelpButtons: Boolean,
|
||||||
hideMetadataTypes: Boolean,
|
hideMetadataTypes: Boolean,
|
||||||
enabledMetadata: Array,
|
enabledMetadata: Object,
|
||||||
sentFormHeading: String,
|
sentFormHeading: String,
|
||||||
sentFormMessage: String,
|
sentFormMessage: String,
|
||||||
documentSectionLabel: String,
|
documentSectionLabel: String,
|
||||||
|
@ -872,6 +872,7 @@ export default {
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return tweakedItemMetadata;
|
return tweakedItemMetadata;
|
||||||
},
|
},
|
||||||
metadataSections() {
|
metadataSections() {
|
||||||
|
@ -917,7 +918,6 @@ export default {
|
||||||
|
|
||||||
// CREATING NEW ITEM SUBMISSION
|
// CREATING NEW ITEM SUBMISSION
|
||||||
this.createNewItem();
|
this.createNewItem();
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.collecionAllowsItemSubmission = false;
|
this.collecionAllowsItemSubmission = false;
|
||||||
|
@ -1208,13 +1208,13 @@ export default {
|
||||||
if ( !Array.isArray(this.collection['metadata_section_order']) || !this.collection['metadata_section_order'][sectionIndex] || !Array.isArray(this.collection['metadata_section_order'][sectionIndex]['metadata_order']) )
|
if ( !Array.isArray(this.collection['metadata_section_order']) || !this.collection['metadata_section_order'][sectionIndex] || !Array.isArray(this.collection['metadata_section_order'][sectionIndex]['metadata_order']) )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
let enabledMetadata = [];
|
let enabledMetadataInSection = [];
|
||||||
for (let metadatum of this.collection['metadata_section_order'][sectionIndex]['metadata_order']) {
|
for (let metadatum of this.collection['metadata_section_order'][sectionIndex]['metadata_order']) {
|
||||||
if ( metadatum.enabled )
|
if ( metadatum.enabled )
|
||||||
enabledMetadata.push(metadatum.id);
|
enabledMetadataInSection.push(metadatum.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return enabledMetadata.indexOf(metadatum.id);
|
return enabledMetadataInSection.indexOf(metadatum.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ export default function({ attributes }) {
|
||||||
hide-help-buttons={ hideHelpButtons.toString() }
|
hide-help-buttons={ hideHelpButtons.toString() }
|
||||||
hide-metadata-types={ hideMetadataTypes.toString() }
|
hide-metadata-types={ hideMetadataTypes.toString() }
|
||||||
hide-collapses={ hideCollapses.toString() }
|
hide-collapses={ hideCollapses.toString() }
|
||||||
enabled-metadata={ enabledMetadata.toString() }
|
enabled-metadata={ JSON.stringify(enabledMetadata) }
|
||||||
sent-form-heading={ sentFormHeading }
|
sent-form-heading={ sentFormHeading }
|
||||||
sent-form-message={ sentFormMessage }
|
sent-form-message={ sentFormMessage }
|
||||||
document-section-label={ documentSectionLabel }
|
document-section-label={ documentSectionLabel }
|
||||||
|
|
|
@ -72,7 +72,7 @@ export default (element) => {
|
||||||
hideHelpButtons: false,
|
hideHelpButtons: false,
|
||||||
hideMetadataTypes: false,
|
hideMetadataTypes: false,
|
||||||
hideCollapses: false,
|
hideCollapses: false,
|
||||||
enabledMetadata: [],
|
enabledMetadata: {},
|
||||||
sentFormHeading: '',
|
sentFormHeading: '',
|
||||||
sentFormMessage: '',
|
sentFormMessage: '',
|
||||||
documentSectionLabel: '',
|
documentSectionLabel: '',
|
||||||
|
@ -143,8 +143,13 @@ export default (element) => {
|
||||||
this.termsAgreementMessage = blockElement.attributes['terms-agreement-message'].value;
|
this.termsAgreementMessage = blockElement.attributes['terms-agreement-message'].value;
|
||||||
|
|
||||||
// List of metadata
|
// List of metadata
|
||||||
if (blockElement.attributes['enabled-metadata'] != undefined && blockElement.attributes['enabled-metadata'].value)
|
if (this.$el.attributes['enabled-metadata'] != undefined && this.$el.attributes['enabled-metadata'].value) {
|
||||||
this.enabledMetadata = blockElement.attributes['enabled-metadata'].value.split(',');
|
try {
|
||||||
|
this.enabledMetadata = JSON.parse(this.$el.attributes['enabled-metadata'].value);
|
||||||
|
} catch {
|
||||||
|
this.enabledMetadata = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
:hide-collapses="$root.hideCollapses ? $root.hideCollapses : false"
|
:hide-collapses="$root.hideCollapses ? $root.hideCollapses : false"
|
||||||
:hide-help-buttons="$root.hideHelpButtons ? $root.hideHelpButtons : false"
|
:hide-help-buttons="$root.hideHelpButtons ? $root.hideHelpButtons : false"
|
||||||
:hide-metadata-types="$root.hideMetadataTypes ? $root.hideMetadataTypes : false"
|
:hide-metadata-types="$root.hideMetadataTypes ? $root.hideMetadataTypes : false"
|
||||||
:enabled-metadata="$root.enabledMetadata ? $root.enabledMetadata : []"
|
:enabled-metadata="$root.enabledMetadata ? $root.enabledMetadata : {}"
|
||||||
:sent-form-heading="$root.sentFormHeading"
|
:sent-form-heading="$root.sentFormHeading"
|
||||||
:sent-form-message="$root.sentFormMessage"
|
:sent-form-message="$root.sentFormMessage"
|
||||||
:document-section-label="$root.documentSectionLabel"
|
:document-section-label="$root.documentSectionLabel"
|
||||||
|
|
Loading…
Reference in New Issue