Merge branch 'develop' into feature/734

This commit is contained in:
vnmedeiros 2022-11-14 08:09:35 -03:00
commit b2add32aed
118 changed files with 5080 additions and 354 deletions

View File

@ -44,9 +44,21 @@ sass -E 'UTF-8' --cache-location .tmp/sass-cache-18 src/views/gutenberg-blocks/b
sass -E 'UTF-8' --cache-location .tmp/sass-cache-19 src/views/gutenberg-blocks/blocks/related-items-list/style.scss:src/assets/css/tainacan-gutenberg-block-related-items-list.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-20 src/views/gutenberg-blocks/scss/gutenberg-blocks-editor-style.scss:src/assets/css/tainacan-gutenberg-block-common-editor-styles.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-20 src/views/gutenberg-blocks/blocks/related-items-list/style.scss:src/assets/css/tainacan-gutenberg-block-item-metadata.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-21 src/views/gutenberg-blocks/scss/gutenberg-blocks-theme-style.scss:src/assets/css/tainacan-gutenberg-block-common-theme-styles.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-21 src/views/gutenberg-blocks/blocks/related-items-list/style.scss:src/assets/css/tainacan-gutenberg-block-item-metadata-section.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-22 src/views/gutenberg-blocks/blocks/related-items-list/style.scss:src/assets/css/tainacan-gutenberg-block-item-metadata-sections.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-23 src/views/gutenberg-blocks/blocks/related-items-list/style.scss:src/assets/css/tainacan-gutenberg-block-item-metadatum.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-24 src/views/gutenberg-blocks/blocks/related-items-list/style.scss:src/assets/css/tainacan-gutenberg-block-metadata-section-name.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-25 src/views/gutenberg-blocks/blocks/related-items-list/style.scss:src/assets/css/tainacan-gutenberg-block-metadata-section-description.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-26 src/views/gutenberg-blocks/scss/gutenberg-blocks-editor-style.scss:src/assets/css/tainacan-gutenberg-block-common-editor-styles.css
sass -E 'UTF-8' --cache-location .tmp/sass-cache-27 src/views/gutenberg-blocks/scss/gutenberg-blocks-theme-style.scss:src/assets/css/tainacan-gutenberg-block-common-theme-styles.css
echo "Compilação do Sass Concluído!"
exit 0

60
package-lock.json generated
View File

@ -2016,9 +2016,9 @@
}
},
"apexcharts": {
"version": "3.35.5",
"resolved": "https://registry.npmjs.org/apexcharts/-/apexcharts-3.35.5.tgz",
"integrity": "sha512-Bi3aq35xWntI71JlywXTBBAOhuKTbB4wijKw4ClkIAFV904YDkHPIJ8N9LcZq9fvVb0VX1AEmyOFBOB2Vwsuew==",
"version": "3.36.3",
"resolved": "https://registry.npmjs.org/apexcharts/-/apexcharts-3.36.3.tgz",
"integrity": "sha512-8/FXEs0ohXMff07Gv28XjhPwEJphIUdq2/wii/pcvi54Tw6z1mjrV8ydN8rlWi/ve8BAPBefJkLmRWv7UOBsLw==",
"requires": {
"svg.draggable.js": "^2.2.2",
"svg.easing.js": "^2.0.0",
@ -2132,14 +2132,20 @@
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA=="
},
"axios": {
"version": "0.27.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.1.3.tgz",
"integrity": "sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA==",
"requires": {
"follow-redirects": "^1.14.9",
"form-data": "^4.0.0"
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
},
"dependencies": {
"follow-redirects": {
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
},
"form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
@ -2249,9 +2255,9 @@
"dev": true
},
"blurhash": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/blurhash/-/blurhash-2.0.2.tgz",
"integrity": "sha512-aYWeITmNkjtnR6X7wNgoIJ198qJc3w5yaIwLa7yxsV7/BMnWDWWgugBNvImSCcWNdVHhpNFIJgEb5jzhV4rkHA=="
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/blurhash/-/blurhash-2.0.4.tgz",
"integrity": "sha512-r/As72u2FbucLoK5NTegM/GucxJc3d8GvHc4ngo13IO/nt2HU4gONxNLq1XPN6EM/V8Y9URIa7PcSz2RZu553A=="
},
"body-parser": {
"version": "1.20.0",
@ -3560,7 +3566,8 @@
"follow-redirects": {
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w=="
"integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==",
"dev": true
},
"forever-agent": {
"version": "0.6.1",
@ -4320,9 +4327,9 @@
"dev": true
},
"loader-utils": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz",
"integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==",
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.3.tgz",
"integrity": "sha512-THWqIsn8QRnvLl0shHYVBN9syumU8pYWEHPTmkiVGd+7K5eFNVSY6AJhRvgGF70gg1Dz+l/k8WicvFCxdEs60A==",
"dev": true,
"requires": {
"big.js": "^5.2.2",
@ -4554,9 +4561,9 @@
"dev": true
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz",
"integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==",
"requires": {
"brace-expansion": "^1.1.7"
}
@ -5101,9 +5108,9 @@
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="
},
"photoswipe": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-5.3.2.tgz",
"integrity": "sha512-QJrf0kGa3tYX3sUascZymkT+ZIkgw8YNcwL+hGqoLTyphcn9vSTEab7tmCnA1tthgVzWQRgPjX9psuk7yFrTcA=="
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-5.3.3.tgz",
"integrity": "sha512-BUuulwZwkYFKADSe5xf0dd+wf6dws34ZvqP8R3oYHepRauOXoQHvw600sw1HlWd8K0S3LRCS4jxyR5fTuI383Q=="
},
"picocolors": {
"version": "1.0.0",
@ -5267,6 +5274,11 @@
}
}
},
"proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"pseudomap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
@ -6235,9 +6247,9 @@
}
},
"swiper": {
"version": "8.4.2",
"resolved": "https://registry.npmjs.org/swiper/-/swiper-8.4.2.tgz",
"integrity": "sha512-nMD/RHVYxJxrLqjWQX2n0B94ANwpnuUv/3PUDT8Aaf+mSteFvZGFng4ypAYq70zW4svryyV+8TRlbRZ+6cgv9A==",
"version": "8.4.4",
"resolved": "https://registry.npmjs.org/swiper/-/swiper-8.4.4.tgz",
"integrity": "sha512-jA/8BfOZwT8PqPSnMX0TENZYitXEhNa7ZSNj1Diqh5LZyUJoBQaZcqAiPQ/PIg1+IPaRn/V8ZYVb0nxHMh51yw==",
"requires": {
"dom7": "^4.0.4",
"ssr-window": "^4.0.2"

View File

@ -8,9 +8,9 @@
"build-prod": "cross-env NODE_ENV=production webpack --config webpack.prod.js --progress --mode production"
},
"dependencies": {
"apexcharts": "^3.35.5",
"axios": "^0.27.2",
"blurhash": "^2.0.2",
"apexcharts": "^3.36.3",
"axios": "^1.1.3",
"blurhash": "^2.0.4",
"buefy": "^0.9.22",
"bulma": "^0.9.4",
"conditioner-core": "^2.3.3",
@ -20,11 +20,11 @@
"masonry-layout": "^4.2.2",
"moment": "^2.29.4",
"node-sass": "^7.0.3",
"photoswipe": "^5.3.2",
"photoswipe": "^5.3.3",
"qs": "^6.11.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"swiper": "^8.4.2",
"swiper": "^8.4.4",
"t": "^0.5.1",
"vue": "^2.6.14",
"vue-apexcharts": "^1.6.2",

View File

@ -10,7 +10,7 @@
.tainacan-block-placeholder.components-placeholder {
align-items: center !important;
margin-bottom: 0 !important;
background: var(--tainacan-block-gray0, #f6f6f6); }
background: var(--tainacan-block-gray0, #f6f6f6) !important; }
.tainacan-block-placeholder.components-placeholder .components-placeholder__label {
margin-bottom: 0; }
.tainacan-block-placeholder.components-placeholder .components-placeholder__fieldset {
@ -36,20 +36,22 @@
margin: 0; }
.wp-block-tainacan-modal {
width: 50%; }
width: 50% !important; }
@media only screen and (max-width: 1024px) {
.wp-block-tainacan-modal {
width: 75%; } }
width: 75% !important; } }
@media only screen and (max-width: 768px) {
.wp-block-tainacan-modal {
width: 100%; } }
width: 100% !important; } }
.wp-block-tainacan-modal.dynamic-modal {
width: 90%;
width: 90% !important;
height: 90%;
width: 80vw;
width: 80vw !important;
height: 80vh; }
.wp-block-tainacan-modal.dynamic-modal iframe {
width: 100%;
height: calc(100% - 76px); }
.wp-block-tainacan-modal.dynamic-modal.wp-version-smaller-than-6-1 iframe {
height: calc(100% - 96px); }
.wp-block-tainacan-modal.dynamic-modal.wp-version-smaller-than-5-9 iframe {
height: calc(100% - 156px); }
@ -97,7 +99,8 @@
.wp-block-tainacan-modal .modal-search-area .components-base-control {
width: 95%; } }
.wp-block-tainacan-modal .modal-search-area .components-base-control:nth-child(2) {
flex-shrink: 2; }
flex-shrink: 2;
margin-left: 0.75em; }
.wp-block-tainacan-modal .modal-search-area .components-base-control .components-base-control__field {
flex-wrap: wrap; }
.wp-block-tainacan-modal .modal-search-area .components-base-control .components-base-control__field .components-select-control {
@ -113,8 +116,7 @@
.wp-block-tainacan-modal .modal-radio-area-label {
font-weight: 500;
margin-left: 1.75em; }
.wp-block-tainacan-modal .modal-checkbox-list,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field {
.wp-block-tainacan-modal .modal-checkbox-list, .wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field, .wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack {
padding: 0;
flex-wrap: wrap;
display: flex;
@ -125,44 +127,44 @@
grid-gap: 0px;
justify-content: space-evenly;
list-style-type: none;
margin: 10px;
margin: 5px 0px;
padding: 2px;
max-height: 37vh;
overflow-y: auto;
overflow-x: hidden; }
.wp-block-tainacan-modal .modal-checkbox-list .components-base-control,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-base-control {
overflow-x: hidden;
width: 100%; }
.wp-block-tainacan-modal .modal-checkbox-list .components-base-control, .wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field .components-base-control, .wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack .components-base-control {
overflow: hidden;
padding-left: 1px; }
.wp-block-tainacan-modal .modal-checkbox-list .modal-checkbox-list-item,
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .modal-checkbox-list-item,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-radio-control__option {
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option, .wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field .modal-checkbox-list-item,
.wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field .components-radio-control__option, .wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack .modal-checkbox-list-item,
.wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack .components-radio-control__option {
display: flex;
justify-content: flex-start;
align-items: center; }
align-items: center;
margin: 0.35em; }
.wp-block-tainacan-modal .modal-checkbox-list .modal-checkbox-list-item img,
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option img,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .modal-checkbox-list-item img,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-radio-control__option img {
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option img, .wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field .modal-checkbox-list-item img,
.wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field .components-radio-control__option img, .wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack .modal-checkbox-list-item img,
.wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack .components-radio-control__option img {
width: 24px;
height: 24px;
margin-right: 10px;
margin-bottom: 8px; }
.wp-block-tainacan-modal .modal-checkbox-list .modal-checkbox-list-item label,
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option label,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .modal-checkbox-list-item label,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-radio-control__option label {
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option label, .wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field .modal-checkbox-list-item label,
.wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field .components-radio-control__option label, .wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack .modal-checkbox-list-item label,
.wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack .components-radio-control__option label {
display: inline-block;
max-width: 85%; }
@media only screen and (max-width: 768px) {
.wp-block-tainacan-modal .modal-checkbox-list .modal-checkbox-list-item label,
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option label,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .modal-checkbox-list-item label,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-radio-control__option label {
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option label, .wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field .modal-checkbox-list-item label,
.wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field .components-radio-control__option label, .wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack .modal-checkbox-list-item label,
.wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack .components-radio-control__option label {
max-width: 80%; } }
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option .components-radio-control__input,
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-radio-control__option .components-radio-control__input {
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option .components-radio-control__input, .wp-block-tainacan-modal.wp-version-smaller-than-6-1 .modal-radio-list .components-base-control__field .components-radio-control__option .components-radio-control__input, .wp-block-tainacan-modal:not(.wp-version-smaller-than-6-1) .modal-radio-list .components-flex.components-h-stack.components-v-stack .components-radio-control__option .components-radio-control__input {
min-width: 20px;
min-height: 20px; }
.wp-block-tainacan-modal .modal-loadmore-section {

View File

@ -1,6 +1,6 @@
{
"version": 3,
"mappings": "AAIA,KAAM;EACF,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,wBAAwB,CAAC,QAAY;;AAIzC,kDAAmD;EAC/C,WAAW,EAAE,iBAAiB;EAC9B,aAAa,EAAE,YAAY;EAC3B,UAAU,EAAE,oCAAmC;EAE/C,iFAA+B;IAC3B,aAAa,EAAE,CAAC;EAEpB,oFAAkC;IAC9B,OAAO,EAAE,IAAI;IACb,cAAc,EAAE,GAAG;IACnB,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,CAAC;IAEV,sFAAE;MACE,SAAS,EAAE,cAAc;MACzB,MAAM,EAAE,IAAI;MACZ,KAAK,EAAE,oCAAmC;MAC1C,IAAI,EAAE,oCAAmC;MAEzC,0FAAI;QACA,YAAY,EAAE,GAAG;QACjB,GAAG,EAAE,GAAG;QACR,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,oCAAmC;IAGjD,uGAAmB;MACf,MAAM,EAAE,CAAC;;AAMrB,wBAAyB;EACrB,KAAK,EAAE,GAAG;EAEV,0CAA2C;IAH/C,wBAAyB;MAGyB,KAAK,EAAE,GAAG;EACxD,yCAA0C;IAJ9C,wBAAyB;MAIuB,KAAK,EAAE,IAAI;EAGvD,sCAAgB;IACZ,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IAEZ,6CAAO;MACH,KAAK,EAAE,IAAI;MACX,MAAM,EAAE,iBAAiB;IAE7B,yEAAqC;MACjC,MAAM,EAAE,kBAAkB;IAG9B,yDAAmB;MACf,MAAM,EAAE,IAAI;MACZ,KAAK,EAAE,IAAI;MACX,UAAU,EAAE,8CAA6C;MACzD,OAAO,EAAE,SAAS;IAGtB,iEAA2B;MACvB,OAAO,EAAE,CAAC;MAEV,2FAA0B;QACtB,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,CAAC;EAM3B,2CAAmB;IACf,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,KAAK,EAAE,oCAAmC;IAC1C,+DAAoB;MAAE,MAAM,EAAE,GAAG;EAGrC;4EACkD;IAC9C,aAAa,EAAE,CAAC;IAEhB;oFAAQ;MACJ,UAAU,EAAE,sBAAsB;MAClC,MAAM,EAAE,eAAe;MACvB,UAAU,EAAE,eAAe;EAInC,2BAAG;IACC,MAAM,EAAE,UAAU;EAGtB,0DAAkC;IAC9B,OAAO,EAAE,kBAAkB;IAC3B,MAAM,EAAE,YAAY;IACpB,WAAW,EAAE,GAAG;EAGpB,2CAAmB;IACf,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,QAAQ;IACrB,aAAa,EAAE,GAAG;IAElB,oEAAyB;MACrB,KAAK,EAAE,GAAG;MAEV,0CAA2C;QAH/C,oEAAyB;UAGyB,KAAK,EAAE,GAAG;MACxD,iFAAe;QACX,WAAW,EAAE,CAAC;MAElB,oGAAgC;QAC5B,SAAS,EAAE,IAAI;QAEf,+HAA2B;UACvB,KAAK,EAAE,IAAI;MAGnB,yGAAqC;QACjC,WAAW,EAAE,GAAG;QAChB,KAAK,EAAE,oCAAmC;QAC1C,SAAS,EAAE,GAAG;QACd,UAAU,EAAE,MAAM;MAEtB,yGAAqC;QACjC,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,IAAI;EAKxB,gDAAwB;IACpB,WAAW,EAAE,GAAG;IAChB,WAAW,EAAE,MAAM;EAGvB;4EACkD;IAC9C,OAAO,EAAE,CAAC;ICjKd,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,IAAI;IDgKT,gBAAgB,EAAE,WAAW;IAC7B,qBAAqB,EAAE,wBAAwB;IAC/C,QAAQ,EAAE,GAAG;IACb,eAAe,EAAE,YAAY;IAC7B,eAAe,EAAE,IAAI;IACrB,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,GAAG;IACZ,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,MAAM;IAElB;uGAAyB;MACrB,QAAQ,EAAE,MAAM;MAChB,YAAY,EAAE,GAAG;IAGrB;;;gHACkC;MAC9B,OAAO,EAAE,IAAI;MACb,eAAe,EAAE,UAAU;MAC3B,WAAW,EAAE,MAAM;MAEnB;;;sHAAI;QACA,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,IAAI;QACZ,YAAY,EAAE,IAAI;QAClB,aAAa,EAAE,GAAG;MAEtB;;;wHAAM;QACF,OAAO,EAAE,YAAY;QACrB,SAAS,EAAE,GAAG;QAEd,yCAA0C;UAJ9C;;;4HAAM;YAI0C,SAAS,EAAE,GAAG;IAGlE;iJAAmE;MAC/D,SAAS,EAAE,IAAI;MACf,UAAU,EAAE,IAAI;EAGxB,gDAAwB;IACpB,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,MAAM;IAEvB,kDAAE;MACE,KAAK,EAAE,oCAAmC;MAC1C,YAAY,EAAE,IAAI;MAClB,UAAU,EAAE,GAAG;EAGvB,2CAAmB;IACf,UAAU,EAAE,iBAAiB;IAC7B,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,aAAa;IAC9B,OAAO,EAAE,UAAU;IAEnB,6CAAE;MACE,OAAO,EAAE,MAAM;MACf,KAAK,EAAE,oCAAmC",
"mappings": "AAIA,KAAM;EACF,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,wBAAwB,CAAC,QAAY;;AAIzC,kDAAmD;EAC/C,WAAW,EAAE,iBAAiB;EAC9B,aAAa,EAAE,YAAY;EAC3B,UAAU,EAAE,+CAA8C;EAE1D,iFAA+B;IAC3B,aAAa,EAAE,CAAC;EAEpB,oFAAkC;IAC9B,OAAO,EAAE,IAAI;IACb,cAAc,EAAE,GAAG;IACnB,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,CAAC;IAEV,sFAAE;MACE,SAAS,EAAE,cAAc;MACzB,MAAM,EAAE,IAAI;MACZ,KAAK,EAAE,oCAAmC;MAC1C,IAAI,EAAE,oCAAmC;MAEzC,0FAAI;QACA,YAAY,EAAE,GAAG;QACjB,GAAG,EAAE,GAAG;QACR,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,oCAAmC;IAGjD,uGAAmB;MACf,MAAM,EAAE,CAAC;;AAMrB,wBAAyB;EACrB,KAAK,EAAE,cAAc;EAErB,0CAA2C;IAH/C,wBAAyB;MAGyB,KAAK,EAAE,cAAc;EACnE,yCAA0C;IAJ9C,wBAAyB;MAIuB,KAAK,EAAE,eAAe;EAGlE,sCAAgB;IACZ,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,eAAe;IACtB,MAAM,EAAE,IAAI;IAEZ,6CAAO;MACH,KAAK,EAAE,IAAI;MACX,MAAM,EAAE,iBAAiB;IAE7B,yEAAqC;MACjC,MAAM,EAAE,iBAAiB;IAE7B,yEAAqC;MACjC,MAAM,EAAE,kBAAkB;IAG9B,yDAAmB;MACf,MAAM,EAAE,IAAI;MACZ,KAAK,EAAE,IAAI;MACX,UAAU,EAAE,8CAA6C;MACzD,OAAO,EAAE,SAAS;IAGtB,iEAA2B;MACvB,OAAO,EAAE,CAAC;MAEV,2FAA0B;QACtB,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,CAAC;EAM3B,2CAAmB;IACf,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,KAAK,EAAE,oCAAmC;IAC1C,+DAAoB;MAAE,MAAM,EAAE,GAAG;EAGrC;4EACkD;IAC9C,aAAa,EAAE,CAAC;IAEhB;oFAAQ;MACJ,UAAU,EAAE,sBAAsB;MAClC,MAAM,EAAE,eAAe;MACvB,UAAU,EAAE,eAAe;EAInC,2BAAG;IACC,MAAM,EAAE,UAAU;EAGtB,0DAAkC;IAC9B,OAAO,EAAE,kBAAkB;IAC3B,MAAM,EAAE,YAAY;IACpB,WAAW,EAAE,GAAG;EAGpB,2CAAmB;IACf,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,QAAQ;IACrB,aAAa,EAAE,GAAG;IAElB,oEAAyB;MACrB,KAAK,EAAE,GAAG;MAEV,0CAA2C;QAH/C,oEAAyB;UAGyB,KAAK,EAAE,GAAG;MACxD,iFAAe;QACX,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,MAAM;MAEvB,oGAAgC;QAC5B,SAAS,EAAE,IAAI;QAEf,+HAA2B;UACvB,KAAK,EAAE,IAAI;MAGnB,yGAAqC;QACjC,WAAW,EAAE,GAAG;QAChB,KAAK,EAAE,oCAAmC;QAC1C,SAAS,EAAE,GAAG;QACd,UAAU,EAAE,MAAM;MAEtB,yGAAqC;QACjC,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,IAAI;EAKxB,gDAAwB;IACpB,WAAW,EAAE,GAAG;IAChB,WAAW,EAAE,MAAM;EAGvB,0RAE6G;IACzG,OAAO,EAAE,CAAC;ICtKd,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,IAAI;IDqKT,gBAAgB,EAAE,WAAW;IAC7B,qBAAqB,EAAE,wBAAwB;IAC/C,QAAQ,EAAE,GAAG;IACb,eAAe,EAAE,YAAY;IAC7B,eAAe,EAAE,IAAI;IACrB,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,GAAG;IACZ,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,MAAM;IAClB,KAAK,EAAE,IAAI;IAEX,qWAAyB;MACrB,QAAQ,EAAE,MAAM;MAChB,YAAY,EAAE,GAAG;IAGrB;;;yKACkC;MAC9B,OAAO,EAAE,IAAI;MACb,eAAe,EAAE,UAAU;MAC3B,WAAW,EAAE,MAAM;MACnB,MAAM,EAAE,MAAM;MAEd;;;+KAAI;QACA,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,IAAI;QACZ,YAAY,EAAE,IAAI;QAClB,aAAa,EAAE,GAAG;MAEtB;;;iLAAM;QACF,OAAO,EAAE,YAAY;QACrB,SAAS,EAAE,GAAG;QAEd,yCAA0C;UAJ9C;;;qLAAM;YAI0C,SAAS,EAAE,GAAG;IAGlE,meAAmE;MAC/D,SAAS,EAAE,IAAI;MACf,UAAU,EAAE,IAAI;EAGxB,gDAAwB;IACpB,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,MAAM;IAEvB,kDAAE;MACE,KAAK,EAAE,oCAAmC;MAC1C,YAAY,EAAE,IAAI;MAClB,UAAU,EAAE,GAAG;EAGvB,2CAAmB;IACf,UAAU,EAAE,iBAAiB;IAC7B,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,aAAa;IAC9B,OAAO,EAAE,UAAU;IAEnB,6CAAE;MACE,OAAO,EAAE,MAAM;MACf,KAAK,EAAE,oCAAmC",
"sources": ["../../views/gutenberg-blocks/scss/gutenberg-blocks-editor-style.scss","../../views/gutenberg-blocks/scss/gutenberg-blocks-variables.scss"],
"names": [],
"file": "tainacan-gutenberg-block-common-editor-styles.css"

View File

@ -10,6 +10,28 @@
text-align: center;
margin: 0 auto;
padding: 8px 2px 2px 2px; }
.item-gallery-edit-container .tainacan-gallery-main-placeholder {
position: relative;
min-height: var(--tainacan-media-main-carousel-height, 60vh);
max-width: var(--tainacan-media-main-carousel-width, 100%);
margin: 0 auto 1em auto; }
.item-gallery-edit-container .tainacan-gallery-thumbnails-placeholder {
display: flex;
flex-wrap: nowrap;
justify-content: center;
gap: 20px;
list-style: none !important;
margin: 0px auto !important;
padding: 0px !important;
max-width: var(--tainacan-media-thumbs-carousel-width, 100%);
width: var(--tainacan-media-thumbs-carousel-width, 100%);
overflow-x: auto;
overflow-y: hidden; }
.item-gallery-edit-container .tainacan-gallery-thumbnails-placeholder li {
height: var(--tainacan-media-thumbs-carousel-item-size, 136px);
min-width: var(--tainacan-media-thumbs-carousel-item-size, 136px);
flex-basis: var(--tainacan-media-thumbs-carousel-item-size, 136px);
position: relative; }
.tainacan-media-component {
--swiper-theme-color: var(--tainacan-secondary, #298596);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,51 @@
.wp-block-tainacan-related-items {
margin: 0.5em auto;
width: 100%; }
.wp-block-tainacan-related-items .spinner-container {
min-height: 56px;
padding: 1em;
display: flex;
justify-content: center;
align-items: center;
color: var(--tainacan-block-gray4, #555758); }
@-webkit-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-moz-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-o-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
.wp-block-tainacan-related-items .skeleton {
border-radius: 2px;
background: var(--tainacan-block-gray1, #f2f2f2);
-webkit-animation: skeleton-animation 1.8s ease infinite;
-moz-animation: skeleton-animation 1.8s ease infinite;
-o-animation: skeleton-animation 1.8s ease infinite;
animation: skeleton-animation 1.8s ease infinite; }
.wp-block-tainacan-related-items .related-items-edit-container {
position: relative; }
.wp-block-tainacan-related-items .related-items-edit-container .skeleton {
min-height: 150px; }
/*# sourceMappingURL=tainacan-gutenberg-block-item-metadata-section.css.map */

View File

@ -0,0 +1,7 @@
{
"version": 3,
"mappings": "AAEA,gCAAiC;EAC7B,MAAM,EAAE,UAAU;EAClB,KAAK,EAAE,IAAI;EAGX,mDAAmB;IACf,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,KAAK,EAAE,oCAAmC;AAI9C,qCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,kCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,gCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,6BAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;EAErB,0CAAU;IACN,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,oCAAmC;IAE/C,iBAAiB,EAAE,qCAAqC;IACxD,cAAc,EAAE,qCAAqC;IACrD,YAAY,EAAE,qCAAqC;IACnD,SAAS,EAAE,qCAAqC;EAIpD,8DAA8B;IAC1B,QAAQ,EAAE,QAAQ;IAElB,wEAAY;MACR,UAAU,EAAE,KAAK",
"sources": ["../../views/gutenberg-blocks/blocks/related-items-list/style.scss"],
"names": [],
"file": "tainacan-gutenberg-block-item-metadata-section.css"
}

View File

@ -0,0 +1,51 @@
.wp-block-tainacan-related-items {
margin: 0.5em auto;
width: 100%; }
.wp-block-tainacan-related-items .spinner-container {
min-height: 56px;
padding: 1em;
display: flex;
justify-content: center;
align-items: center;
color: var(--tainacan-block-gray4, #555758); }
@-webkit-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-moz-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-o-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
.wp-block-tainacan-related-items .skeleton {
border-radius: 2px;
background: var(--tainacan-block-gray1, #f2f2f2);
-webkit-animation: skeleton-animation 1.8s ease infinite;
-moz-animation: skeleton-animation 1.8s ease infinite;
-o-animation: skeleton-animation 1.8s ease infinite;
animation: skeleton-animation 1.8s ease infinite; }
.wp-block-tainacan-related-items .related-items-edit-container {
position: relative; }
.wp-block-tainacan-related-items .related-items-edit-container .skeleton {
min-height: 150px; }
/*# sourceMappingURL=tainacan-gutenberg-block-item-metadata-sections.css.map */

View File

@ -0,0 +1,7 @@
{
"version": 3,
"mappings": "AAEA,gCAAiC;EAC7B,MAAM,EAAE,UAAU;EAClB,KAAK,EAAE,IAAI;EAGX,mDAAmB;IACf,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,KAAK,EAAE,oCAAmC;AAI9C,qCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,kCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,gCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,6BAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;EAErB,0CAAU;IACN,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,oCAAmC;IAE/C,iBAAiB,EAAE,qCAAqC;IACxD,cAAc,EAAE,qCAAqC;IACrD,YAAY,EAAE,qCAAqC;IACnD,SAAS,EAAE,qCAAqC;EAIpD,8DAA8B;IAC1B,QAAQ,EAAE,QAAQ;IAElB,wEAAY;MACR,UAAU,EAAE,KAAK",
"sources": ["../../views/gutenberg-blocks/blocks/related-items-list/style.scss"],
"names": [],
"file": "tainacan-gutenberg-block-item-metadata-sections.css"
}

View File

@ -0,0 +1,51 @@
.wp-block-tainacan-related-items {
margin: 0.5em auto;
width: 100%; }
.wp-block-tainacan-related-items .spinner-container {
min-height: 56px;
padding: 1em;
display: flex;
justify-content: center;
align-items: center;
color: var(--tainacan-block-gray4, #555758); }
@-webkit-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-moz-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-o-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
.wp-block-tainacan-related-items .skeleton {
border-radius: 2px;
background: var(--tainacan-block-gray1, #f2f2f2);
-webkit-animation: skeleton-animation 1.8s ease infinite;
-moz-animation: skeleton-animation 1.8s ease infinite;
-o-animation: skeleton-animation 1.8s ease infinite;
animation: skeleton-animation 1.8s ease infinite; }
.wp-block-tainacan-related-items .related-items-edit-container {
position: relative; }
.wp-block-tainacan-related-items .related-items-edit-container .skeleton {
min-height: 150px; }
/*# sourceMappingURL=tainacan-gutenberg-block-item-metadata.css.map */

View File

@ -0,0 +1,7 @@
{
"version": 3,
"mappings": "AAEA,gCAAiC;EAC7B,MAAM,EAAE,UAAU;EAClB,KAAK,EAAE,IAAI;EAGX,mDAAmB;IACf,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,KAAK,EAAE,oCAAmC;AAI9C,qCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,kCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,gCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,6BAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;EAErB,0CAAU;IACN,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,oCAAmC;IAE/C,iBAAiB,EAAE,qCAAqC;IACxD,cAAc,EAAE,qCAAqC;IACrD,YAAY,EAAE,qCAAqC;IACnD,SAAS,EAAE,qCAAqC;EAIpD,8DAA8B;IAC1B,QAAQ,EAAE,QAAQ;IAElB,wEAAY;MACR,UAAU,EAAE,KAAK",
"sources": ["../../views/gutenberg-blocks/blocks/related-items-list/style.scss"],
"names": [],
"file": "tainacan-gutenberg-block-item-metadata.css"
}

View File

@ -0,0 +1,51 @@
.wp-block-tainacan-related-items {
margin: 0.5em auto;
width: 100%; }
.wp-block-tainacan-related-items .spinner-container {
min-height: 56px;
padding: 1em;
display: flex;
justify-content: center;
align-items: center;
color: var(--tainacan-block-gray4, #555758); }
@-webkit-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-moz-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-o-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
.wp-block-tainacan-related-items .skeleton {
border-radius: 2px;
background: var(--tainacan-block-gray1, #f2f2f2);
-webkit-animation: skeleton-animation 1.8s ease infinite;
-moz-animation: skeleton-animation 1.8s ease infinite;
-o-animation: skeleton-animation 1.8s ease infinite;
animation: skeleton-animation 1.8s ease infinite; }
.wp-block-tainacan-related-items .related-items-edit-container {
position: relative; }
.wp-block-tainacan-related-items .related-items-edit-container .skeleton {
min-height: 150px; }
/*# sourceMappingURL=tainacan-gutenberg-block-item-metadatum.css.map */

View File

@ -0,0 +1,7 @@
{
"version": 3,
"mappings": "AAEA,gCAAiC;EAC7B,MAAM,EAAE,UAAU;EAClB,KAAK,EAAE,IAAI;EAGX,mDAAmB;IACf,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,KAAK,EAAE,oCAAmC;AAI9C,qCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,kCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,gCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,6BAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;EAErB,0CAAU;IACN,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,oCAAmC;IAE/C,iBAAiB,EAAE,qCAAqC;IACxD,cAAc,EAAE,qCAAqC;IACrD,YAAY,EAAE,qCAAqC;IACnD,SAAS,EAAE,qCAAqC;EAIpD,8DAA8B;IAC1B,QAAQ,EAAE,QAAQ;IAElB,wEAAY;MACR,UAAU,EAAE,KAAK",
"sources": ["../../views/gutenberg-blocks/blocks/related-items-list/style.scss"],
"names": [],
"file": "tainacan-gutenberg-block-item-metadatum.css"
}

View File

@ -0,0 +1,51 @@
.wp-block-tainacan-related-items {
margin: 0.5em auto;
width: 100%; }
.wp-block-tainacan-related-items .spinner-container {
min-height: 56px;
padding: 1em;
display: flex;
justify-content: center;
align-items: center;
color: var(--tainacan-block-gray4, #555758); }
@-webkit-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-moz-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-o-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
.wp-block-tainacan-related-items .skeleton {
border-radius: 2px;
background: var(--tainacan-block-gray1, #f2f2f2);
-webkit-animation: skeleton-animation 1.8s ease infinite;
-moz-animation: skeleton-animation 1.8s ease infinite;
-o-animation: skeleton-animation 1.8s ease infinite;
animation: skeleton-animation 1.8s ease infinite; }
.wp-block-tainacan-related-items .related-items-edit-container {
position: relative; }
.wp-block-tainacan-related-items .related-items-edit-container .skeleton {
min-height: 150px; }
/*# sourceMappingURL=tainacan-gutenberg-block-metadata-section-description.css.map */

View File

@ -0,0 +1,7 @@
{
"version": 3,
"mappings": "AAEA,gCAAiC;EAC7B,MAAM,EAAE,UAAU;EAClB,KAAK,EAAE,IAAI;EAGX,mDAAmB;IACf,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,KAAK,EAAE,oCAAmC;AAI9C,qCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,kCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,gCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,6BAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;EAErB,0CAAU;IACN,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,oCAAmC;IAE/C,iBAAiB,EAAE,qCAAqC;IACxD,cAAc,EAAE,qCAAqC;IACrD,YAAY,EAAE,qCAAqC;IACnD,SAAS,EAAE,qCAAqC;EAIpD,8DAA8B;IAC1B,QAAQ,EAAE,QAAQ;IAElB,wEAAY;MACR,UAAU,EAAE,KAAK",
"sources": ["../../views/gutenberg-blocks/blocks/related-items-list/style.scss"],
"names": [],
"file": "tainacan-gutenberg-block-metadata-section-description.css"
}

View File

@ -0,0 +1,51 @@
.wp-block-tainacan-related-items {
margin: 0.5em auto;
width: 100%; }
.wp-block-tainacan-related-items .spinner-container {
min-height: 56px;
padding: 1em;
display: flex;
justify-content: center;
align-items: center;
color: var(--tainacan-block-gray4, #555758); }
@-webkit-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-moz-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@-o-keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
@keyframes skeleton-animation {
0% {
opacity: 1.0; }
50% {
opacity: 0.2; }
100% {
opacity: 1.0; } }
.wp-block-tainacan-related-items .skeleton {
border-radius: 2px;
background: var(--tainacan-block-gray1, #f2f2f2);
-webkit-animation: skeleton-animation 1.8s ease infinite;
-moz-animation: skeleton-animation 1.8s ease infinite;
-o-animation: skeleton-animation 1.8s ease infinite;
animation: skeleton-animation 1.8s ease infinite; }
.wp-block-tainacan-related-items .related-items-edit-container {
position: relative; }
.wp-block-tainacan-related-items .related-items-edit-container .skeleton {
min-height: 150px; }
/*# sourceMappingURL=tainacan-gutenberg-block-metadata-section-name.css.map */

View File

@ -0,0 +1,7 @@
{
"version": 3,
"mappings": "AAEA,gCAAiC;EAC7B,MAAM,EAAE,UAAU;EAClB,KAAK,EAAE,IAAI;EAGX,mDAAmB;IACf,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,KAAK,EAAE,oCAAmC;AAI9C,qCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,kCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,gCAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;AAErB,6BAIC;EAHG,EAAE;IAAC,OAAO,EAAE,GAAG;EACf,GAAG;IAAC,OAAO,EAAE,GAAG;EAChB,IAAI;IAAC,OAAO,EAAE,GAAG;EAErB,0CAAU;IACN,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,oCAAmC;IAE/C,iBAAiB,EAAE,qCAAqC;IACxD,cAAc,EAAE,qCAAqC;IACrD,YAAY,EAAE,qCAAqC;IACnD,SAAS,EAAE,qCAAqC;EAIpD,8DAA8B;IAC1B,QAAQ,EAAE,QAAQ;IAElB,wEAAY;MACR,UAAU,EAAE,KAAK",
"sources": ["../../views/gutenberg-blocks/blocks/related-items-list/style.scss"],
"names": [],
"file": "tainacan-gutenberg-block-metadata-section-name.css"
}

View File

@ -93,7 +93,8 @@ class REST_Controller extends \WP_REST_Controller {
'hierarchical' => 'hierarchical',
'exclude' => 'post__not_in',
'excludetree' => 'exclude_tree',
'include' => 'include'
'include' => 'include',
'sentence' => 'sentence'
];
$meta_query = [
@ -312,6 +313,12 @@ class REST_Controller extends \WP_REST_Controller {
'validate_callback' => 'rest_validate_request_arg',
);
$query_params['sentence'] = array(
'description' => __( 'Whether to search by phrase. Default false.', 'tainacan' ),
'type' => 'boolean',
'default' => true,
);
$query_params['authorid'] = array(
'description' => __("Limit result set to objects assigned to specific authors by id.", 'tainacan'),
'type' => 'integer',
@ -364,7 +371,8 @@ class REST_Controller extends \WP_REST_Controller {
'meta_value',
'meta_value_num',
'menu_order',
'rand'
'rand',
'post__in'
),
);

View File

@ -14,7 +14,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
private $metadatum_repository;
public function __construct() {
$this->rest_base = 'metadata';
$this->rest_base = 'item';
parent::__construct();
add_action('init', array(&$this, 'init_objects'), 11);
}
@ -40,7 +40,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
* Both of GETs return the metadatum of matched objects
*/
public function register_routes() {
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/' . $this->rest_base . '/(?P<metadatum_id>[\d]+)',
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<item_id>[\d]+)/metadata/(?P<metadatum_id>[\d]+)',
array(
array(
'methods' => \WP_REST_Server::READABLE,
@ -60,7 +60,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
),
)
);
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/' . $this->rest_base,
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<item_id>[\d]+)/metadata',
array(
array(
'methods' => \WP_REST_Server::READABLE,
@ -70,6 +70,15 @@ class REST_Item_Metadata_Controller extends REST_Controller {
)
)
);
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<item_id>[\d]+)/metadata-sections/(?P<metadata_section_id>[\d|default_section]+)',
array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array($this, 'get_items'),
'permission_callback' => array($this, 'get_items_permissions_check'),
),
)
);
}
/**
@ -115,13 +124,27 @@ class REST_Item_Metadata_Controller extends REST_Controller {
public function get_items( $request ) {
$item_id = $request['item_id'];
$args = array();
if( isset($request['metadata_section_id']) ) {
$args = array_merge($args, array(
'parent' => 0,
'meta_query' => [
[
'key' => 'metadata_section_id',
'value' => $request['metadata_section_id'],
'compare' => '='
]
]
));
}
$item = $this->item_repository->fetch($item_id);
if( in_array($item->get_status(), ['auto-draft'] ) ) {
$this->item_metadata_repository->create_default_value_metadata($item);
}
$items_metadata = $item->get_metadata();
$items_metadata = $item->get_metadata( $args );
$prepared_item = [];

View File

@ -607,7 +607,7 @@ class REST_Items_Controller extends REST_Controller {
foreach($filters_args as $filters_arg) {
if($filters_arg['filter'] !== false) {
for($idx = 0; $idx < count($args['meta_query']); $idx++) {
if($args['meta_query'][$idx]['key'] == $filters_arg['metadatum']['metadatum_id']) {
if( isset($args['meta_query'][$idx]['key']) && $args['meta_query'][$idx]['key'] == $filters_arg['metadatum']['metadatum_id']) {
$args['meta_query'][$idx]['type'] = $filters_arg['type'];
}
}

View File

@ -53,9 +53,21 @@ class Elastic_Press {
//https://www.elasticpress.io/blog/2019/02/custom-search-with-elasticpress-how-to-limit-results-to-full-text-matches/
if ( ! empty( $formatted_args['query']['bool']['should'] ) ) {
$formatted_args['query']['bool']['must'] = $formatted_args['query']['bool']['should'];
$formatted_args['query']['bool']['must'][0]['multi_match']['operator'] = 'AND';
$formatted_args["query"]["bool"]["must"][0]["multi_match"]["type"] = "phrase_prefix";
// $formatted_args['query']['bool']['must'][0]['multi_match']['operator'] = 'AND';
if ( isset($formatted_args['query']['bool']['must'][0]['multi_match']['operator']))
unset($formatted_args['query']['bool']['must'][0]['multi_match']['operator']);
if ( isset($formatted_args['query']['bool']['must'][1]['multi_match']['operator']))
unset($formatted_args['query']['bool']['must'][1]['multi_match']['operator']);
if ( isset($formatted_args['query']['bool']['must'][2]['multi_match']['operator']))
unset($formatted_args['query']['bool']['must'][2]['multi_match']['operator']);
if ( isset($formatted_args['query']['bool']['must'][2]) ) {
$formatted_args['query']['bool']['must'][2]['multi_match']['analyzer'] = 'default';
}
unset( $formatted_args['query']['bool']['should'] );
unset( $formatted_args["query"]["bool"]["must"][0]["multi_match"]["type"] );
}
/**
@ -63,22 +75,22 @@ class Elastic_Press {
* Elasticsearch is not good a substring matches similar to SQL like.
* here we replace `match_phrase` with` wildcard`, but this is not an efficient operation.
*/
if ( ! empty( $formatted_args['post_filter']['bool']['must'] ) ) {
$array_must = $formatted_args['post_filter']['bool']['must'];
for($i = 0; $i < count($array_must); $i++ ) {
$el_must = $array_must[$i];
if( ! empty($el_must['bool']['must']) ) {
$array_must_nested = $el_must['bool']['must'];
for($j = 0; $j < count($array_must_nested); $j++ ) {
if ( isset ($array_must_nested[$j]['match_phrase'] ) ) {
$formatted_args['post_filter']['bool']['must'][$i]['bool']['must'][$j]['match_phrase_prefix'] =
array_map( function($match) { return "$match"; } ,$array_must_nested[$j]['match_phrase']);
unset($formatted_args['post_filter']['bool']['must'][$i]['bool']['must'][$j]['match_phrase']);
}
}
}
}
}
// if ( ! empty( $formatted_args['post_filter']['bool']['must'] ) ) {
// $array_must = $formatted_args['post_filter']['bool']['must'];
// for($i = 0; $i < count($array_must); $i++ ) {
// $el_must = $array_must[$i];
// if( ! empty($el_must['bool']['must']) ) {
// $array_must_nested = $el_must['bool']['must'];
// for($j = 0; $j < count($array_must_nested); $j++ ) {
// if ( isset ($array_must_nested[$j]['match_phrase'] ) ) {
// $formatted_args['post_filter']['bool']['must'][$i]['bool']['must'][$j]['match_phrase_prefix'] =
// array_map( function($match) { return "$match"; } ,$array_must_nested[$j]['match_phrase']);
// unset($formatted_args['post_filter']['bool']['must'][$i]['bool']['must'][$j]['match_phrase']);
// }
// }
// }
// }
// }
return $formatted_args;
} );

View File

@ -39,26 +39,19 @@ class Search_Engine {
function search_hooks() {
add_filter( 'posts_join', array( &$this, 'terms_join' ) );
add_filter( 'posts_join', array( &$this, 'search_metadata_join' ) );
// add_filter( 'posts_join', array( &$this, 'terms_join' ) );
// add_filter( 'posts_join', array( &$this, 'search_metadata_join' ) );
add_filter( 'posts_join', array( &$this, 'relationships_join' ) );
//add_filter( 'posts_where', array( &$this, 'search_attachments' ) );
add_filter( 'posts_join', array( &$this, 'search_authors_join' ) );
add_filter( 'posts_search', array( &$this, 'search_where' ), 10, 2 );
add_filter( 'posts_request', array( &$this, 'distinct' ) );
//add_filter( 'posts_request', array( &$this, 'log_query' ), 10, 2 );
}
// creates the list of search keywords from the 's' parameters.
function get_search_terms() {
global $wpdb;
$s = isset( $this->query_instance->query_vars['s'] ) ? $this->query_instance->query_vars['s'] : '';
$sentence = isset( $this->query_instance->query_vars['sentence'] ) ? $this->query_instance->query_vars['sentence'] : false;
$search_terms = array();
@ -67,7 +60,7 @@ class Search_Engine {
// added slashes screw with quote grouping when done early, so done later
$s = stripslashes( $s );
if ( $sentence ) {
$search_terms = array( $s );
$search_terms = array( trim($s, " '\"\n\r\t\v\0") );
} else {
preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
@ -123,6 +116,78 @@ class Search_Engine {
}
}
function get_where_to_title_and_content() {
global $wpdb;
$searchQuery = '';
$seperator = '';
$not_exact = empty($this->query_instance->query_vars['exact']);
$terms = $this->get_search_terms();
foreach ( $terms as $term ) {
$esc_term = $wpdb->prepare("%s", $not_exact ? "%".$term."%" : $term);
if ( !empty( $this->relationships ) ) {
$searchQuery .= "{$seperator}($wpdb->posts.post_title LIKE {$esc_term} OR $wpdb->posts.post_content LIKE {$esc_term} OR p2.post_title LIKE {$esc_term} OR p2.post_content LIKE {$esc_term})";
} else {
$searchQuery .= "{$seperator}($wpdb->posts.post_title LIKE {$esc_term} OR $wpdb->posts.post_content LIKE {$esc_term})";
}
$seperator = ' OR ';
}
return empty($searchQuery) ? false : "($searchQuery)";
}
function get_where_to_term_taxonomies() {
if ( $this->is_tainacan_search && !empty( $this->taxonomies ) ) {
global $wpdb;
$search_tax_query = '';
$seperator = '';
$not_exact = empty($this->query_instance->query_vars['exact']);
$terms = $this->get_search_terms();
foreach ( $terms as $term ) {
$esc_term = $wpdb->prepare("%s", $not_exact ? "%".$term."%" : $term);
$search_tax_query .= "{$seperator}(tter.name LIKE {$esc_term})";
$seperator = ' OR ';
}
if (empty($search_tax_query)) return '';
$tax_where = ' ttax.taxonomy IN ( \'' . implode( '\',\'', $this->taxonomies ) . '\' ) ';
return "EXISTS (
SELECT trel.object_id
FROM
$wpdb->term_relationships AS trel
INNER JOIN $wpdb->term_taxonomy AS ttax ON trel.term_taxonomy_id = ttax.term_taxonomy_id
INNER JOIN $wpdb->terms AS tter ON ttax.term_id = tter.term_id
WHERE
$wpdb->posts.ID = trel.object_id AND $tax_where AND ( $search_tax_query )
)";
}
return '';
}
function get_where_to_metadatas() {
if ( $this->is_tainacan_search ) {
global $wpdb;
$search_meta_query = '';
$seperator = '';
$not_exact = empty($this->query_instance->query_vars['exact']);
$terms = $this->get_search_terms();
foreach ( $terms as $term ) {
$esc_term = $wpdb->prepare("%s", $not_exact ? "%".$term."%" : $term);
$search_meta_query .= "{$seperator}(m.meta_value LIKE {$esc_term})";
$seperator = ' OR ';
}
if ( empty($search_meta_query) ) return '';
$join = \is_user_logged_in()
? ''
: " INNER JOIN $wpdb->posts pmeta ON m.meta_key = pmeta.ID AND pmeta.post_status = 'publish'";
return "EXISTS (
SELECT m.post_id
FROM $wpdb->postmeta m $join
WHERE ( $wpdb->posts.ID = m.post_id AND ($search_meta_query) )
)";
}
return '';
}
// add where clause to the search query
function search_where( $where, $wp_query ) {
@ -136,47 +201,22 @@ class Search_Engine {
if ( !$this->is_tainacan_search && !$this->ajax_request)
return $where;
global $wpdb;
$search_query = $this->get_where_to_title_and_content();
$search_tax_query = $this->get_where_to_term_taxonomies();
$search_meta_query = $this->get_where_to_metadatas();
$search_query = "($search_query) ";
if(!empty($search_tax_query)) $search_query .= " OR ($search_tax_query) ";
if(!empty($search_meta_query)) $search_query .= " OR ($search_meta_query) ";
$search_query_fields = array();
$search_query_fields = array_merge($search_query_fields, $this->search_default());
$search_query_fields = array_merge($search_query_fields, $this->build_search_categories());
$search_query_fields = array_merge($search_query_fields, $this->build_search_metadata());
$search_query_fields = array_merge($search_query_fields, $this->build_search_relationships());
$search_query_fields = array_merge($search_query_fields, $this->search_authors());
$searchQuery = '(';
$seperator = '';
$not_exact = empty($this->query_instance->query_vars['exact']);
$terms = $this->get_search_terms();
$fields = implode(", ", $search_query_fields);
foreach ( $terms as $term ) {
$esc_term = $wpdb->prepare("%s", $not_exact ? "%".$term."%" : $term);
$searchQuery .= "{$seperator}CONCAT_WS(' || ', $fields ) LIKE $esc_term";
$seperator = ' OR ';
}
$searchQuery .= ')';
if ( $searchQuery != '' && $searchQuery != '()' ) {
if ( $search_query != '' && $search_query != '()' ) {
// lets use _OUR_ query instead of WP's, as we have posts already included in our query as well(assuming it's not empty which we check for)
$where = " AND ((" . $searchQuery . ")) ";
$where = " AND ((" . $search_query . ")) ";
}
return $where;
}
// search for terms in default locations like title and content
// replacing the old search terms seems to be the best way to
// avoid issue with multiple terms
function search_default() {
global $wpdb;
return ["$wpdb->posts.post_title", "$wpdb->posts.post_content"];
}
//Duplicate fix provided by Tiago.Pocinho
function distinct( $query ) {
global $wpdb;
if ( !empty( $this->query_instance->query_vars['s'] ) ) {
if ( strstr( $query, 'DISTINCT' ) ) {}
else {
@ -186,82 +226,6 @@ class Search_Engine {
return $query;
}
//search attachments
function search_attachments( $where ) {
global $wpdb;
if ( !empty( $this->query_instance->query_vars['s'] ) ) {
$where = str_replace( '"', '\'', $where );
if ( !$this->wp_ver28 ) {
$where = str_replace( " AND (post_status = 'publish'", " AND (post_status = 'publish' OR post_type = 'attachment'", $where );
$where = str_replace( "AND post_type != 'attachment'", "", $where );
}
else {
$where = str_replace( " AND ($wpdb->posts.post_status = 'publish'", " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_type = 'attachment'", $where );
$where = str_replace( "AND $wpdb->posts.post_type != 'attachment'", "", $where );
}
}
return $where;
}
// Build the author search
function search_authors() {
return ["u.display_name"];
}
function build_search_relationships(){
if ( empty( $this->relationships ) ) {
return [];
}
return ['p2.post_title'];
}
// create the search meta data query
function build_search_metadata() {
return ["m.meta_value"];
}
// create the search categories query
function build_search_categories() {
if (empty($this->taxonomies)) {
return [];
}
return ["tter.name", "ttax.description"];
}
//join for searching authors
function search_authors_join( $join ) {
if ($this->is_inner_query) {
return $join;
}
global $wpdb;
if ( $this->is_tainacan_search ) {
$join .= " LEFT JOIN $wpdb->users AS u ON ($wpdb->posts.post_author = u.ID) ";
}
return $join;
}
//join for searching metadata
function search_metadata_join( $join ) {
if ($this->is_inner_query) {
return $join;
}
global $wpdb;
if ( $this->is_tainacan_search ) {
$join .= " LEFT JOIN $wpdb->postmeta AS m ON ($wpdb->posts.ID = m.post_id) ";
}
return $join;
}
// join for relationship metadata
function relationships_join( $join ) {
@ -274,31 +238,81 @@ class Search_Engine {
if ( $this->is_tainacan_search && !empty( $this->relationships ) ) {
$relationships = implode(',', $this->relationships);
$join .= " LEFT JOIN $wpdb->posts AS p2 ON (m.meta_value = p2.ID AND m.meta_key IN ($relationships)) ";
$join .= "
LEFT JOIN $wpdb->postmeta m_rel ON ($wpdb->posts.ID = m_rel.post_id AND m_rel.meta_key IN ($relationships))
LEFT JOIN $wpdb->posts p2 ON (m_rel.meta_value = p2.ID) ";
}
return $join;
}
//join for searching tags
function terms_join( $join ) {
// //search attachments
// function search_attachments( $where ) {
// global $wpdb;
// if ( !empty( $this->query_instance->query_vars['s'] ) ) {
// $where = str_replace( '"', '\'', $where );
// if ( !$this->wp_ver28 ) {
// $where = str_replace( " AND (post_status = 'publish'", " AND (post_status = 'publish' OR post_type = 'attachment'", $where );
// $where = str_replace( "AND post_type != 'attachment'", "", $where );
// }
// else {
// $where = str_replace( " AND ($wpdb->posts.post_status = 'publish'", " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_type = 'attachment'", $where );
// $where = str_replace( "AND $wpdb->posts.post_type != 'attachment'", "", $where );
// }
// }
// return $where;
// }
// //join for searching metadata
// function search_metadata_join( $join ) {
if ($this->is_inner_query) {
return $join;
}
// if ($this->is_inner_query) {
// return $join;
// }
global $wpdb;
// global $wpdb;
// if ( $this->is_tainacan_search ) {
// $searchMetaQuery = $this->build_search_terms_query('meta_terms');
// $join .= <<<EOF
// LEFT JOIN
// (
// SELECT
// m.post_id, true as contains
// FROM
// $wpdb->postmeta m
// WHERE
// ( $searchMetaQuery )
// ) AS metas ON $wpdb->posts.ID = metas.post_id
// EOF;
// }
// return $join;
// }
if ( $this->is_tainacan_search && !empty( $this->taxonomies ) ) {
// //join for searching taxonomies terms
// function terms_join( $join ) {
// if ($this->is_inner_query) {
// return $join;
// }
// global $wpdb;
// $searchTaxQuery = $this->build_search_terms_query('tax_terms');
// if ( $this->is_tainacan_search && !empty( $this->taxonomies ) ) {
// $tax_where = ' ttax.taxonomy IN ( \'' . implode( '\',\'', $this->taxonomies ) . '\' ) ';
// $join .= <<<EOF
// LEFT JOIN (
// SELECT DISTINCT
// trel.object_id as post_id,
// true as contains
// FROM
// $wpdb->term_relationships AS trel
// INNER JOIN $wpdb->term_taxonomy AS ttax ON trel.term_taxonomy_id = ttax.term_taxonomy_id
// INNER JOIN $wpdb->terms AS tter ON ttax.term_id = tter.term_id
// WHERE
// $tax_where AND ( $searchTaxQuery )
// ) tax_terms ON $wpdb->posts.ID = tax_terms.post_id
// EOF;
// }
// return $join;
// }
foreach ( $this->taxonomies as $taxonomy ) {
$on[] = "ttax.taxonomy = '" . addslashes( $taxonomy )."'";
}
// build our final string
$on = ' ( ' . implode( ' OR ', $on ) . ' ) ';
$join .= " LEFT JOIN $wpdb->term_relationships AS trel ON ($wpdb->posts.ID = trel.object_id) LEFT JOIN $wpdb->term_taxonomy AS ttax ON ( " . $on . " AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN $wpdb->terms AS tter ON (ttax.term_id = tter.term_id) ";
}
return $join;
}
} // END
}

View File

@ -148,6 +148,9 @@ class Item_Metadata_Entity extends Entity {
}
$value = $this->get_value();
if ($value === false)
return '';
$return = '';

View File

@ -599,7 +599,7 @@ class Item extends Entity {
// A metadatum ID was passed
} elseif ( is_int($metadatum) ) {
$metadatum_object = $Tainacan_Metadata->fetch($metadatum);
// A metadatum slug was passed
} elseif ( is_string($metadatum) ) {
$query = $Tainacan_Metadata->fetch(['slug' => $metadatum], 'OBJECT');
@ -667,7 +667,7 @@ class Item extends Entity {
// Get the item metadata objects from the item repository
$item_metadata = $this->get_metadata($query_args);
}
// Loop item metadata to print their "values" as html
$metadatum_index = 0;
foreach ( $item_metadata as $item_metadatum ) {
@ -1017,7 +1017,7 @@ class Item extends Entity {
'hide_description' => true,
'hide_empty' => true,
'empty_metadata_list_message' => '',
'before' => '<section class="metadata-section-slug-$slug" id="$id">',
'before' => '<section class="metadata-section-slug-$slug" id="metadata-section-$id">',
'after' => '</section>',
'before_name' => '<h2 id="metadata-section-$slug">',
'after_name' => '</h2>',
@ -1033,15 +1033,19 @@ class Item extends Entity {
$metadata_section = $args['metadata_section'];
$metadata_section_object = null;
// A metadata section object was passed
if ( $metadata_section instanceof \Tainacan\Entities\Metadata_Section ) {
$metadata_section_object = $metadata_section;
// A metadata section ID was passed
} elseif ( is_int($metadata_section) ) {
} elseif ( is_numeric($metadata_section) ) {
$metadata_section_object = $Tainacan_Metadata_Sections->fetch($metadata_section);
// The default metadata section was passed
} elseif ( $metadata_section == \Tainacan\Entities\Metadata_Section::$default_section_slug ) {
$metadata_section_object = $Tainacan_Metadata_Sections->get_default_section($this->get_collection_id());
// A metadata section slug was passed
} elseif ( is_string($metadata_section) ) {
$query = $Tainacan_Metadata_Sections->fetch(['slug' => $metadata_section], 'OBJECT');
@ -1170,7 +1174,7 @@ class Item extends Entity {
'hide_description' => true,
'hide_empty' => true,
'empty_metadata_list_message' => '',
'before' => '<section class="metadata-section-slug-$slug" id="$id">',
'before' => '<section class="metadata-section-slug-$slug" id="metadata-section-$id">',
'after' => '</section>',
'before_name' => '<h2 id="metadata-section-$slug">',
'after_name' => '</h2>',

View File

@ -98,7 +98,10 @@ class Item_Metadata extends Repository {
if ( is_array( $item_metadata->get_value() ) ) {
$values = $item_metadata->get_value();
// for relationship metadata do not allow the same item to be present more than once in the value.
if ( $metadata_type->get_primitive_type() == 'item' ) {
$values = array_unique($values);
}
foreach ( $values as $value ) {
if ( !is_numeric($value) && empty($value) ) {
continue;

View File

@ -413,7 +413,7 @@ class Items extends Repository {
$clauses = [];
$user_id = get_current_user_id();
$post_status = $wp_query->get( 'post_status' );
$post_status = is_array($post_status) ? $post_status : explode(",", $post_status);
$post_status = is_array($post_status) || empty($post_status) ? $post_status : explode(",", $post_status);
foreach ($this->fetching_from_collections as $collection) {

View File

@ -136,9 +136,9 @@ class Metadata_Sections extends Repository {
* @return \Tainacan\Entities\Metadata_Section|false return de the default metadata section or false otherwise.
*/
public function get_default_section ($collection) {
if($collection instanceof Entities\Collection) {
if ($collection instanceof Entities\Collection) {
$collection_id = $collection->get_id();
} else if (is_int($collection)) {
} else if (is_numeric($collection)) {
$collection_id = $collection;
$collection = \tainacan_collections()->fetch($collection, 'OBJECT');
} else {
@ -295,7 +295,9 @@ class Metadata_Sections extends Repository {
$args['meta_query'][] = $meta_query;
$results = $this->fetch( $args, 'OBJECT' );
}
$results[] = $this->get_default_section($collection->get_id());
if ( !isset($args['post__not_in']) || !in_array(\Tainacan\Entities\Metadata_Section::$default_section_slug, $args['post__not_in']) ) {
$results[] = $this->get_default_section($collection->get_id());
}
return $this->order_result(
$results,

View File

@ -26,7 +26,6 @@ class Theme_Helper {
private function __construct() {
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);
@ -162,16 +161,32 @@ class Theme_Helper {
}
$item = new Entities\Item($post);
$content = '';
// document
$content .= $item->get_document_as_html();
// metadata
$content .= $item->get_metadata_as_html();
$content .= '<section id="tainacan-default-document-section">';
$content .= '<h2>' . __( 'Document', 'tainacan' ) . '</h2>';
$content .= $this->get_tainacan_item_gallery(array(
'layoutElements' => array( 'main' => true, 'thumbnails' => false ),
'mediaSources' => array( 'document' => true, 'attachments' => false, 'metadata' => false),
));
$content .= '</section>';
// metadata sections
$content .= $item->get_metadata_sections_as_html();
// attachments
$content .= '<section id="tainacan-default-attachments-section">';
$content .= '<h2>' . __( 'Attachments', 'tainacan' ) . '</h2>';
$content .= $this->get_tainacan_item_gallery(array(
'layoutElements' => array( 'main' => false, 'thumbnails' => true ),
'mediaSources' => array( 'document' => false, 'attachments' => true, 'metadata' => false),
));
$content .= '</section>';
$content = apply_filters('tainacan_single_item_content', $content, $item);
return $content;
}
@ -1028,7 +1043,7 @@ class Theme_Helper {
);
$args = wp_parse_args($args, $defaults);
$props = ' ';
// Always pass the class needed by Vue to mount the component;
$args['class'] = $args['class_name'] . ' wp-block-tainacan-dynamic-items-list';
unset($args['class_name']);
@ -1054,6 +1069,7 @@ class Theme_Helper {
* Optional. Array of arguments.
* @type string $item_id The Item ID
* @type string $items_list_layout The type of list to be rendered. Accepts 'grid', 'list', 'mosaic' and 'carousel'.
* @type string $order Sorting direction to the related items query. Either 'desc' or 'asc'.
* @type string $class_name Extra class to add to the wrapper, besides the default wp-block-tainacan-carousel-related-items
* @type string $collection_heading_class_name Extra class to add to the collection name wrapper. Defaults to ''
* @type string $collection_heading_tag Tag to be used as wrapper of the collection name. Defaults to h2
@ -1081,7 +1097,11 @@ class Theme_Helper {
return;
// Then fetches related ones
$related_items = $item->get_related_items();
$related_items_query_args = [];
if ( isset($args['order']) )
$related_items_query_args['order'] = $args['order'];
$related_items = $item->get_related_items($related_items_query_args);
if (!count($related_items))
return;
@ -1112,10 +1132,11 @@ class Theme_Helper {
: $args['carousel_args'];
$no_crop_images_to_square = isset($block_args['crop_images_to_square']) && !$block_args['crop_images_to_square'];
$image_size = isset($block_args['image_size'])
$image_size = isset($block_args['image_size'])
? $block_args['image_size']
: ($no_crop_images_to_square ? 'tainacan-medium-full' : 'tainacan-medium');
// remove attribute description and unused thumbnails image sizes, to avoid poluting HTML
// Remove attribute description and unused thumbnails image sizes, to avoid poluting HTML
$related_group['items'] = array_map(
function($el) use ($image_size) {
$el['thumbnail'] = array_filter($el['thumbnail'], function($key) use ($image_size) {
@ -1131,7 +1152,8 @@ class Theme_Helper {
'collection_id' => $related_group['collection_id'],
'load_strategy' => 'parent',
'selected_items' => json_encode($related_group['items']),
'layout' => $args['items_list_layout']
'layout' => $args['items_list_layout'],
'image_size' => $image_size
], $block_args);
$items_list_div = $this->get_tainacan_dynamic_items_list($items_list_args);
@ -1139,7 +1161,8 @@ class Theme_Helper {
$items_list_args = wp_parse_args([
'collection_id' => $related_group['collection_id'],
'load_strategy' => 'parent',
'selected_items' => json_encode($related_group['items'])
'selected_items' => json_encode($related_group['items']),
'image_size' => $image_size
], $block_args);
$items_list_div = $this->get_tainacan_items_carousel($items_list_args);
@ -1159,7 +1182,7 @@ class Theme_Helper {
$related_group['total_items'] > 1 ?
'<div class="wp-block-buttons">
<div class="wp-block-button">
<a class="wp-block-button__link" href="' . esc_url('/' . $related_group['collection_slug']) . '?metaquery[0][key]=' . esc_attr($related_group['metadata_id']) . '&metaquery[0][value][0]=' . esc_attr($item->get_ID()) . '&metaquery[0][compare]=IN">
<a class="wp-block-button__link" href="' . esc_url( get_permalink( $related_group['collection_id'] ) ) . '?metaquery[0][key]=' . esc_attr($related_group['metadata_id']) . '&metaquery[0][value][0]=' . esc_attr($item->get_ID()) . '&metaquery[0][compare]=IN">
' . sprintf( __('View all %s related items', 'tainacan'), $related_group['total_items'] ) . '
</a>
</div>
@ -1239,11 +1262,11 @@ class Theme_Helper {
// Gets the current Item. This way, the function can be used in the loop without needing to pass it
$item = isset($args['itemId']) ? $this->tainacan_get_item($args['itemId']) : $this->tainacan_get_item();
$item_id = $item->get_id();
if (!$item)
return;
// Gets options from block attributes
$item_id = $item->get_id();
$block_id = $args['blockId'];
$layout_elements = $args['layoutElements'];
$media_sources = $args['mediaSources'];
@ -1497,5 +1520,549 @@ class Theme_Helper {
)
);
}
}
/**
* To be used inside Gutenberg editor side preview of template blocks
*
* Return the metadata with placeholder item metadata values as a HTML string to be used as output.
*
* Each metadata is a label with the metadatum name and the placeholder value.
*
* If an ID, a slug or a Tainacan\Entities\Metadatum object is passed in 'metadata' parameter, it returns only one metadata, otherwise
* it returns all metadata
*
* @param array|string $args {
* Optional. Array or string of arguments.
*
* @type mixed $metadata Metadatum object, ID or slug to retrieve only one metadatum. empty returns all metadata
* @type array $metadata__in Array of metadata IDs or Slugs to be retrieved. Default none
* @type array $metadata__not_in Array of metadata IDs (slugs not accepted) to excluded. Default none
* @type bool $exclude_title Exclude the Core Title Metadata from result. Default false
* @type bool $exclude_description Exclude the Core Description Metadata from result. Default false
* @type bool $exclude_core Exclude Core Metadata (title and description) from result. Default false
* @type bool $hide_empty Wether to hide or not metadata the item has no value to
* Default: true
* @type string $empty_value_message Message string to display if $hide_empty is false and there is not metadata value. Default ''
* @type string $before String to be added before each metadata block
* Default '<div class="metadata-type-$type">' where $type is the metadata type slug
* @type string $after String to be added after each metadata block
* Default '</div>'
* @type string $before_title String to be added before each metadata title
* Default '<h3>'
* @type string $after_title String to be added after each metadata title
* Default '</h3>'
* @type string $before_value String to be added before each metadata value
* Default '<p>'
* @type string $after_value String to be added after each metadata value
* Default '</p>'
* }
*
* @param int|string $item_id (Optional) The item ID to retrive the metadatum as a HTML string to be used as output. Default is the global $post
*
*
* @return string The HTML output
*/
function get_tainacan_item_metadata_template($args = array(), $collection_id = 0) {
if ( !$collection_id )
return '';
if ( isset($args['metadata']) )
$args['p'] = $args['metadata'];
if ( isset($args['metadata__in']) )
$args['post__in'] = $args['metadata__in'];
if ( isset($args['metadata__not_in']) )
$args['post__not_in'] = $args['metadata__not_in'];
$collection = \Tainacan\Repositories\Collections::get_instance()->fetch($collection_id);
$metadata = \Tainacan\Repositories\Metadata::get_instance()->fetch_by_collection($collection, $args);
if (!is_array($metadata) || count($metadata) <= 0 && !($metadata[0] instanceof \Tainacan\Entities\Metadatum))
return '';
$defaults = array(
'hide_empty' => true,
'empty_value_message' => '',
'display_slug_as_class' => false,
'before' => '<div class="metadata-type-$type" $id>',
'after' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
'before_value' => '<p>',
'after_value' => '</p>'
);
$args = wp_parse_args($args, $defaults);
$return = '';
foreach($metadata as $metadatum) {
$item_metadatum = new \Tainacan\Entities\Item_Metadata_Entity(null, $metadatum);
// Gets the metadata type object to use it if we need the slug
$metadata_type_object = $metadatum->get_metadata_type_object();
// Get metadatum wrapper tag.
$before = str_replace('$type', $metadata_type_object->get_slug(), $args['before']);
// Adds class with slug and adds metadatum id
if ($args['display_slug_as_class']) {
if ( !strpos($before, 'class="') ) {
$before = str_replace('>', ' class="metadata-slug-'. $metadatum->get_slug() . '">', $before);
} else
$before = str_replace('class="', 'class="metadata-slug-'. $metadatum->get_slug() . ' ', $before);
}
$before = str_replace('$id', ' id="metadata-id-' . $metadatum->get_id() . '"', $before);
// Let theme authors tweak the wrapper opener
$before = apply_filters( 'tainacan-get-item-metadatum-as-html-before', $before, $item_metadatum );
$before = apply_filters( 'tainacan-get-item-metadatum-as-html-before--type-' . $metadatum->get_metadata_type(), $before, $item_metadatum );
$before = apply_filters( 'tainacan-get-item-metadatum-as-html-before--id-' . $metadatum->get_id(), $before, $item_metadatum );
// Renders the metadatum opener
$return .= $before;
// Renders the metadatum name
$metadatum_title_before = $args['before_title'];
$metadatum_title_before = apply_filters( 'tainacan-get-item-metadatum-as-html-before-title', $metadatum_title_before, $item_metadatum );
$metadatum_title_after = $args['after_title'];
$metadatum_title_after = apply_filters( 'tainacan-get-item-metadatum-as-html-after-title', $metadatum_title_after, $item_metadatum );
$return .= $metadatum_title_before . $metadatum->get_name() . $metadatum_title_after;
// Renders the metadatum value
$metadatum_value_before = $args['before_value'];
$metadatum_value_before = apply_filters( 'tainacan-get-item-metadatum-as-html-before-value', $metadatum_value_before, $item_metadatum );
$metadatum_value_after = $args['after_value'];
$metadatum_value_after = apply_filters( 'tainacan-get-item-metadatum-as-html-after-value', $metadatum_value_after, $item_metadatum );
$return .= $metadatum_value_before . __('The item metadata value goes here', 'tainacan' ) . $metadatum_value_after;
$after = $args['after'];
// Let theme authors tweak the wrapper closer
$after = apply_filters( 'tainacan-get-item-metadatum-as-html-after--id-' . $metadatum->get_id(), $after, $item_metadatum );
$after = apply_filters( 'tainacan-get-item-metadatum-as-html-after--type-' . $metadatum->get_metadata_type(), $after, $item_metadatum );
$after = apply_filters( 'tainacan-get-item-metadatum-as-html-after', $after, $item_metadatum );
// Closes the wrapper
$return .= $after;
}
// Returns the html content created by the function
return $return;
}
function get_tainacan_item_metadata_sections_template($args = array(), $collection_id = 0) {
if ( !$collection_id )
return '';
$Tainacan_Metadata_Sections = \Tainacan\Repositories\Metadata_Sections::get_instance();
$return = '';
$defaults = array(
'metadata_section' => null,
'metadata_sections__in' => null,
'metadata_sections__not_in' => null,
'hide_name' => false,
'hide_description' => true,
'hide_empty' => true,
'empty_metadata_list_message' => '',
'before' => '<section class="metadata-section-slug-$slug" id="$id">',
'after' => '</section>',
'before_name' => '<h2 id="metadata-section-$slug">',
'after_name' => '</h2>',
'before_metadata_list' => '<div class="metadata-section__metadata-list" aria-labelledby="metadata-section-$slug">',
'after_metadata_list' => '</div>',
'metadata_list_args' => []
);
$args = wp_parse_args($args, $defaults);
$metadata_sections = array();
// If a single metadata section is passed, we use it instead of fetching more
if ( !is_null($args['metadata_section']) ) {
$metadata_section = $args['metadata_section'];
$metadata_section_object = null;
// A metadata section object was passed
if ( $metadata_section instanceof \Tainacan\Entities\Metadata_Section ) {
$metadata_section_object = $metadata_section;
// A metadata section ID was passed
} elseif ( is_numeric($metadata_section) ) {
$metadata_section_object = $Tainacan_Metadata_Sections->fetch($metadata_section);
// The default metadata section was passed
} elseif ( $metadata_section == \Tainacan\Entities\Metadata_Section::$default_section_slug ) {
$metadata_section_object = $Tainacan_Metadata_Sections->get_default_section($collection_id);
// A metadata section slug was passed
} elseif ( is_string($metadata_section) ) {
$query = $Tainacan_Metadata_Sections->fetch(['slug' => $metadata_section], 'OBJECT');
if ( is_array($query) && sizeof($query) == 1 && isset($metadata_section[0]) ) {
$metadata_section_object = $metadata_section[0];
}
}
// Some checks to see if things are really ok
if ( !($metadata_section_object instanceof \Tainacan\Entities\Metadata_Section) ) {
return $return;
} else {
// Makes sure the current Metadata Section is desired
if ( is_array($args['metadata_sections__not_in'])
&& (
in_array($metadata_section_object->get_slug(), $args['metadata_sections__not_in']) ||
in_array($metadata_section_object->get_id(), $args['metadata_sections__not_in'])
)
) {
return $return;
}
}
// Add it to the array which will be looped below
$metadata_sections[] = $metadata_section_object;
// If not single metadata section is passed, we query them
} else {
// Build query args ready to be passed to the API fetch
$query_args = [];
$post__in = [];
$post__not_in = [];
$post__name_in = [];
if (is_array($args['metadata_sections__in'])) {
$post__in[] = -1; // If metadata_sections__in is an empty array, this forces empty result
foreach ($args['metadata_sections__in'] as $metadata_section) {
if (is_numeric($metadata_section) || $metadata_section === \Tainacan\Entities\Metadata_Section::$default_section_slug) {
$post__in[] = $metadata_section;
} elseif (is_string($metadata_section)) {
$post__name_in[] = $metadata_section;
}
}
}
if (is_array($args['metadata_sections__not_in'])) {
foreach ($args['metadata_sections__not_in'] as $metadata_section) {
if (is_integer($metadata_section) || $metadata_section === \Tainacan\Entities\Metadata_Section::$default_section_slug) {
$post__not_in[] = $metadata_section;
}
}
}
if (sizeof($post__in) > 0) {
$query_args['post__in'] = $post__in;
}
if (sizeof($post__not_in) > 0) {
$query_args['post__not_in'] = $post__not_in;
}
if (sizeof($post__name_in) > 0) {
$query_args['post__name_in'] = $post__name_in;
}
// Get metadata section objects from the metadata sections repository
$TainacanCollections = \Tainacan\Repositories\Collections::get_instance();
$collection = $TainacanCollections->fetch($collection_id);
if ( $collection instanceof \Tainacan\Entities\Collection ) {
$metadata_sections = $Tainacan_Metadata_Sections->fetch_by_collection($collection, $query_args);
}
}
// Loop metadata sections to print their "values" as html
$section_index = 0;
foreach ( $metadata_sections as $metadata_section_object ) {
$return .= $this->get_metadata_section_template($metadata_section_object, $args, $section_index, $collection_id);
$section_index++;
}
// Returns the html content created by the function
return $return;
}
public function get_metadata_section_template($metadata_section, $args = array(), $section_index = null, $collection_id = 0) {
$return = '';
$defaults = array(
'hide_name' => false,
'hide_description' => true,
'hide_empty' => true,
'empty_metadata_list_message' => '',
'before' => '<section class="metadata-section-slug-$slug" id="$id">',
'after' => '</section>',
'before_name' => '<h2 id="metadata-section-$slug">',
'after_name' => '</h2>',
'before_metadata_list' => '<div class="metadata-section__metadata-list" aria-labelledby="metadata-section-$slug">',
'after_metadata_list' => '</div>',
'metadata_list_args' => []
);
$args = wp_parse_args($args, $defaults);
// Gets the metadata section inner metadata list
$metadata_section_metadata_list = $metadata_section->get_metadata_object_list();
$has_metadata_list = (is_array($metadata_section_metadata_list) && count($metadata_section_metadata_list) > 0 );
if ( $has_metadata_list || !$args['hide_empty'] ) {
// Slug and ID are used in numerous situations
$section_slug = $metadata_section->get_slug();
$section_id = $metadata_section->get_id();
// Get section wrapper tag
$before = $args['before'];
$before = str_replace('$id', $section_id, $before);
$before = str_replace('$slug', $section_slug, $before);
// Let theme authors tweak the wrapper opener
$before = apply_filters( 'tainacan-get-metadata-section-as-html-before', $before, $metadata_section );
$before = apply_filters( 'tainacan-get-metadata-section-as-html-before--id-' . $section_id, $before, $metadata_section );
if ( is_numeric($section_index) && $section_index >= 0 ) {
$before = apply_filters( 'tainacan-get-metadata-section-as-html-before--index-' . $section_index, $before, $metadata_section );
}
// Renders the wrapper opener
$return .= $before;
// Adds section label (name)
if ( !$args['hide_name'] ) {
// Get section name wrapper
$before_name = $args['before_name'];
$before_name = str_replace('$id', $section_id, $before_name);
$before_name = str_replace('$slug', $section_slug, $before_name);
// Let theme authors tweak the name wrapper
$before_name = apply_filters( 'tainacan-get-metadata-section-as-html-before-name', $before_name, $metadata_section );
$before_name = apply_filters( 'tainacan-get-metadata-section-as-html-before-name--id-' . $section_id, $before_name, $metadata_section );
if ( is_numeric($section_index) && $section_index >= 0 ) {
$before_name = apply_filters( 'tainacan-get-metadata-section-as-html-before-name--index-' . $section_index, $before_name, $metadata_section );
}
// Get section name closer
$after_name = $args['after_name'];
// Let theme authors tweak the name wrapper
$after_name = apply_filters( 'tainacan-get-metadata-section-as-html-after-name', $after_name, $metadata_section );
$after_name = apply_filters( 'tainacan-get-metadata-section-as-html-after-name--id-' . $section_id, $after_name, $metadata_section );
if ( is_numeric($section_index) && $section_index >= 0 ) {
$after_name = apply_filters( 'tainacan-get-metadata-section-as-html-after-name--index-' . $section_index, $after_name, $metadata_section );
}
// Renders the metadata section name
$return .= $before_name . $metadata_section->get_name() . $after_name;
}
// Adds section description
if ( !$args['hide_description'] ) {
$return .= $args['before_description'] . $metadata_section->get_description() . $args['after_description'];
}
// Gets the section metadata list wrapper
$before_metadata_list = $args['before_metadata_list'];
$before_metadata_list = str_replace('$id', $section_id, $before_metadata_list);
$before_metadata_list = str_replace('$slug', $section_slug, $before_metadata_list);
// Let theme authors tweak the metadata list wrapper
$before_description = isset($args['before_description']) ? $args['before_description'] : '';
$before_description = apply_filters( 'tainacan-get-metadata-section-as-html-before-metadata-list', $before_description, $metadata_section );
$before_description = apply_filters( 'tainacan-get-metadata-section-as-html-before-metadata-list--id-' . $section_id, $before_description, $metadata_section );
if ( is_numeric($section_index) && $section_index >= 0 ) {
$before_description = apply_filters( 'tainacan-get-metadata-section-as-html-before-metadata-list--index-' . $section_index, $before_description, $metadata_section );
}
// Renders the section metadata list wrapper
$return .= $before_metadata_list;
// Renders the section metadata list, using get_tainacan_item_metadata_template
if ($has_metadata_list) {
$has_some_metadata_value = false;
foreach( $metadata_section_metadata_list as $metadata_object) {
$the_metadata_list = $this->get_tainacan_item_metadata_template( wp_parse_args($args['metadata_list_args'], [ 'metadata' => $metadata_object->get_id() ]), $collection_id );
if (!$has_some_metadata_value && !empty($the_metadata_list))
$has_some_metadata_value = true;
$return .= $the_metadata_list;
}
// If no metadata value was found, this section may not be necessary
if (!$has_some_metadata_value && $args['hide_empty'])
return '';
} else {
$return .= $args['empty_metadata_list_message'];
}
// Gets the wrapper closer
$after_metadata_list = $args['after_metadata_list'];
// Let theme authors tweak the metadata list closer
$after_description = isset($args['after_description']) ? $args['after_description'] : '';
$after_description = apply_filters( 'tainacan-get-metadata-section-as-html-after-metadata-list', $after_description, $metadata_section );
$after_description = apply_filters( 'tainacan-get-metadata-section-as-html-after-metadata-list--id-' . $section_id, $after_description, $metadata_section );
if ( is_numeric($section_index) && $section_index >= 0 ) {
$after_description = apply_filters( 'tainacan-get-metadata-section-as-html-after-metadata-list--index-' . $section_index, $after_description, $metadata_section );
}
// Renders the section metadata list wrapper
$return .= $after_metadata_list;
// Gets the wrapper closer
$after = $args['after'];
// Let theme authors tweak the wrapper closer
if ( is_numeric($section_index) && $section_index >= 0 ) {
$after = apply_filters( 'tainacan-get-metadata-section-as-html-after--index-' . $section_index, $after, $metadata_section );
}
$after = apply_filters( 'tainacan-get-metadata-section-as-html-after--id-' . $section_id, $after, $metadata_section );
$after = apply_filters( 'tainacan-get-metadata-section-as-html-after', $after, $metadata_section );
// Closes the wrapper
$return .= $after;
}
// Returns the html content created by the function
return $return;
}
/**
* Returns a placeholder for the item gallery, to be
* used in the block editor.
*
* @param array $args {
* Optional. Array of arguments.
* @type string $item_id The Item ID
* @type string $blockId A unique identifier for the gallery, will be generated automatically if not provided,
* @type bool $isBlock An identifier if we're comming from a block renderer, to avois using functions not available outside of the gutenberg scope;
* @type array $layoutElements Array of elements present in the gallery. Possible values are 'main' and 'carousel'
* @type array $mediaSources Array of sources for the gallery. Possible values are 'document' and 'attachments'
* @type bool $hideFileNameMain Hides the Main slider file name
* @type bool $hideFileCaptionMain Hides the Main slider file caption
* @type bool $hideFileDescriptionMain Hides the Main slider file description
* @type bool $hideFileNameThumbnails Hides the Thumbnails carousel file name
* @type bool $hideFileCaptionThumbnails Hides the Thumbnails carousel file caption
* @type bool $hideFileDescriptionThumbnails Hides the Thumbnails carousel file description
* @type bool $hideFileNameLightbox Hides the Lightbox file name
* @type bool $hideFileCaptionLightbox Hides the Lightbox file caption
* @type bool $hideFileDescriptionLightbox Hides the Lightbox file description
* @type bool $openLightboxOnClick Enables the behaviour of opening a lightbox with zoom when clicking on the media item
* @type bool $showDownloadButtonMain Displays a download button below the Main slider
* @type bool $lightboxHasLightBackground Show a light background instead of dark in the lightbox
* @type bool $showArrowsAsSVG Decides if the swiper carousel arrows will be an SVG icon or font icon
* @return string The HTML div to be used for rendering the item galery component
*/
public function get_tainacan_item_gallery_template($args = []) {
$defaults = array(
'blockId' => uniqid(),
'layoutElements' => array( 'main' => true, 'thumbnails' => true ),
'isBlock' => false,
'mediaSources' => array( 'document' => true, 'attachments' => true, 'metadata' => false),
'hideFileNameMain' => true,
'hideFileCaptionMain' => false,
'hideFileDescriptionMain' => true,
'hideFileNameThumbnails' => true,
'hideFileCaptionThumbnails' => true,
'hideFileDescriptionThumbnails' => true,
'hideFileNameLightbox' => false,
'hideFileCaptionLightbox' => false,
'hideFileDescriptionLightbox' => false,
'openLightboxOnClick' => true,
'showDownloadButtonMain' => true,
'lightboxHasLightBackground' => false,
'showArrowsAsSVG' => true
);
$args = wp_parse_args($args, $defaults);
// Gets options from block attributes
$block_id = $args['blockId'];
$layout_elements = $args['layoutElements'];
$media_sources = $args['mediaSources'];
$hide_file_name_main = $args['hideFileNameMain'];
$hide_file_caption_main = $args['hideFileCaptionMain'];
$hide_file_description_main = $args['hideFileDescriptionMain'];
$hide_file_name_thumbnails = $args['hideFileNameThumbnails'];
$hide_file_caption_thumbnails = $args['hideFileCaptionThumbnails'];
$hide_file_description_thumbnails = $args['hideFileDescriptionThumbnails'];
$hide_file_name_lightbox = $args['hideFileNameLightbox'];
$hide_file_caption_lightbox = $args['hideFileCaptionLightbox'];
$hide_file_description_lightbox = $args['hideFileDescriptionLightbox'];
$open_lightbox_on_click = $args['openLightboxOnClick'];
$show_download_button_main = $args['showDownloadButtonMain'];
$lightbox_has_light_background = $args['lightboxHasLightBackground'];
$show_arrows_as_svg = $args['showArrowsAsSVG'];
// Prefils arrays with proper values to avoid messsy IFs
$layout_elements = array(
'main' => (isset($layout_elements['main']) && ($layout_elements['main'] === true || $layout_elements['main'] == 'true')) ? true : false,
'thumbnails' => (isset($layout_elements['thumbnails']) && ($layout_elements['thumbnails'] === true || $layout_elements['thumbnails'] == 'true')) ? true : false
);
$block_custom_css = '';
// Text color. First we check for custom preset colors, then actual values
$block_custom_css .= isset($args['textColor']) ? sprintf('--tainacan-media-metadata-color: var(--wp--preset--color--%s);', $args['textColor']) : '';
$block_custom_css .= isset($args['style']['color']['text']) ? sprintf('--tainacan-media-metadata-color: %s;', $args['style']['color']['text']) : '';
// Background color. First we check for custom preset colors, then actual values
$block_custom_css .= isset($args['backgroundColor']) ? sprintf('--tainacan-media-background: var(--wp--preset--color--%s);', $args['backgroundColor']) : '';
$block_custom_css .= isset($args['style']['color']['background']) ? sprintf('--tainacan-media-background: %s;', $args['style']['color']['background']) : '';
// Link color, if enabled. Firts we check for custom preset colors, then actual values.
$block_custom_css .= isset($args['linkColor']) ? sprintf('--swiper-theme-color: var(--wp--preset--color--%s);', $args['linkColor']) : '';
if ( isset($args['style']['elements']['link']['color']['text']) ) {
$link_color = $args['style']['elements']['link']['color']['text'];
if ( strpos( $link_color, 'var:' ) !== false ) {
$link_color = str_replace('|', '--', $link_color);
$link_color = str_replace('var:', 'var(--wp--', $link_color) . ')';
}
$block_custom_css .= sprintf('--swiper-theme-color: %s;', $link_color);
}
// Other values are obtained directly from the attributes
$block_custom_css .= (isset($args['arrowsSize']) && is_numeric($args['arrowsSize'])) ? sprintf('--swiper-navigation-size: %spx;', $args['arrowsSize']) : '';
$block_custom_css .= (isset($args['mainSliderHeight']) && is_numeric($args['mainSliderHeight'])) ? sprintf('--tainacan-media-main-carousel-height: %svh;', $args['mainSliderHeight']) : '';
$block_custom_css .= (isset($args['mainSliderWidth']) && is_numeric($args['mainSliderWidth'])) ? sprintf('--tainacan-media-main-carousel-width: %s%%;', $args['mainSliderWidth']) : '';
$block_custom_css .= (isset($args['thumbnailsCarouselWidth']) && is_numeric($args['thumbnailsCarouselWidth'])) ? sprintf('--tainacan-media-thumbs-carousel-width: %s%%;', $args['thumbnailsCarouselWidth']) : '';
$block_custom_css .= (isset($args['thumbnailsCarouselItemSize']) && is_numeric($args['thumbnailsCarouselItemSize'])) ? sprintf('--tainacan-media-thumbs-carousel-item-size: %spx;', $args['thumbnailsCarouselItemSize']) : '';
// Checks if we're inside a block, otherwise we have to build this manually.
if ( isset($args['isBlock']) && $args['isBlock'] ) {
$wrapper_attributes = get_block_wrapper_attributes(
array(
'style' => $block_custom_css,
'class' => 'tainacan-media-component'
)
);
} else {
$wrapper_attributes = '';
if ( !empty($block_custom_css) )
$wrapper_attributes .= 'style="' . $block_custom_css . '" ';
$wrapper_attributes .= 'class="tainacan-media-component"';
}
$placeholder_content = '';
if ($layout_elements['main'])
$placeholder_content .= '<div class="tainacan-gallery-main-placeholder wp-block-post-featured-image wp-block-post-featured-image"><div class="wp-block-post-featured-image__placeholder"><svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" preserveAspectRatio="none" class="components-placeholder__illustration" aria-hidden="true" focusable="false"><path vector-effect="non-scaling-stroke" d="M60 60 0 0"></path></svg></div></div>';
if ($layout_elements['thumbnails'])
$placeholder_content .= '<ul class="tainacan-gallery-thumbnails-placeholder">
<li class="wp-block-post-featured-image wp-block-post-featured-image">
<div class="wp-block-post-featured-image__placeholder"><svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" preserveAspectRatio="none" class="components-placeholder__illustration" aria-hidden="true" focusable="false"><path vector-effect="non-scaling-stroke" d="M60 60 0 0"></path></svg></div>
</li>
<li class="wp-block-post-featured-image wp-block-post-featured-image">
<div class="wp-block-post-featured-image__placeholder"><svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" preserveAspectRatio="none" class="components-placeholder__illustration" aria-hidden="true" focusable="false"><path vector-effect="non-scaling-stroke" d="M60 60 0 0"></path></svg></div>
</li>
<li class="wp-block-post-featured-image wp-block-post-featured-image">
<div class="wp-block-post-featured-image__placeholder"><svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" preserveAspectRatio="none" class="components-placeholder__illustration" aria-hidden="true" focusable="false"><path vector-effect="non-scaling-stroke" d="M60 60 0 0"></path></svg></div>
</li>
<li class="wp-block-post-featured-image wp-block-post-featured-image">
<div class="wp-block-post-featured-image__placeholder"><svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" preserveAspectRatio="none" class="components-placeholder__illustration" aria-hidden="true" focusable="false"><path vector-effect="non-scaling-stroke" d="M60 60 0 0"></path></svg></div>
</li>
<li class="wp-block-post-featured-image wp-block-post-featured-image">
<div class="wp-block-post-featured-image__placeholder"><svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" preserveAspectRatio="none" class="components-placeholder__illustration" aria-hidden="true" focusable="false"><path vector-effect="non-scaling-stroke" d="M60 60 0 0"></path></svg></div>
</li>
</ul>';
return '<div ' . $wrapper_attributes . '>' . $placeholder_content . '</div>';
}
}

View File

@ -46,7 +46,7 @@ use \Tainacan\Repositories;
* @return string The HTML output
*/
function tainacan_get_the_metadata($args = array(), $item_id = 0) {
$item = tainacan_get_item( $item_id );
if ($item instanceof \Tainacan\Entities\Item) {
@ -1187,7 +1187,7 @@ function tainacan_the_item_gallery($args = []) {
function tainacan_get_the_metadata_sections($args = array(), $item_id = 0) {
$item = tainacan_get_item( $item_id );
if ($item instanceof \Tainacan\Entities\Item) {
return $item->get_metadata_sections_as_html($args);
}

View File

@ -2,9 +2,9 @@
Contributors: andrebenedito, daltonmartins, fabianobn, jacsonp, leogermani, weryques, wetah, eduardohumberto, ravipassos, jessicafpx, marinagiolo, omarceloavila, vnmedeiros, tainacan, r-guimaraes, suelanesilva, ccaio, alanargomes, ateneagarcia123, rodrigo0freire, clarandreozzi
Tags: museums, libraries, archives, GLAM, collections, repository
Requires at least: 5.0
Tested up to: 6.0
Tested up to: 6.1
Requires PHP: 5.6
Stable tag: 0.19.1
Stable tag: 0.19.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

View File

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

View File

@ -262,11 +262,11 @@
<!-- Metadata navigation Progress -->
<div
v-if="isMetadataNavigation && metadatumList && metadatumList.length > 3"
v-if="isMetadataNavigation && itemMetadata && itemMetadata.length > 3"
class="sequence-progress-background" />
<div
v-if="isMetadataNavigation && focusedMetadatum !== false && metadatumList && metadatumList.length > 3"
:style="{ width: ((focusedMetadatum + 1)/metadatumList.length)*100 + '%' }"
v-if="isMetadataNavigation && focusedMetadatum !== false && itemMetadata && itemMetadata.length > 3"
:style="{ width: ((focusedMetadatum + 1)/itemMetadata.length)*100 + '%' }"
class="sequence-progress" />
<a
@ -283,7 +283,7 @@
</a>
<b-field
v-if="metadatumList && metadatumList.length > 3"
v-if="itemMetadata && itemMetadata.length > 3"
class="header-item metadata-navigation"
:style="$adminOptions.hideItemEditionCollapses ? 'padding-left: 0.35em !important;' : ''">
<b-button
@ -310,7 +310,7 @@
</b-button>
<b-button
v-if="isMetadataNavigation"
:disabled="(focusedMetadatum === metadatumList.length - 1) && (!isCurrentlyFocusedOnCompoundMetadatum || isOnLastMetadatumOfCompoundNavigation)"
:disabled="(focusedMetadatum === itemMetadata.length - 1) && (!isCurrentlyFocusedOnCompoundMetadatum || isOnLastMetadatumOfCompoundNavigation)"
@click="focusNextMetadatum"
outlined>
<span
@ -340,7 +340,7 @@
</span>
<b-switch
v-if="!isMetadataNavigation && !$adminOptions.hideItemEditionRequiredOnlySwitch && metadatumList && metadatumList.length > 3"
v-if="!isMetadataNavigation && !$adminOptions.hideItemEditionRequiredOnlySwitch && itemMetadata && itemMetadata.length > 3"
id="tainacan-switch-required-metadata"
:style="'font-size: 0.625em;' + (isMobileScreen ? 'margin-right: 2rem;' : '')"
size="is-small"
@ -349,7 +349,7 @@
</b-switch>
<b-field
v-if="!isMetadataNavigation && metadatumList && metadatumList.length > 5"
v-if="!isMetadataNavigation && itemMetadata && itemMetadata.length > 5"
class="header-item metadata-name-search">
<b-input
v-if="!isMobileScreen || openMetadataNameFilter"
@ -416,7 +416,7 @@
{{ metadataSection.description }}
</p>
<template v-for="(itemMetadatum, index) of metadatumList">
<template v-for="(itemMetadatum, index) of itemMetadata">
<tainacan-form-item
v-if="itemMetadatum.metadatum.metadata_section_id == metadataSection.id"
:key="index"
@ -429,7 +429,7 @@
:is-collapsed="metadataCollapses[index]"
:hide-collapses="$adminOptions.hideItemEditionCollapses || isMetadataNavigation"
:is-mobile-screen="isMobileScreen"
:is-last-metadatum="index > 2 && (index == metadatumList.length - 1)"
:is-last-metadatum="index > 2 && (index == itemMetadata.length - 1)"
:is-focused="focusedMetadatum === index"
:is-metadata-navigation="isMetadataNavigation"
@changeCollapse="onChangeCollapse($event, index)"
@ -807,8 +807,29 @@ export default {
collection() {
return this.getCollection()
},
metadatumList() {
return JSON.parse(JSON.stringify(this.getItemMetadata()));
itemMetadata() {
const realItemMetadata = JSON.parse(JSON.stringify(this.getItemMetadata()));
const tweakedItemMetadata = realItemMetadata.map((anItemMetadatum) => {
// We need this because repository level metadata have an array of section IDs
const metadatumSectionId = anItemMetadatum.metadatum.metadata_section_id;
if ( !Array.isArray(metadatumSectionId) )
return anItemMetadatum;
anItemMetadatum.metadatum.metadata_section_id = 'default_section';
// 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'
);
if (intersectionOfSections.length === 1)
anItemMetadatum.metadatum.metadata_section_id = intersectionOfSections[0].id;
return anItemMetadatum;
});
return tweakedItemMetadata;
},
metadataSections() {
return this.getMetadataSections();
@ -839,7 +860,7 @@ export default {
slug: 'metadata',
icon: 'metadata',
name: this.$i18n.get('metadata'),
total: this.metadatumList.length
total: this.itemMetadata.length
}];
if ( this.$adminOptions.itemEditionDocumentInsideTabs && (!this.$adminOptions.hideItemEditionDocument || !this.$adminOptions.hideItemEditionThumbnail) ) {
pageTabs.push({
@ -867,9 +888,9 @@ export default {
return pageTabs;
},
isCurrentlyFocusedOnCompoundMetadatum() {
if (!this.isMetadataNavigation || !this.metadatumList[this.focusedMetadatum])
if (!this.isMetadataNavigation || !this.itemMetadata[this.focusedMetadatum])
return false;
return this.metadatumList[this.focusedMetadatum].metadatum && this.metadatumList[this.focusedMetadatum].metadatum.metadata_type === 'Tainacan\\Metadata_Types\\Compound';
return this.itemMetadata[this.focusedMetadatum].metadatum && this.itemMetadata[this.focusedMetadatum].metadatum.metadata_type === 'Tainacan\\Metadata_Types\\Compound';
}
},
watch: {
@ -1661,7 +1682,7 @@ export default {
this.loadMetadata();
this.setLastUpdated(this.item.modification_date);
this.shouldLoadAttachments = true;
this.shouldLoadAttachments = !this.shouldLoadAttachments;
// Initializes Media Frames now that itemId and item.document exists
this.initializeMediaFrames();
@ -1713,7 +1734,7 @@ export default {
});
}, 500),
focusPreviousMetadatum() {
const previouslyFocusedMetadatum = this.metadatumList[this.focusedMetadatum - 1];
const previouslyFocusedMetadatum = this.itemMetadata[this.focusedMetadatum - 1];
const isPreviouslyFocusedOnCompoundMetadatum = previouslyFocusedMetadatum.metadatum && previouslyFocusedMetadatum.metadatum.metadata_type === 'Tainacan\\Metadata_Types\\Compound';
if (isPreviouslyFocusedOnCompoundMetadatum || this.isCurrentlyFocusedOnCompoundMetadatum)

View File

@ -42,8 +42,8 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
// Admin default tab should load publish, private and draft statuses
if (!isOnTheme && !postQueries.status) {
delete postQueries.status;
dispatch('search/setStatus', '', { root: true });
postQueries.status = 'publish,private,draft';
dispatch('search/setStatus', 'publish,private,draft', { root: true });
}
// Guarantees at least status is passed in case none is found

View File

@ -102,9 +102,11 @@
</span>
</label>
</div>
<template v-if="metadatumList && Array.isArray(metadatumList)">
<template v-if="itemMetadata && Array.isArray(itemMetadata)">
<div
v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)"
v-for="(itemMetadatum, index) of itemMetadata.filter(
anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id
)"
:key="index"
class="field">
<label class="label">{{ itemMetadatum.metadatum.name }}</label>
@ -475,8 +477,29 @@
return this.getItem();
},
metadatumList() {
return JSON.parse(JSON.stringify(this.getItemMetadata()));
itemMetadata() {
const realItemMetadata = JSON.parse(JSON.stringify(this.getItemMetadata()));
const tweakedItemMetadata = realItemMetadata.map((anItemMetadatum) => {
// We need this because repository level metadata have an array of section IDs
const metadatumSectionId = anItemMetadatum.metadatum.metadata_section_id;
if ( !Array.isArray(metadatumSectionId) )
return anItemMetadatum;
anItemMetadatum.metadatum.metadata_section_id = 'default_section';
// 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'
);
if (intersectionOfSections.length === 1)
anItemMetadatum.metadatum.metadata_section_id = intersectionOfSections[0].id;
return anItemMetadatum;
});
return tweakedItemMetadata;
},
totalRelatedItems() {
return (this.item && this.item.related_items) ? Object.values(this.item.related_items).reduce((totalItems, aRelatedItemsGroup) => totalItems + parseInt(aRelatedItemsGroup.total_items), 0) : false;
@ -492,7 +515,7 @@
slug: 'metadata',
icon: 'metadata',
name: this.$i18n.get('metadata'),
total: this.metadatumList.length
total: this.itemMetadata.length
}];
if (this.totalRelatedItems) {
pageTabs.push({

View File

@ -4,6 +4,7 @@ import axios from 'axios';
const { __ } = wp.i18n;
const { TextControl, Button, Modal, CheckboxControl, Spinner } = wp.components;
const currentWPVersion = (typeof tainacan_blocks != 'undefined') ? tainacan_blocks.wp_version : tainacan_plugin.wp_version;
export default class CollectionsModal extends React.Component {
constructor(props) {
@ -192,7 +193,7 @@ export default class CollectionsModal extends React.Component {
render() {
return (
<Modal
className="wp-block-tainacan-modal"
className={ 'wp-block-tainacan-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={__('Select the desired collections from your repository', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
contentLabel={__('Select collections', 'tainacan')}>

View File

@ -145,7 +145,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
collections = [];
let endpoint = '/collections?'+ qs.stringify({ postin: selectedCollections.map((collection) => { return collection.id }), perpage: selectedCollections.length, fetch_preview_image_items: showCollectionThumbnail ? 0 : 3 }) + '&fetch_only=name,url,thumbnail';
let endpoint = '/collections?'+ qs.stringify({ postin: selectedCollections.map((collection) => { return collection.id }), perpage: selectedCollections.length, fetch_preview_image_items: showCollectionThumbnail ? 0 : 3 }) + '&orderby=post__in&fetch_only=name,url,thumbnail';
tainacan.get(endpoint, { cancelToken: itemsRequestSource.token })
.then(response => {

View File

@ -220,7 +220,7 @@ export default {
this.collectionsRequestSource = axios.CancelToken.source();
let endpoint = '/collections?'+ qs.stringify({ postin: this.selectedCollections, perpage: this.selectedCollections.length, fetch_preview_image_items: this.showCollectionThumbnail ? 0 : 3 }) + '&fetch_only=name,url,thumbnail';
let endpoint = '/collections?'+ qs.stringify({ postin: this.selectedCollections, perpage: this.selectedCollections.length, fetch_preview_image_items: this.showCollectionThumbnail ? 0 : 3 }) + '&orderby=post__in&fetch_only=name,url,thumbnail';
this.tainacanAxios.get(endpoint, { cancelToken: this.collectionsRequestSource.token })
.then(response => {

View File

@ -206,7 +206,7 @@ export default class CarouselItemsModal extends React.Component {
return this.state.collectionId ? (
// Items modal
<Modal
className={ 'wp-block-tainacan-modal dynamic-modal ' + (currentWPVersion < 5.9 ? 'wp-version-smaller-than-5-9' : '') }
className={ 'wp-block-tainacan-modal dynamic-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={ this.props.loadStrategy == 'selection' ? __('Select items to add on block', 'tainacan') : __('Configure the items search to be used on block', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
shouldCloseOnClickOutside={ false }
@ -242,7 +242,7 @@ export default class CarouselItemsModal extends React.Component {
) : (
// Collections modal
<Modal
className="wp-block-tainacan-modal"
className={ 'wp-block-tainacan-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={__('Select a collection to fetch items from', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
shouldCloseOnClickOutside={ false }

View File

@ -150,7 +150,7 @@ export default function({ attributes, setAttributes, className, isSelected, clie
itemsRequestSource = axios.CancelToken.source();
let endpoint = '/collection/' + collectionId + '/items?'+ qs.stringify({ postin: selectedItems, perpage: selectedItems.length }) + '&fetch_only=title,url,thumbnail';
let endpoint = '/collection/' + collectionId + '/items?'+ qs.stringify({ postin: selectedItems, perpage: selectedItems.length }) + '&orderby=post__in&fetch_only=title,url,thumbnail';
tainacan.get(endpoint, { cancelToken: itemsRequestSource.token })
.then(response => {

View File

@ -246,7 +246,7 @@ export default {
});
} else if (this.loadStrategy == 'selection') {
let endpoint = '/collection/' + this.collectionId + '/items?' + qs.stringify({ postin: this.selectedItems, perpage: this.selectedItems.length }) + '&fetch_only=title,url,thumbnail';
let endpoint = '/collection/' + this.collectionId + '/items?' + qs.stringify({ postin: this.selectedItems, perpage: this.selectedItems.length }) + '&orderby=post__in&fetch_only=title,url,thumbnail';
this.tainacanAxios.get(endpoint, { cancelToken: this.itemsRequestSource.token })
.then(response => {

View File

@ -68,6 +68,36 @@ export default {
}
);
},
},
{
type: 'block',
blocks: [ 'tainacan/item-metadata' ],
isMatch: ({ items } ) => {
return Array.isArray(items) && items.length && items[0].key;
},
transform: ( {
items,
collectionId,
align,
textColor,
fontSize
} ) => {
const itemMetadataBlocks = items.map((item) =>
createBlock(
'tainacan/item-metadata',
{
itemId: Number(item.key),
content: [ { type: true } ],
collectionId: Number(collectionId),
isModalOpen: false,
align: align,
textColor: textColor,
fontSize: fontSize
}
)
);
return itemMetadataBlocks;
}
}
]
};

View File

@ -4,6 +4,7 @@ import axios from 'axios';
const { __ } = wp.i18n;
const { TextControl, Button, Modal, CheckboxControl, Spinner } = wp.components;
const currentWPVersion = (typeof tainacan_blocks != 'undefined') ? tainacan_blocks.wp_version : tainacan_plugin.wp_version;
export default class CollectionsModal extends React.Component {
constructor(props) {
@ -193,7 +194,7 @@ export default class CollectionsModal extends React.Component {
render() {
return (
<Modal
className="wp-block-tainacan-modal"
className={ 'wp-block-tainacan-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={__('Select the desired collections from your repository', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
contentLabel={__('Select collections', 'tainacan')}>

View File

@ -233,7 +233,7 @@ export default function({ attributes, setAttributes, className, isSelected, clie
itemsRequestSource = axios.CancelToken.source();
let endpoint = '/collection/' + collectionId + '/items?'+ qs.stringify({ postin: selectedItems, perpage: selectedItems.length }) + '&fetch_only=title,url,thumbnail';
let endpoint = '/collection/' + collectionId + '/items?'+ qs.stringify({ postin: selectedItems, perpage: selectedItems.length }) + '&orderby=post__in&fetch_only=title,url,thumbnail';
tainacan.get(endpoint, { cancelToken: itemsRequestSource.token })
.then(response => {

View File

@ -206,11 +206,11 @@
:class="(!showName ? 'item-without-title' : '') + ' ' + (!showImage ? 'item-without-image' : '')">
<blur-hash-image
v-if="showImage"
:height="$thumbHelper.getHeight(item['thumbnail'], ( layout == 'list' || imageSize ))"
:width="$thumbHelper.getWidth(item['thumbnail'], ( layout == 'list' || imageSize ))"
:src="$thumbHelper.getSrc(item['thumbnail'], ( layout == 'list' || imageSize ), item['document_mimetype'])"
:srcset="$thumbHelper.getSrcSet(item['thumbnail'], ( layout == 'list' || imageSize ), item['document_mimetype'])"
:hash="$thumbHelper.getBlurhashString(item['thumbnail'], ( layout == 'list' || imageSize ))"
:height="$thumbHelper.getHeight(item['thumbnail'], imageSize)"
:width="$thumbHelper.getWidth(item['thumbnail'], imageSize)"
:src="$thumbHelper.getSrc(item['thumbnail'], imageSize, item['document_mimetype'])"
:srcset="$thumbHelper.getSrcSet(item['thumbnail'], imageSize, item['document_mimetype'])"
:hash="$thumbHelper.getBlurhashString(item['thumbnail'], imageSize)"
:alt="item.thumbnail_alt ? item.thumbnail_alt : (item && item.name ? item.name : $root.__( 'Thumbnail', 'tainacan' ))"
:transition-duration="500" />
<span v-if="item.title">{{ item.title }}</span>
@ -252,11 +252,11 @@
:href="item.url"
:class="(!showName ? 'item-without-title' : '') + ' ' + (!showImage ? 'item-without-image' : '')">
<blur-hash-image
:height="$thumbHelper.getHeight(item['thumbnail'], ( layout == 'list' || imageSize ))"
:width="$thumbHelper.getWidth(item['thumbnail'], ( layout == 'list' || imageSize ))"
:src="$thumbHelper.getSrc(item['thumbnail'], ( layout == 'list' || imageSize ), item['document_mimetype'])"
:srcset="$thumbHelper.getSrcSet(item['thumbnail'], ( layout == 'list' || imageSize ), item['document_mimetype'])"
:hash="$thumbHelper.getBlurhashString(item['thumbnail'], ( layout == 'list' || imageSize ))"
:height="$thumbHelper.getHeight(item['thumbnail'], imageSize)"
:width="$thumbHelper.getWidth(item['thumbnail'], imageSize)"
:src="$thumbHelper.getSrc(item['thumbnail'], imageSize, item['document_mimetype'])"
:srcset="$thumbHelper.getSrcSet(item['thumbnail'], imageSize, item['document_mimetype'])"
:hash="$thumbHelper.getBlurhashString(item['thumbnail'], imageSize)"
:alt="item.thumbnail_alt ? item.thumbnail_alt : (item && item.name ? item.name : $root.__( 'Thumbnail', 'tainacan' ))"
:transition-duration="500" />
<span v-if="item.title">{{ item.title }}</span>
@ -373,7 +373,7 @@ export default {
this.localMaxItemsNumber = this.selectedItems.length;
let endpoint = '/collection/' + this.collectionId + '/items?' + qs.stringify({ postin: this.selectedItems, perpage: this.localMaxItemsNumber }) + '&fetch_only=title,url,thumbnail';
let endpoint = '/collection/' + this.collectionId + '/items?' + qs.stringify({ postin: this.selectedItems, perpage: this.localMaxItemsNumber }) + '&orderby=post__in&fetch_only=title,url,thumbnail';
this.tainacanAxios.get(endpoint, { cancelToken: this.itemsRequestSource.token })
.then(response => {

View File

@ -61,6 +61,36 @@ export default {
}
);
},
},
{
type: 'block',
blocks: [ 'tainacan/item-metadata' ],
isMatch: ({ items } ) => {
return Array.isArray(items) && items.length && items[0].key;
},
transform: ( {
items,
collectionId,
align,
textColor,
fontSize
} ) => {
const itemMetadataBlocks = items.map((item) =>
createBlock(
'tainacan/item-metadata',
{
itemId: Number(item.key),
content: [ { type: true } ],
collectionId: Number(collectionId),
isModalOpen: false,
align: align,
textColor: textColor,
fontSize: fontSize
}
)
);
return itemMetadataBlocks;
}
}
]
};

View File

@ -5,6 +5,7 @@ import qs from 'qs';
const { __ } = wp.i18n;
const { TextControl, Button, Modal, SelectControl, RadioControl, Spinner } = wp.components;
const currentWPVersion = (typeof tainacan_blocks != 'undefined') ? tainacan_blocks.wp_version : tainacan_plugin.wp_version;
export default class CollectionModal extends React.Component {
constructor(props) {
@ -208,7 +209,7 @@ export default class CollectionModal extends React.Component {
render() {
return (
<Modal
className="wp-block-tainacan-modal"
className={ 'wp-block-tainacan-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={__('Select a collection to fetch items from', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
contentLabel={__('Select items', 'tainacan')}>

View File

@ -3,6 +3,7 @@ import tainacan from '../../js/axios.js';
const { __ } = wp.i18n;
const { TextControl, Button, Modal, SelectControl, RadioControl, Spinner } = wp.components;
const currentWPVersion = (typeof tainacan_blocks != 'undefined') ? tainacan_blocks.wp_version : tainacan_plugin.wp_version;
export default class TermModal extends React.Component {
constructor(props) {
@ -268,7 +269,7 @@ export default class TermModal extends React.Component {
return this.state.taxonomyId != null && this.state.taxonomyId != undefined ? (
// Terms modal
<Modal
className="wp-block-tainacan-modal"
className={ 'wp-block-tainacan-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={__('Select the desired terms from taxonomy ' + this.state.taxonomyName, 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
contentLabel={__('Select terms', 'tainacan')}>
@ -386,7 +387,7 @@ export default class TermModal extends React.Component {
) : (
// Taxonomies modal
<Modal
className="wp-block-tainacan-modal"
className={ 'wp-block-tainacan-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={__('Select a taxonomy to fetch terms from', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
contentLabel={__('Select terms', 'tainacan')}>

View File

@ -4,6 +4,7 @@ import axios from 'axios';
const { __ } = wp.i18n;
const { TextControl, Button, Modal, RadioControl, SelectControl, Spinner } = wp.components;
const currentWPVersion = (typeof tainacan_blocks != 'undefined') ? tainacan_blocks.wp_version : tainacan_plugin.wp_version;
export default class MetadataModal extends React.Component {
constructor(props) {
@ -243,7 +244,7 @@ export default class MetadataModal extends React.Component {
return this.state.collectionId ? (
// Metadata modal
<Modal
className="wp-block-tainacan-modal"
className={ 'wp-block-tainacan-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={__('Select a metadatum to show it\'s facets on block', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
contentLabel={__('Select metadatum', 'tainacan')}>
@ -290,7 +291,7 @@ export default class MetadataModal extends React.Component {
) : (
// Collections modal
<Modal
className="wp-block-tainacan-modal"
className={ 'wp-block-tainacan-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={__('Select a collection to fetch metadata from', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
contentLabel={__('Select collection', 'tainacan')}>

View File

@ -4,6 +4,7 @@ import axios from 'axios';
const { __ } = wp.i18n;
const { TextControl, Button, Modal, RadioControl, SelectControl, Spinner } = wp.components;
const currentWPVersion = (typeof tainacan_blocks != 'undefined') ? tainacan_blocks.wp_version : tainacan_plugin.wp_version;
export default class ParentTermModal extends React.Component {
constructor(props) {
@ -163,7 +164,7 @@ export default class ParentTermModal extends React.Component {
// Facets modal
<Modal
className="wp-block-tainacan-modal"
className={ 'wp-block-tainacan-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={__('Select a parent term to fetch facets from', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
contentLabel={__('Select term', 'tainacan')}>

View File

@ -116,6 +116,10 @@
"lightboxHasLightBackground": {
"type": "boolean",
"default": false
},
"templateMode": {
"type": "boolean",
"default": false
}
},
"supports": {

View File

@ -6,6 +6,7 @@ const ServerSideRender = wp.serverSideRender;
const { InspectorControls, useBlockProps } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
import SingleItemModal from '../../js/selection/single-item-modal.js';
import getCollectionIdFromPossibleTemplateEdition from '../../js/template/tainacan-blocks-single-item-template-mode.js';
export default function ({ attributes, setAttributes, className, isSelected, clientId }) {
@ -32,7 +33,8 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
thumbnailsCarouselWidth,
thumbnailsCarouselItemSize,
showDownloadButtonMain,
lightboxHasLightBackground
lightboxHasLightBackground,
templateMode
} = attributes;
// Gets blocks props from hook
@ -42,6 +44,19 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
// Obtains block's client id to render it on save function
setAttributes({ blockId: clientId });
// Checks if we are in template mode, if so, gets the collection Id from URL.
if ( !templateMode ) {
const possibleCollectionId = getCollectionIdFromPossibleTemplateEdition();
if (possibleCollectionId) {
collectionId = String(possibleCollectionId);
templateMode = true;
setAttributes({
collectionId: collectionId,
templateMode: templateMode
});
}
}
return content == 'preview' ?
<div className={className}>
<img
@ -339,7 +354,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
) : null
}
{ !itemId ? (
{ !itemId && !templateMode ? (
<Placeholder
className="tainacan-block-placeholder"
icon={(
@ -374,7 +389,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
) : null
}
{ itemId ? (
{ itemId || templateMode ? (
<div className={ 'item-gallery-edit-container' }>
<div class="preview-warning">{__('Warning: this is just a demonstration. To see the gallery in action, either preview or publish your post.', 'tainacan') }</div>
<ServerSideRender

View File

@ -8,5 +8,21 @@
*/
function tainacan_blocks_render_items_gallery( $block_attributes, $content ) {
$block_attributes['isBlock'] = true;
return \Tainacan\Theme_Helper::get_instance()->get_tainacan_item_gallery($block_attributes);
$template_mode = isset($block_attributes['templateMode']) ? $block_attributes['templateMode'] : false;
$collection_id = isset($block_attributes['collectionId']) ? $block_attributes['collectionId'] : false;
if ( $template_mode && $collection_id ) {
// Checks if we are in the edit page or in the published
$current_post = get_post();
$collection_pt_pattern = '/' . \Tainacan\Entities\Collection::$db_identifier_prefix . '\d+' . \Tainacan\Entities\Collection::$db_identifier_sufix . '/';
if ( $current_post === NULL ) {
return \Tainacan\Theme_Helper::get_instance()->get_tainacan_item_gallery_template($block_attributes);
} else if ( $current_post->post_type !== false && preg_match($collection_pt_pattern, $current_post->post_type) ) {
$block_attributes['item_id'] = $current_post->ID;
return \Tainacan\Theme_Helper::get_instance()->get_tainacan_item_gallery($block_attributes);
}
} else {
return \Tainacan\Theme_Helper::get_instance()->get_tainacan_item_gallery($block_attributes);
}
}

View File

@ -15,6 +15,32 @@
margin: 0 auto;
padding: 8px 2px 2px 2px;
}
.tainacan-gallery-main-placeholder {
position: relative;
min-height: var(--tainacan-media-main-carousel-height, 60vh);
max-width: var(--tainacan-media-main-carousel-width, 100%);
margin: 0 auto 1em auto;
}
.tainacan-gallery-thumbnails-placeholder {
display: flex;
flex-wrap: nowrap;
justify-content: center;
gap: 20px;
list-style: none !important;
margin: 0px auto !important;
padding: 0px !important;
max-width: var(--tainacan-media-thumbs-carousel-width, 100%);
width: var(--tainacan-media-thumbs-carousel-width, 100%);
overflow-x: auto;
overflow-y: hidden;
li {
height: var(--tainacan-media-thumbs-carousel-item-size, 136px);
min-width: var(--tainacan-media-thumbs-carousel-item-size, 136px);
flex-basis: var(--tainacan-media-thumbs-carousel-item-size, 136px);
position: relative;
}
}
}
.tainacan-media-component {
--swiper-theme-color: var(--tainacan-secondary, #298596);

View File

@ -0,0 +1,101 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"name": "tainacan/item-metadata-section",
"title": "Tainacan Item Metadata Section",
"apiVersion": 2,
"category": "tainacan-blocks",
"keywords": [ "item", "metadata", "section", "regions", "fields" ],
"description": "A single metadata section, including its label and metadata whitin it.",
"textdomain": "tainacan",
"example": {
"attributes": {
"content": "preview"
}
},
"attributes": {
"content": {
"type": "array",
"source": "query",
"selector": "div"
},
"dataSource": {
"type": "string",
"default": "selection"
},
"templateMode": {
"type": "boolean",
"default": false
},
"isDynamic": {
"type": "boolean",
"default": false
},
"collectionId": {
"type": "integer"
},
"itemId": {
"type": "integer"
},
"isModalOpen": {
"type": "boolean",
"default": false
},
"isLoading": {
"type": "boolean",
"default": false
},
"metadataSectionRequestSource": {
"type": "object",
"default": ""
},
"metadataSectionTemplate": {
"type": "array",
"default": []
},
"sectionId": {
"type": "string",
"default": ""
},
"sectionName": {
"type": "string"
},
"sectionDescription": {
"type": "string"
},
"sectionMetadata": {
"type": "array",
"default": []
},
"textAlign": {
"type": "string"
}
},
"providesContext": {
"tainacan/metadataSectionId": "sectionId",
"tainacan/metadataSectionName": "sectionName",
"tainacan/metadataSectionDescription": "sectionDescription"
},
"supports": {
"align": ["full", "wide"],
"multiple": true,
"html": true,
"anchor": true,
"color": {
"text": true,
"background": true,
"gradients": true,
"link": true
},
"typography": {
"fontSize": true,
"lineHeight": true
},
"spacing": {
"margin": true,
"padding": true,
"spacing": true
}
},
"editorScript": "item-metadata-section",
"editorStyle": "item-metadata-section"
}

View File

@ -0,0 +1 @@
export default [];

View File

@ -0,0 +1,298 @@
const { __ } = wp.i18n;
const { Button, Spinner, Placeholder, ToggleControl, PanelBody } = wp.components;
const ServerSideRender = wp.serverSideRender;
const { useBlockProps, InnerBlocks, BlockControls, AlignmentControl, InspectorControls } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
import SingleItemMetadataSectionModal from '../../js/selection/single-item-metadata-section-modal.js';
import getCollectionIdFromPossibleTemplateEdition from '../../js/template/tainacan-blocks-single-item-template-mode.js';
import tainacan from '../../js/axios.js';
import axios from 'axios';
export default function ({ attributes, setAttributes, className, isSelected }) {
let {
content,
collectionId,
itemId,
isLoading,
metadataSectionRequestSource,
isModalOpen,
sectionId,
sectionName,
sectionDescription,
sectionMetadata,
metadataSectionTemplate,
dataSource,
templateMode,
isDynamic,
textAlign
} = attributes;
// Gets blocks props from hook
const blockProps = tainacan_blocks.wp_version < '5.6' ? { className: className } : useBlockProps( {
className: {
[ `has-text-align-${ textAlign }` ]: textAlign,
}
} );
const currentWPVersion = (typeof tainacan_blocks != 'undefined') ? tainacan_blocks.wp_version : tainacan_plugin.wp_version;
function setContent() {
if ( sectionId && collectionId ) {
isLoading = true;
setAttributes({
isLoading: isLoading
});
if ( dataSource === 'parent' ) {
getMetadataSectionTemplates({
sectionId: sectionId,
sectionName: sectionName,
sectionDescription: sectionDescription,
sectionMetadata: sectionMetadata,
metadataSectionRequestSource: metadataSectionRequestSource
});
} else {
if (metadataSectionRequestSource != undefined && typeof metadataSectionRequestSource == 'function')
metadataSectionRequestSource.cancel('Previous metadata sections search canceled.');
metadataSectionRequestSource = axios.CancelToken.source();
let endpoint = '/collection/'+ collectionId + '/metadata-sections/' + sectionId;
tainacan.get(endpoint, { cancelToken: metadataSectionRequestSource.token })
.then(response => {
let metadataSection = response.data ? response.data : [];
getMetadataSectionTemplates({
sectionId: String(metadataSection.id),
sectionName: metadataSection.name,
sectionDescription: metadataSection.description,
sectionMetadata: metadataSection['metadata_object_list'],
metadataSectionRequestSource: metadataSectionRequestSource
});
})
.catch((error) => {
console.error(error);
setAttributes({
sectionId: '',
sectionName: '',
sectionDescription: '',
sectionMetadata: [],
isLoading: false
});
});
}
}
}
function getMetadataSectionTemplates({
sectionId,
sectionName,
sectionDescription,
sectionMetadata,
metadataSectionRequestSource
}) {
metadataSectionTemplate = [];
if (sectionName) {
metadataSectionTemplate.push([
'tainacan/metadata-section-name',
]);
}
if (sectionDescription) {
metadataSectionTemplate.push([
'tainacan/metadata-section-description',
]);
}
if (sectionMetadata.length) {
metadataSectionTemplate.push([
'tainacan/item-metadata',
{
sectionId: String(sectionId),
itemId: isNaN(itemId) ? 0 : Number(itemId),
collectionId: Number(collectionId),
metadata: sectionMetadata,
dataSource: 'parent',
templateMode: templateMode
}
]);
}
setAttributes({
metadataSectionTemplate: metadataSectionTemplate,
sectionId: sectionId,
sectionName: sectionName,
sectionDescription: sectionDescription,
sectionMetadata: sectionMetadata,
isLoading: false,
metadataSectionRequestSource: metadataSectionRequestSource
});
}
// Checks if we are in template mode, if so, gets the collection Id from URL.
if ( !templateMode ) {
const possibleCollectionId = getCollectionIdFromPossibleTemplateEdition();
if (possibleCollectionId) {
collectionId = possibleCollectionId;
templateMode = true
setAttributes({
collectionId: collectionId,
templateMode: templateMode
});
setContent();
}
}
// Executed only on the first load of page
if (content === undefined || (content && content.length && content[0].type)) {
setAttributes({ content: '' });
setContent();
}
return content == 'preview' ?
<div className={className}>
<img
width="100%"
src={ `${tainacan_blocks.base_url}/assets/images/related-carousel-items.png` } />
</div>
: (
<div { ...blockProps }>
{ sectionId ?
<InspectorControls>
<PanelBody
title={ __('Data source', 'tainacan') }
initialOpen={ true }
>
<ToggleControl
label={ __('Dynamic sync from Tainacan', 'tainacan') }
help={ __( 'Check this if you want the item metadata and section values to be always sync with its source from Tainacan. If disabled, however, you will be able to change order of inner blocks, delete and wrap them inside other blocks.', 'tainacan' ) }
checked={ isDynamic }
onChange={ ( isChecked ) => {
isDynamic = isChecked;
setAttributes({ isDynamic: isDynamic });
}
}
/>
</PanelBody>
</InspectorControls>
: null }
<BlockControls group="block">
<AlignmentControl
value={ textAlign }
onChange={ ( nextAlign ) => {
setAttributes( { textAlign: nextAlign } );
} }
/>
</BlockControls>
{ isSelected ?
(
<div>
{ isModalOpen ?
<SingleItemMetadataSectionModal
modalTitle={ __('Select one item to render a metadata section of it', 'tainacan') }
existingCollectionId={ collectionId }
existingItemId={ itemId }
existingMetadataSectionId={ sectionId }
isTemplateMode={ templateMode }
onSelectCollection={ (selectedCollectionId) => {
collectionId = Number(selectedCollectionId);
setAttributes({
collectionId: collectionId
});
}}
onSelectItem={ (selectedItemId) => {
itemId = selectedItemId;
setAttributes({
itemId: itemId
});
}}
onApplySelectedMetadataSection={ (selectedMetadataSection) => {
sectionId = selectedMetadataSection.sectionId;
setAttributes({
sectionId: sectionId,
isModalOpen: false
});
setContent();
}}
onCancelSelection={ () => setAttributes({ isModalOpen: false }) }/>
: null
}
</div>
) : null
}
{ !sectionId && dataSource !== 'parent' ? (
<Placeholder
className="tainacan-block-placeholder"
icon={(
<img
width={148}
src={ `${tainacan_blocks.base_url}/assets/images/tainacan_logo_header.svg` }
alt="Tainacan Logo"/>
)}>
<p>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
height="24px"
width="24px">
<path d="M16,6H12a2,2,0,0,0-2,2v6.52A6,6,0,0,1,12,19a6,6,0,0,1-.73,2.88A1.92,1.92,0,0,0,12,22h8a2,2,0,0,0,2-2V12Zm-1,6V7.5L19.51,12ZM15,2V4H8v9.33A5.8,5.8,0,0,0,6,13V4A2,2,0,0,1,8,2ZM10.09,19.05,7,22.11V16.05L8,17l2,2ZM5,16.05v6.06L2,19.11Z"/>
</svg>
{ collectionId ? __('Select a metadata section to display it.', 'tainacan') : __('Select an item and a metadata section to display it.', 'tainacan') }
</p>
<Button
isPrimary
type="button"
onClick={ () => {
isModalOpen = true;
setAttributes( {
isModalOpen: isModalOpen
});
}
}>
{ collectionId ? __('Select a Metadata Section', 'tainacan') : __('Select Item and Metadata Section', 'tainacan') }
</Button>
</Placeholder>
) : null
}
{ isLoading ?
<div class="spinner-container">
<Spinner />
</div> :
<div className={ 'item-metadata-sections-edit-container' }>
{ metadataSectionTemplate.length ?
( isDynamic ?
<ServerSideRender
block="tainacan/item-metadata-section"
attributes={ attributes }
httpMethod={ currentWPVersion >= '5.5' ? 'POST' : 'GET' }
/>
:
<InnerBlocks
allowedBlocks={ true }
template={ metadataSectionTemplate }
templateInsertUpdatesSelection={ true } />
)
: null
}
</div>
}
</div>
);
};

View File

@ -0,0 +1,14 @@
const { SVG, Path } = wp.components;
export default (
<SVG
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 6 6"
height="24px"
width="24px">
<Path d="m1.2849 0.84891c-0.085556 0-0.15764 0.029712-0.21631 0.088379-0.058667 0.058667-0.087891 0.13075-0.087891 0.21631v0.76611c0 0.083111 0.030686 0.1552 0.091797 0.21631l1.0669 1.0669c0.026889 0.026889 0.058548 0.049295 0.095215 0.066406 0.039111 0.017111 0.079538 0.025391 0.12109 0.025391 0.041556 0 0.080521-0.00828 0.11719-0.025391 0.039111-0.017111 0.072232-0.039518 0.099121-0.066406l0.7627-0.7627c0.058667-0.058667 0.087891-0.13075 0.087891-0.21631 0-0.085556-0.029224-0.15764-0.087891-0.21631l-1.0708-1.0703c-0.058667-0.058667-0.12929-0.088379-0.2124-0.088379zm0.21924 0.30469c0.00391-1.815e-4 0.00775 0 0.011719 0 0.063556 0 0.11762 0.022891 0.16162 0.069336 0.044 0.044 0.065918 0.098066 0.065918 0.16162 0 0.063556-0.021918 0.11713-0.065918 0.16113s-0.098066 0.065918-0.16162 0.065918c-0.063555 0-0.11859-0.021918-0.16504-0.065918-0.044-0.044-0.065918-0.097577-0.065918-0.16113 0-0.063556 0.021918-0.11762 0.065918-0.16162 0.043542-0.043542 0.09474-0.066615 0.15332-0.069336z" stroke-width=".25"/>
<Path d="m0.98355 3.7638v0.37834h4.0357v-0.37834z" stroke-width=".25223"/>
<Path d="m0.98355 5.1511h2.2701v-0.37836h-2.2701z" stroke-width=".25223"/>
</SVG>
);

View File

@ -0,0 +1,17 @@
import tainacanRegisterBlockType from '../../js/compatibility/tainacan-blocks-compat-register.js';
import metadata from './block.json';
import icon from './icon.js';
import edit from './edit.js';
import save from './save.js';
import deprecated from './deprecated.js';
import transforms from './transforms.js';
tainacanRegisterBlockType({
metadata,
icon,
edit,
save,
deprecated,
transforms
});

View File

@ -0,0 +1,11 @@
const { useBlockProps, InnerBlocks } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
export default function({ attributes }) {
const { textAlign, isDynamic } = attributes;
// Gets blocks props from hook
const blockProps = tainacan_blocks.wp_version < '5.6' ? { className: `has-text-align-${ textAlign }` } : useBlockProps.save( {
className: `has-text-align-${ textAlign }`
} );
return isDynamic ? null : <div { ...blockProps }><InnerBlocks.Content /></div>
};

View File

@ -0,0 +1,66 @@
<?php
/**
* Renders the content of the item metadata section
* using Tainacan template functions
*/
function tainacan_blocks_render_metadata_section( $block_attributes, $content, $block ) {
$is_dynamic = isset($block_attributes['isDynamic']) ? ($block_attributes['isDynamic'] === 'true' || $block_attributes['isDynamic'] == 1) : false;
if ( $is_dynamic) {
// Basic check, otherwise we don't have nothing to render here.
$item_id = !empty($block->context['tainacan/itemId']) ? $block->context['tainacan/itemId'] : (isset($block_attributes['itemId']) ? $block_attributes['itemId'] : false);
$collection_id = isset($block_attributes['collectionId']) ? $block_attributes['collectionId'] : false;
$section_id = isset($block_attributes['sectionId']) ? $block_attributes['sectionId'] : false;
$template_mode = isset($block_attributes['templateMode']) ? $block_attributes['templateMode'] : false;
// Builds args from backend query
$args = [
'metadata_section' => $section_id
];
// Classes from block and Text alignment
$text_align = isset($block_attributes['textAlign']) ? $block_attributes['textAlign'] : false;
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => 'metadata-section-slug-$slug' . ( $text_align ? (' has-text-align-' . $text_align) : '' ),
)
);
$args['before'] = '<section id="metadata-section-$id ' . $wrapper_attributes . '>';
$args['after'] = '</section>';
if ( $template_mode && $collection_id ) {
// Checks if we are in the edit page or in the published
$current_post = get_post();
$collection_pt_pattern = '/' . \Tainacan\Entities\Collection::$db_identifier_prefix . '\d+' . \Tainacan\Entities\Collection::$db_identifier_sufix . '/';
if ( $current_post === NULL )
return \Tainacan\Theme_Helper::get_instance()->get_tainacan_item_metadata_sections_template(['metadata_section' => $section_id], $collection_id );
else if ( $current_post->post_type !== false && preg_match($collection_pt_pattern, $current_post->post_type) )
return tainacan_get_the_metadata_sections( $args, $current_post->ID );
} else if ( $item_id ) {
return tainacan_get_the_metadata_sections( $args, $item_id );
}
} else {
// Classes from block and Text alignment
$text_align = isset($block_attributes['textAlign']) ? $block_attributes['textAlign'] : false;
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => ( $text_align ? (' has-text-align-' . $text_align) : '' ),
)
);
// Gets inner blocks and wraps them with this parent wrapper
$inner_blocks = $block->inner_blocks;
$inner_blocks_html = '';
foreach ( $inner_blocks as $inner_block ) {
$inner_blocks_html .= $inner_block->render();
}
return '<div ' . $wrapper_attributes . '>' . $inner_blocks_html . '</div>';
}
}

View File

@ -0,0 +1,48 @@
const { createBlock } = wp.blocks;
export default {
to: [
{
type: 'block',
blocks: [ 'tainacan/carousel-items-list' ],
isMultiBlock: true,
transform: ( itemMetadataBlocks ) => {
const items = itemMetadataBlocks.map((anItemMetadataBlock) => anItemMetadataBlock.itemId);
return createBlock(
'tainacan/carousel-items-list',
{
selectedItems: items,
loadStrategy: 'selection',
content: [ { type: true } ],
collectionId: itemMetadataBlocks[0].collectionId,
isModalOpen: false,
align: itemMetadataBlocks[0].align,
textColor: itemMetadataBlocks[0].textColor,
fontSize: itemMetadataBlocks[0].fontSize
}
);
},
},
{
type: 'block',
blocks: [ 'tainacan/dynamic-items-list' ],
isMultiBlock: true,
transform: ( itemMetadataBlocks ) => {
const items = itemMetadataBlocks.map((anItemMetadataBlock) => anItemMetadataBlock.itemId);
return createBlock(
'tainacan/dynamic-items-list',
{
selectedItems: items,
loadStrategy: 'selection',
content: [ { type: true } ],
collectionId: itemMetadataBlocks[0].collectionId,
isModalOpen: false,
align: itemMetadataBlocks[0].align,
textColor: itemMetadataBlocks[0].textColor,
fontSize: itemMetadataBlocks[0].fontSize
}
);
},
}
]
};

View File

@ -0,0 +1,82 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"name": "tainacan/item-metadata-sections",
"title": "Tainacan Item Metadata Sections",
"apiVersion": 2,
"category": "tainacan-blocks",
"keywords": [ "item", "metadata", "sections", "regions", "fields" ],
"description": "The metadata sections, including their labels and metadata whitin it.",
"textdomain": "tainacan",
"example": {
"attributes": {
"content": "preview"
}
},
"attributes": {
"content": {
"type": "array",
"source": "query",
"selector": "div"
},
"templateMode": {
"type": "boolean",
"default": false
},
"isDynamic": {
"type": "boolean",
"default": false
},
"collectionId": {
"type": "integer"
},
"itemId": {
"type": "integer"
},
"isModalOpen": {
"type": "boolean",
"default": false
},
"isLoading": {
"type": "boolean",
"default": false
},
"metadataSectionsRequestSource": {
"type": "object",
"default": ""
},
"metadataSections": {
"type": "array",
"default": []
},
"metadataSectionsTemplate": {
"type": "array",
"default": []
},
"textAlign": {
"type": "string"
}
},
"supports": {
"align": ["full", "wide"],
"multiple": true,
"html": true,
"anchor": true,
"color": {
"text": true,
"background": true,
"gradients": true,
"link": true
},
"typography": {
"fontSize": true,
"lineHeight": true
},
"spacing": {
"margin": true,
"padding": true,
"spacing": true
}
},
"editorScript": "item-metadata-sections",
"editorStyle": "item-metadata-sections"
}

View File

@ -0,0 +1 @@
export default [];

View File

@ -0,0 +1,246 @@
const { __ } = wp.i18n;
const { Button, Spinner, Placeholder, ToggleControl, PanelBody } = wp.components;
const ServerSideRender = wp.serverSideRender;
const { useBlockProps, InnerBlocks, BlockControls, AlignmentControl, InspectorControls } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
import SingleItemModal from '../../js/selection/single-item-modal.js';
import getCollectionIdFromPossibleTemplateEdition from '../../js/template/tainacan-blocks-single-item-template-mode.js';
import tainacan from '../../js/axios.js';
import axios from 'axios';
export default function ({ attributes, setAttributes, className, isSelected }) {
let {
content,
collectionId,
itemId,
isLoading,
metadataSectionsRequestSource,
isModalOpen,
metadataSections,
metadataSectionsTemplate,
templateMode,
isDynamic,
textAlign
} = attributes;
// Gets blocks props from hook
const blockProps = tainacan_blocks.wp_version < '5.6' ? { className: className } : useBlockProps( {
className: {
[ `has-text-align-${ textAlign }` ]: textAlign,
}
} );
const currentWPVersion = (typeof tainacan_blocks != 'undefined') ? tainacan_blocks.wp_version : tainacan_plugin.wp_version;
function setContent() {
if (collectionId) {
isLoading = true;
setAttributes({
isLoading: isLoading
});
if (metadataSectionsRequestSource != undefined && typeof metadataSectionsRequestSource == 'function')
metadataSectionsRequestSource.cancel('Previous metadata sections search canceled.');
metadataSectionsRequestSource = axios.CancelToken.source();
let endpoint = '/collection/'+ collectionId + '/metadata-sections';
tainacan.get(endpoint, { cancelToken: metadataSectionsRequestSource.token })
.then(response => {
metadataSections = response.data ? response.data : [];
getMetadataSectionsTemplates({
metadataSections: metadataSections,
metadataSectionsRequestSource: metadataSectionsRequestSource
});
})
.catch((error) => {
console.error(error);
setAttributes({
metadataSections: [],
isLoading: false
});
});
}
}
function getMetadataSectionsTemplates({
metadataSections,
metadataSectionsRequestSource
}) {
let metadataSectionsTemplate = [];
metadataSections.forEach((aMetadataSection) => {
if ( aMetadataSection['metadata_object_list'] && aMetadataSection['metadata_object_list'].length ) {
metadataSectionsTemplate.push([
'tainacan/item-metadata-section',
{
sectionId: String(aMetadataSection.id),
sectionName: aMetadataSection.name,
sectionDescription: aMetadataSection.description,
sectionMetadata: aMetadataSection['metadata_object_list'],
itemId: itemId ? Number(itemId) : 0,
collectionId: Number(collectionId),
dataSource: 'parent',
templateMode: templateMode
}
]);
}
});
setAttributes({
metadataSectionsTemplate: metadataSectionsTemplate,
metadataSections: metadataSections,
isLoading: false,
metadataSectionsRequestSource: metadataSectionsRequestSource
});
}
// Checks if we are in template mode, if so, gets the collection Id from URL.
if ( !templateMode ) {
const possibleCollectionId = getCollectionIdFromPossibleTemplateEdition();
if (possibleCollectionId) {
collectionId = possibleCollectionId;
templateMode = true
setAttributes({
collectionId: collectionId,
templateMode: templateMode
});
setContent();
}
}
return content == 'preview' ?
<div className={className}>
<img
width="100%"
src={ `${tainacan_blocks.base_url}/assets/images/related-carousel-items.png` } />
</div>
: (
<div { ...blockProps }>
<InspectorControls>
<PanelBody
title={ __('Data source', 'tainacan') }
initialOpen={ true }
>
<ToggleControl
label={ __('Dynamic sync from Tainacan', 'tainacan') }
help={ __( 'Check this if you want the item metadata and section values to be always sync with its source from Tainacan. If disabled, however, you will be able to change order of inner blocks, delete and wrap them inside other blocks.', 'tainacan' ) }
checked={ isDynamic }
onChange={ ( isChecked ) => {
isDynamic = isChecked;
setAttributes({ isDynamic: isDynamic });
}
}
/>
</PanelBody>
</InspectorControls>
<BlockControls group="block">
<AlignmentControl
value={ textAlign }
onChange={ ( nextAlign ) => {
setAttributes( { textAlign: nextAlign } );
} }
/>
</BlockControls>
{ isSelected ?
(
<div>
{ isModalOpen ?
<SingleItemModal
modalTitle={ templateMode ? __('Select one metadata section', 'tainacan') : __('Select one item to render its metadata section', 'tainacan') }
applyButtonLabel={ templateMode ? __('Show metadata sections', 'tainacan') : __('Show metadata sections for this item', 'tainacan') }
existingCollectionId={ collectionId }
existingItemId={ itemId }
onSelectCollection={ (selectedCollectionId) => {
collectionId = Number(selectedCollectionId);
setAttributes({
collectionId: collectionId
});
}}
onApplySelectedItem={ (selectedItemId) => {
itemId = Number(selectedItemId);
setAttributes({
itemId: itemId,
isModalOpen: false
});
setContent();
}}
onCancelSelection={ () => setAttributes({ isModalOpen: false }) }/>
: null
}
</div>
) : null
}
{ !itemId && !templateMode ? (
<Placeholder
className="tainacan-block-placeholder"
icon={(
<img
width={148}
src={ `${tainacan_blocks.base_url}/assets/images/tainacan_logo_header.svg` }
alt="Tainacan Logo"/>
)}>
<p>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
height="24px"
width="24px">
<path d="M16,6H12a2,2,0,0,0-2,2v6.52A6,6,0,0,1,12,19a6,6,0,0,1-.73,2.88A1.92,1.92,0,0,0,12,22h8a2,2,0,0,0,2-2V12Zm-1,6V7.5L19.51,12ZM15,2V4H8v9.33A5.8,5.8,0,0,0,6,13V4A2,2,0,0,1,8,2ZM10.09,19.05,7,22.11V16.05L8,17l2,2ZM5,16.05v6.06L2,19.11Z"/>
</svg>
{__('Select an item to display its metadata list.', 'tainacan')}
</p>
<Button
isPrimary
type="button"
onClick={ () => {
isModalOpen = true;
setAttributes( {
isModalOpen: isModalOpen
});
}
}>
{ __('Select Item', 'tainacan') }
</Button>
</Placeholder>
) : null
}
{ isLoading ?
<div class="spinner-container">
<Spinner />
</div> :
<div className={ 'item-metadata-sections-edit-container' }>
{ metadataSectionsTemplate.length ?
( isDynamic ?
<ServerSideRender
block="tainacan/item-metadata-sections"
attributes={ attributes }
httpMethod={ currentWPVersion >= '5.5' ? 'POST' : 'GET' }
/>
:
<InnerBlocks
allowedBlocks={ true }
template={ metadataSectionsTemplate } />
)
: null
}
</div>
}
</div>
);
};

View File

@ -0,0 +1,15 @@
const { SVG, Path } = wp.components;
export default (
<SVG
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 6 6"
height="24px"
width="24px">
<Path d="m1.2849 0.84891c-0.085556 0-0.15764 0.029712-0.21631 0.088379-0.058667 0.058667-0.087891 0.13075-0.087891 0.21631v0.76611c0 0.083111 0.030686 0.1552 0.091797 0.21631l1.0669 1.0669c0.026889 0.026889 0.058548 0.049295 0.095215 0.066406 0.039111 0.017111 0.079538 0.025391 0.12109 0.025391 0.041556 0 0.080521-0.00828 0.11719-0.025391 0.039111-0.017111 0.072232-0.039518 0.099121-0.066406l0.7627-0.7627c0.058667-0.058667 0.087891-0.13075 0.087891-0.21631 0-0.085556-0.029224-0.15764-0.087891-0.21631l-1.0708-1.0703c-0.058667-0.058667-0.12929-0.088379-0.2124-0.088379zm0.21924 0.30469c0.00391-1.815e-4 0.00775 0 0.011719 0 0.063556 0 0.11762 0.022891 0.16162 0.069336 0.044 0.044 0.065918 0.098066 0.065918 0.16162 0 0.063556-0.021918 0.11713-0.065918 0.16113s-0.098066 0.065918-0.16162 0.065918c-0.063555 0-0.11859-0.021918-0.16504-0.065918-0.044-0.044-0.065918-0.097577-0.065918-0.16113 0-0.063556 0.021918-0.11762 0.065918-0.16162 0.043542-0.043542 0.09474-0.066615 0.15332-0.069336z" stroke-width=".25"/>
<Path d="m2.7444 1.1095 0.17272-0.099996s0.031904-0.0143 0.085176-0.010025c0.046428 0.003726 0.072053 0.029979 0.072053 0.029979l0.97841 0.97841c0.061111 0.061111 0.091667 0.13322 0.091667 0.21633 0 0.085553-0.029333 0.15766-0.088 0.21633l-0.73575 0.73575s-0.033678 0.042018-0.088029 0.047173c-0.063189 0.00599-0.098573-0.020678-0.098573-0.020678l-0.16231-0.094919 0.87267-0.88367z" stroke-width=".25"/>
<Path d="m0.98355 3.7638v0.37834h4.0357v-0.37834z" stroke-width=".25223"/>
<Path d="m0.98355 5.1511h2.2701v-0.37836h-2.2701z" stroke-width=".25223"/>
</SVG>
);

View File

@ -0,0 +1,17 @@
import tainacanRegisterBlockType from '../../js/compatibility/tainacan-blocks-compat-register.js';
import metadata from './block.json';
import icon from './icon.js';
import edit from './edit.js';
import save from './save.js';
import deprecated from './deprecated.js';
import transforms from './transforms.js';
tainacanRegisterBlockType({
metadata,
icon,
edit,
save,
deprecated,
transforms
});

View File

@ -0,0 +1,11 @@
const { useBlockProps, InnerBlocks } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
export default function({ attributes }) {
const { textAlign, isDynamic } = attributes;
// Gets blocks props from hook
const blockProps = tainacan_blocks.wp_version < '5.6' ? { className: `has-text-align-${ textAlign }` } : useBlockProps.save( {
className: `has-text-align-${ textAlign }`
} );
return isDynamic ? null : <div { ...blockProps }><InnerBlocks.Content /></div>
};

View File

@ -0,0 +1,64 @@
<?php
/**
* Renders the content of the item metadata sections
* using Tainacan template functions
*/
function tainacan_blocks_render_metadata_sections( $block_attributes, $content, $block ) {
$is_dynamic = isset($block_attributes['isDynamic']) ? ($block_attributes['isDynamic'] === 'true' || $block_attributes['isDynamic'] == 1) : false;
if ( $is_dynamic) {
// Basic check, otherwise we don't have nothing to render here.
$item_id = !empty($block->context['tainacan/itemId']) ? $block->context['tainacan/itemId'] : (isset($block_attributes['itemId']) ? $block_attributes['itemId'] : false);
$collection_id = isset($block_attributes['collectionId']) ? $block_attributes['collectionId'] : false;
$template_mode = isset($block_attributes['templateMode']) ? $block_attributes['templateMode'] : false;
// Builds args from backend query
$args = [];
// Classes from block and Text alignment
$text_align = isset($block_attributes['textAlign']) ? $block_attributes['textAlign'] : false;
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => 'metadata-section-slug-$slug' . ( $text_align ? (' has-text-align-' . $text_align) : '' ),
)
);
$args['before'] = '<section id="metadata-section-$id ' . $wrapper_attributes . '>';
$args['after'] = '</section>';
// Checks if we are in the edit page or in the published
$current_post = get_post();
if ( $template_mode && $collection_id ) {
$collection_pt_pattern = '/' . \Tainacan\Entities\Collection::$db_identifier_prefix . '\d+' . \Tainacan\Entities\Collection::$db_identifier_sufix . '/';
if ( $current_post === NULL )
return \Tainacan\Theme_Helper::get_instance()->get_tainacan_item_metadata_sections_template( [], $collection_id );
else if ( $current_post->post_type !== false && preg_match($collection_pt_pattern, $current_post->post_type) )
return tainacan_get_the_metadata_sections( $args, $current_post->ID );
} else if ( $item_id ) {
return tainacan_get_the_metadata_sections( $args, $item_id );
}
} else {
// Classes from block and Text alignment
$text_align = isset($block_attributes['textAlign']) ? $block_attributes['textAlign'] : false;
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => ( $text_align ? (' has-text-align-' . $text_align) : '' ),
)
);
// Gets inner blocks and wraps them with this parent wrapper
$inner_blocks = $block->inner_blocks;
$inner_blocks_html = '';
foreach ( $inner_blocks as $inner_block ) {
$inner_blocks_html .= $inner_block->render();
}
return '<div ' . $wrapper_attributes . '>' . $inner_blocks_html . '</div>';
}
}

View File

@ -0,0 +1,48 @@
const { createBlock } = wp.blocks;
export default {
to: [
{
type: 'block',
blocks: [ 'tainacan/carousel-items-list' ],
isMultiBlock: true,
transform: ( itemMetadataBlocks ) => {
const items = itemMetadataBlocks.map((anItemMetadataBlock) => anItemMetadataBlock.itemId);
return createBlock(
'tainacan/carousel-items-list',
{
selectedItems: items,
loadStrategy: 'selection',
content: [ { type: true } ],
collectionId: itemMetadataBlocks[0].collectionId,
isModalOpen: false,
align: itemMetadataBlocks[0].align,
textColor: itemMetadataBlocks[0].textColor,
fontSize: itemMetadataBlocks[0].fontSize
}
);
},
},
{
type: 'block',
blocks: [ 'tainacan/dynamic-items-list' ],
isMultiBlock: true,
transform: ( itemMetadataBlocks ) => {
const items = itemMetadataBlocks.map((anItemMetadataBlock) => anItemMetadataBlock.itemId);
return createBlock(
'tainacan/dynamic-items-list',
{
selectedItems: items,
loadStrategy: 'selection',
content: [ { type: true } ],
collectionId: itemMetadataBlocks[0].collectionId,
isModalOpen: false,
align: itemMetadataBlocks[0].align,
textColor: itemMetadataBlocks[0].textColor,
fontSize: itemMetadataBlocks[0].fontSize
}
);
},
}
]
};

View File

@ -0,0 +1,97 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"name": "tainacan/item-metadata",
"title": "Tainacan Item Metadata",
"apiVersion": 2,
"category": "tainacan-blocks",
"keywords": [ "item", "metadata", "fields", "values" ],
"description": "The item metadata, including their labels and values.",
"textdomain": "tainacan",
"example": {
"attributes": {
"content": "preview"
}
},
"attributes": {
"content": {
"type": "array",
"source": "query",
"selector": "div"
},
"dataSource": {
"type": "string",
"default": "selection"
},
"templateMode": {
"type": "boolean",
"default": false
},
"isDynamic": {
"type": "boolean",
"default": false
},
"collectionId": {
"type": "integer"
},
"itemId": {
"type": "integer"
},
"isModalOpen": {
"type": "boolean",
"default": false
},
"isLoading": {
"type": "boolean",
"default": false
},
"itemMetadataRequestSource": {
"type": "object",
"default": ""
},
"itemMetadata": {
"type": "array",
"default": []
},
"metadata": {
"type": "array",
"default": []
},
"itemMetadataTemplate": {
"type": "array",
"default": []
},
"sectionId": {
"type": "string",
"default": ""
},
"textAlign": {
"type": "string"
}
},
"providesContext": {
"tainacan/itemId": "itemId"
},
"supports": {
"align": ["full", "wide"],
"multiple": true,
"html": true,
"anchor": true,
"color": {
"text": true,
"background": true,
"gradients": true,
"link": true
},
"typography": {
"fontSize": true,
"lineHeight": true
},
"spacing": {
"margin": true,
"padding": true,
"spacing": true
}
},
"editorScript": "item-metadata",
"editorStyle": "item-metadata"
}

View File

@ -0,0 +1 @@
export default [];

View File

@ -0,0 +1,328 @@
const { __ } = wp.i18n;
const { Button, Spinner, ToggleControl, Placeholder, PanelBody } = wp.components;
const ServerSideRender = wp.serverSideRender;
const { useBlockProps, InnerBlocks, BlockControls, AlignmentControl, InspectorControls } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
import SingleItemModal from '../../js/selection/single-item-modal.js';
import getCollectionIdFromPossibleTemplateEdition from '../../js/template/tainacan-blocks-single-item-template-mode.js';
import tainacan from '../../js/axios.js';
import axios from 'axios';
export default function ({ attributes, setAttributes, className, isSelected }) {
let {
content,
collectionId,
itemId,
sectionId,
isLoading,
itemMetadataRequestSource,
isModalOpen,
itemMetadata,
metadata,
itemMetadataTemplate,
dataSource,
templateMode,
isDynamic,
textAlign
} = attributes;
// Gets blocks props from hook
const blockProps = tainacan_blocks.wp_version < '5.6' ? { className: className } : useBlockProps( {
className: {
[ `has-text-align-${ textAlign }` ]: textAlign,
}
} );
const currentWPVersion = (typeof tainacan_blocks != 'undefined') ? tainacan_blocks.wp_version : tainacan_plugin.wp_version;
function setContent() {
if ( dataSource === 'parent' && templateMode) {
isLoading = true;
setAttributes({
isLoading: isLoading
});
getItemMetadataTemplates({
metadata: metadata,
itemMetadata: itemMetadata,
itemMetadataRequestSource: itemMetadataRequestSource
});
} else if ( dataSource !== 'parent' && templateMode && collectionId ) {
isLoading = true;
setAttributes({
isLoading: isLoading
});
if (itemMetadataRequestSource != undefined && typeof itemMetadataRequestSource == 'function')
itemMetadataRequestSource.cancel('Previous metadata search canceled.');
itemMetadataRequestSource = axios.CancelToken.source();
let endpoint = '/collection/' + collectionId + (sectionId ? ('/metadata-sections/' + sectionId) : '/metadata');
tainacan.get(endpoint, { cancelToken: itemMetadataRequestSource.token })
.then(response => {
metadata = response.data ? response.data : [];
if (sectionId)
metadata = metadata['metadata_object_list'];
getItemMetadataTemplates({
metadata: metadata,
itemMetadata: [],
itemMetadataRequestSource: itemMetadataRequestSource
});
})
.catch((error) => {
console.error(error);
setAttributes({
metadata: [],
itemMetadata: [],
isLoading: false
});
});
} else if (itemId) {
isLoading = true;
setAttributes({
isLoading: isLoading
});
if (itemMetadataRequestSource != undefined && typeof itemMetadataRequestSource == 'function')
itemMetadataRequestSource.cancel('Previous item metadata search canceled.');
itemMetadataRequestSource = axios.CancelToken.source();
const endpoint = '/item/' + itemId + (sectionId ? ('/metadata-sections/' + sectionId) : '/metadata');
tainacan.get(endpoint, { cancelToken: itemMetadataRequestSource.token })
.then(response => {
itemMetadata = response.data ? response.data : [];
getItemMetadataTemplates({
metadata: itemMetadata.map(anItemMetadata => anItemMetadata.metadatum),
itemMetadata: itemMetadata,
itemMetadataRequestSource: itemMetadataRequestSource
});
})
.catch((error) => {
console.error(error);
setAttributes({
metadata: [],
itemMetadata: [],
isLoading: false
});
});
}
}
function getItemMetadataTemplates({
metadata,
itemMetadata,
itemMetadataRequestSource
}) {
let itemMetadataTemplate = [];
if ( templateMode ) {
metadata.forEach((aMetadatum) => {
itemMetadataTemplate.push([
'tainacan/item-metadatum',
{
placeholder: __( 'Item Metadatum', 'tainacan' ),
metadatumId: aMetadatum.id,
collectionId: Number(collectionId),
dataSource: 'parent',
templateMode: templateMode
}
]);
});
} else {
itemMetadata.forEach((itemMetadatum) => {
if (
itemMetadatum.metadatum &&
itemMetadatum.metadatum.id &&
(itemMetadatum.value !== '' && itemMetadatum.value !== false) &&
(!Array.isArray(itemMetadatum.value) || itemMetadatum.value.length)
) {
itemMetadataTemplate.push([
'tainacan/item-metadatum',
{
placeholder: __( 'Item Metadatum', 'tainacan' ),
metadatumId: itemMetadatum.metadatum.id,
itemId: Number(itemId),
collectionId: Number(collectionId),
dataSource: 'parent',
templateMode: templateMode
}
]);
}
});
}
setAttributes({
itemMetadataTemplate: itemMetadataTemplate,
metadata: metadata,
itemMetadata: itemMetadata,
isLoading: false,
itemMetadataRequestSource: itemMetadataRequestSource
});
}
// Checks if we are in template mode, if so, gets the collection Id from URL.
if ( !templateMode ) {
const possibleCollectionId = getCollectionIdFromPossibleTemplateEdition();
if (possibleCollectionId) {
collectionId = possibleCollectionId;
templateMode = true
setAttributes({
collectionId: collectionId,
templateMode: templateMode
});
setContent();
}
}
// Executed only on the first load of page
if (content === undefined || (content && content.length && content[0].type)) {
setAttributes({ content: '' });
setContent();
}
return content == 'preview' ?
<div className={className}>
<img
width="100%"
src={ `${tainacan_blocks.base_url}/assets/images/related-carousel-items.png` } />
</div>
: (
<div { ...blockProps }>
<InspectorControls>
<PanelBody
title={ __('Data source', 'tainacan') }
initialOpen={ true }
>
<ToggleControl
label={ __('Dynamic sync from Tainacan', 'tainacan') }
help={ __( 'Check this if you want the item metadata values to be always sync with its source from Tainacan. If disabled, however, you will be able to change order of inner blocks, delete and wrap them inside other blocks.', 'tainacan' ) }
checked={ isDynamic }
onChange={ ( isChecked ) => {
isDynamic = isChecked;
setAttributes({ isDynamic: isDynamic });
}
}
/>
</PanelBody>
</InspectorControls>
<BlockControls group="block">
<AlignmentControl
value={ textAlign }
onChange={ ( nextAlign ) => {
setAttributes( { textAlign: nextAlign } );
} }
/>
</BlockControls>
{ isSelected ?
(
<div>
{ isModalOpen ?
<SingleItemModal
modalTitle={ __('Select one item to render its metadata', 'tainacan') }
applyButtonLabel={ __('List metadata for this item', 'tainacan') }
existingCollectionId={ collectionId }
existingItemId={ itemId }
onSelectCollection={ (selectedCollectionId) => {
collectionId = Number(selectedCollectionId);
setAttributes({
collectionId: collectionId
});
}}
onApplySelectedItem={ (selectedItemId) => {
itemId = Number(selectedItemId);
setAttributes({
itemId: itemId,
isModalOpen: false
});
setContent();
}}
onCancelSelection={ () => setAttributes({ isModalOpen: false }) }/>
: null
}
</div>
) : null
}
{ !itemId && !templateMode && dataSource !== 'parent' ? (
<Placeholder
className="tainacan-block-placeholder"
icon={(
<img
width={148}
src={ `${tainacan_blocks.base_url}/assets/images/tainacan_logo_header.svg` }
alt="Tainacan Logo"/>
)}>
<p>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
height="24px"
width="24px">
<path d="M16,6H12a2,2,0,0,0-2,2v6.52A6,6,0,0,1,12,19a6,6,0,0,1-.73,2.88A1.92,1.92,0,0,0,12,22h8a2,2,0,0,0,2-2V12Zm-1,6V7.5L19.51,12ZM15,2V4H8v9.33A5.8,5.8,0,0,0,6,13V4A2,2,0,0,1,8,2ZM10.09,19.05,7,22.11V16.05L8,17l2,2ZM5,16.05v6.06L2,19.11Z"/>
</svg>
{__('Select an item to display its metadata list.', 'tainacan')}
</p>
<Button
isPrimary
type="button"
onClick={ () => {
isModalOpen = true;
setAttributes( {
isModalOpen: isModalOpen
});
}
}>
{__('Select Item', 'tainacan')}
</Button>
</Placeholder>
) : null
}
{ isLoading ?
<div class="spinner-container">
<Spinner />
</div> :
<div className={ 'item-metadata-edit-container' }>
{ itemMetadataTemplate.length ?
( isDynamic ?
<ServerSideRender
block="tainacan/item-metadata"
attributes={ attributes }
httpMethod={ currentWPVersion >= '5.5' ? 'POST' : 'GET' }
/>
:
<InnerBlocks
allowedBlocks={ true }
template={ itemMetadataTemplate }
templateInsertUpdatesSelection={ true } />
)
: null
}
</div>
}
</div>
);
};

View File

@ -0,0 +1,14 @@
const { SVG, Path } = wp.components;
export default (
<SVG
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
height="24px"
width="24px">
<Path
d="m 3.996,3.9959991 h 5.016 q 0.816,0 1.392,0.576 l 7.008,7.0079999 q 0.576,0.576 0.576,1.416 0,0.84 -0.576,1.416 l -4.992,4.992 q -0.264,0.264 -0.648,0.432 -0.36,0.168 -0.768,0.168 -0.408,0 -0.792,-0.168 -0.36,-0.168 -0.624,-0.432 l -6.984,-6.984 q -0.6,-0.6 -0.6,-1.416 V 5.9879991 q 0,-0.84 0.576,-1.416 0.576,-0.576 1.416,-0.576 z m 9.552,1.704 0.984,-0.984 6.864,6.8639999 q 0.6,0.6 0.6,1.416 0,0.84 -0.576,1.416 l -5.376,5.376 -1.008,-1.008 5.712,-5.784 z m -8.04,3.288 q 0.624,0 1.056,-0.432 0.432,-0.432 0.432,-1.056 0,-0.624 -0.432,-1.056 -0.432,-0.456 -1.056,-0.456 -0.624,0 -1.08,0.456 -0.432,0.432 -0.432,1.056 0,0.624 0.432,1.056 0.456,0.432 1.08,0.432 z"
/>
</SVG>
);

View File

@ -0,0 +1,17 @@
import tainacanRegisterBlockType from '../../js/compatibility/tainacan-blocks-compat-register.js';
import metadata from './block.json';
import icon from './icon.js';
import edit from './edit.js';
import save from './save.js';
import deprecated from './deprecated.js';
import transforms from './transforms.js';
tainacanRegisterBlockType({
metadata,
icon,
edit,
save,
deprecated,
transforms
});

View File

@ -0,0 +1,11 @@
const { useBlockProps, InnerBlocks } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
export default function({ attributes }) {
const { textAlign, isDynamic } = attributes;
// Gets blocks props from hook
const blockProps = tainacan_blocks.wp_version < '5.6' ? { className: `has-text-align-${ textAlign }` } : useBlockProps.save( {
className: `has-text-align-${ textAlign }`
} );
return isDynamic ? null : <div { ...blockProps }><InnerBlocks.Content /></div>
};

View File

@ -0,0 +1,67 @@
<?php
/**
* Renders the content of the item metadata
* using Tainacan template functions
*/
function tainacan_blocks_render_item_metadata( $block_attributes, $content, $block ) {
$is_dynamic = isset($block_attributes['isDynamic']) ? ($block_attributes['isDynamic'] === 'true' || $block_attributes['isDynamic'] == 1) : false;
if ( $is_dynamic) {
// Basic check, otherwise we don't have nothing to render here.
$item_id = !empty($block->context['tainacan/itemId']) ? $block->context['tainacan/itemId'] : (isset($block_attributes['itemId']) ? $block_attributes['itemId'] : false);
$collection_id = isset($block_attributes['collectionId']) ? $block_attributes['collectionId'] : false;
$metadata = isset($block_attributes['metadata']) ? $block_attributes['metadata'] : [];
$template_mode = isset($block_attributes['templateMode']) ? $block_attributes['templateMode'] : false;
// Builds args from backend query
$args = [
'metadata__in' => array_map(function($metadatum) { return $metadatum['id']; }, $metadata)
];
// Classes from block and Text alignment
$text_align = isset($block_attributes['textAlign']) ? $block_attributes['textAlign'] : false;
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => 'metadata-type-$type' . ( $text_align ? (' has-text-align-' . $text_align) : '' )
)
);
$args['before'] = '<div ' . $wrapper_attributes . '>';
$args['after'] = '</div>';
if ( $template_mode && $collection_id ) {
// Checks if we are in the edit page or in the published
$current_post = get_post();
$collection_pt_pattern = '/' . \Tainacan\Entities\Collection::$db_identifier_prefix . '\d+' . \Tainacan\Entities\Collection::$db_identifier_sufix . '/';
if ( $current_post === NULL )
return \Tainacan\Theme_Helper::get_instance()->get_tainacan_item_metadata_template($args, $collection_id );
else if ( $current_post->post_type !== false && preg_match($collection_pt_pattern, $current_post->post_type) )
return tainacan_get_the_metadata( $args, $current_post->ID );
} else if ( $item_id ) {
return tainacan_get_the_metadata( $args, $item_id );
}
} else {
// Classes from block and Text alignment
$text_align = isset($block_attributes['textAlign']) ? $block_attributes['textAlign'] : false;
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => ( $text_align ? (' has-text-align-' . $text_align) : '' )
)
);
// Gets inner blocks and wraps them with this parent wrapper
$inner_blocks = $block->inner_blocks;
$inner_blocks_html = '';
foreach ( $inner_blocks as $inner_block ) {
$inner_blocks_html .= $inner_block->render();
}
return '<div ' . $wrapper_attributes . '>' . $inner_blocks_html . '</div>';
}
}

View File

@ -0,0 +1,48 @@
const { createBlock } = wp.blocks;
export default {
to: [
{
type: 'block',
blocks: [ 'tainacan/carousel-items-list' ],
isMultiBlock: true,
transform: ( itemMetadataBlocks ) => {
const items = itemMetadataBlocks.map((anItemMetadataBlock) => anItemMetadataBlock.itemId);
return createBlock(
'tainacan/carousel-items-list',
{
selectedItems: items,
loadStrategy: 'selection',
content: [ { type: true } ],
collectionId: itemMetadataBlocks[0].collectionId,
isModalOpen: false,
align: itemMetadataBlocks[0].align,
textColor: itemMetadataBlocks[0].textColor,
fontSize: itemMetadataBlocks[0].fontSize
}
);
},
},
{
type: 'block',
blocks: [ 'tainacan/dynamic-items-list' ],
isMultiBlock: true,
transform: ( itemMetadataBlocks ) => {
const items = itemMetadataBlocks.map((anItemMetadataBlock) => anItemMetadataBlock.itemId);
return createBlock(
'tainacan/dynamic-items-list',
{
selectedItems: items,
loadStrategy: 'selection',
content: [ { type: true } ],
collectionId: itemMetadataBlocks[0].collectionId,
isModalOpen: false,
align: itemMetadataBlocks[0].align,
textColor: itemMetadataBlocks[0].textColor,
fontSize: itemMetadataBlocks[0].fontSize
}
);
},
}
]
};

View File

@ -0,0 +1,79 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"name": "tainacan/item-metadatum",
"title": "Tainacan Item Metadatum",
"apiVersion": 2,
"category": "tainacan-blocks",
"keywords": [ "item", "metadatum", "field", "value" ],
"description": "A single item metadatum, including a label and its value.",
"textdomain": "tainacan",
"example": {
"attributes": {
"content": "preview"
}
},
"attributes": {
"content": {
"type": "array",
"source": "query",
"selector": "div"
},
"dataSource": {
"type": "string",
"default": "selection"
},
"templateMode": {
"type": "boolean",
"default": false
},
"collectionId": {
"type": "integer"
},
"itemId": {
"type": "integer"
},
"metadatumId": {
"type": "integer"
},
"metadatumType": {
"type": "string",
"default": ""
},
"isModalOpen": {
"type": "boolean",
"default": false
},
"labelLevel": {
"type": "number",
"default": 3
},
"textAlign": {
"type": "string"
}
},
"usesContext": [
"tainacan/itemId"
],
"supports": {
"align": ["full", "wide"],
"multiple": true,
"html": true,
"anchor": true,
"color": {
"text": true,
"background": true,
"gradients": true,
"link": true
},
"typography": {
"fontSize": true,
"lineHeight": true
},
"spacing": {
"margin": true,
"padding": true
}
},
"editorScript": "item-metadatum",
"editorStyle": "item-metadatum"
}

View File

@ -0,0 +1 @@
export default [];

View File

@ -0,0 +1,229 @@
const { __ } = wp.i18n;
const { Button, Placeholder, ToolbarDropdownMenu, SVG, Path } = wp.components;
const ServerSideRender = wp.serverSideRender;
const { useBlockProps, BlockControls, AlignmentControl } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
import SingleItemMetadatumModal from '../../js/selection/single-item-metadatum-modal.js';
import TainacanBlocksCompatToolbar from '../../js/compatibility/tainacan-blocks-compat-toolbar.js';
import getCollectionIdFromPossibleTemplateEdition from '../../js/template/tainacan-blocks-single-item-template-mode.js';
const levelToPath = {
1: 'M9 5h2v10H9v-4H5v4H3V5h2v4h4V5zm6.6 0c-.6.9-1.5 1.7-2.6 2v1h2v7h2V5h-1.4z',
2: 'M7 5h2v10H7v-4H3v4H1V5h2v4h4V5zm8 8c.5-.4.6-.6 1.1-1.1.4-.4.8-.8 1.2-1.3.3-.4.6-.8.9-1.3.2-.4.3-.8.3-1.3 0-.4-.1-.9-.3-1.3-.2-.4-.4-.7-.8-1-.3-.3-.7-.5-1.2-.6-.5-.2-1-.2-1.5-.2-.4 0-.7 0-1.1.1-.3.1-.7.2-1 .3-.3.1-.6.3-.9.5-.3.2-.6.4-.8.7l1.2 1.2c.3-.3.6-.5 1-.7.4-.2.7-.3 1.2-.3s.9.1 1.3.4c.3.3.5.7.5 1.1 0 .4-.1.8-.4 1.1-.3.5-.6.9-1 1.2-.4.4-1 .9-1.6 1.4-.6.5-1.4 1.1-2.2 1.6V15h8v-2H15z',
3: 'M12.1 12.2c.4.3.8.5 1.2.7.4.2.9.3 1.4.3.5 0 1-.1 1.4-.3.3-.1.5-.5.5-.8 0-.2 0-.4-.1-.6-.1-.2-.3-.3-.5-.4-.3-.1-.7-.2-1-.3-.5-.1-1-.1-1.5-.1V9.1c.7.1 1.5-.1 2.2-.4.4-.2.6-.5.6-.9 0-.3-.1-.6-.4-.8-.3-.2-.7-.3-1.1-.3-.4 0-.8.1-1.1.3-.4.2-.7.4-1.1.6l-1.2-1.4c.5-.4 1.1-.7 1.6-.9.5-.2 1.2-.3 1.8-.3.5 0 1 .1 1.6.2.4.1.8.3 1.2.5.3.2.6.5.8.8.2.3.3.7.3 1.1 0 .5-.2.9-.5 1.3-.4.4-.9.7-1.5.9v.1c.6.1 1.2.4 1.6.8.4.4.7.9.7 1.5 0 .4-.1.8-.3 1.2-.2.4-.5.7-.9.9-.4.3-.9.4-1.3.5-.5.1-1 .2-1.6.2-.8 0-1.6-.1-2.3-.4-.6-.2-1.1-.6-1.6-1l1.1-1.4zM7 9H3V5H1v10h2v-4h4v4h2V5H7v4z',
4: 'M9 15H7v-4H3v4H1V5h2v4h4V5h2v10zm10-2h-1v2h-2v-2h-5v-2l4-6h3v6h1v2zm-3-2V7l-2.8 4H16z',
5: 'M12.1 12.2c.4.3.7.5 1.1.7.4.2.9.3 1.3.3.5 0 1-.1 1.4-.4.4-.3.6-.7.6-1.1 0-.4-.2-.9-.6-1.1-.4-.3-.9-.4-1.4-.4H14c-.1 0-.3 0-.4.1l-.4.1-.5.2-1-.6.3-5h6.4v1.9h-4.3L14 8.8c.2-.1.5-.1.7-.2.2 0 .5-.1.7-.1.5 0 .9.1 1.4.2.4.1.8.3 1.1.6.3.2.6.6.8.9.2.4.3.9.3 1.4 0 .5-.1 1-.3 1.4-.2.4-.5.8-.9 1.1-.4.3-.8.5-1.3.7-.5.2-1 .3-1.5.3-.8 0-1.6-.1-2.3-.4-.6-.2-1.1-.6-1.6-1-.1-.1 1-1.5 1-1.5zM9 15H7v-4H3v4H1V5h2v4h4V5h2v10z',
6: 'M9 15H7v-4H3v4H1V5h2v4h4V5h2v10zm8.6-7.5c-.2-.2-.5-.4-.8-.5-.6-.2-1.3-.2-1.9 0-.3.1-.6.3-.8.5l-.6.9c-.2.5-.2.9-.2 1.4.4-.3.8-.6 1.2-.8.4-.2.8-.3 1.3-.3.4 0 .8 0 1.2.2.4.1.7.3 1 .6.3.3.5.6.7.9.2.4.3.8.3 1.3s-.1.9-.3 1.4c-.2.4-.5.7-.8 1-.4.3-.8.5-1.2.6-1 .3-2 .3-3 0-.5-.2-1-.5-1.4-.9-.4-.4-.8-.9-1-1.5-.2-.6-.3-1.3-.3-2.1s.1-1.6.4-2.3c.2-.6.6-1.2 1-1.6.4-.4.9-.7 1.4-.9.6-.3 1.1-.4 1.7-.4.7 0 1.4.1 2 .3.5.2 1 .5 1.4.8 0 .1-1.3 1.4-1.3 1.4zm-2.4 5.8c.2 0 .4 0 .6-.1.2 0 .4-.1.5-.2.1-.1.3-.3.4-.5.1-.2.1-.5.1-.7 0-.4-.1-.8-.4-1.1-.3-.2-.7-.3-1.1-.3-.3 0-.7.1-1 .2-.4.2-.7.4-1 .7 0 .3.1.7.3 1 .1.2.3.4.4.6.2.1.3.3.5.3.2.1.5.2.7.1z',
};
export default function ({ attributes, setAttributes, className, isSelected }) {
let {
content,
collectionId,
itemId,
metadatumId,
metadatumType,
isModalOpen,
dataSource,
templateMode,
labelLevel,
textAlign
} = attributes;
// Gets blocks props from hook
const blockProps = tainacan_blocks.wp_version < '5.6' ? { className: className } : useBlockProps( {
className: {
[ `has-text-align-${ textAlign }` ]: textAlign,
}
} );
const currentWPVersion = (typeof tainacan_blocks != 'undefined') ? tainacan_blocks.wp_version : tainacan_plugin.wp_version;
// Checks if we are in template mode, if so, gets the collection Id from URL.
if ( !templateMode ) {
const possibleCollectionId = getCollectionIdFromPossibleTemplateEdition();
if (possibleCollectionId) {
collectionId = possibleCollectionId;
templateMode = true
setAttributes({
collectionId: collectionId,
templateMode: templateMode
});
}
}
return content == 'preview' ?
<div className={className}>
<img
width="100%"
src={ `${tainacan_blocks.base_url}/assets/images/related-carousel-items.png` } />
</div>
: (
<div { ...blockProps }>
<BlockControls group="block">
<ToolbarDropdownMenu
popoverProps={{
className: 'block-library-heading-level-dropdown',
}}
icon={ (
<SVG
width="24"
height="24"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<Path d={ levelToPath[ labelLevel ] } />
</SVG>
) }
label={ __( 'Change heading level', 'tainacan' ) }
controls={ [ 1, 2, 3, 4, 5, 6 ].map( ( targetLevel ) => {
const isActive = targetLevel === labelLevel;
return {
label: sprintf(
// translators: %s: heading level e.g: "1", "2", "3"
__( 'Heading %d', 'tainacan' ),
targetLevel
),
icon: (
<SVG
width="24"
height="24"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
isPressed={ isActive }
>
<Path d={ levelToPath[ targetLevel ] } />
</SVG>
),
isActive,
onClick: () => {
labelLevel = targetLevel;
setAttributes({ labelLevel: labelLevel });
}
};
} ) }
/>
<AlignmentControl
value={ textAlign }
onChange={ ( nextAlign ) => {
setAttributes( { textAlign: nextAlign } );
} }
/>
</BlockControls>
{ dataSource == 'selection' ? (
<BlockControls group="other">
{
TainacanBlocksCompatToolbar({
label: templateMode ? __('Select metadatum', 'tainacan') : __('Select item metadatum', 'tainacan'),
icon: <svg
xmlns="http://www.w3.org/2000/svg"
viewBox="-2 -2 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"/>
</svg>,
onClick: () => {
isModalOpen = true;
setAttributes( {
isModalOpen: isModalOpen
});
}
})
}
</BlockControls>
): null
}
{ isSelected ?
(
<div>
{ isModalOpen ?
<SingleItemMetadatumModal
modalTitle={ templateMode ? __('Select one metadatum', 'tainacan') : __('Select one item to render its metadata', 'tainacan') }
existingCollectionId={ collectionId }
existingItemId={ itemId }
existingMetadatumId={ metadatumId }
isTemplateMode={ templateMode }
onSelectCollection={ (selectedCollectionId) => {
collectionId = selectedCollectionId;
setAttributes({
collectionId: collectionId
});
}}
onSelectItem={ (selectedItemId) => {
itemId = selectedItemId;
setAttributes({
itemId: itemId
});
}}
onApplySelectedMetadatum={ (selectedMetadatum) => {
metadatumId = selectedMetadatum.metadatumId;
metadatumType = selectedMetadatum.metadatumType;
setAttributes({
metadatumId: metadatumId,
metadatumType: metadatumType,
isModalOpen: false
});
}}
onCancelSelection={ () => setAttributes({ isModalOpen: false }) }/>
: null
}
</div>
) : null
}
{ dataSource == 'selection' && !(collectionId && (templateMode || itemId) && metadatumId) ? (
<Placeholder
className="tainacan-block-placeholder"
icon={(
<img
width={148}
src={ `${tainacan_blocks.base_url}/assets/images/tainacan_logo_header.svg` }
alt="Tainacan Logo"/>
)}>
<p>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="-2 -2 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"/>
</svg>
{__('Select an item metadata to display its label and value.', 'tainacan')}
</p>
<Button
isPrimary
type="button"
onClick={ () => {
isModalOpen = true;
setAttributes( {
isModalOpen: isModalOpen
});
}
}>
{__('Select Item Metadatum', 'tainacan')}
</Button>
</Placeholder>
) : null
}
{ (collectionId && (itemId || templateMode) && metadatumId) ? (
<div className={ 'item-metadatum-edit-container' }>
<ServerSideRender
block="tainacan/item-metadatum"
attributes={ attributes }
httpMethod={ currentWPVersion >= '5.5' ? 'POST' : 'GET' }
/>
</div>
) : null
}
</div>
);
};

View File

@ -0,0 +1,14 @@
const { SVG, Path } = wp.components;
export default (
<SVG
xmlns="http://www.w3.org/2000/svg"
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"
/>
</SVG>
);

View File

@ -0,0 +1,15 @@
import tainacanRegisterBlockType from '../../js/compatibility/tainacan-blocks-compat-register.js';
import metadata from './block.json';
import icon from './icon.js';
import edit from './edit.js';
import save from './save.js';
import deprecated from './deprecated.js';
tainacanRegisterBlockType({
metadata,
icon,
edit,
save,
deprecated
});

View File

@ -0,0 +1,3 @@
export default function() {
return null
};

View File

@ -0,0 +1,58 @@
<?php
/**
* Renders the content of the item metadata block
* using Tainacan template functions
*/
function tainacan_blocks_render_item_metadatum( $block_attributes, $content, $block ) {
// Basic check, otherwise we don't have nothing to render here.
$item_id = !empty($block->context['tainacan/itemId']) ? $block->context['tainacan/itemId'] : (isset($block_attributes['itemId']) ? $block_attributes['itemId'] : false);
$metadatum_id = isset($block_attributes['metadatumId']) ? $block_attributes['metadatumId'] : false;
$collection_id = isset($block_attributes['collectionId']) ? $block_attributes['collectionId'] : false;
$data_source = isset($block_attributes['dataSource']) ? $block_attributes['dataSource'] : 'parent';
$template_mode = isset($block_attributes['templateMode']) ? $block_attributes['templateMode'] : false;
if ( !$metadatum_id )
return '';
// Builds args from backend query
$args = array(
'metadata' => $metadatum_id,
'before_title' => '<h3 class="wp-block-tainacan-item-metadatum__metadatum-label">',
'after_title' => '</h3>',
'before_value' => '<p class="wp-block-tainacan-item-metadatum__metadatum-value">',
'after_value' => '</p>'
);
// Label heading level
$label_level = (isset($block_attributes['labelLevel']) && is_numeric($block_attributes['labelLevel'])) ? $block_attributes['labelLevel'] : false;
if ($label_level) {
$args['before_title'] = '<h' . $label_level . ' class="wp-block-tainacan-item-metadatum__metadatum-label">';
$args['after_title'] = '</h' . $label_level . '>';
}
// Classes from block and Text alignment
$text_align = isset($block_attributes['textAlign']) ? $block_attributes['textAlign'] : false;
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => 'metadata-type-$type' . ( $text_align ? (' has-text-align-' . $text_align) : '' ),
)
);
$args['before'] = '<div ' . $wrapper_attributes . '>';
$args['after'] = '</div>';
if ( $template_mode && $collection_id ) {
// Checks if we are in the edit page or in the published
$current_post = get_post();
$collection_pt_pattern = '/' . \Tainacan\Entities\Collection::$db_identifier_prefix . '\d+' . \Tainacan\Entities\Collection::$db_identifier_sufix . '/';
if ( $current_post === NULL )
return \Tainacan\Theme_Helper::get_instance()->get_tainacan_item_metadata_template( $args, $collection_id );
else if ( $current_post->post_type !== false && preg_match($collection_pt_pattern, $current_post->post_type) )
return tainacan_get_the_metadata( $args, $current_post->ID );
} else if ( $item_id ) {
return tainacan_get_the_metadata( $args, $item_id );
}
}

View File

@ -463,8 +463,8 @@
v-if="metadataSection.description && (!hideHelpButtons && helpInfoBellowLabel)">
{{ metadataSection.description }}
</p>
<template v-if="metadatumList && Array.isArray(metadatumList)">
<template v-for="(itemMetadatum, index) of metadatumList.filter(anItemMetadatum => anItemMetadatum.metadatum.metadata_section_id == metadataSection.id)">
<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
@ -712,18 +712,43 @@ export default {
itemSubmissionMetadata() {
return this.getItemSubmissionMetadata();
},
metadatumList() {
return (this.itemSubmissionMetadata && this.itemSubmissionMetadata.length) ?
JSON.parse(JSON.stringify(
this.getMetadata().map((metadatum) => {
const metadatumValue = this.itemSubmissionMetadata.find((aMetadatum) => aMetadatum.metadatum_id == metadatum.id);
return {
metadatum: metadatum,
item: {},
value: metadatumValue && metadatumValue.value ? metadatumValue.value : ''
}
} )
)) : [];
itemMetadata() {
if ( !this.itemSubmissionMetadata || !this.itemSubmissionMetadata.length)
return [];
const realItemMetadata = JSON.parse(JSON.stringify(this.getMetadata()));
const tweakedItemMetadata = realItemMetadata.map((metadatum) => {
const metadatumValue = this.itemSubmissionMetadata.find((aMetadatum) => aMetadatum.metadatum_id == metadatum.id);
// We need this because repository level metadata have an array of section IDs
const metadatumSectionId = metadatum.metadata_section_id;
if ( !Array.isArray(metadatumSectionId) )
return {
metadatum: metadatum,
item: {},
value: metadatumValue && metadatumValue.value ? metadatumValue.value : ''
}
metadatum.metadata_section_id = 'default_section';
// 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'
);
if (intersectionOfSections.length === 1)
metadatum.metadata_section_id = intersectionOfSections[0].id;
return {
metadatum: metadatum,
item: {},
value: metadatumValue && metadatumValue.value ? metadatumValue.value : ''
};
});
return tweakedItemMetadata;
},
metadataSections() {
return this.getMetadataSections();

View File

@ -86,7 +86,7 @@ export default class ItemsModal extends React.Component {
let anItemsRequestSource = axios.CancelToken.source();
let endpoint = '/collection/' + this.state.collectionId + '/items?'+ qs.stringify({ postin: selectedItems, perpage: selectedItems.length }) + '&fetch_only=title,url,thumbnail';
let endpoint = '/collection/' + this.state.collectionId + '/items?'+ qs.stringify({ postin: selectedItems, perpage: selectedItems.length }) + '&orderby=post__in&fetch_only=title,url,thumbnail';
tainacan.get(endpoint, { cancelToken: anItemsRequestSource.token })
.then(response => {
@ -239,7 +239,7 @@ export default class ItemsModal extends React.Component {
return this.state.collectionId ? (
// Items modal
<Modal
className={ 'wp-block-tainacan-modal dynamic-modal ' + (currentWPVersion < 5.9 ? 'wp-version-smaller-than-5-9' : '') }
className={ 'wp-block-tainacan-modal dynamic-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={ __('Select items to add on block', 'tainacan', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
shouldCloseOnClickOutside={ false }
@ -264,7 +264,7 @@ export default class ItemsModal extends React.Component {
) : (
// Collections modal
<Modal
className="wp-block-tainacan-modal"
className={ 'wp-block-tainacan-modal ' + (currentWPVersion < '5.9' ? 'wp-version-smaller-than-5-9' : '') + (currentWPVersion < '6.1' ? 'wp-version-smaller-than-6-1' : '') }
title={__('Select a collection to fetch items from', 'tainacan')}
onRequestClose={ () => this.cancelSelection() }
contentLabel={__('Select items', 'tainacan')}>

View File

@ -0,0 +1,61 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"name": "tainacan/metadata-section-description",
"title": "Tainacan Metadata Section Description",
"apiVersion": 2,
"category": "tainacan-blocks",
"keywords": ["metadata", "description", "field", "section"],
"description": "A metadata section description, used to complement information about a metadata section.",
"textdomain": "tainacan",
"parent": [ "tainacan/item-metadata-section" ],
"example": {
"attributes": {
"content": "preview"
}
},
"attributes": {
"content": {
"type": "array",
"source": "query",
"selector": "div"
},
"sectionId": {
"type": "string",
"default": ""
},
"sectionDescription": {
"type": "string",
"default": ""
},
"textAlign": {
"type": "string"
}
},
"usesContext": [
"tainacan/metadataSectionId",
"tainacan/metadataSectionDescription"
],
"supports": {
"align": ["full", "wide"],
"multiple": true,
"html": true,
"anchor": true,
"color": {
"text": true,
"background": true,
"gradients": true,
"link": true
},
"typography": {
"fontSize": true,
"lineHeight": true
},
"spacing": {
"margin": true,
"padding": true,
"spacing": true
}
},
"editorScript": "metadata-section-description",
"editorStyle": "metadata-section-description"
}

View File

@ -0,0 +1 @@
export default [];

View File

@ -0,0 +1,54 @@
const { __ } = wp.i18n;
const { useBlockProps, BlockControls, AlignmentControl } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
export default function ({ attributes, setAttributes, className, context }) {
let {
content,
sectionId,
sectionDescription,
textAlign
} = attributes;
// Gets blocks props from hook
const blockProps = tainacan_blocks.wp_version < '5.6' ? { className: className } : useBlockProps( {
className: {
[ `has-text-align-${ textAlign }` ]: textAlign,
}
} );
if (context['tainacan/metadataSectionId'])
sectionId = context['tainacan/metadataSectionId'];
if (context['tainacan/metadataSectionDescription'])
sectionDescription = context['tainacan/metadataSectionDescription'];
if ( context['tainacan/metadataSectionId'] || context['tainacan/metadataSectionDescription'] )
setAttributes({ sectionId, sectionDescription });
return content == 'preview' ?
<div className={className}>
<img
width="100%"
src={ `${tainacan_blocks.base_url}/assets/images/related-carousel-items.png` } />
</div>
: (
<>
<BlockControls group="block">
<AlignmentControl
value={ textAlign }
onChange={ ( nextAlign ) => {
setAttributes( { textAlign: nextAlign } );
} }
/>
</BlockControls>
<p
{ ...blockProps }
id={ 'tainacan-metadata-section-description-block-id--' + sectionId }>
{ sectionDescription }
</p>
</>
);
};

View File

@ -0,0 +1,16 @@
const { SVG, Path, G } = wp.components;
export default (
<SVG
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 6 6"
height="24px"
width="24px">
<Path d="m0.9834 3.7637v0.37842h1.8848v-0.37842h-1.8848zm2.1602 0v0.37842h1.8755v-0.37842h-1.8755z"/>
<Path d="m0.9834 4.7729v0.37793h1.0845v-0.37793h-1.0845zm1.3599 0v0.37793h0.91016v-0.37793h-0.91016z"/>
<G stroke-width=".25">
<Path d="m2.3397 2.6393q0-0.13997-0.094401-0.22624-0.092773-0.086263-0.43131-0.19043-0.33691-0.10579-0.5485-0.26855-0.20996-0.16439-0.20996-0.44922 0-0.28646 0.23112-0.47038 0.23275-0.18555 0.60872-0.18555 0.40202 0 0.62825 0.21484 0.22624 0.21322 0.22624 0.50944h-0.41016q0-0.17415-0.10905-0.28483-0.10905-0.1123-0.34017-0.1123-0.21647 0-0.32064 0.094401-0.10254 0.092773-0.10254 0.23275 0 0.13346 0.1237 0.22135 0.1237 0.086263 0.37272 0.1595 0.40202 0.11719 0.59407 0.29297 0.19368 0.17578 0.19368 0.45898 0 0.29948-0.22949 0.47363-0.22786 0.17415-0.61361 0.17415-0.22786 0-0.44108-0.083008-0.21159-0.083008-0.34993-0.24902-0.13672-0.16602-0.13672-0.41667h0.41178q0 0.22461 0.14811 0.32389 0.14974 0.099284 0.36784 0.099284 0.21484 0 0.32227-0.087891 0.10905-0.08789 0.10905-0.23112z"/>
</G>
</SVG>
);

View File

@ -0,0 +1,15 @@
import tainacanRegisterBlockType from '../../js/compatibility/tainacan-blocks-compat-register.js';
import metadata from './block.json';
import icon from './icon.js';
import edit from './edit.js';
import save from './save.js';
import deprecated from './deprecated.js';
tainacanRegisterBlockType({
metadata,
icon,
edit,
save,
deprecated
});

View File

@ -0,0 +1,15 @@
const { useBlockProps } = (tainacan_blocks.wp_version < '5.2' ? wp.editor : wp.blockEditor );
export default function({ attributes }) {
const { textAlign, sectionId, sectionDescription } = attributes;
// Gets blocks props from hook
const blockProps = tainacan_blocks.wp_version < '5.6' ? { className: `has-text-align-${ textAlign }` } : useBlockProps.save( {
className: `has-text-align-${ textAlign }`
} );
return (
<p { ...blockProps } id={ 'tainacan-metadata-section-description-block-id--' + sectionId }>
{ sectionDescription }
</p>
);
};

View File

@ -0,0 +1,65 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"name": "tainacan/metadata-section-name",
"title": "Tainacan Metadata Section Name",
"apiVersion": 2,
"category": "tainacan-blocks",
"keywords": ["metadata", "name", "field", "section"],
"description": "A metadata section label, used to identify different metadata sections.",
"textdomain": "tainacan",
"parent": [ "tainacan/item-metadata-section" ],
"example": {
"attributes": {
"content": "preview"
}
},
"attributes": {
"content": {
"type": "array",
"source": "query",
"selector": "div"
},
"sectionId": {
"type": "string",
"default": ""
},
"sectionName": {
"type": "string",
"default": ""
},
"labelLevel": {
"type": "number",
"default": 2
},
"textAlign": {
"type": "string"
}
},
"usesContext": [
"tainacan/metadataSectionId",
"tainacan/metadataSectionName"
],
"supports": {
"align": ["full", "wide"],
"multiple": true,
"html": true,
"anchor": true,
"color": {
"text": true,
"background": true,
"gradients": true,
"link": true
},
"typography": {
"fontSize": true,
"lineHeight": true
},
"spacing": {
"margin": true,
"padding": true,
"spacing": true
}
},
"editorScript": "metadata-section-name",
"editorStyle": "metadata-section-name"
}

Some files were not shown because too many files have changed in this diff Show More