Merge branch 'develop' into feature/114
This commit is contained in:
commit
e5815651e9
|
@ -31,6 +31,7 @@ module.exports = {
|
|||
'_': true,
|
||||
'jQuery': true,
|
||||
'tainacan_extra_components': true,
|
||||
'tainacan_extra_plugins': true
|
||||
'tainacan_extra_plugins': true,
|
||||
'grecaptcha': true
|
||||
}
|
||||
}
|
|
@ -35,7 +35,9 @@ sass -E 'UTF-8' --cache-location .tmp/sass-cache-12 src/views/gutenberg-blocks/t
|
|||
|
||||
sass -E 'UTF-8' --cache-location .tmp/sass-cache-13 src/views/gutenberg-blocks/tainacan-facets/faceted-search/faceted-search.scss:src/assets/css/tainacan-gutenberg-block-faceted-search.css
|
||||
|
||||
sass -E 'UTF-8' --cache-location .tmp/sass-cache-14 src/views/gutenberg-blocks/gutenberg-blocks-style.scss:src/assets/css/tainacan-gutenberg-block-common-styles.css
|
||||
sass -E 'UTF-8' --cache-location .tmp/sass-cache-14 src/views/gutenberg-blocks/tainacan-items/item-submission-form/item-submission-form.scss:src/assets/css/tainacan-gutenberg-block-item-submission-form.css
|
||||
|
||||
sass -E 'UTF-8' --cache-location .tmp/sass-cache-15 src/views/gutenberg-blocks/gutenberg-blocks-style.scss:src/assets/css/tainacan-gutenberg-block-common-styles.css
|
||||
|
||||
echo "Compilação do Sass Concluído!"
|
||||
exit 0
|
||||
|
|
|
@ -2362,11 +2362,11 @@
|
|||
}
|
||||
},
|
||||
"buefy": {
|
||||
"version": "0.9.2",
|
||||
"resolved": "https://registry.npmjs.org/buefy/-/buefy-0.9.2.tgz",
|
||||
"integrity": "sha512-f3UXfI6DDIHXE+pk8TC0mjT5BkKyGgoiZpdA5QGf9hVz0yfphJxWeu8+2WrOQLxahrr7HleD0B7ZkslsTQZZIA==",
|
||||
"version": "0.9.4",
|
||||
"resolved": "https://registry.npmjs.org/buefy/-/buefy-0.9.4.tgz",
|
||||
"integrity": "sha512-LRSIYVNrKTPQhmNRegASkntX+ObtZ7aSSA/3cybDKXzGtPNy8g8cl2tp79Rl8/LBVH/KkRT5rmmzJ21nxz9IcQ==",
|
||||
"requires": {
|
||||
"bulma": "0.9.0"
|
||||
"bulma": "0.9.1"
|
||||
}
|
||||
},
|
||||
"buffer": {
|
||||
|
@ -2405,9 +2405,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"bulma": {
|
||||
"version": "0.9.0",
|
||||
"resolved": "https://registry.npmjs.org/bulma/-/bulma-0.9.0.tgz",
|
||||
"integrity": "sha512-rV75CJkubNUroAt0qCRkjznZLoaXq/ctfMXsMvKSL84UetbSyx5REl96e8GoQ04G4Tkw0XF3STECffTOQrbzOQ=="
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/bulma/-/bulma-0.9.1.tgz",
|
||||
"integrity": "sha512-LSF69OumXg2HSKl2+rN0/OEXJy7WFEb681wtBlNS/ulJYR27J3rORHibdXZ6GVb/vyUzzYK/Arjyh56wjbFedA=="
|
||||
},
|
||||
"bytes": {
|
||||
"version": "3.0.0",
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
"buefy": "^0.9.2",
|
||||
"bulma": "^0.9.0",
|
||||
"buefy": "^0.9.4",
|
||||
"bulma": "^0.9.1",
|
||||
"css-vars-ponyfill": "^2.3.1",
|
||||
"mdi": "^2.2.43",
|
||||
"moment": "^2.25.3",
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
.tainacan-embed-container {
|
||||
position: relative;
|
||||
padding-bottom: 56.25%;
|
||||
padding-top: 30px;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
.tainacan-embed-container:not(.tainacan-embed-without-iframe) {
|
||||
padding-bottom: 56.25%;
|
||||
padding-top: 30px;
|
||||
}
|
||||
.tainacan-embed-container iframe,
|
||||
.tainacan-embed-container object,
|
||||
.tainacan-embed-container embed {
|
||||
|
|
|
@ -0,0 +1,242 @@
|
|||
#metadata-checkbox-list {
|
||||
margin: 8px 12px 18px 12px; }
|
||||
#metadata-checkbox-list .components-base-control__help {
|
||||
margin-left: 33px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--tainacan-block-gray4, #555758); }
|
||||
|
||||
.wp-block-tainacan-item-submission-form {
|
||||
margin: 2em auto; }
|
||||
.wp-block-tainacan-item-submission-form .spinner-container {
|
||||
min-height: 56px;
|
||||
padding: 1em;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: var(--tainacan-block-gray4, #555758); }
|
||||
.wp-block-tainacan-item-submission-form .preview-warning {
|
||||
width: 100%;
|
||||
font-size: 0.875em;
|
||||
font-style: italic;
|
||||
color: var(--tainacan-block-gray4, #555758);
|
||||
text-align: center;
|
||||
margin: 4px auto; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder {
|
||||
background-color: var(--tainacan-background-color, white);
|
||||
padding: 0 4.1666667%;
|
||||
font-size: 1.125em;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
flex-direction: column;
|
||||
border-radius: 4px;
|
||||
border: 1px solid rgba(200, 200, 200, 0.3);
|
||||
overflow: hidden; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-text {
|
||||
background-color: var(--tainacan-label-color, rgba(200, 200, 200, 0.3));
|
||||
height: 0.25em;
|
||||
width: 15%;
|
||||
min-width: 1.25em;
|
||||
border-radius: 2px;
|
||||
display: inline-block; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-text.section-label {
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
height: 0.32em; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-text.fake-text-info {
|
||||
background-color: var(--tainacan-info-color, rgba(200, 200, 200, 0.3));
|
||||
width: 5%;
|
||||
opacity: 0.75;
|
||||
margin-left: 6px; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-text.fake-help-button {
|
||||
background-color: var(--tainacan-secondary, rgba(200, 200, 200, 0.3));
|
||||
height: 0.32em;
|
||||
width: 0.32em;
|
||||
min-width: 0.25em;
|
||||
border-radius: 0.2em;
|
||||
margin-left: 6px; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-collapse-arrow {
|
||||
position: relative;
|
||||
top: 0.2em;
|
||||
left: -0.75em;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0.2em 0.2em 0 0.2em;
|
||||
border-color: var(--tainacan-secondary, rgba(200, 200, 200, 0.3)) transparent transparent transparent; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-link {
|
||||
background-color: var(--tainacan-secondary, rgba(200, 200, 200, 0.3));
|
||||
height: 0.2em;
|
||||
width: 10%;
|
||||
border-radius: 2px;
|
||||
display: inline-block; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-icon {
|
||||
background-color: var(--tainacan-info-color, rgba(200, 200, 200, 0.3));
|
||||
height: 0.5em;
|
||||
width: 0.5em;
|
||||
min-height: 0.5em;
|
||||
min-width: 0.5em;
|
||||
max-height: 0.5em;
|
||||
max-width: 0.5em;
|
||||
border-radius: 2px;
|
||||
display: inline-block; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-image-uploader {
|
||||
background-size: cover;
|
||||
height: 3em;
|
||||
background-color: var(--tainacan-input-background-color, rgba(200, 200, 200, 0.3));
|
||||
border: 2px dashed var(--tainacan-input-border-color, rgba(200, 200, 200, 0.3));
|
||||
width: 100%;
|
||||
border-radius: 2px;
|
||||
display: inline-block; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-image-uploader:hover {
|
||||
background-color: var(--tainacan-primary, rgba(200, 200, 200, 0.1)); }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-tooltip {
|
||||
background-color: var(--tainacan-primary, rgba(200, 200, 200, 0.1));
|
||||
position: absolute;
|
||||
height: 0.75em;
|
||||
width: 4em;
|
||||
border-radius: 2px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
top: -1.0em;
|
||||
left: 1em; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-tooltip .fake-link {
|
||||
width: 100%;
|
||||
margin: 0 4px 0 8px; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-tooltip:before {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-tooltip:before {
|
||||
border-color: var(--tainacan-primary) transparent transparent transparent;
|
||||
border-right-width: 6px;
|
||||
border-top-width: 6px;
|
||||
border-left-width: 6px;
|
||||
bottom: -8px; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-input {
|
||||
background-color: var(--tainacan-input-background-color, rgba(200, 200, 200, 0.3));
|
||||
height: 1.5em;
|
||||
width: 18%;
|
||||
border: 2px solid var(--tainacan-input-border-color, rgba(200, 200, 200, 0.3));
|
||||
border-radius: 3px;
|
||||
display: inline-block; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-textarea {
|
||||
background-color: var(--tainacan-input-background-color, rgba(200, 200, 200, 0.3));
|
||||
height: 2.5em;
|
||||
width: 100%;
|
||||
border: 2px solid var(--tainacan-input-border-color, rgba(200, 200, 200, 0.3));
|
||||
border-radius: 3px;
|
||||
display: inline-block; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-button {
|
||||
background-color: var(--tainacan-secondary, rgba(200, 200, 200, 0.3));
|
||||
padding: 0.4em 0.7em;
|
||||
height: 0.95em;
|
||||
width: 10%;
|
||||
max-width: 3.25em;
|
||||
min-width: 1em;
|
||||
margin-left: 6px;
|
||||
border-radius: 3px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: auto; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-button .fake-text {
|
||||
background-color: white;
|
||||
width: 95%;
|
||||
margin: 0 2px; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-button .fake-icon {
|
||||
background-color: white;
|
||||
flex: 1 0 auto;
|
||||
margin: 0 2px; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-button.outline {
|
||||
border: 2px solid var(--tainacan-input-border-color rgba(200, 200, 200, 0.3));
|
||||
background-color: var(--tainacan-background-color, white); }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-button.outline .fake-text {
|
||||
background-color: var(--tainacan-secondary, rgba(200, 200, 200, 0.1)); }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-switch {
|
||||
padding: 0.5em;
|
||||
display: flex;
|
||||
align-items: center; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-switch .fake-icon {
|
||||
background-color: var(--tainacan-secondary, rgba(200, 200, 200, 0.3));
|
||||
width: 1.5em;
|
||||
height: 0.5em;
|
||||
border-radius: 1em;
|
||||
max-height: 1em;
|
||||
max-width: 1em; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .fake-switch .fake-text {
|
||||
margin-left: 0.5em;
|
||||
width: 24%;
|
||||
max-width: 4em; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .documents-section {
|
||||
display: flex;
|
||||
padding: 0.5em; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .documents-section .fake-circle {
|
||||
margin-right: 1.75em;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 3em;
|
||||
height: 3em;
|
||||
border-radius: 100%;
|
||||
background-color: var(--tainacan-input-border-color, rgba(200, 200, 200, 0.3)); }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .documents-section .fake-circle .fake-icon {
|
||||
background-color: var(--tainacan-secondary, rgba(200, 200, 200, 0.3)); }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .documents-section .fake-circle:hover {
|
||||
background-color: var(--tainacan-primary, rgba(200, 200, 200, 0.2)); }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .thumbnail-section {
|
||||
padding: 0.5em; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .thumbnail-section .fake-button {
|
||||
position: relative;
|
||||
max-width: 0.85em;
|
||||
min-width: 0.85em;
|
||||
margin-top: -1em;
|
||||
margin-left: 2rem;
|
||||
border-radius: 100%;
|
||||
z-index: 99;
|
||||
padding: 4px; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .thumbnail-section .fake-icon {
|
||||
max-height: 0.2em;
|
||||
max-width: 0.2em;
|
||||
width: 0.2em;
|
||||
height: 0.2em;
|
||||
min-width: 0.2em;
|
||||
min-height: 0.2em;
|
||||
border-radius: 100%; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .attachments-section {
|
||||
padding: 0.5em;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-start; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .metadata-section {
|
||||
width: 100%;
|
||||
padding: 0.5em 1em;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
flex-direction: column; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .metadata-section .fake-metadata {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .metadata-section .fake-metadata .fake-input {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin: 0.25em 0 0.4em 0; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .metadata-section .fake-metadata.has-collapse {
|
||||
border-bottom: 1px solid var(--tainacan-input-border-color, rgba(200, 200, 200, 0.3));
|
||||
margin-bottom: 0.5em; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .form-footer {
|
||||
padding: 1em 0 2em 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between; }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .form-footer > .fake-text {
|
||||
background-color: var(--tainacan-info-color, rgba(200, 200, 200, 0.3)); }
|
||||
.wp-block-tainacan-item-submission-form .item-submission-form-placeholder .form-footer .fake-button {
|
||||
margin: 0 1em; }
|
||||
|
||||
/*# sourceMappingURL=tainacan-gutenberg-block-item-submission-form.css.map */
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"version": 3,
|
||||
"mappings": "AAEA,uBAAwB;EACpB,MAAM,EAAE,kBAAkB;EAE1B,sDAA+B;IAC3B,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,OAAO;IAClB,KAAK,EAAE,oCAAmC;;AAGlD,uCAAwC;EACpC,MAAM,EAAE,QAAQ;EAGhB,0DAAmB;IACf,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,MAAM;IACvB,WAAW,EAAE,MAAM;IACnB,KAAK,EAAE,oCAAmC;EAG9C,wDAAiB;IACb,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,OAAO;IAClB,UAAU,EAAE,MAAM;IAClB,KAAK,EAAE,oCAAmC;IAC1C,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,QAAQ;EAEpB,yEAAkC;IAC9B,gBAAgB,EAAE,uCAAuC;IACzD,OAAO,EAAE,YAAY;IACrB,SAAS,EAAE,OAAO;IAClB,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,MAAM;IACjB,cAAc,EAAE,MAAM;IACtB,aAAa,EAAE,GAAG;IAClB,MAAM,EAAE,kCAAgC;IACxC,QAAQ,EAAE,MAAM;IAEhB,oFAAW;MACP,gBAAgB,EAAE,qDAAmD;MACrE,MAAM,EAAE,MAAM;MACd,KAAK,EAAE,GAAG;MACV,SAAS,EAAE,MAAM;MACjB,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,YAAY;MAErB,kGAAgB;QACZ,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,GAAG;QACf,MAAM,EAAE,MAAM;MAElB,mGAAiB;QACb,gBAAgB,EAAE,oDAAkD;QACpE,KAAK,EAAE,EAAE;QACT,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,GAAG;MAEpB,qGAAmB;QACf,gBAAgB,EAAE,mDAAiD;QACnE,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,KAAK;QACpB,WAAW,EAAE,GAAG;IAGxB,8FAAqB;MACjB,QAAQ,EAAE,QAAQ;MAClB,GAAG,EAAE,KAAK;MACV,IAAI,EAAE,OAAO;MACb,KAAK,EAAE,CAAC;MACR,MAAM,EAAE,CAAC;MACT,YAAY,EAAE,KAAK;MACnB,YAAY,EAAE,mBAAmB;MACjC,YAAY,EAAE,uFAAqF;IAEvG,oFAAW;MACP,gBAAgB,EAAE,mDAAiD;MACnE,MAAM,EAAE,KAAK;MACb,KAAK,EAAE,GAAG;MACV,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,YAAY;IAEzB,oFAAW;MACP,gBAAgB,EAAE,oDAAkD;MACpE,MAAM,EAAE,KAAK;MACb,KAAK,EAAE,KAAK;MACZ,UAAU,EAAE,KAAK;MACjB,SAAS,EAAE,KAAK;MAChB,UAAU,EAAE,KAAK;MACjB,SAAS,EAAE,KAAK;MAChB,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,YAAY;IAEzB,8FAAqB;MACjB,eAAe,EAAE,KAAK;MACtB,MAAM,EAAE,GAAG;MACX,gBAAgB,EAAE,gEAA8D;MAChF,MAAM,EAAE,uEAAqE;MAC7E,KAAK,EAAE,IAAI;MACX,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,YAAY;MAErB,oGAAQ;QACJ,gBAAgB,EAAE,iDAA+C;IAGzE,uFAAc;MACV,gBAAgB,EAAE,iDAA+C;MACjE,QAAQ,EAAE,QAAQ;MAClB,MAAM,EAAE,MAAM;MACd,KAAK,EAAE,GAAG;MACV,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,IAAI;MACb,eAAe,EAAE,MAAM;MACvB,WAAW,EAAE,MAAM;MACnB,GAAG,EAAE,MAAM;MACX,IAAI,EAAE,GAAG;MAET,kGAAW;QACP,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,WAAW;MAGvB,8FAAS;QACL,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,YAAY,EAAE,KAAK;MAEvB,8FAAS;QACL,YAAY,EAAE,2DAA2D;QACzE,kBAAkB,EAAE,GAAG;QACvB,gBAAgB,EAAE,GAAG;QACrB,iBAAiB,EAAE,GAAG;QACtB,MAAM,EAAE,IAAI;IAGpB,qFAAY;MACR,gBAAgB,EAAE,gEAA8D;MAChF,MAAM,EAAE,KAAK;MACb,KAAK,EAAE,GAAG;MACV,MAAM,EAAE,sEAAoE;MAC5E,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,YAAY;IAEzB,wFAAe;MACX,gBAAgB,EAAE,gEAA8D;MAChF,MAAM,EAAE,KAAK;MACb,KAAK,EAAE,IAAI;MACX,MAAM,EAAE,sEAAoE;MAC5E,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,YAAY;IAEzB,sFAAa;MACT,gBAAgB,EAAE,mDAAiD;MACnE,OAAO,EAAE,WAAW;MACpB,MAAM,EAAE,MAAM;MACd,KAAK,EAAE,GAAG;MACV,SAAS,EAAE,MAAM;MACjB,SAAS,EAAE,GAAG;MACd,WAAW,EAAE,GAAG;MAChB,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,IAAI;MACb,WAAW,EAAE,MAAM;MACnB,YAAY,EAAE,IAAI;MAElB,iGAAW;QACP,gBAAgB,EAAE,KAAK;QACvB,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,KAAK;MAEjB,iGAAW;QACP,gBAAgB,EAAE,KAAK;QACvB,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,KAAK;MAEjB,8FAAU;QACN,MAAM,EAAE,qEAAmE;QAC3E,gBAAgB,EAAE,uCAAuC;QAEzD,yGAAW;UACP,gBAAgB,EAAE,mDAAiD;IAI/E,sFAAa;MACT,OAAO,EAAE,KAAK;MACd,OAAO,EAAE,IAAI;MACb,WAAW,EAAE,MAAM;MAEnB,iGAAW;QACP,gBAAgB,EAAE,mDAAiD;QACnE,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,GAAG;QAClB,UAAU,EAAE,GAAG;QACf,SAAS,EAAE,GAAG;MAElB,iGAAW;QACP,WAAW,EAAE,KAAK;QAClB,KAAK,EAAE,GAAG;QACV,SAAS,EAAE,GAAG;IAGtB,4FAAmB;MACf,OAAO,EAAE,IAAI;MACb,OAAO,EAAE,KAAK;MAEd,yGAAa;QACT,YAAY,EAAE,MAAM;QACpB,OAAO,EAAE,IAAI;QACb,eAAe,EAAE,MAAM;QACvB,WAAW,EAAE,MAAM;QACnB,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,aAAa,EAAE,IAAI;QACnB,gBAAgB,EAAE,4DAA0D;QAE5E,oHAAW;UACP,gBAAgB,EAAE,mDAAiD;QAEvE,+GAAQ;UACJ,gBAAgB,EAAE,iDAA+C;IAI7E,4FAAmB;MACf,OAAO,EAAE,KAAK;MAEd,yGAAa;QACT,QAAQ,EAAE,QAAQ;QAClB,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,MAAM;QACjB,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,GAAG;MAEhB,uGAAW;QACP,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,KAAK;QACjB,aAAa,EAAE,IAAI;IAG3B,8FAAqB;MACjB,OAAO,EAAE,KAAK;MACd,OAAO,EAAE,IAAI;MACb,SAAS,EAAE,IAAI;MACf,eAAe,EAAE,UAAU;IAE/B,2FAAkB;MACd,KAAK,EAAE,IAAI;MACX,OAAO,EAAE,SAAS;MAClB,OAAO,EAAE,IAAI;MACb,SAAS,EAAE,MAAM;MACjB,cAAc,EAAE,MAAM;MAEtB,0GAAe;QACX,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,MAAM;QACtB,SAAS,EAAE,MAAM;QAEjB,sHAAY;UACR,KAAK,EAAE,IAAI;UACX,SAAS,EAAE,IAAI;UACf,MAAM,EAAE,gBAAgB;QAE5B,uHAAe;UACX,aAAa,EAAE,sEAAoE;UACnF,aAAa,EAAE,KAAK;IAIhC,sFAAa;MACT,OAAO,EAAE,WAAW;MACpB,OAAO,EAAE,IAAI;MACb,WAAW,EAAE,MAAM;MACnB,eAAe,EAAE,aAAa;MAE9B,mGAAa;QACT,gBAAgB,EAAE,oDAAkD;MAExE,mGAAa;QACT,MAAM,EAAE,KAAK",
|
||||
"sources": ["../../views/gutenberg-blocks/tainacan-items/item-submission-form/item-submission-form.scss"],
|
||||
"names": [],
|
||||
"file": "tainacan-gutenberg-block-item-submission-form.css"
|
||||
}
|
|
@ -66,6 +66,9 @@ font-weight: normal;
|
|||
.tainacan-icon-attachments:before {
|
||||
content: "attachments";
|
||||
}
|
||||
.tainacan-icon-form:before {
|
||||
content: "form";
|
||||
}
|
||||
.tainacan-icon-wordpress:before {
|
||||
content: "wordpress";
|
||||
}
|
||||
|
@ -282,6 +285,9 @@ font-weight: normal;
|
|||
.tainacan-icon-viewtable:before {
|
||||
content: "viewtable";
|
||||
}
|
||||
.tainacan-icon-viewlist:before {
|
||||
content: "viewlist";
|
||||
}
|
||||
.tainacan-icon-facebook:before {
|
||||
content: "facebook";
|
||||
}
|
||||
|
@ -560,8 +566,8 @@ font-weight: normal;
|
|||
}
|
||||
|
||||
.tainacan-icon-spin:before {
|
||||
-webkit-animation: mdi-spin 2s infinite linear;
|
||||
animation: mdi-spin 2s infinite linear;
|
||||
-webkit-animation: mdi-spin 2s infinite linear reverse !important;
|
||||
animation: mdi-spin 2s infinite linear reverse !important;
|
||||
}
|
||||
|
||||
@-webkit-keyframes mdi-spin {
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 109 KiB |
|
@ -69,6 +69,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
'authorid' => 'author',
|
||||
'authorname' => 'author_name',
|
||||
'search' => 's',
|
||||
's' => 's',
|
||||
'searchterm' => 'search',
|
||||
'status' => 'post_status',
|
||||
'offset' => 'offset',
|
||||
|
@ -146,7 +147,7 @@ class REST_Controller extends \WP_REST_Controller {
|
|||
}
|
||||
|
||||
$args['perm'] = 'readable';
|
||||
|
||||
|
||||
return apply_filters('tainacan-api-prepare-items-args', $args, $request);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class REST_Items_Controller extends REST_Controller {
|
|||
private $item;
|
||||
private $item_metadata;
|
||||
private $collections_repository;
|
||||
private $metadatum_repository;
|
||||
|
||||
/**
|
||||
* REST_Items_Controller constructor.
|
||||
|
@ -36,6 +37,7 @@ class REST_Items_Controller extends REST_Controller {
|
|||
$this->item = new Entities\Item();
|
||||
$this->item_metadata = Repositories\Item_Metadata::get_instance();
|
||||
$this->collections_repository = Repositories\Collections::get_instance();
|
||||
$this->metadatum_repository = Repositories\Metadata::get_instance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,6 +133,27 @@ class REST_Items_Controller extends REST_Controller {
|
|||
),
|
||||
)
|
||||
);
|
||||
register_rest_route(
|
||||
$this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base . '/submission',
|
||||
array(
|
||||
array(
|
||||
'methods' => \WP_REST_Server::CREATABLE,
|
||||
'callback' => array($this, 'submission_item'),
|
||||
'permission_callback' => array($this, 'submission_item_permissions_check'),
|
||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
|
||||
),
|
||||
)
|
||||
);
|
||||
register_rest_route(
|
||||
$this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base . '/submission/(?P<submission_id>[\d]+)/finish',
|
||||
array(
|
||||
array(
|
||||
'methods' => \WP_REST_Server::CREATABLE,
|
||||
'callback' => array($this, 'submission_item_finish'),
|
||||
'permission_callback' => array($this, 'submission_item_permissions_check'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,6 +234,11 @@ class REST_Items_Controller extends REST_Controller {
|
|||
|
||||
if ( $request->get_method() != 'GET') {
|
||||
$item_arr['thumbnail'] = $item->get_thumbnail();
|
||||
$item_arr['thumbnail_alt'] = get_post_meta( $item->get__thumbnail_id(), '_wp_attachment_image_alt', true );
|
||||
$item_arr['thumbnail_id'] = $item->get__thumbnail_id();
|
||||
$item_arr['nonces'] = array(
|
||||
'update-post_' . $item->get_id() => wp_create_nonce('update-post_' . $item->get_id())
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -248,6 +276,13 @@ class REST_Items_Controller extends REST_Controller {
|
|||
if ( $request['context'] === 'edit' ) {
|
||||
$item_arr['current_user_can_edit'] = $item->can_edit();
|
||||
$item_arr['current_user_can_delete'] = $item->can_delete();
|
||||
$item_arr['nonces'] = array(
|
||||
'update-post_' . $item->get_id() => wp_create_nonce('update-post_' . $item->get_id())
|
||||
);
|
||||
}
|
||||
if( isset($item_arr['thumbnail']) ) {
|
||||
$item_arr['thumbnail_alt'] = get_post_meta( $item->get__thumbnail_id(), '_wp_attachment_image_alt', true );
|
||||
$item_arr['thumbnail_id'] = $item->get__thumbnail_id();
|
||||
}
|
||||
|
||||
$item_arr['url'] = get_permalink( $item_arr['id'] );
|
||||
|
@ -364,7 +399,6 @@ class REST_Items_Controller extends REST_Controller {
|
|||
|
||||
// Free php session early so simultaneous requests dont get queued
|
||||
session_write_close();
|
||||
|
||||
$args = $this->prepare_filters($request);
|
||||
|
||||
/**
|
||||
|
@ -829,6 +863,254 @@ class REST_Items_Controller extends REST_Controller {
|
|||
|
||||
}
|
||||
|
||||
private function submission_item_metadada ( \Tainacan\Entities\Item_Metadata_Entity &$item_metadata, $request) {
|
||||
$collection_id = $item_metadata->get_item()->get_collection_id();
|
||||
$item = $item_metadata->get_item();
|
||||
$collection = $this->collections_repository->fetch($collection_id);
|
||||
if ( $item_metadata->validate() ) {
|
||||
if($item->can_edit() || $collection->get_submission_anonymous_user() == 'yes') {
|
||||
return $this->item_metadata->update( $item_metadata );
|
||||
}
|
||||
elseif($item_metadata->get_metadatum()->get_accept_suggestion()) {
|
||||
return $this->item_metadata->suggest( $item_metadata );
|
||||
}
|
||||
else {
|
||||
return new \WP_REST_Response( [
|
||||
'error_message' => __( 'The metadatum does not accept suggestions', 'tainacan' ),
|
||||
], 400 );
|
||||
}
|
||||
} else {
|
||||
return new \WP_REST_Response( [
|
||||
'error_message' => __( 'Please verify, invalid value(s)', 'tainacan' ),
|
||||
'errors' => $item_metadata->get_errors(),
|
||||
'item_metadata' => $this->prepare_item_for_response($item_metadata, $request),
|
||||
], 400 );
|
||||
}
|
||||
}
|
||||
|
||||
public function submission_item ($request) {
|
||||
$collection_id = $request['collection_id'];
|
||||
$item = json_decode($request->get_body(), true);
|
||||
$metadata = $item['metadata'];
|
||||
|
||||
$response_recaptcha = $this->submission_item_check_recaptcha($request);
|
||||
if ($response_recaptcha !== true) {
|
||||
return $response_recaptcha;
|
||||
}
|
||||
|
||||
if(empty($item) || empty($metadata)) {
|
||||
return new \WP_REST_Response([
|
||||
'error_message' => __('Body can not be empty.', 'tainacan'),
|
||||
'item' => $item
|
||||
], 400);
|
||||
}
|
||||
|
||||
try {
|
||||
$item['status'] = 'auto-draft';
|
||||
$item = $this->prepare_item_for_database( [ $item, $collection_id ] );
|
||||
|
||||
if ( $item->validate() ) {
|
||||
$item = $this->items_repository->insert( $item );
|
||||
$item_id = $item->get_id();
|
||||
foreach ( $metadata as $m ) {
|
||||
$value = $m['value'];
|
||||
$metadatum_id = $m['metadatum_id'];
|
||||
$metadatum = $this->metadatum_repository->fetch( $metadatum_id );
|
||||
$item_metadata = new Entities\Item_Metadata_Entity($item, $metadatum);
|
||||
|
||||
if($metadatum->get_metadata_type() == 'Tainacan\Metadata_Types\Compound') {
|
||||
if ($item_metadata->is_multiple()) {
|
||||
foreach($value as $row) {
|
||||
$parent_meta_id = null;
|
||||
foreach($row as $child) {
|
||||
$metadatum_child = $this->metadatum_repository->fetch( $child['metadatum_id'] );
|
||||
$item_metadata_child = new Entities\Item_Metadata_Entity($item, $metadatum_child, null, $parent_meta_id);
|
||||
$item_metadata_child->set_value(is_array($child['value']) ? implode(' ', $child['value']) : $child['value']);
|
||||
$item_metadata_child = $this->submission_item_metadada($item_metadata_child, $request);
|
||||
if ($item_metadata_child instanceof \WP_REST_Response) {
|
||||
return $item_metadata_child;
|
||||
}
|
||||
$parent_meta_id = $item_metadata_child->get_parent_meta_id();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$parent_meta_id = null;
|
||||
foreach($value as $child) {
|
||||
$metadatum_child = $this->metadatum_repository->fetch( $child['metadatum_id'] );
|
||||
$item_metadata_child = new Entities\Item_Metadata_Entity($item, $metadatum_child, null, $parent_meta_id);
|
||||
$item_metadata_child->set_value(is_array($child['value']) ? implode(' ', $child['value']) : $child['value']);
|
||||
$item_metadata_child = $this->submission_item_metadada($item_metadata_child, $request);
|
||||
if ($item_metadata_child instanceof \WP_REST_Response) {
|
||||
return $item_metadata_child;
|
||||
}
|
||||
$parent_meta_id = $item_metadata_child->get_parent_meta_id();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($item_metadata->is_multiple()) {
|
||||
$item_metadata->set_value( is_array($value) ? $value : [$value] );
|
||||
} else {
|
||||
$item_metadata->set_value( is_array($value) ? implode(' ', $value) : $value);
|
||||
}
|
||||
$item_metadata = $this->submission_item_metadada($item_metadata, $request);
|
||||
if ($item_metadata instanceof \WP_REST_Response) {
|
||||
return $item_metadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($item->validate()) {
|
||||
$item = $this->items_repository->insert( $item );
|
||||
$fake_id = \hexdec(\uniqid());
|
||||
$id = $item->get_id();
|
||||
set_transient('tnc_transient_submission_' . $fake_id, $id, 300);
|
||||
$response_item = $this->prepare_item_for_response($item, $request);
|
||||
$response_item['id'] = $fake_id;
|
||||
return new \WP_REST_Response($response_item, 201 );
|
||||
} else {
|
||||
return new \WP_REST_Response([
|
||||
'error_message' => __('One or more values are invalid.', 'tainacan'),
|
||||
'errors' => $item->get_errors(),
|
||||
'item' => $this->prepare_item_for_response($this->item, $request)
|
||||
], 400);
|
||||
}
|
||||
} else {
|
||||
return new \WP_REST_Response([
|
||||
'error_message' => __('One or more values are invalid.', 'tainacan'),
|
||||
'errors' => $item->get_errors(),
|
||||
'item' => $this->prepare_item_for_response($this->item, $request)
|
||||
], 400);
|
||||
}
|
||||
} catch (\Exception $exception){
|
||||
return new \WP_REST_Response($exception->getMessage(), 400);
|
||||
}
|
||||
}
|
||||
|
||||
public function submission_item_finish ( $request ) {
|
||||
$submission_id = $request['submission_id'];
|
||||
$collection_id = $request['collection_id'];
|
||||
$item_id = get_transient('tnc_transient_submission_' . $submission_id);
|
||||
if($item_id === false) {
|
||||
return new \WP_REST_Response([
|
||||
'error_message' => __('submission ID not exist.', 'tainacan'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
$item = $this->items_repository->fetch($item_id);
|
||||
$collection = $this->collections_repository->fetch($collection_id);
|
||||
$default_status = $collection->get_submission_default_status();
|
||||
$item->set_status($default_status);
|
||||
|
||||
$TainacanMedia = \Tainacan\Media::get_instance();
|
||||
$files = $request->get_file_params();
|
||||
|
||||
$insert_attachments = [];
|
||||
$entities_erros = [];
|
||||
if( isset($files['document']) && !is_array($files['document']['tmp_name']) == 1 && $files['document']['size'] > 0 ) {
|
||||
$tmp_file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . \hexdec(\uniqid()) . '_' . $files['document']['name'];
|
||||
move_uploaded_file($files['document']['tmp_name'], $tmp_file_name);
|
||||
$document_id = $TainacanMedia->insert_attachment_from_file($tmp_file_name, $item_id);
|
||||
if($document_id === false) {
|
||||
$entities_erros[] = ["document" => __('Error while creating document', 'tainacan')];
|
||||
wp_delete_attachment($document_id, true);
|
||||
} else {
|
||||
$item->set_document_type('attachment');
|
||||
$item->set_document($document_id);
|
||||
$insert_attachments[] = $document_id;
|
||||
}
|
||||
unlink($tmp_file_name);
|
||||
}
|
||||
|
||||
if( isset($files['thumbnail']) && !is_array($files['thumbnail']['tmp_name']) == 1 && $files['thumbnail']['size'] > 0 ) {
|
||||
$tmp_file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . \hexdec(\uniqid()) . '_' . $files['thumbnail']['name'];
|
||||
move_uploaded_file($files['thumbnail']['tmp_name'], $tmp_file_name);
|
||||
$thumbnail_id = $TainacanMedia->insert_attachment_from_file($tmp_file_name);
|
||||
if($thumbnail_id === false) {
|
||||
$entities_erros[] = ["thumbnail" => __('Error while creating thumbnail', 'tainacan')];
|
||||
wp_delete_attachment($thumbnail_id, true);
|
||||
} else {
|
||||
$item->set__thumbnail_id($thumbnail_id);
|
||||
$insert_attachments[] = $thumbnail_id;
|
||||
}
|
||||
unlink($tmp_file_name);
|
||||
} else {
|
||||
$thumbnail_id = $this->items_repository->get_thumbnail_id_from_document($item);
|
||||
if (!is_null($thumbnail_id)) {
|
||||
set_post_thumbnail( $item_id, (int) $thumbnail_id );
|
||||
$insert_attachments[] = $thumbnail_id;
|
||||
}
|
||||
}
|
||||
|
||||
if( isset($files['attachments']) ) {
|
||||
$attachments = is_array($files['attachments']['tmp_name']) ? $files['attachments']['tmp_name'] : [$files['attachments']['tmp_name']];
|
||||
$attachments_name = is_array($files['attachments']['name']) ? $files['attachments']['name'] : [$files['attachments']['name']];
|
||||
for ($i = 0; $i < count($attachments); $i++) {
|
||||
$tmp_file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . \hexdec(\uniqid()) . '_' . $attachments_name[$i];
|
||||
move_uploaded_file($attachments[$i], $tmp_file_name);
|
||||
$attachment_id = $TainacanMedia->insert_attachment_from_file($tmp_file_name, $item_id);
|
||||
unlink($tmp_file_name);
|
||||
if($attachment_id === false) {
|
||||
$entities_erros[] = ['attachments' => __('Error while creating attachment ', 'tainacan') . "($attachments_name[$i])" ];
|
||||
break;
|
||||
}
|
||||
$insert_attachments[] = $attachment_id;
|
||||
}
|
||||
}
|
||||
|
||||
if( !empty($entities_erros) ) {
|
||||
foreach($insert_attachments as $remove_id) {
|
||||
wp_delete_attachment($remove_id, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($entities_erros) & $item->validate()) {
|
||||
$item = $this->items_repository->insert( $item );
|
||||
delete_transient('tnc_transient_submission_' . $submission_id);
|
||||
return new \WP_REST_Response($this->prepare_item_for_response($item, $request), 201 );
|
||||
} else {
|
||||
return new \WP_REST_Response([
|
||||
'error_message' => __('One or more values are invalid.', 'tainacan'),
|
||||
'errors' => array_merge($item->get_errors(), $entities_erros),
|
||||
'item' => $this->prepare_item_for_response($this->item, $request)
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
||||
public function submission_item_permissions_check ( $request ) {
|
||||
$collection = $this->collections_repository->fetch($request['collection_id']);
|
||||
if ($collection instanceof Entities\Collection && $collection->get_allows_submission() == 'yes') {
|
||||
if ($collection->get_submission_anonymous_user() == 'yes') {
|
||||
return true;
|
||||
}
|
||||
return current_user_can($collection->get_items_capabilities()->edit_posts);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function submission_item_check_recaptcha( $request ) {
|
||||
$collection = $this->collections_repository->fetch($request['collection_id']);
|
||||
$body = json_decode($request->get_body(), true);
|
||||
if ($collection instanceof Entities\Collection && $collection->get_submission_use_recaptcha() == 'yes') {
|
||||
$captcha_data = $body['g-recaptcha-response'];
|
||||
if (!$captcha_data) {
|
||||
return new \WP_REST_Response([
|
||||
'error_message' => __('reCAPTCHA data it is need.', 'tainacan'),
|
||||
'errors' => []
|
||||
], 400);
|
||||
}
|
||||
$secret_key = get_option("tnc_option_recaptch_secret_key");
|
||||
$response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret_key&response=".$captcha_data."&remoteip=".$_SERVER['REMOTE_ADDR']));
|
||||
if ($response->success) {
|
||||
return true;
|
||||
} else {
|
||||
return new \WP_REST_Response([
|
||||
'error_message' => __('reCAPTCHA not valid.', 'tainacan'),
|
||||
'errors' => []
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
|
|
|
@ -306,7 +306,6 @@ class REST_Metadata_Controller extends REST_Controller {
|
|||
public function prepare_item_for_response( $item, $request ) {
|
||||
if(!empty($item)){
|
||||
$item_arr = $item->_toArray();
|
||||
|
||||
$item_arr['metadata_type_object'] = $item->get_metadata_type_object()->_toArray();
|
||||
|
||||
if(isset($item_arr['metadata_type_options']) && isset($item_arr['metadata_type_options']['taxonomy_id'])){
|
||||
|
@ -400,7 +399,7 @@ class REST_Metadata_Controller extends REST_Controller {
|
|||
}
|
||||
|
||||
return new \WP_REST_Response($prepared_item, 200);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \WP_REST_Request $request
|
||||
|
|
|
@ -294,6 +294,7 @@ class REST_Roles_Controller extends REST_Controller {
|
|||
|
||||
foreach ( $newcaps as $cap => $val ) {
|
||||
\wp_roles()->add_cap($role_slug, $cap, $val);
|
||||
\tainacan_roles()->add_dependencies($role_slug, $cap);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,6 +57,29 @@ class Elastic_Press {
|
|||
unset( $formatted_args['query']['bool']['should'] );
|
||||
unset( $formatted_args["query"]["bool"]["must"][0]["multi_match"]["type"] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO
|
||||
* 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]['wildcard'] =
|
||||
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;
|
||||
} );
|
||||
|
||||
|
@ -134,7 +157,7 @@ class Elastic_Press {
|
|||
$args['ep_integrate'] = true;
|
||||
|
||||
add_action('ep_valid_response', function ( $response, $query, $query_args ) {
|
||||
$aggregations = $response['aggregations'];
|
||||
$aggregations = isset($response['aggregations']) ? $response['aggregations'] : [];
|
||||
$this->last_aggregations = $this->format_aggregations($aggregations);
|
||||
}, 10, 3);
|
||||
|
||||
|
|
|
@ -125,7 +125,13 @@ class Embed {
|
|||
* @return string Updated embed markup
|
||||
*/
|
||||
function responsive_embed($html, $url, $attr) {
|
||||
return $html !== '' ? '<div class="tainacan-embed-container">'.$html.'</div>' : '';
|
||||
|
||||
$class = 'tainacan-embed-container';
|
||||
|
||||
if ( !preg_match('/(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/i', $html ) && !preg_match('/(?:<object[^>]*)(?:(?:\/>)|(?:>.*?<\/object>))/i', $html) && !preg_match('/(?:<embed[^>]*)(?:(?:\/>)|(?:>.*?<\/embed>))/i', $html ) )
|
||||
$class .= ' tainacan-embed-without-iframe';
|
||||
|
||||
return $html !== '' ? '<div class="' . $class . '">'.$html.'</div>' : '';
|
||||
}
|
||||
|
||||
}
|
|
@ -42,7 +42,7 @@ class Media {
|
|||
if( ob_get_level() > 0 ) {
|
||||
ob_flush();
|
||||
}
|
||||
flush();
|
||||
// flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,16 +5,6 @@ use Tainacan\Repositories\Repository;
|
|||
|
||||
class Roles {
|
||||
|
||||
|
||||
public static $dependencies = [
|
||||
"tainacan-items" => [
|
||||
'edit_posts' => 'upload_files',
|
||||
"edit_private_posts" => 'upload_files',
|
||||
"edit_published_posts" => 'upload_files',
|
||||
"edit_others_posts" => 'upload_files'
|
||||
]
|
||||
];
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
private $capabilities;
|
||||
|
@ -536,6 +526,8 @@ class Roles {
|
|||
}
|
||||
}
|
||||
|
||||
$collection_capabilities = tainacan_collections()->get_capabilities();
|
||||
|
||||
foreach ( $caps as $cap ) {
|
||||
|
||||
if ( array_key_exists($cap, $allcaps) && $allcaps[$cap] === true ) {
|
||||
|
@ -548,24 +540,64 @@ class Roles {
|
|||
|
||||
$allcaps = array_merge($allcaps, [ $cap => true ]);
|
||||
|
||||
} elseif ( \strpos($cap, 'tnc_col_') === 0 ) {
|
||||
/**
|
||||
* Handle checks for collection specific capabilities.
|
||||
* Either tnc_col_* or tnc_rep_*_collections
|
||||
*/
|
||||
} elseif ( \strpos($cap, 'tnc_col_') === 0 || in_array( $cap, (array) $collection_capabilities ) ) {
|
||||
|
||||
$col_id = preg_replace('/[a-z_]+(\d+)[a-z_]+?$/', '$1', $cap );
|
||||
$check_all_collections_cap = false;
|
||||
$has_all_collections_cap = false;
|
||||
|
||||
|
||||
/**
|
||||
* We are only interested in checks for a specific collection.
|
||||
* $args[2] will be set if this came from a meta cap of a specific collection ( e.g. current_user_can('tnc_rep_edit_collection', 3) ).
|
||||
*/
|
||||
if ( isset( $args[2] ) && is_numeric( $args[2] ) ) {
|
||||
$col_id = $args[2];
|
||||
/**
|
||||
* Or we extract the collectino id from the capability itself. Example: tnc_col_3_delete_items
|
||||
*/
|
||||
} else {
|
||||
$col_id = preg_replace('/[a-z_]+(\d+)[a-z_]+?$/', '$1', $cap );
|
||||
$check_all_collections_cap = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If there is no specific collection, do nothing.
|
||||
*/
|
||||
if ( ! is_numeric($col_id) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check for tnc_col_all_* capabilities
|
||||
$all_collections_cap = preg_replace('/([a-z_]+)(\d+)([a-z_]+?)$/', '${1}all${3}', $cap );
|
||||
// In case of a tnc_col_* capability check,
|
||||
// Let's see if the user has the respective tnc_col_all_* capability
|
||||
if ( $check_all_collections_cap ) {
|
||||
$all_collections_cap = preg_replace('/([a-z_]+)(\d+)([a-z_]+?)$/', '${1}all${3}', $cap );
|
||||
$has_all_collections_cap = $user->has_cap( $all_collections_cap );
|
||||
}
|
||||
|
||||
if (
|
||||
$user->has_cap('manage_tainacan_collection_' . $col_id) ||
|
||||
$user->has_cap('manage_tainacan_collection_all') ||
|
||||
$user->has_cap($all_collections_cap) ) {
|
||||
$has_all_collections_cap
|
||||
) {
|
||||
|
||||
$allcaps = array_merge($allcaps, [ $cap => true ]);
|
||||
} else {
|
||||
// check if the user is the owner
|
||||
|
||||
/**
|
||||
* If a user is trying to edit a collection relying on the manage_tainacan_collection_* cap
|
||||
* they will also need the edit_others_posts capability. But since it is 'manage_tainacan',
|
||||
* we have to treat this here because this check will not get here since we are only handling
|
||||
* caps that starts with tnc_
|
||||
*/
|
||||
if ( $collection_capabilities->edit_posts === $cap ) {
|
||||
$allcaps = array_merge($allcaps, [ $collection_capabilities->edit_others_posts => true ]);
|
||||
}
|
||||
|
||||
} elseif ( \strpos($cap, 'tnc_col_') === 0 ) {
|
||||
// check if the user is the owner only when checking tnc_col_* capabilities
|
||||
$collection = tainacan_collections()->fetch( (int) $col_id );
|
||||
if ( $collection instanceof \Tainacan\Entities\Collection ) {
|
||||
if ( (int) $collection->get_author_id() == (int) $user->ID ) {
|
||||
|
@ -580,7 +612,6 @@ class Roles {
|
|||
|
||||
return $allcaps;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,35 +9,39 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
|||
*/
|
||||
class Collection extends Entity {
|
||||
|
||||
protected
|
||||
$diplay_name,
|
||||
$full,
|
||||
$_thumbnail_id,
|
||||
$modification_date,
|
||||
$creation_date,
|
||||
$author_id,
|
||||
$url,
|
||||
$name,
|
||||
$slug,
|
||||
$order,
|
||||
$parent,
|
||||
$description,
|
||||
$default_order,
|
||||
$default_orderby,
|
||||
$columns,
|
||||
protected
|
||||
$diplay_name,
|
||||
$full,
|
||||
$_thumbnail_id,
|
||||
$modification_date,
|
||||
$creation_date,
|
||||
$author_id,
|
||||
$url,
|
||||
$name,
|
||||
$slug,
|
||||
$order,
|
||||
$parent,
|
||||
$description,
|
||||
$default_order,
|
||||
$default_orderby,
|
||||
$columns,
|
||||
$default_view_mode,
|
||||
$enabled_view_modes,
|
||||
$metadata_order,
|
||||
$filters_order,
|
||||
$enable_cover_page,
|
||||
$cover_page_id,
|
||||
$header_image_id,
|
||||
$header_image,
|
||||
$comment_status,
|
||||
$metadata_order,
|
||||
$filters_order,
|
||||
$enable_cover_page,
|
||||
$cover_page_id,
|
||||
$header_image_id,
|
||||
$header_image,
|
||||
$comment_status,
|
||||
$allow_comments,
|
||||
$hide_items_thumbnail_on_lists;
|
||||
$allows_submission,
|
||||
$hide_items_thumbnail_on_lists,
|
||||
$submission_anonymous_user,
|
||||
$submission_default_status,
|
||||
$submission_use_recaptcha;
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Tainacan\Entities\Entity::post_type
|
||||
* @var string
|
||||
|
@ -131,7 +135,7 @@ class Collection extends Entity {
|
|||
'revisions',
|
||||
'page-attributes',
|
||||
'post-formats',
|
||||
'comments'
|
||||
'comments'
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -227,7 +231,7 @@ class Collection extends Entity {
|
|||
return apply_filters("tainacan-collection-get-attachments", $attachments, $exclude, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function get_author_name() {
|
||||
|
@ -242,11 +246,11 @@ class Collection extends Entity {
|
|||
|
||||
$sizes = get_intermediate_image_sizes();
|
||||
|
||||
array_unshift($sizes, 'full');
|
||||
array_unshift($sizes, 'full');
|
||||
|
||||
foreach ( $sizes as $size ) {
|
||||
$thumbs[$size] = wp_get_attachment_image_src( $this->get__thumbnail_id(), $size );
|
||||
}
|
||||
foreach ( $sizes as $size ) {
|
||||
$thumbs[$size] = wp_get_attachment_image_src( $this->get__thumbnail_id(), $size );
|
||||
}
|
||||
|
||||
return apply_filters("tainacan-collection-get-thumbnail", $thumbs, $this);
|
||||
}
|
||||
|
@ -271,10 +275,10 @@ class Collection extends Entity {
|
|||
*/
|
||||
|
||||
function get__thumbnail_id() {
|
||||
$_thumbnail_id = $this->get_mapped_property("_thumbnail_id");
|
||||
if ( isset( $_thumbnail_id ) ) {
|
||||
return $_thumbnail_id;
|
||||
}
|
||||
$_thumbnail_id = $this->get_mapped_property("_thumbnail_id");
|
||||
if ( isset( $_thumbnail_id ) ) {
|
||||
return $_thumbnail_id;
|
||||
}
|
||||
|
||||
return get_post_thumbnail_id( $this->get_id() );
|
||||
}
|
||||
|
@ -430,8 +434,8 @@ class Collection extends Entity {
|
|||
* @return boolean
|
||||
*/
|
||||
function is_cover_page_enabled() {
|
||||
return $this->get_enable_cover_page() === 'yes';
|
||||
}
|
||||
return $this->get_enable_cover_page() === 'yes';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enable cover page attribute
|
||||
|
@ -533,7 +537,7 @@ class Collection extends Entity {
|
|||
* @return string "open"|"closed"
|
||||
*/
|
||||
public function get_comment_status() {
|
||||
return $this->get_mapped_property('comment_status');
|
||||
return $this->get_mapped_property('comment_status');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -541,7 +545,34 @@ class Collection extends Entity {
|
|||
* @return bool
|
||||
*/
|
||||
public function get_allow_comments() {
|
||||
return $this->get_mapped_property('allow_comments');
|
||||
return $this->get_mapped_property('allow_comments');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enable submission with anonymous user
|
||||
*
|
||||
* @return string "yes"|"no"
|
||||
*/
|
||||
function get_submission_anonymous_user() {
|
||||
return $this->get_mapped_property( 'submission_anonymous_user' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default submission status
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_submission_default_status() {
|
||||
return $this->get_mapped_property( 'submission_default_status' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if submission items are allowed for the current collection.
|
||||
*
|
||||
* @return string "yes"|"no"
|
||||
*/
|
||||
function get_allows_submission() {
|
||||
return $this->get_mapped_property( 'allows_submission' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -553,6 +584,15 @@ class Collection extends Entity {
|
|||
return $this->get_mapped_property( 'hide_items_thumbnail_on_lists' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if submission items use a recaptcha.
|
||||
*
|
||||
* @return string "yes"|"no"
|
||||
*/
|
||||
function get_submission_use_recaptcha() {
|
||||
return $this->get_mapped_property( 'submission_use_recaptcha' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the collection name
|
||||
*
|
||||
|
@ -730,7 +770,7 @@ class Collection extends Entity {
|
|||
* @param $value string "open"|"closed"
|
||||
*/
|
||||
public function set_comment_status( $value ) {
|
||||
$this->set_mapped_property('comment_status', $value);
|
||||
$this->set_mapped_property('comment_status', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -739,7 +779,40 @@ class Collection extends Entity {
|
|||
* @param $value bool
|
||||
*/
|
||||
public function set_allow_comments( $value ) {
|
||||
$this->set_mapped_property('allow_comments', $value );
|
||||
$this->set_mapped_property('allow_comments', $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set enable submission with anonymous user
|
||||
*
|
||||
* @param [string] $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function set_submission_anonymous_user( $value ) {
|
||||
$this->set_mapped_property( 'submission_anonymous_user', $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default submission status
|
||||
*
|
||||
* @param [string] $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function set_submission_default_status( $value ) {
|
||||
$this->set_mapped_property( 'submission_default_status', $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if submission items are allowes for the current collection.
|
||||
*
|
||||
* @param [string] $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function set_allows_submission( $value ) {
|
||||
$this->set_mapped_property( 'allows_submission', $value );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -753,6 +826,17 @@ class Collection extends Entity {
|
|||
$this->set_mapped_property( 'hide_items_thumbnail_on_lists', $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if submission items are use recaptcha.
|
||||
*
|
||||
* @param [string] $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function set_submission_use_recaptcha( $value ) {
|
||||
return $this->set_mapped_property( 'submission_use_recaptcha', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Collection
|
||||
*
|
||||
|
|
|
@ -93,6 +93,8 @@ class Item extends Entity {
|
|||
}
|
||||
|
||||
$attachments_query = [
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'post_type' => 'attachment',
|
||||
'posts_per_page' => -1,
|
||||
'post_parent' => $item_id,
|
||||
|
|
|
@ -173,13 +173,16 @@ class Metadatum extends Entity {
|
|||
function get_metadata_type_object(){
|
||||
$class_name = $this->get_metadata_type();
|
||||
|
||||
if( !class_exists( $class_name ) ){
|
||||
return null;
|
||||
if( !class_exists( $class_name ) ) {
|
||||
$class_name = "Tainacan\\Metadata_Types\\Text";
|
||||
if( !class_exists( $class_name ) ){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$object_type = new $class_name();
|
||||
$object_type->set_options( $this->get_mapped_property('metadata_type_options') );
|
||||
return $object_type;
|
||||
return $object_type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,17 +5,25 @@ use Tainacan;
|
|||
use Tainacan\Entities;
|
||||
|
||||
class CSV extends Exporter {
|
||||
private $collection_name;
|
||||
|
||||
public function __construct($attributes = array()) {
|
||||
parent::__construct($attributes);
|
||||
$this->set_accepted_mapping_methods('any'); // set all method to mapping
|
||||
$this->accept_no_mapping = true;
|
||||
if ($current_collection = $this->get_current_collection_object()) {
|
||||
$name = $current_collection->get_name();
|
||||
$this->collection_name = sanitize_title($name) . "_csv_export.csv";;
|
||||
} else {
|
||||
$this->collection_name = "csv_export.csv";
|
||||
}
|
||||
|
||||
//$this->set_accepted_mapping_methods('list', [ "dublin-core" ]); // set specific list of methods to mapping
|
||||
$this->set_default_options([
|
||||
'delimiter' => ',',
|
||||
'multivalued_delimiter' => '||',
|
||||
'enclosure' => '"'
|
||||
]);
|
||||
'delimiter' => ',',
|
||||
'multivalued_delimiter' => '||',
|
||||
'enclosure' => '"'
|
||||
]);
|
||||
}
|
||||
|
||||
public function filter_multivalue_separator($separator) {
|
||||
|
@ -79,10 +87,8 @@ class CSV extends Exporter {
|
|||
$line[] = $item->get_modification_date();
|
||||
|
||||
$line_string = $this->str_putcsv($line, $this->get_option('delimiter'), $this->get_option('enclosure'));
|
||||
|
||||
|
||||
$this->append_to_file('csvexporter.csv', $line_string."\n");
|
||||
|
||||
|
||||
$this->append_to_file($this->collection_name, $line_string."\n");
|
||||
}
|
||||
|
||||
function get_compound_metadata_cell($meta) {
|
||||
|
@ -214,7 +220,7 @@ class CSV extends Exporter {
|
|||
|
||||
$line_string = $this->str_putcsv($line, $this->get_option('delimiter'), $this->get_option('enclosure'));
|
||||
|
||||
$this->append_to_file('csvexporter.csv', $line_string."\n");
|
||||
$this->append_to_file($this->collection_name, $line_string."\n");
|
||||
|
||||
}
|
||||
|
||||
|
@ -237,10 +243,15 @@ class CSV extends Exporter {
|
|||
public function get_output() {
|
||||
$files = $this->get_output_files();
|
||||
|
||||
if ( is_array($files) && isset($files['csvexporter.csv'])) {
|
||||
$file = $files['csvexporter.csv'];
|
||||
if ( is_array($files) && isset($files[$this->collection_name])) {
|
||||
$file = $files[$this->collection_name];
|
||||
$current_user = wp_get_current_user();
|
||||
$author_name = $current_user->user_login;
|
||||
|
||||
$message = __('target collections:', 'tainacan');
|
||||
$message .= " <b>" . implode(", ", $this->get_collections_names() ) . "</b><br/>";
|
||||
$message .= __('Exported by:', 'tainacan');
|
||||
$message .= " <b> ${author_name} </b><br/>";
|
||||
$message .= __('Your CSV file is ready! Access it in the link below:', 'tainacan');
|
||||
$message .= '<br/><br/>';
|
||||
$message .= '<a href="' . $file['url'] . '">Download</a>';
|
||||
|
@ -267,7 +278,7 @@ class CSV extends Exporter {
|
|||
|
||||
public function options_form() {
|
||||
ob_start();
|
||||
?>
|
||||
?>
|
||||
<div class="field">
|
||||
<label class="label"><?php _e('CSV Delimiter', 'tainacan'); ?></label>
|
||||
<span class="help-wrapper">
|
||||
|
@ -335,11 +346,7 @@ class CSV extends Exporter {
|
|||
</div>
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
return ob_get_clean();
|
||||
|
||||
}
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
|
@ -568,7 +568,13 @@ abstract class Exporter {
|
|||
|
||||
$processed_items = $this->get_items($current_collection_item, $collection_definition);
|
||||
foreach ($processed_items as $processed_item) {
|
||||
$init = microtime(true);
|
||||
$this->process_item( $processed_item['item'], $processed_item['metadata'] );
|
||||
$final = microtime(true);
|
||||
$total = ($final - $init);
|
||||
$time_log = sprintf( __('Processed in %f seconds', 'tainacan'), $total );
|
||||
|
||||
$this->add_log($time_log);
|
||||
}
|
||||
|
||||
$this->process_footer($current_collection_item, $collection_definition);
|
||||
|
@ -618,7 +624,6 @@ abstract class Exporter {
|
|||
$this->update_current_collection($collection_definition);
|
||||
}
|
||||
|
||||
|
||||
$data = [];
|
||||
while ($items->have_posts()) {
|
||||
$items->the_post();
|
||||
|
@ -681,14 +686,15 @@ abstract class Exporter {
|
|||
$upload_dir = trailingslashit( $upload_dir_info['basedir'] );
|
||||
$upload_url = trailingslashit( $upload_dir_info['baseurl'] );
|
||||
$exporter_folder = 'tainacan/exporter';
|
||||
$file_suffix = "{$exporter_folder}/{$prefix}_{$key}";
|
||||
|
||||
if (!is_dir($upload_dir . $exporter_folder)) {
|
||||
if (!mkdir($upload_dir . $exporter_folder)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$file_name = "$upload_dir$exporter_folder/$prefix$key";
|
||||
$file_url = "$upload_url$exporter_folder/$prefix$key";
|
||||
$file_name = "{$upload_dir}{$file_suffix}";
|
||||
$file_url = "{$upload_url}{$file_suffix}";
|
||||
$this->output_files[$key] = [
|
||||
'filename' => $file_name,
|
||||
'url' => $file_url
|
||||
|
@ -716,7 +722,7 @@ abstract class Exporter {
|
|||
* Method called by Exporters classes to set accepted mapping method
|
||||
*
|
||||
* @param string $method THe accepted methods. any or list. If list, Exporter must also inform
|
||||
* default mapper and the list of accepted mappers
|
||||
* default mapper and the list of accepted mappers
|
||||
* @param string $default_mapping The default mapping method. Required if list is chosen
|
||||
* @param array $list List of accepted mapping methods
|
||||
*/
|
||||
|
|
|
@ -83,10 +83,45 @@ class Bulk_Edit_Process extends Generic_Process {
|
|||
}
|
||||
|
||||
public function get_output() {
|
||||
$message = __('Bulk edit finished', 'tainacan');
|
||||
$name = $this->get_bulk_edit_collection_name();
|
||||
$metadata = $this->get_changed_metadata();
|
||||
$current_user = wp_get_current_user();
|
||||
$author_name = $current_user->user_login;
|
||||
|
||||
$title_label = __('Collection', 'tainacan');
|
||||
$author_label = __('Edited by', 'tainacan');
|
||||
$metadata_label = __('Changed metadata', 'tainacan');
|
||||
|
||||
$message = __('Bulk edit finished', 'tainacan');
|
||||
$message .= "<p> <strong> ${title_label}: </strong> ${name} </p>";
|
||||
$message .= "<p> <strong> ${author_label}: </strong> ${author_name} </p>";
|
||||
$message .= "<p> <strong> ${metadata_label}: </strong> ${metadata} </p>";
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
private function get_bulk_edit_collection_name() {
|
||||
$params = $this->get_options();
|
||||
if ($params['collection_id']) {
|
||||
$collection = $params['collection_id'];
|
||||
$bulk_collection = Tainacan\Repositories\Collections::get_instance()->fetch($collection);
|
||||
|
||||
if ($bulk_collection instanceof \Tainacan\Entities\Collection) {
|
||||
return $bulk_collection->get_name();
|
||||
}
|
||||
}
|
||||
|
||||
return __('Collection', 'tainacan');
|
||||
}
|
||||
|
||||
private function get_changed_metadata() {
|
||||
$metadatum = $this->metadatum_repository->fetch($this->bulk_edit_data['metadatum_id']);
|
||||
if ($metadatum instanceof \Tainacan\Entities\Metadatum) {
|
||||
return $metadatum->get_name();
|
||||
}
|
||||
return __('Metadata', 'tainacan');
|
||||
}
|
||||
|
||||
public function set_bulk_edit_data($bulk_edit_data = false) {
|
||||
$this->bulk_edit_data = $bulk_edit_data;
|
||||
}
|
||||
|
|
|
@ -50,18 +50,18 @@ abstract class Generic_Process {
|
|||
];
|
||||
|
||||
/**
|
||||
* Transients is used to store temporary data to be used accross multiple requests
|
||||
* Transients are used to store temporary data to be used across multiple requests
|
||||
*
|
||||
* Add and remove transient data using add_transient() and delete_transient() methods
|
||||
*
|
||||
* Transitens can be strings, numbers or arrays. Avoid storing objects.
|
||||
* Transients can be strings, numbers or arrays. Avoid storing objects.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $transients = [];
|
||||
|
||||
/**
|
||||
* Wether to abort process execution.
|
||||
* Whether to abort process execution.
|
||||
* @var bool
|
||||
*/
|
||||
protected $abort = false;
|
||||
|
@ -74,7 +74,7 @@ abstract class Generic_Process {
|
|||
|
||||
/**
|
||||
* List of attributes that are saved in DB and that are used to
|
||||
* reconstruct the object, this property need be overwrite.
|
||||
* reconstruct the object, this property needs be overwritten.
|
||||
* @var array
|
||||
*/
|
||||
protected $array_attributes = [
|
||||
|
|
|
@ -63,8 +63,4 @@ class Background_Importer extends Background_Process {
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
}
|
|
@ -283,7 +283,6 @@ class CSV extends Importer {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function options_form() {
|
||||
ob_start();
|
||||
?>
|
||||
|
@ -1018,9 +1017,17 @@ class CSV extends Importer {
|
|||
* @return string
|
||||
*/
|
||||
public function get_output() {
|
||||
$imported_file = basename($this->get_tmp_file());
|
||||
$current_user = wp_get_current_user();
|
||||
$author = $current_user->user_login;
|
||||
|
||||
$message = __('target collections:', 'tainacan');
|
||||
$message = __('imported file:', 'tainacan');
|
||||
$message .= " <b> ${imported_file} </b><br/>";
|
||||
$message .= __('target collections:', 'tainacan');
|
||||
$message .= " <b>" . implode(", ", $this->get_collections_names() ) . "</b><br/>";
|
||||
$message .= __('Imported by:', 'tainacan');
|
||||
$message .= " <b> ${author} </b><br/>";
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
|
|
|
@ -761,8 +761,6 @@ abstract class Importer {
|
|||
}
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -913,8 +911,6 @@ abstract class Importer {
|
|||
}
|
||||
|
||||
return $return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -990,7 +986,6 @@ abstract class Importer {
|
|||
'input_type' => 'tainacan-taxonomy-checkbox'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*Properties of metadatum*/
|
||||
|
|
|
@ -195,6 +195,31 @@ class Collections extends Repository {
|
|||
'default' => 'open',
|
||||
'validation' => v::optional(v::stringType()->in( [ 'open', 'closed' ] )),
|
||||
],
|
||||
'submission_anonymous_user' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Allows submission by anonymous user', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'If enabled, allows submission by anonymous users, whose does not have to be logged in with permissions on the WordPress system.', 'tainacan' ),
|
||||
'default' => 'no',
|
||||
'on_error' => __( 'Value should be yes or no', 'tainacan' ),
|
||||
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
|
||||
],
|
||||
'submission_default_status' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Default submission item status', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'The default status of the item that will be created in the collection after submission.', 'tainacan' ),
|
||||
'default' => 'draft'
|
||||
],
|
||||
'allows_submission' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Allows item submission', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'If enabled, the collection allows item submission, for example via the Item Submission block.', 'tainacan' ),
|
||||
'default' => 'no',
|
||||
'on_error' => __( 'Value should be yes or no', 'tainacan' ),
|
||||
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
|
||||
],
|
||||
'hide_items_thumbnail_on_lists' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Hide items thumbnail on lists', 'tainacan' ),
|
||||
|
@ -204,6 +229,16 @@ class Collections extends Repository {
|
|||
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
|
||||
'default' => 'no'
|
||||
],
|
||||
'submission_use_recaptcha' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Use reCAPTCHA verification on submission form', 'tainacan' ),
|
||||
'type' => 'string',
|
||||
'description' => __( 'If enabled, the collection allows item submission using a reCAPTCHA', 'tainacan' ),
|
||||
'default' => 'no',
|
||||
'on_error' => __( 'Value should be yes or no', 'tainacan' ),
|
||||
'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
|
||||
],
|
||||
|
||||
] );
|
||||
}
|
||||
|
||||
|
@ -270,7 +305,8 @@ class Collections extends Repository {
|
|||
public function insert( $collection ) {
|
||||
|
||||
$this->pre_process( $collection );
|
||||
|
||||
|
||||
$this->handle_parent_order_metadata_clone( $collection );
|
||||
$new_collection = parent::insert( $collection );
|
||||
|
||||
$this->handle_core_metadata( $new_collection );
|
||||
|
@ -381,6 +417,24 @@ class Collections extends Repository {
|
|||
$Tainacan_Metadata->register_control_metadata( $collection );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function guarantees that children collections has its own clone
|
||||
* of "metadata_order" from the parent collention.
|
||||
*
|
||||
* @param \Tainacan\Entities\Collection $collection, children collection
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function handle_parent_order_metadata_clone( &$collection ) {
|
||||
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
||||
if ($collection instanceof Entities\Collection && $collection->get_parent() != 0) {
|
||||
$parent_collection = $this->fetch( $collection->get_parent() );
|
||||
$collection->set_metadata_order($parent_collection->get_metadata_order());
|
||||
|
||||
if (!$collection->validate()) {
|
||||
throw new \Exception( implode(",", $collection->get_errors()) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,7 +70,8 @@ class Item_Metadata extends Repository {
|
|||
return $item_metadata;
|
||||
} else {
|
||||
if ( $unique ) {
|
||||
if( empty( $item_metadata->get_value() ) ) {
|
||||
|
||||
if ( !is_numeric($item_metadata->get_value()) && empty( $item_metadata->get_value() ) ) {
|
||||
if ( $item_metadata->get_metadatum()->get_parent() > 0 )
|
||||
delete_metadata_by_mid( 'post', $item_metadata->get_meta_id() );
|
||||
else
|
||||
|
@ -101,7 +102,7 @@ class Item_Metadata extends Repository {
|
|||
$values = $item_metadata->get_value();
|
||||
|
||||
foreach ( $values as $value ) {
|
||||
if( empty($value) || $value == "" ) {
|
||||
if ( !is_numeric($value) && empty($value) ) {
|
||||
continue;
|
||||
}
|
||||
add_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id(), wp_slash( $value ) );
|
||||
|
|
|
@ -231,7 +231,7 @@ class Items extends Repository {
|
|||
$no_collection_set = false;
|
||||
|
||||
/**
|
||||
* We can not user $collections->fetch() here because facets
|
||||
* We can not use $collections->fetch() here because facets
|
||||
* filter wp_query to just return the query and not the results
|
||||
* See Repositories\Metadata::fetch_all_metadatum_values()
|
||||
*
|
||||
|
|
|
@ -433,7 +433,6 @@ class Metadata extends Repository {
|
|||
$args['meta_query'][] = $meta_query;
|
||||
|
||||
$results = array_merge($results, $this->fetch( $args, 'OBJECT' ));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -456,6 +455,7 @@ class Metadata extends Repository {
|
|||
$args['meta_query'][] = $meta_query;
|
||||
|
||||
$results = $this->fetch( $args, 'OBJECT' );
|
||||
|
||||
}
|
||||
|
||||
$results = array_filter($results, function($meta) {
|
||||
|
@ -573,6 +573,7 @@ class Metadata extends Repository {
|
|||
*/
|
||||
public function order_result( $result, Entities\Collection $collection, $include_disabled = false ) {
|
||||
$order = $collection->get_metadata_order();
|
||||
|
||||
if ( $order ) {
|
||||
$order = ( is_array( $order ) ) ? $order : unserialize( $order );
|
||||
|
||||
|
|
|
@ -49,7 +49,8 @@ class Theme_Helper {
|
|||
add_filter('get_the_archive_title', array($this, 'filter_archive_title'));
|
||||
|
||||
add_shortcode( 'tainacan-search', array($this, 'search_shortcode'));
|
||||
|
||||
add_shortcode( 'tainacan-item-submission', array($this, 'item_submission_shortcode'));
|
||||
|
||||
add_action( 'generate_rewrite_rules', array( &$this, 'rewrite_rules' ), 10, 1 );
|
||||
add_filter( 'query_vars', array( &$this, 'rewrite_rules_query_vars' ) );
|
||||
add_filter( 'template_include', array( &$this, 'rewrite_rule_template_include' ) );
|
||||
|
@ -106,7 +107,7 @@ class Theme_Helper {
|
|||
'label' => __('List', 'tainacan'),
|
||||
'dynamic_metadata' => true,
|
||||
'description' => 'A list view, similiar to the records, but full width',
|
||||
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewrecords tainacan-icon-1-25em"></i></span>',
|
||||
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewlist tainacan-icon-1-25em"></i></span>',
|
||||
'type' => 'component',
|
||||
'implements_skeleton' => true,
|
||||
'requires_thumbnail' => false
|
||||
|
@ -366,6 +367,28 @@ class Theme_Helper {
|
|||
return $image;
|
||||
}
|
||||
|
||||
public function item_submission_shortcode($args) {
|
||||
global $TAINACAN_BASE_URL;
|
||||
|
||||
$props = ' ';
|
||||
|
||||
// Passes arguments to custom props
|
||||
if ($args) {
|
||||
foreach ($args as $key => $value) {
|
||||
if ($value == true || $value == 'true') {
|
||||
$props .= str_replace('_', '-', $key) . '="' . $value . '" ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wp_enqueue_media();
|
||||
wp_enqueue_script('jcrop');
|
||||
wp_enqueue_script('tainacan-item-submission', $TAINACAN_BASE_URL . '/assets/js/item_submission.js' , ['underscore', 'jcrop', 'media-editor', 'media-views', 'customize-controls'] , TAINACAN_VERSION);
|
||||
wp_localize_script('tainacan-item-submission', 'tainacan_plugin', \Tainacan\Admin::get_instance()->get_admin_js_localization_params());
|
||||
|
||||
return "<div id='tainacan-item-submission-form' $props ></div>";
|
||||
}
|
||||
|
||||
public function search_shortcode($args) {
|
||||
|
||||
$props = ' ';
|
||||
|
@ -487,7 +510,7 @@ class Theme_Helper {
|
|||
*
|
||||
* @type string $label Label, visible to users. Default to $slug
|
||||
* @type string $description Description, visible only to editors in the admin. Default none.
|
||||
* @type string $type Type. Accepted values are 'template' or 'component'. Defautl 'template'
|
||||
* @type string $type Type. Accepted values are 'template' or 'component'. Default 'template'
|
||||
* @type string $template Full path to the template file to be used. Required if $type is set to template.
|
||||
* Default: theme-path/tainacan/view-mode-{$slug}.php
|
||||
* @type string $component Component tag name. The web component js must be included and must accept two props:
|
||||
|
|
|
@ -8,77 +8,82 @@ Stable tag: 0.16.3
|
|||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Tainacan is an open-source, powerful and flexible repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform.
|
||||
|
||||
Tainacan is an open-source, powerful and flexible digital repository platform for WordPress. With all the tools of a professional repository platform, you can manage and publish your digital collections as easily as posting to your blog. It is versatile and can be used to create a digital collection, a digital library or a digital repository for your institutional or personal collection.
|
||||
|
||||
== Description ==
|
||||
|
||||
[Tainacan](https://tainacan.org/) is an open-source, powerful and flexible digital repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. It can be used for the creation of a digital collection, a digital library or a digital repository for your institutional or personal collection.
|
||||
|
||||
[Tainacan](https://tainacan.org/) is an open-source, powerful and flexible repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform.
|
||||
Tainacan aims to facilitate the activities of organizing, documenting, disseminating and displaying digital objects based on simple and accessible principles of digital curation. The plugin integrates with the Wordpress block engine, making it easy to reuse objects for different and varied uses.
|
||||
|
||||
|
||||
|
||||
= Features =
|
||||
|
||||
|
||||
* "Metadata and Filters": Use a metadata standard or choose whatever set of metadata you want to describe the items in your collections. Also, choose which metadata will be used as a filter when browsing collections.
|
||||
|
||||
|
||||
* "Faceted Search". Browse your collection (and let the public browse it) using a faceted search interface with the filters you have chosen.
|
||||
|
||||
|
||||
* "Manage Taxonomies": Manage vocabularies that can be used across all your collections.
|
||||
|
||||
|
||||
* "Themes": The Tainacan plugin has its own default theme, which helps you to showcase your collections in a beautiful and effective manner. But it can also work with any WordPress theme, so interface developers can easily add Tainacan specific features to an existing theme.
|
||||
|
||||
|
||||
* "API and Interoperability": Tainacan implements a RESTful API (read and write) to allow other applications to interact with your repository. That way, you can expose your collection in different formats, such as JSON, JsonLD, OAI-PMH and others. If your collection has a specific set of metadata, you can map this metadata to match the patterns you want to use.
|
||||
|
||||
|
||||
* "Gutenberg blocks": Tell stories with your collections. Tainacan offers you several Gutenberg blocks so you can present your collections to the public in many different ways!
|
||||
|
||||
|
||||
== Getting Started ==
|
||||
|
||||
|
||||
After installation, you will see a new menu item in your admin panel called "Tainacan". Click on it to open the Tainacan admin interface.
|
||||
|
||||
|
||||
To get an overview of the main concepts of Tainacan, please visit [this page](https://tainacan.github.io/tainacan-wiki/#/general-concepts).
|
||||
|
||||
|
||||
= Create a collection =
|
||||
|
||||
|
||||
Click "New Collection" to create a new collection, use a mapping standard or import it using one of our importers.
|
||||
|
||||
|
||||
= Configure your collection =
|
||||
|
||||
|
||||
Navigate to the top menu to set your collection up. Create the metadata that items in this collection will have, and choose, from these metadata, which ones are going to be used as a filter.
|
||||
|
||||
|
||||
= Add items =
|
||||
|
||||
|
||||
Back to the "Items" screen, click "Add new" to create a new item.
|
||||
|
||||
|
||||
= Manage and browse your collection =
|
||||
|
||||
|
||||
Through this admin interface you can manage your collection and browse its item using the faceted search interface or advanced search interface.
|
||||
|
||||
|
||||
If you want to visit your collections in the public side of your site, using your current theme, visit http://your-site/collections and you will get the list of your collections.
|
||||
|
||||
|
||||
= Set up Taxonomies =
|
||||
|
||||
|
||||
You can also have metadata as taxonomies, which you can configure with a set of hierarchical terms of your own vocabulary.
|
||||
|
||||
|
||||
= Add links to your menu =
|
||||
|
||||
|
||||
Edit your menu and links directly to your collections. Click "Screen options" at the top of the Menu edition page and enable "Collections".
|
||||
|
||||
|
||||
If you want to add a link to the list of collections, click "View all" tab on the Collections box on the left, and then add the first item named "Collections" to the menu.
|
||||
|
||||
|
||||
= Faceted search in your theme =
|
||||
|
||||
To have a fully-featured faceted search in your theme, you can either make it compatible with a few templates or use our Faceted Search Block.
|
||||
|
||||
|
||||
To have a fully-featured faceted search in your theme, you can either make it compatible with a few templates or use our Faceted Search Block.
|
||||
|
||||
== Installation ==
|
||||
|
||||
|
||||
Upload the files to the plugins directory and activate it. You can also install and activate directly from the admin panel.
|
||||
|
||||
|
||||
If you have Imagick installed in your server, Tainacan will be able to automatically generate a thumbnail from your PDF files. This is desired but not required.
|
||||
|
||||
|
||||
== Find out more ==
|
||||
|
||||
|
||||
* Visit our official website: [https://tainacan.org/](https://tainacan.org/)
|
||||
* Check our documentation Wiki: [https://wiki.tainacan.org/](https://wiki.tainacan.org/)
|
||||
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
|
||||
1. Manage your repository
|
||||
2. Set up your collection
|
||||
3. Choose the metadata and filters for your collection
|
||||
|
|
|
@ -458,6 +458,97 @@
|
|||
:message="$i18n.getHelperMessage('collections', 'allow_comments')"/>
|
||||
</b-field>
|
||||
|
||||
<!-- Allows Submissions ------------------------ -->
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.getHelperTitle('collections', 'allows_submission')"
|
||||
:type="editFormErrors['allows_submission'] != undefined ? 'is-danger' : ''"
|
||||
:message="editFormErrors['allows_submission'] != undefined ? editFormErrors['allows_submission'] : ''">
|
||||
|
||||
<b-switch
|
||||
id="tainacan-checkbox-allow-submission"
|
||||
size="is-small"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
v-model="form.allows_submission" />
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('collections', 'allows_submission')"
|
||||
:message="$i18n.getHelperMessage('collections', 'allows_submission')"/>
|
||||
</b-field>
|
||||
|
||||
<transition name="filter-item">
|
||||
<div
|
||||
v-if="form.allows_submission === 'yes'"
|
||||
class="item-submission-options">
|
||||
|
||||
<!-- Allows Submissions by anonynmous user ------------------------ -->
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.getHelperTitle('collections', 'submission_anonymous_user')"
|
||||
:type="editFormErrors['submission_anonymous_user'] != undefined ? 'is-danger' : ''"
|
||||
:message="editFormErrors['submission_anonymous_user'] != undefined ? editFormErrors['submission_anonymous_user'] : ''">
|
||||
|
||||
<b-switch
|
||||
id="tainacan-checkbox-allow-submission"
|
||||
size="is-small"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
v-model="form.submission_anonymous_user" />
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('collections', 'submission_anonymous_user')"
|
||||
:message="$i18n.getHelperMessage('collections', 'submission_anonymous_user')"/>
|
||||
</b-field>
|
||||
|
||||
<!-- Item submission default Status -------------------------------- -->
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.getHelperTitle('collections', 'submission_default_status')"
|
||||
:type="editFormErrors['submission_default_status'] != undefined ? 'is-danger' : ''"
|
||||
:message="editFormErrors['submission_default_status'] != undefined ? editFormErrors['submission_default_status'] : ''">
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('collections', 'submission_default_status')"
|
||||
:message="$i18n.getHelperMessage('collections', 'submission_default_status')"/>
|
||||
<div class="status-radios">
|
||||
<b-radio
|
||||
v-model="form.submission_default_status"
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses().filter((status) => status.slug != 'trash')"
|
||||
:key="index"
|
||||
:native-value="statusOption.slug">
|
||||
<span class="icon has-text-gray">
|
||||
<i
|
||||
class="tainacan-icon tainacan-icon-18px"
|
||||
:class="$statusHelper.getIcon(statusOption.slug)"/>
|
||||
</span>
|
||||
{{ statusOption.name }}
|
||||
</b-radio>
|
||||
</div>
|
||||
</b-field>
|
||||
|
||||
<!-- Submission process uses reCAPTCHA ------------------------ -->
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.getHelperTitle('collections', 'submission_use_recaptcha')"
|
||||
:type="editFormErrors['submission_use_recaptcha'] != undefined ? 'is-danger' : ''"
|
||||
:message="editFormErrors['submission_use_recaptcha'] != undefined ? editFormErrors['submission_use_recaptcha'] : ''">
|
||||
|
||||
<b-switch
|
||||
id="tainacan-checkbox-submission-use-recaptcha"
|
||||
size="is-small"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
v-model="form.submission_use_recaptcha" />
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('collections', 'submission_use_recaptcha')"
|
||||
:message="$i18n.getHelperMessage('collections', 'submission_use_recaptcha')"/>
|
||||
<p
|
||||
v-if="form.submission_use_recaptcha == 'yes'"
|
||||
v-html="$i18n.getWithVariables('info_recaptcha_link_%s', [ reCAPTCHASettingsPagePath ])" />
|
||||
</b-field>
|
||||
|
||||
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
v-if="formHooks != undefined &&
|
||||
|
@ -556,7 +647,11 @@ export default {
|
|||
enabled_view_modes: [],
|
||||
default_view_mode: [],
|
||||
allow_comments: '',
|
||||
hide_items_thumbnail_on_lists: ''
|
||||
allows_submission: 'no',
|
||||
submission_default_status: 'draft',
|
||||
submission_anonymous_user: 'no',
|
||||
hide_items_thumbnail_on_lists: '',
|
||||
submission_use_recaptcha: 'no'
|
||||
},
|
||||
thumbnail: {},
|
||||
cover: {},
|
||||
|
@ -581,6 +676,7 @@ export default {
|
|||
viewModesList: [],
|
||||
fromImporter: '',
|
||||
registeredViewModes: tainacan_plugin.registered_view_modes,
|
||||
reCAPTCHASettingsPagePath: tainacan_plugin.admin_url + 'admin.php?page=tainacan_item_submission',
|
||||
newPagePath: tainacan_plugin.admin_url + 'post-new.php?post_type=page',
|
||||
isUpdatingSlug: false,
|
||||
entityName: 'collection'
|
||||
|
@ -650,6 +746,10 @@ export default {
|
|||
this.form.default_view_mode = this.collection.default_view_mode;
|
||||
this.form.enabled_view_modes = JSON.parse(JSON.stringify(this.collection.enabled_view_modes.reduce((result, viewMode) => { typeof viewMode == 'string' ? result.push(viewMode) : null; return result }, [])));
|
||||
this.form.allow_comments = this.collection.allow_comments;
|
||||
this.form.allows_submission = this.collection.allows_submission;
|
||||
this.form.submission_anonymous_user = this.collection.submission_anonymous_user;
|
||||
this.form.submission_default_status = this.collection.submission_default_status;
|
||||
this.form.submission_use_recaptcha = this.collection.submission_use_recaptcha;
|
||||
this.form.hide_items_thumbnail_on_lists = this.collection.hide_items_thumbnail_on_lists;
|
||||
|
||||
// Generates CoverPage from current cover_page_id info
|
||||
|
@ -747,6 +847,10 @@ export default {
|
|||
parent: this.form.parent,
|
||||
enabled_view_modes: this.form.enabled_view_modes,
|
||||
default_view_mode: this.form.default_view_mode,
|
||||
allows_submission: this.form.allows_submission,
|
||||
submission_anonymous_user: this.form.submission_anonymous_user,
|
||||
submission_default_status: this.form.submission_default_status,
|
||||
submission_use_recaptcha: this.form.submission_use_recaptcha,
|
||||
allow_comments: this.form.allow_comments,
|
||||
hide_items_thumbnail_on_lists: this.form.hide_items_thumbnail_on_lists
|
||||
};
|
||||
|
@ -770,6 +874,10 @@ export default {
|
|||
this.form.enabled_view_modes = this.collection.enabled_view_modes.map((viewMode) => viewMode.viewMode);
|
||||
this.form.default_view_mode = this.collection.default_view_mode;
|
||||
this.form.allow_comments = this.collection.allow_comments;
|
||||
this.form.allows_submission = this.collection.allows_submission;
|
||||
this.form.submission_anonymous_user = this.collection.submission_anonymous_user;
|
||||
this.form.submission_default_status = this.collection.submission_default_status;
|
||||
this.form.submission_use_recaptcha = this.collection.submission_use_recaptcha;
|
||||
this.form.hide_items_thumbnail_on_lists = this.collection.hide_items_thumbnail_on_lists;
|
||||
|
||||
this.isLoading = false;
|
||||
|
@ -824,6 +932,10 @@ export default {
|
|||
this.form.default_view_mode = this.collection.default_view_mode;
|
||||
this.form.enabled_view_modes = [];
|
||||
this.form.allow_comments = this.collection.allow_comments;
|
||||
this.form.allows_submission = this.collection.allows_submission;
|
||||
this.form.submission_anonymous_user = this.collection.submission_anonymous_user;
|
||||
this.form.submission_default_status = this.collection.submission_default_status;
|
||||
this.form.submission_use_recaptcha = this.collection.submission_use_recaptcha;
|
||||
this.form.hide_items_thumbnail_on_lists = this.collection.hide_items_thumbnail_on_lists;
|
||||
|
||||
// Pre-fill status with publish to incentivate it
|
||||
|
@ -1129,6 +1241,12 @@ export default {
|
|||
align-items: center;
|
||||
}
|
||||
}
|
||||
.item-submission-options {
|
||||
padding-left: 1em;
|
||||
padding-top: 1.25em;
|
||||
margin-top: -1.5em;
|
||||
border-left: 1px solid var(--tainacan-gray2);
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ export default {
|
|||
this.uploadedItems.push( item );
|
||||
|
||||
// Uploads Media Document
|
||||
this.sendFile(file)
|
||||
this.sendFile({ itemId: item.id, file:file })
|
||||
.then((uploadedFile) => {
|
||||
|
||||
// Updates Item with Document
|
||||
|
|
|
@ -351,6 +351,20 @@
|
|||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="form.thumbnail_id"
|
||||
class="thumbnail-alt-input">
|
||||
<label class="label">{{ $i18n.get('label_thumbnail_alt') }}</label>
|
||||
<help-button
|
||||
:title="$i18n.get('label_thumbnail_alt')"
|
||||
:message="$i18n.get('info_thumbnail_alt')"/>
|
||||
<b-input
|
||||
type="textarea"
|
||||
lazy
|
||||
:placeholder="$i18n.get('instruction_thumbnail_alt')"
|
||||
:value="form.thumbnail_alt ? form.thumbnail_alt : ''"
|
||||
@input="onUpdateThumbnailAlt" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
|
@ -485,6 +499,7 @@
|
|||
:key="index"
|
||||
:item-metadatum="itemMetadatum"
|
||||
:is-collapsed="metadataCollapses[index]"
|
||||
:is-last-metadatum="index > 2 && (index == metadatumList.length - 1)"
|
||||
@changeCollapse="onChangeCollapse($event, index)"/>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
|
@ -516,25 +531,20 @@
|
|||
</template>
|
||||
|
||||
<div v-if="item != undefined && item.id != undefined">
|
||||
<br>
|
||||
<button
|
||||
style="margin-left: calc(var(--tainacan-one-column) + 12px)"
|
||||
type="button"
|
||||
class="button is-secondary"
|
||||
@click.prevent="attachmentMediaFrame.openFrame($event)"
|
||||
:disabled="isLoadingAttachments">
|
||||
{{ $i18n.get("label_edit_attachments") }}
|
||||
</button>
|
||||
<!--
|
||||
<button
|
||||
style="margin-left: calc(var(--tainacan-one-column) + 12px)"
|
||||
type="button"
|
||||
class="button is-secondary"
|
||||
@click.prevent="openNewAttachmentsMediaFrame"
|
||||
:disabled="isLoadingAttachments">
|
||||
{{ $i18n.get("label_edit_attachments") + ' 2' }}
|
||||
</button>
|
||||
-->
|
||||
<div class="attachments-list-heading">
|
||||
<button
|
||||
style="margin-left: calc(var(--tainacan-one-column) + 12px)"
|
||||
type="button"
|
||||
class="button is-secondary"
|
||||
@click.prevent="attachmentMediaFrame.openFrame($event)"
|
||||
:disabled="isLoadingAttachments">
|
||||
{{ $i18n.get("label_edit_attachments") }}
|
||||
</button>
|
||||
<p>
|
||||
{{ $i18n.get("info_edit_attachments") }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<attachments-list
|
||||
v-if="item != undefined && item.id != undefined"
|
||||
:item="item"
|
||||
|
@ -819,7 +829,9 @@ export default {
|
|||
status: '',
|
||||
document: '',
|
||||
document_type: '',
|
||||
comment_status: ''
|
||||
comment_status: '',
|
||||
thumbnail_id: '',
|
||||
thumbnail_alt: ''
|
||||
},
|
||||
thumbnail: {},
|
||||
formErrorMessage: '',
|
||||
|
@ -987,6 +999,7 @@ export default {
|
|||
'sendItem',
|
||||
'updateItem',
|
||||
'updateItemDocument',
|
||||
'updateThumbnailAlt',
|
||||
'fetchItemMetadata',
|
||||
'fetchItem',
|
||||
'cleanItemMetadata',
|
||||
|
@ -1053,6 +1066,8 @@ export default {
|
|||
this.form.document = this.item.document;
|
||||
this.form.document_type = this.item.document_type;
|
||||
this.form.comment_status = this.item.comment_status;
|
||||
this.form.thumbnail_id = this.item.thumbnail_id;
|
||||
this.form.thumbnail_alt = this.item.thumbnail_alt;
|
||||
|
||||
this.isLoading = false;
|
||||
|
||||
|
@ -1151,6 +1166,8 @@ export default {
|
|||
this.form.document = this.item.document;
|
||||
this.form.document_type = this.item.document_type;
|
||||
this.form.comment_status = this.item.comment_status;
|
||||
this.form.thumbnail_id = this.item.thumbnail_id;
|
||||
this.form.thumbnail_alt = this.item.thumbnail_alt;
|
||||
|
||||
// If a parameter was passed with a suggestion of item title, also send a patch to item metadata
|
||||
if (this.$route.query.newitemtitle) {
|
||||
|
@ -1296,9 +1313,10 @@ export default {
|
|||
});
|
||||
},
|
||||
deleteThumbnail() {
|
||||
this.updateThumbnail({itemId: this.itemId, thumbnailId: 0})
|
||||
this.updateThumbnail({ itemId: this.itemId, thumbnailId: 0 })
|
||||
.then(() => {
|
||||
this.item.thumbnail = false;
|
||||
this.item.thumbnail_id = null;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
|
@ -1371,25 +1389,31 @@ export default {
|
|||
button_labels: {
|
||||
frame_title: this.$i18n.get('instruction_select_item_thumbnail'),
|
||||
},
|
||||
thumbnail: this.form.thumbnail_id,
|
||||
relatedPostId: this.itemId,
|
||||
onSave: (media) => {
|
||||
this.updateThumbnail({itemId: this.itemId, thumbnailId: media.id})
|
||||
.then((res) => {
|
||||
this.item.thumbnail = res.thumbnail;
|
||||
})
|
||||
.catch(error => this.$console.error(error));
|
||||
this.updateThumbnail({ itemId: this.itemId, thumbnailId: media.id})
|
||||
.then((res) => {
|
||||
this.item.thumbnail = res.thumbnail;
|
||||
this.item.thumbnail_id = res.thumbnail_id;
|
||||
this.item.thumbnail_alt = res.thumbnail_alt;
|
||||
this.form.thumbnail = res.thumbnail;
|
||||
this.form.thumbnail_id = res.thumbnail_id;
|
||||
this.form.thumbnail_alt = res.thumbnail_alt;
|
||||
})
|
||||
.catch(error => this.$console.error(error));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
this.attachmentMediaFrame = new wpMediaFrames.attachmentControl(
|
||||
'my-attachment-media-frame', {
|
||||
button_labels: {
|
||||
frame_title: this.$i18n.get('instruction_select_files_to_attach_to_item'),
|
||||
frame_button: this.$i18n.get('label_attach_to_item'),
|
||||
},
|
||||
nonce: this.item.nonces ? this.item.nonces['update-post_' + this.item.id] : null,
|
||||
relatedPostId: this.itemId,
|
||||
document: this.item.document,
|
||||
document: this.item.document_type == 'attachment' ? this.item.document : null,
|
||||
onSave: () => {
|
||||
// Fetch current existing attachments
|
||||
this.isLoadingAttachments = true;
|
||||
|
@ -1401,27 +1425,17 @@ export default {
|
|||
);
|
||||
|
||||
},
|
||||
// openNewAttachmentsMediaFrame() {
|
||||
// const newAttachmentMediaFrame = new wpMediaFrames.customAttachmentsControl({
|
||||
// existingAttachments: this.getAttachments().map((attachment) => attachment.id),
|
||||
// button_labels: {
|
||||
// frame_title: this.$i18n.get('instruction_select_files_to_attach_to_item'),
|
||||
// frame_button_new: this.$i18n.get('label_attach_to_item'),
|
||||
// frame_button_update: this.$i18n.get('finish')
|
||||
// },
|
||||
// relatedPostId: this.itemId,
|
||||
// onSelect: (selected) => {
|
||||
// console.log(selected);
|
||||
// // Fetch current existing attachments
|
||||
// this.isLoadingAttachments = true;
|
||||
// this.fetchAttachments({ page: 1, attachmentsPerPage: 24, itemId: this.itemId, documentId: this.item.document })
|
||||
// .then(() => this.isLoadingAttachments = false)
|
||||
// .catch(() => this.isLoadingAttachments = false);
|
||||
|
||||
// }
|
||||
// });
|
||||
// setTimeout(() => newAttachmentMediaFrame.openModal(), 1000);
|
||||
// },
|
||||
onUpdateThumbnailAlt(updatedThumbnailAlt) {
|
||||
|
||||
this.updateThumbnailAlt({ thumbnailId: this.item.thumbnail_id, thumbnailAlt: updatedThumbnailAlt })
|
||||
.then((res) => {
|
||||
this.item.thumbnail_id = res.thumbnail_id;
|
||||
this.item.thumbnail_alt = res.thumbnail_alt;
|
||||
this.form.thumbnail_id = res.thumbnail_id;
|
||||
this.form.thumbnail_alt = res.thumbnail_alt;
|
||||
})
|
||||
.catch(error => this.$console.error(error));
|
||||
},
|
||||
toggleCollapseAll() {
|
||||
this.collapseAll = !this.collapseAll;
|
||||
|
||||
|
@ -1494,6 +1508,8 @@ export default {
|
|||
this.form.document = this.item.document;
|
||||
this.form.document_type = this.item.document_type;
|
||||
this.form.comment_status = this.item.comment_status;
|
||||
this.form.thumbnail_id = this.item.thumbnail_id;
|
||||
this.form.thumbnail_alt = this.item.thumbnail_alt;
|
||||
|
||||
if (this.form.document_type != undefined && this.form.document_type == 'url')
|
||||
this.urlLink = this.form.document;
|
||||
|
@ -1571,7 +1587,7 @@ export default {
|
|||
}
|
||||
.status-tag {
|
||||
color: var(--tainacan-white);
|
||||
background: var(--tainacan-turquoise5);
|
||||
background: var(--tainacan-secondary);
|
||||
padding: 0.15em 0.5em;
|
||||
font-size: 0.75em;
|
||||
margin: 0 1em 0 0;
|
||||
|
@ -1637,7 +1653,7 @@ export default {
|
|||
label {
|
||||
font-size: 1em !important;
|
||||
font-weight: 500 !important;
|
||||
color: var(--tainacan-gray5) !important;
|
||||
color: var(--tainacan-label-color) !important;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
}
|
||||
|
@ -1669,7 +1685,7 @@ export default {
|
|||
color: var(--tainacan-secondary);
|
||||
margin-bottom: 6px;
|
||||
&:hover {
|
||||
background-color: var(--tainacan-turquoise2);
|
||||
background-color: var(--tainacan-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
@ -1757,6 +1773,27 @@ export default {
|
|||
left: 90px;
|
||||
bottom: 1.0em;
|
||||
}
|
||||
|
||||
.thumbnail-alt-input {
|
||||
.label {
|
||||
font-size: 0.875em;
|
||||
font-weight: 500;
|
||||
margin-left: 15px;
|
||||
margin-bottom: 0;
|
||||
margin-top: 0.15em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.attachments-list-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 24px;
|
||||
margin-bottom: 24px;
|
||||
|
||||
button {
|
||||
margin-right: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
|
@ -1808,7 +1845,7 @@ export default {
|
|||
|
||||
.sequence-progress {
|
||||
height: 5px;
|
||||
background: var(--tainacan-turquoise5);
|
||||
background: var(--tainacan-secondary);
|
||||
width: 0%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
@ -1826,7 +1863,7 @@ export default {
|
|||
|
||||
.sequence-button {
|
||||
background-color: transparent;
|
||||
color: var(--tainacan-turquoise5);
|
||||
color: var(--tainacan-secondary);
|
||||
border: none;
|
||||
|
||||
.icon {
|
||||
|
@ -1837,7 +1874,7 @@ export default {
|
|||
&:focus,
|
||||
&:active {
|
||||
background-color: transparent !important;
|
||||
color: var(--tainacan-turquoise5) !important;
|
||||
color: var(--tainacan-secondary) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -575,6 +575,7 @@
|
|||
z-index: 99;
|
||||
text-align: center;
|
||||
color: var(--tainacan-info-color);
|
||||
background-color: transparent;
|
||||
}
|
||||
#button-delete-header,
|
||||
#button-edit-header {
|
||||
|
|
|
@ -154,7 +154,7 @@
|
|||
|
||||
let route = '';
|
||||
|
||||
if (this.isRepositoryLevel)
|
||||
if (this.isRepositoryLevel || this.filter.collection_id == 'default')
|
||||
route = `/facets/${this.metadatumId}?getSelected=1&order=asc&parent=0&number=${this.filter.max_options}&` + qs.stringify(query_items);
|
||||
else {
|
||||
if ((this.collectionId == 'default' || this.filter.inherited) && this.currentCollectionId)
|
||||
|
|
|
@ -114,10 +114,10 @@
|
|||
|
||||
let endpoint = '';
|
||||
|
||||
if (this.isRepositoryLevel)
|
||||
if (this.isRepositoryLevel || this.filter.collection_id == 'default')
|
||||
endpoint += '/facets/' + this.metadatumId;
|
||||
else {
|
||||
if (this.collectionId == 'default' && this.currentCollection)
|
||||
if (this.collectionId == 'default' && this.currentCollectionId)
|
||||
endpoint += '/collection/' + this.currentCollectionId +'/facets/' + this.metadatumId;
|
||||
else
|
||||
endpoint += '/collection/' + this.collectionId +'/facets/' + this.metadatumId;
|
||||
|
|
|
@ -189,7 +189,6 @@
|
|||
|
||||
.uploaded-files {
|
||||
display: block;
|
||||
text-align: center;
|
||||
|
||||
.file-item-container {
|
||||
display: inline-block;
|
||||
|
|
|
@ -177,19 +177,19 @@
|
|||
@click.left="onClickCollection($event, collection.id, index)"
|
||||
@click.right="onRightClickCollection($event, collection.id, index)"
|
||||
:label="$i18n.get('label_description')"
|
||||
:aria-label="$i18n.get('label_description') + ': ' + (collection.description != undefined && collection.description != '') ? collection.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_informed') + `</span>`">
|
||||
:aria-label="$i18n.get('label_description') + ': ' + (collection.description != undefined && collection.description != '') ? collection.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_provided') + `</span>`">
|
||||
<p
|
||||
v-tooltip="{
|
||||
delay: {
|
||||
show: 500,
|
||||
hide: 300,
|
||||
},
|
||||
content: (collection.description != undefined && collection.description != '') ? collection.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_informed') + `</span>`,
|
||||
content: (collection.description != undefined && collection.description != '') ? collection.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_provided') + `</span>`,
|
||||
autoHide: false,
|
||||
classes: ['tooltip', 'repository-tooltip'],
|
||||
placement: 'auto-start'
|
||||
}"
|
||||
v-html="(collection.description != undefined && collection.description != '') ? collection.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_informed') + `</span>`"/>
|
||||
v-html="(collection.description != undefined && collection.description != '') ? collection.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_provided') + `</span>`"/>
|
||||
</td>
|
||||
<!-- Creation Date -->
|
||||
<td
|
||||
|
|
|
@ -16,14 +16,13 @@
|
|||
|
||||
<span
|
||||
style="margin-left: 10px"
|
||||
v-if="allItemsOnPageSelected && items.length > 1">
|
||||
v-if="totalPages > 1 && allItemsOnPageSelected && items.length > 1">
|
||||
<b-checkbox
|
||||
v-model="isAllItemsSelected">
|
||||
{{ $i18n.getWithVariables('label_select_all_%s_items', [totalItems]) }}
|
||||
</b-checkbox>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<b-dropdown
|
||||
:mobile-modal="true"
|
||||
|
@ -36,7 +35,7 @@
|
|||
<button
|
||||
class="button is-white"
|
||||
slot="trigger">
|
||||
<span>{{ $i18n.get('label_bulk_actions') }}</span>
|
||||
<span>{{ $i18n.get('label_actions_for_the_selection') }}</span>
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-arrowdown"/>
|
||||
</span>
|
||||
|
@ -63,10 +62,16 @@
|
|||
</b-dropdown-item>
|
||||
<b-dropdown-item
|
||||
v-if="collectionId && isOnTrash"
|
||||
@click="untrashSelectedItems()"
|
||||
@click="untrashSelectedItems();"
|
||||
aria-role="listitem">
|
||||
{{ $i18n.get('label_untrash_selected_items') }}
|
||||
</b-dropdown-item>
|
||||
<b-dropdown-item
|
||||
:disabled="isAllItemsSelected"
|
||||
@click="$parent.openExposersModal(selectedItems)"
|
||||
aria-role="listitem">
|
||||
{{ $i18n.get('label_view_selected_items_as') }}
|
||||
</b-dropdown-item>
|
||||
</b-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -173,7 +178,7 @@
|
|||
class="grid-item-thumbnail"
|
||||
:style="{ backgroundImage: 'url(' + (item['thumbnail']['tainacan-medium'] ? item['thumbnail']['tainacan-medium'][0] : (item['thumbnail'].medium ? item['thumbnail'].medium[0] : thumbPlaceholderPath)) + ')' }">
|
||||
<img
|
||||
:alt="$i18n.get('label_thumbnail')"
|
||||
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
|
||||
:src="item['thumbnail']['tainacan-medium'] ? item['thumbnail']['tainacan-medium'][0] : (item['thumbnail'].medium ? item['thumbnail'].medium[0] : thumbPlaceholderPath)">
|
||||
</a>
|
||||
|
||||
|
@ -286,7 +291,7 @@
|
|||
class="tainacan-masonry-item-thumbnail"
|
||||
:style="{ backgroundImage: 'url(' + (item['thumbnail']['tainacan-medium-full'] ? item['thumbnail']['tainacan-medium-full'][0] : (item['thumbnail'].medium_large ? item['thumbnail'].medium_large[0] : thumbPlaceholderPath)) + ')' }">
|
||||
<img
|
||||
:alt="$i18n.get('label_thumbnail')"
|
||||
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
|
||||
:src="item['thumbnail']['tainacan-medium-full'] ? item['thumbnail']['tainacan-medium-full'][0] : (item['thumbnail'].medium_large ? item['thumbnail'].medium_large[0] : thumbPlaceholderPath)">
|
||||
</div>
|
||||
|
||||
|
@ -454,7 +459,7 @@
|
|||
:style="{ backgroundImage: 'url(' + (item['thumbnail']['tainacan-medium'] ? item['thumbnail']['tainacan-medium'][0] : (item['thumbnail'].medium ? item['thumbnail'].medium[0] : thumbPlaceholderPath)) + ')' }"
|
||||
class="card-thumbnail">
|
||||
<img
|
||||
:alt="$i18n.get('label_thumbnail')"
|
||||
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
|
||||
v-if="item.thumbnail != undefined"
|
||||
:src="item['thumbnail']['tainacan-medium'] ? item['thumbnail']['tainacan-medium'][0] : (item['thumbnail'].medium ? item['thumbnail'].medium[0] : thumbPlaceholderPath)">
|
||||
</div>
|
||||
|
@ -467,13 +472,13 @@
|
|||
show: 500,
|
||||
hide: 300,
|
||||
},
|
||||
content: item.description != undefined && item.description != '' ? item.description : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_description_not_informed') + `</span>`,
|
||||
content: item.description != undefined && item.description != '' ? item.description : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_description_not_provided') + `</span>`,
|
||||
html: true,
|
||||
autoHide: false,
|
||||
placement: 'auto-start'
|
||||
}"
|
||||
class="metadata-description"
|
||||
v-html="item.description != undefined && item.description != '' ? getLimitedDescription(item.description) : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_description_not_informed') + `</span>`" />
|
||||
v-html="item.description != undefined && item.description != '' ? getLimitedDescription(item.description) : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_description_not_provided') + `</span>`" />
|
||||
<!-- Author-->
|
||||
<p
|
||||
v-tooltip="{
|
||||
|
@ -645,7 +650,7 @@
|
|||
<div class="list-metadata media-body">
|
||||
<div class="tainacan-record-thumbnail">
|
||||
<img
|
||||
:alt="$i18n.get('label_thumbnail')"
|
||||
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
|
||||
v-if="item.thumbnail != undefined"
|
||||
:src="item['thumbnail']['tainacan-medium-full'] ? item['thumbnail']['tainacan-medium-full'][0] : (item['thumbnail'].medium_large ? item['thumbnail'].medium_large[0] : thumbPlaceholderPath)">
|
||||
</div>
|
||||
|
@ -771,7 +776,7 @@
|
|||
show: 500,
|
||||
hide: 300,
|
||||
},
|
||||
content: item.title != undefined && item.title != '' ? item.title : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`,
|
||||
content: item.title != undefined && item.title != '' ? item.title : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_provided') + `</span>`,
|
||||
html: true,
|
||||
autoHide: false,
|
||||
placement: 'auto-start'
|
||||
|
@ -779,14 +784,14 @@
|
|||
v-if="collectionId == undefined &&
|
||||
column.metadata_type_object != undefined &&
|
||||
column.metadata_type_object.related_mapped_prop == 'title'"
|
||||
v-html="`<span class='sr-only'>` + column.name + ': </span>' + ((item.title != undefined && item.title != '') ? item.title : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`)"/>
|
||||
v-html="`<span class='sr-only'>` + column.name + ': </span>' + ((item.title != undefined && item.title != '') ? item.title : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_provided') + `</span>`)"/>
|
||||
<p
|
||||
v-tooltip="{
|
||||
delay: {
|
||||
show: 500,
|
||||
hide: 300,
|
||||
},
|
||||
content: item.description != undefined && item.description != '' ? item.description : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`,
|
||||
content: item.description != undefined && item.description != '' ? item.description : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_provided') + `</span>`,
|
||||
html: true,
|
||||
autoHide: false,
|
||||
placement: 'auto-start'
|
||||
|
@ -794,7 +799,7 @@
|
|||
v-if="collectionId == undefined &&
|
||||
column.metadata_type_object != undefined &&
|
||||
column.metadata_type_object.related_mapped_prop == 'description'"
|
||||
v-html="`<span class='sr-only'>` + column.name + ': </span>' + ((item.description != undefined && item.description) != '' ? item.description : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`)"/>
|
||||
v-html="`<span class='sr-only'>` + column.name + ': </span>' + ((item.description != undefined && item.description) != '' ? item.description : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_provided') + `</span>`)"/>
|
||||
<p
|
||||
v-tooltip="{
|
||||
delay: {
|
||||
|
@ -802,7 +807,7 @@
|
|||
hide: 300,
|
||||
},
|
||||
classes: [ column.metadata_type_object != undefined && column.metadata_type_object.component == 'tainacan-textarea' ? 'metadata-type-textarea' : '' ],
|
||||
content: renderMetadata(item.metadata, column) != '' ? renderMetadata(item.metadata, column) : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`,
|
||||
content: renderMetadata(item.metadata, column) != '' ? renderMetadata(item.metadata, column) : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_provided') + `</span>`,
|
||||
html: true,
|
||||
autoHide: false,
|
||||
placement: 'auto-start'
|
||||
|
@ -814,11 +819,11 @@
|
|||
column.metadatum !== 'row_author' &&
|
||||
column.metadatum !== 'row_title' &&
|
||||
column.metadatum !== 'row_description'"
|
||||
v-html="renderMetadata(item.metadata, column) != '' ? renderMetadata(item.metadata, column) : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`"/>
|
||||
v-html="renderMetadata(item.metadata, column) != '' ? renderMetadata(item.metadata, column) : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_provided') + `</span>`"/>
|
||||
|
||||
<span v-if="column.metadatum == 'row_thumbnail'">
|
||||
<img
|
||||
:alt="$i18n.get('label_thumbnail')"
|
||||
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
|
||||
class="table-thumb"
|
||||
:src="item['thumbnail']['tainacan-small'] ? item['thumbnail']['tainacan-small'][0] : (item['thumbnail'].thumbnail ? item['thumbnail'].thumbnail[0] : thumbPlaceholderPath)">
|
||||
</span>
|
||||
|
@ -958,7 +963,7 @@
|
|||
v-for="(column, metadatumIndex) in displayedMetadata"
|
||||
:key="metadatumIndex"
|
||||
v-if="column.display && column.metadata_type_object != undefined && (column.metadata_type_object.related_mapped_prop == 'title')"
|
||||
v-html="item.metadata != undefined && collectionId ? renderMetadata(item.metadata, column) : (item.title ? item.title :`<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`)" />
|
||||
v-html="item.metadata != undefined && collectionId ? renderMetadata(item.metadata, column) : (item.title ? item.title :`<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_provided') + `</span>`)" />
|
||||
</div>
|
||||
|
||||
<!-- Actions -->
|
||||
|
@ -1023,7 +1028,7 @@
|
|||
class="tainacan-list-thumbnail"
|
||||
v-if="item.thumbnail != undefined">
|
||||
<img
|
||||
:alt="$i18n.get('label_thumbnail')"
|
||||
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
|
||||
:src="item['thumbnail']['tainacan-medium-full'] ? item['thumbnail']['tainacan-medium-full'][0] : (item['thumbnail'].medium_large ? item['thumbnail'].medium_large[0] : thumbPlaceholderPath)">
|
||||
</div>
|
||||
<div class="list-metadata media-body">
|
||||
|
@ -1072,7 +1077,7 @@ export default {
|
|||
thumbPlaceholderPath: tainacan_plugin.base_url + '/assets/images/placeholder_square.png',
|
||||
cursorPosX: -1,
|
||||
cursorPosY: -1,
|
||||
contextMenuItem: null
|
||||
contextMenuItem: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -1082,15 +1087,15 @@ export default {
|
|||
highlightedItem () {
|
||||
return this.getHighlightedItem();
|
||||
},
|
||||
selectedItemsFromStore() {
|
||||
return this.getSelectedItems();
|
||||
},
|
||||
selectedItems () {
|
||||
if (this.$route.query.iframemode)
|
||||
this.$eventBusSearch.setSelectedItemsForIframe(this.getSelectedItems());
|
||||
|
||||
return this.getSelectedItems();
|
||||
},
|
||||
firstSelectedIndex() {
|
||||
return (this.selectedItems && this.selectedItems.length) ? this.items.findIndex((anItem) => this.selectedItems[0] == anItem.id) : null;
|
||||
},
|
||||
isSelectingItems () {
|
||||
return this.selectedItems.length > 0;
|
||||
},
|
||||
|
@ -1100,7 +1105,13 @@ export default {
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
itemsPerPage(){
|
||||
return this.getItemsPerPage();
|
||||
},
|
||||
totalPages(){
|
||||
return Math.ceil(Number(this.totalItems)/Number(this.itemsPerPage));
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
isAllItemsSelected(value) {
|
||||
|
@ -1152,13 +1163,15 @@ export default {
|
|||
'getOrder',
|
||||
'getOrderBy',
|
||||
'getSelectedItems',
|
||||
'getHighlightedItem'
|
||||
'getHighlightedItem',
|
||||
'getItemsPerPage'
|
||||
]),
|
||||
setSelectedItemChecked(itemId) {
|
||||
if (this.selectedItems.find((item) => item == itemId) != undefined)
|
||||
this.removeSelectedItem(itemId);
|
||||
else
|
||||
else {
|
||||
this.addSelectedItem(itemId);
|
||||
}
|
||||
},
|
||||
getSelectedItemChecked(itemId) {
|
||||
return this.selectedItems.find(item => item == itemId) != undefined;
|
||||
|
@ -1295,6 +1308,7 @@ export default {
|
|||
groupId: groupId
|
||||
}).then(() => {
|
||||
this.$eventBusSearch.loadItems();
|
||||
this.$root.$emit('openProcessesPopup');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1326,6 +1340,7 @@ export default {
|
|||
groupId: groupId
|
||||
}).then(() => {
|
||||
this.$eventBusSearch.loadItems();
|
||||
this.$root.$emit('openProcessesPopup');
|
||||
});
|
||||
} else {
|
||||
this.trashItemsInBulk({
|
||||
|
@ -1333,6 +1348,7 @@ export default {
|
|||
groupId: groupId
|
||||
}).then(() => {
|
||||
this.$eventBusSearch.loadItems();
|
||||
this.$root.$emit('openProcessesPopup');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1361,8 +1377,26 @@ export default {
|
|||
this.clearContextMenu();
|
||||
},
|
||||
onClickItem($event, item) {
|
||||
if ($event.ctrlKey || $event.shiftKey) {
|
||||
if ($event.ctrlKey) {
|
||||
this.setSelectedItemChecked(item.id);
|
||||
} else if ($event.shiftKey) {
|
||||
|
||||
if (this.firstSelectedIndex != null) {
|
||||
const lastFirstSelectedIndex = this.firstSelectedIndex;
|
||||
const lastSelectedIndex = this.items.findIndex((anItem) => anItem.id == item.id);
|
||||
|
||||
this.cleanSelectedItems();
|
||||
if (lastFirstSelectedIndex > lastSelectedIndex) {
|
||||
for (let i = lastFirstSelectedIndex; i >= lastSelectedIndex; i--)
|
||||
this.setSelectedItemChecked(this.items[i].id);
|
||||
} else {
|
||||
for (let i = lastFirstSelectedIndex; i <= lastSelectedIndex; i++)
|
||||
this.setSelectedItemChecked(this.items[i].id);
|
||||
}
|
||||
} else {
|
||||
this.setSelectedItemChecked(item.id);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (this.$route.query.iframemode && !this.$route.query.readmode) {
|
||||
this.setSelectedItemChecked(item.id)
|
||||
|
|
|
@ -109,18 +109,18 @@
|
|||
class="column-large-width"
|
||||
@click="onClickTaxonomy($event, taxonomy.id, index)"
|
||||
:label="$i18n.get('label_description')"
|
||||
:aria-label="$i18n.get('label_description') + ': ' + taxonomy.description != undefined && taxonomy.description != '' ? taxonomy.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_informed') + `</span>`">
|
||||
:aria-label="$i18n.get('label_description') + ': ' + taxonomy.description != undefined && taxonomy.description != '' ? taxonomy.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_provided') + `</span>`">
|
||||
<p
|
||||
v-tooltip="{
|
||||
delay: {
|
||||
show: 500,
|
||||
hide: 300,
|
||||
},
|
||||
content: taxonomy.description != undefined && taxonomy.description != '' ? taxonomy.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_informed') + `</span>`,
|
||||
content: taxonomy.description != undefined && taxonomy.description != '' ? taxonomy.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_provided') + `</span>`,
|
||||
autoHide: false,
|
||||
placement: 'auto-start'
|
||||
}"
|
||||
v-html="(taxonomy.description != undefined && taxonomy.description != '') ? taxonomy.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_informed') + `</span>`" />
|
||||
v-html="(taxonomy.description != undefined && taxonomy.description != '') ? taxonomy.description : `<span class='has-text-gray is-italic'>` + $i18n.get('label_description_not_provided') + `</span>`" />
|
||||
</td>
|
||||
<!-- Collections using -->
|
||||
<td
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
</p>
|
||||
<a
|
||||
v-if="isMultiple"
|
||||
:disabled="childItemMetadataGroups.length > 0 && !someValueOnLastInput"
|
||||
:disabled="itemMetadatum.item.id && (childItemMetadataGroups.length > 0 && !someValueOnLastInput)"
|
||||
@click="addGroup"
|
||||
class="is-block add-link">
|
||||
<span class="icon is-small">
|
||||
|
@ -137,10 +137,10 @@
|
|||
}
|
||||
},
|
||||
created() {
|
||||
eventBusItemMetadata.$on('hasRemovedItemMetadataGroup', () => this.isRemovingGroup = false);
|
||||
eventBusItemMetadata.$on('hasRemovedItemMetadataGroup', () => this.$nextTick(() => this.isRemovingGroup = false));
|
||||
},
|
||||
beforeDestroy() {
|
||||
eventBusItemMetadata.$off('hasRemovedItemMetadataGroup', () => this.isRemovingGroup = false);
|
||||
eventBusItemMetadata.$off('hasRemovedItemMetadataGroup', () => this.$nextTick(() => this.isRemovingGroup = false));
|
||||
},
|
||||
methods: {
|
||||
createChildMetadataGroups() {
|
||||
|
@ -153,7 +153,6 @@
|
|||
this.itemMetadatum.metadatum.metadata_type_options &&
|
||||
this.itemMetadatum.metadatum.metadata_type_options.children_objects.length > 0
|
||||
) {
|
||||
|
||||
// Here we load the values from the object, but must also create some
|
||||
if (parentValues && parentValues.length) {
|
||||
|
||||
|
@ -162,9 +161,9 @@
|
|||
let existingChildItemMetadata = [];
|
||||
|
||||
if (childItemMetadata && childItemMetadata.length) {
|
||||
|
||||
|
||||
for (let childMetadatum of this.itemMetadatum.metadatum.metadata_type_options.children_objects) {
|
||||
|
||||
|
||||
const childItemMetadatumIndex = childItemMetadata.findIndex((aChildItemMetadatum) => childMetadatum.id == aChildItemMetadatum.metadatum_id);
|
||||
// Loads the existing values
|
||||
if (childItemMetadatumIndex >= 0) {
|
||||
|
@ -172,7 +171,7 @@
|
|||
existingChildItemMetadata.push({
|
||||
item: this.itemMetadatum.item,
|
||||
metadatum: childMetadatum,
|
||||
parent_meta_id: childItemMetadatum.parent_meta_id,
|
||||
parent_meta_id: (this.itemMetadatum.item && this.itemMetadatum.item.id) ?childItemMetadatum.parent_meta_id : groupIndex,
|
||||
value: childItemMetadatum.value,
|
||||
value_as_html: childItemMetadatum.value_as_html,
|
||||
value_as_string: childItemMetadatum.value_as_string,
|
||||
|
@ -184,7 +183,7 @@
|
|||
existingChildItemMetadata.push({
|
||||
item: this.itemMetadatum.item,
|
||||
metadatum: childMetadatum,
|
||||
parent_meta_id: existingParentMetaIdIndex >= 0 ? childItemMetadata[existingParentMetaIdIndex].parent_meta_id : 0,
|
||||
parent_meta_id: (this.itemMetadatum.item && this.itemMetadatum.item.id) ? (existingParentMetaIdIndex >= 0 ? childItemMetadata[existingParentMetaIdIndex].parent_meta_id : 0) : groupIndex,
|
||||
value: '',
|
||||
value_as_html: '',
|
||||
value_as_string: '',
|
||||
|
@ -200,7 +199,7 @@
|
|||
let childObject = {
|
||||
item: this.itemMetadatum.item,
|
||||
metadatum: childMetadatum,
|
||||
parent_meta_id: '0',
|
||||
parent_meta_id: (this.itemMetadatum.item && this.itemMetadatum.item.id) ? '0' : currentChildItemMetadataGroups.length,
|
||||
value: '',
|
||||
value_as_html: '',
|
||||
value_as_string: '',
|
||||
|
@ -209,7 +208,7 @@
|
|||
existingChildItemMetadata.push(childObject)
|
||||
}
|
||||
}
|
||||
currentChildItemMetadataGroups.push(existingChildItemMetadata)
|
||||
currentChildItemMetadataGroups.push(existingChildItemMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,12 +228,44 @@
|
|||
addGroup() {
|
||||
|
||||
this.isCreatingGroup = true;
|
||||
|
||||
if (this.itemMetadatum.item && this.itemMetadatum.item.id) {
|
||||
|
||||
// Sends value to api so we can obtain the parent_meta_id
|
||||
eventBusItemMetadata.fetchCompoundFirstParentMetaId({
|
||||
itemId: this.itemMetadatum.item.id,
|
||||
metadatumId: this.itemMetadatum.metadatum.id
|
||||
}).then((parentMetaId) => {
|
||||
// Sends value to api so we can obtain the parent_meta_id
|
||||
eventBusItemMetadata.fetchCompoundFirstParentMetaId({
|
||||
itemId: this.itemMetadatum.item.id,
|
||||
metadatumId: this.itemMetadatum.metadatum.id
|
||||
}).then((parentMetaId) => {
|
||||
|
||||
// Create a new placeholder parent_meta_id group here.
|
||||
let newEmptyGroup = [];
|
||||
|
||||
if (this.itemMetadatum &&
|
||||
this.itemMetadatum.metadatum &&
|
||||
this.itemMetadatum.metadatum.metadata_type_options &&
|
||||
this.itemMetadatum.metadatum.metadata_type_options.children_objects.length > 0
|
||||
) {
|
||||
for (let childMetadatum of this.itemMetadatum.metadatum.metadata_type_options.children_objects) {
|
||||
let childObject = {
|
||||
item: this.itemMetadatum.item,
|
||||
metadatum: childMetadatum,
|
||||
parent_meta_id: parentMetaId,
|
||||
value: '',
|
||||
value_as_html: '',
|
||||
value_as_string: '',
|
||||
collapse: true
|
||||
};
|
||||
newEmptyGroup.push(childObject)
|
||||
}
|
||||
}
|
||||
|
||||
this.childItemMetadataGroups.push(newEmptyGroup);
|
||||
|
||||
this.isCreatingGroup = false;
|
||||
});
|
||||
|
||||
// If no itemId is provided, we are probably on an item Submission flow
|
||||
} else {
|
||||
|
||||
// Create a new placeholder parent_meta_id group here.
|
||||
let newEmptyGroup = [];
|
||||
|
@ -248,7 +279,7 @@
|
|||
let childObject = {
|
||||
item: this.itemMetadatum.item,
|
||||
metadatum: childMetadatum,
|
||||
parent_meta_id: parentMetaId,
|
||||
parent_meta_id: this.childItemMetadataGroups.length,
|
||||
value: '',
|
||||
value_as_html: '',
|
||||
value_as_string: '',
|
||||
|
@ -257,21 +288,21 @@
|
|||
newEmptyGroup.push(childObject)
|
||||
}
|
||||
}
|
||||
|
||||
this.childItemMetadataGroups.push(newEmptyGroup);
|
||||
|
||||
this.isCreatingGroup = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
removeGroup(groupIndex) {
|
||||
removeGroup(groupIndex) {
|
||||
|
||||
if (this.itemMetadatum.value && this.itemMetadatum.value[groupIndex] && this.itemMetadatum.value[groupIndex][0]) {
|
||||
this.isRemovingGroup = true;
|
||||
this.isRemovingGroup = true;
|
||||
eventBusItemMetadata.$emit('remove_group', {
|
||||
itemId: this.itemMetadatum.item.id,
|
||||
metadatumId: this.itemMetadatum.metadatum.id,
|
||||
parentMetaId: this.itemMetadatum.value[groupIndex][0].parent_meta_id
|
||||
parentMetaId: this.itemMetadatum.item.id ? this.itemMetadatum.value[groupIndex][0].parent_meta_id : groupIndex
|
||||
});
|
||||
if (!this.itemMetadatum.item.id)
|
||||
this.childItemMetadataGroups.splice(groupIndex, 1);
|
||||
} else {
|
||||
this.childItemMetadataGroups.splice(groupIndex, 1);
|
||||
}
|
||||
|
@ -316,7 +347,8 @@
|
|||
height: 1px;
|
||||
}
|
||||
.empty-label {
|
||||
color: var(--tainacan-gray3);
|
||||
color: var(--tainacan-gray4);
|
||||
font-size: 0.875em;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,6 +169,8 @@ class Compound extends Metadata_Type {
|
|||
public function get_value_as_html(Item_Metadata_Entity $item_metadata) {
|
||||
$value = $item_metadata->get_value();
|
||||
$separator = $item_metadata->get_multivalue_separator();
|
||||
$options = $item_metadata->get_metadatum()->get_metadata_type_object()->get_options();
|
||||
$order = $options['children_order'];
|
||||
$return = '';
|
||||
|
||||
if ( empty($value) )
|
||||
|
@ -178,29 +180,36 @@ class Compound extends Metadata_Type {
|
|||
$elements = [];
|
||||
foreach ( $value as $compound_element ) {
|
||||
if ( !empty($compound_element) ) {
|
||||
$metadata_value = '';
|
||||
foreach ( $compound_element as $meta ) {
|
||||
$metadata_value = array_fill(0, count($compound_element), null);
|
||||
$metadata_value_not_ordinate = [];
|
||||
foreach ( $compound_element as $meta_id => $meta ) {
|
||||
$index = array_search( $meta_id, array_column( $order, 'id' ) );
|
||||
if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) {
|
||||
$metadata_value .= '<label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p> \n";
|
||||
if ( $index !== false ) {
|
||||
$metadata_value[$index] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>";
|
||||
} else {
|
||||
$metadata_value_not_ordinate[] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$elements[] = '<div class="tainacan-compound-metadatum">' . $metadata_value . "</div> \n" ;
|
||||
$elements[] = '<div class="tainacan-compound-metadatum">' . implode("\n", array_merge($metadata_value, $metadata_value_not_ordinate)) . "</div> \n" ;
|
||||
}
|
||||
}
|
||||
$return .= '<div class="tainacan-compound-group">' . implode($separator, $elements) . '</div>';
|
||||
$return = '<div class="tainacan-compound-group">' . implode($separator, $elements) . '</div>';
|
||||
} else {
|
||||
$return .= '<div class="tainacan-compound-group">';
|
||||
foreach ( $value as $meta ) {
|
||||
if ( $meta->get_value_as_html() != '' ) {
|
||||
$return .= '<div class="tainacan-metadatum">';
|
||||
if ( $meta instanceof Item_Metadata_Entity ) {
|
||||
$return .= '<label class="label">' . $meta->get_metadatum()->get_name() . "</label>\n";
|
||||
$return .= '<p>' . $meta->get_value_as_html() . '</p>';
|
||||
}
|
||||
$return .= '</div>' . "\n\n";
|
||||
}
|
||||
}
|
||||
$return .= '</div>' . "\n\n";
|
||||
$metadata_value = array_fill(0, count($value), null);
|
||||
$metadata_value_not_ordinate = [];
|
||||
foreach ( $value as $meta_id => $meta ) {
|
||||
$index = array_search( $meta_id, array_column( $order, 'id' ) );
|
||||
if ( $meta instanceof Item_Metadata_Entity && $meta->get_value_as_html() != '' ) {
|
||||
if ( $index !== false ) {
|
||||
$metadata_value[intval($index)] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>";
|
||||
} else {
|
||||
$metadata_value_not_ordinate[] = '<div class="tainacan-metadatum"><label class="label">' . $meta->get_metadatum()->get_name() . '</label> <p>' . $meta->get_value_as_html() . "</p></div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$return = '<div class="tainacan-compound-group">' . implode("\n", array_merge($metadata_value, $metadata_value_not_ordinate)) . "</div> \n";
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
@input="onInput"
|
||||
@blur="onBlur"
|
||||
:data="options"
|
||||
:maxtags="maxtags != undefined ? maxtags : (itemMetadatum.metadatum.multiple == 'yes' || allowNew === true ? 100 : 1)"
|
||||
:maxtags="maxtags != undefined ? maxtags : (itemMetadatum.metadatum.multiple == 'yes' || allowNew === true ? null : 1)"
|
||||
autocomplete
|
||||
:remove-on-keys="[]"
|
||||
:dropdown-position="isLastMetadatum ? 'top' :'auto'"
|
||||
attached
|
||||
:placeholder="$i18n.get('instruction_type_existing_item')"
|
||||
:loading="isLoading"
|
||||
|
@ -42,7 +44,7 @@
|
|||
{{ $i18n.get('info_no_item_found') }}
|
||||
</template>
|
||||
<template
|
||||
v-if="currentUserCanEditItems && !$route.query.iframemode"
|
||||
v-if="currentUserCanEditItems && !($route && $route.query.iframemode)"
|
||||
slot="footer">
|
||||
<a @click="createNewItemModal = true">
|
||||
{{ $i18n.get('label_crate_new_item') + ' "' + searchQuery + '"' }}
|
||||
|
@ -50,8 +52,8 @@
|
|||
</template>
|
||||
</b-taginput>
|
||||
<a
|
||||
v-if="currentUserCanEditItems"
|
||||
:disabled="$route.query.iframemode"
|
||||
v-if="currentUserCanEditItems && itemMetadatum.item && itemMetadatum.item.id"
|
||||
:disabled="!$route || $route.query.iframemode"
|
||||
@click="createNewItemModal = !createNewItemModal"
|
||||
class="add-link">
|
||||
<span class="icon is-small">
|
||||
|
@ -82,7 +84,8 @@
|
|||
itemMetadatum: Object,
|
||||
maxtags: undefined,
|
||||
disabled: false,
|
||||
allowNew: true
|
||||
allowNew: true,
|
||||
isLastMetadatum: false
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -120,7 +123,7 @@
|
|||
if (this.itemMetadatum.value && (Array.isArray( this.itemMetadatum.value ) ? this.itemMetadatum.value.length > 0 : true )) {
|
||||
let query = qs.stringify({ postin: ( Array.isArray( this.itemMetadatum.value ) ) ? this.itemMetadatum.value : [ this.itemMetadatum.value ] });
|
||||
query += this.itemMetadatum.metadatum.metadata_type_options.search ? '&fetch_only_meta=' + this.itemMetadatum.metadatum.metadata_type_options.search : '';
|
||||
axios.get('/collection/' + this.collectionId + '/items?' + query + '&nopaging=1&fetch_only=title,thumbnail')
|
||||
axios.get('/collection/' + this.collectionId + '/items?' + query + '&nopaging=1&fetch_only=title,thumbnail&order=asc')
|
||||
.then( res => {
|
||||
if (res.data.items) {
|
||||
for (let item of res.data.items)
|
||||
|
@ -137,7 +140,7 @@
|
|||
}
|
||||
|
||||
// Checks if current user can edit itens on the related collection to offer modal
|
||||
if (this.collection.id == this.collectionId)
|
||||
if (this.collection && this.collection.id == this.collectionId)
|
||||
this.currentUserCanEditItems = this.collection.current_user_can_edit_items;
|
||||
else {
|
||||
axios.get('/collections/' + this.collectionId + '?fetch_only=name,url,allow_comments&context=edit')
|
||||
|
@ -226,16 +229,43 @@
|
|||
},
|
||||
getQueryString( search ) {
|
||||
let query = [];
|
||||
|
||||
if (this.itemMetadatum.metadatum.metadata_type_options &&
|
||||
this.itemMetadatum.metadatum.metadata_type_options.search)
|
||||
{
|
||||
query['metaquery'] = [];
|
||||
if (this.itemMetadatum.metadatum.metadata_type_options.search_by_tax) {
|
||||
query['taxquery'] = [];
|
||||
|
||||
query['taxquery'][0] = {
|
||||
taxonomy: `tnc_tax_${this.itemMetadatum.metadatum.metadata_type_options.search_by_tax}`,
|
||||
operator: 'LIKE',
|
||||
taxonomy_id : this.itemMetadatum.metadatum.metadata_type_options.search_by_tax,
|
||||
terms: search
|
||||
}
|
||||
} else {
|
||||
query['metaquery'] = [];
|
||||
|
||||
query['metaquery'][0] = {
|
||||
key: this.itemMetadatum.metadatum.metadata_type_options.search,
|
||||
value: search,
|
||||
compare: 'LIKE'
|
||||
query['metaquery'][0] = {
|
||||
key: this.itemMetadatum.metadatum.metadata_type_options.search,
|
||||
value: search,
|
||||
compare: 'LIKE'
|
||||
}
|
||||
|
||||
// Sorting options depend on metadata type. Notice that this won't work with taxonomies
|
||||
switch(this.itemMetadatum.metadatum.metadata_type_options.related_primitive_type) {
|
||||
case 'float':
|
||||
case 'int':
|
||||
query['orderby'] = 'meta_value_num';
|
||||
query['metakey'] = this.itemMetadatum.metadatum.metadata_type_options.search;
|
||||
break;
|
||||
case 'date':
|
||||
query['orderby'] = 'meta_value';
|
||||
query['metakey'] = this.itemMetadatum.metadatum.metadata_type_options.search;
|
||||
query['metatype'] = 'DATETIME';
|
||||
break;
|
||||
default:
|
||||
query['orderby'] = 'meta_value';
|
||||
query['metakey'] = this.itemMetadatum.metadatum.metadata_type_options.search;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -245,6 +275,7 @@
|
|||
query['fetch_only_meta'] = this.itemMetadatum.metadatum.metadata_type_options.search;
|
||||
query['perpage'] = 12;
|
||||
query['paged'] = this.page;
|
||||
query['order'] = 'asc';
|
||||
|
||||
if (this.selected.length > 0)
|
||||
query['exclude'] = this.selected.map((item) => item.value);
|
||||
|
|
|
@ -9,86 +9,86 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
|||
*/
|
||||
class Relationship extends Metadata_Type {
|
||||
|
||||
function __construct(){
|
||||
// call metadatum type constructor
|
||||
parent::__construct();
|
||||
$this->set_primitive_type('item');
|
||||
$this->set_repository( \Tainacan\Repositories\Items::get_instance() );
|
||||
$this->set_component('tainacan-relationship');
|
||||
$this->set_form_component('tainacan-form-relationship');
|
||||
$this->set_name( __('Relationship', 'tainacan') );
|
||||
$this->set_description( __('A relationship with another item', 'tainacan') );
|
||||
$this->set_preview_template('
|
||||
<div>
|
||||
<div class="taginput control is-expanded has-selected">
|
||||
<div class="taginput-container is-focusable">
|
||||
<div class="autocomplete control">
|
||||
<div class="control has-icon-right is-loading is-clearfix">
|
||||
<input type="text" class="input" value="'. __('Item') . ' 9" >
|
||||
</div>
|
||||
<div class="dropdown-menu" style="">
|
||||
<div class="dropdown-content">
|
||||
<a class="dropdown-item is-hovered">
|
||||
<span>'. __('Collection') . ' 2 <strong>'._('item') . ' 9</strong>9</span>
|
||||
</a>
|
||||
<a class="dropdown-item">
|
||||
<span>'. __('Collection') . ' 3 <strong>'._('item') . ' 9</strong>9</span>
|
||||
</a>
|
||||
<a class="dropdown-item">
|
||||
<span>'. __('Collection') . ' 3 <strong>'._('item') . ' 9</strong>8</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
');
|
||||
}
|
||||
function __construct(){
|
||||
// call metadatum type constructor
|
||||
parent::__construct();
|
||||
$this->set_primitive_type('item');
|
||||
$this->set_repository( \Tainacan\Repositories\Items::get_instance() );
|
||||
$this->set_component('tainacan-relationship');
|
||||
$this->set_form_component('tainacan-form-relationship');
|
||||
$this->set_name( __('Relationship', 'tainacan') );
|
||||
$this->set_description( __('A relationship with another item', 'tainacan') );
|
||||
$this->set_preview_template('
|
||||
<div>
|
||||
<div class="taginput control is-expanded has-selected">
|
||||
<div class="taginput-container is-focusable">
|
||||
<div class="autocomplete control">
|
||||
<div class="control has-icon-right is-loading is-clearfix">
|
||||
<input type="text" class="input" value="'. __('Item') . ' 9" >
|
||||
</div>
|
||||
<div class="dropdown-menu" style="">
|
||||
<div class="dropdown-content">
|
||||
<a class="dropdown-item is-hovered">
|
||||
<span>'. __('Collection') . ' 2 <strong>'._('item') . ' 9</strong>9</span>
|
||||
</a>
|
||||
<a class="dropdown-item">
|
||||
<span>'. __('Collection') . ' 3 <strong>'._('item') . ' 9</strong>9</span>
|
||||
</a>
|
||||
<a class="dropdown-item">
|
||||
<span>'. __('Collection') . ' 3 <strong>'._('item') . ' 9</strong>8</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_form_labels(){
|
||||
return [
|
||||
'collection_id' => [
|
||||
'title' => __( 'Related Collection', 'tainacan' ),
|
||||
'description' => __( 'Select the collection to fetch items', 'tainacan' ),
|
||||
],
|
||||
'search' => [
|
||||
'title' => __( 'Related Metadatum', 'tainacan' ),
|
||||
'description' => __( 'Select the metadata to use as search criteria in the target collection and as a label when representing the relationship', 'tainacan' ),
|
||||
],
|
||||
'repeated' => [
|
||||
'title' =>__( 'Allow repeated items', 'tainacan' ),
|
||||
'description' => __( 'Allows different items to be related to the same item selected in another collection.', 'tainacan' ),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function validate_options(\Tainacan\Entities\Metadatum $metadatum) {
|
||||
if ( !in_array($metadatum->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
|
||||
return true;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_form_labels(){
|
||||
return [
|
||||
'collection_id' => [
|
||||
'title' => __( 'Related Collection', 'tainacan' ),
|
||||
'description' => __( 'Select the collection to fetch items', 'tainacan' ),
|
||||
],
|
||||
'search' => [
|
||||
'title' => __( 'Related Metadatum', 'tainacan' ),
|
||||
'description' => __( 'Select the metadata to use as search criteria in the target collection and as a label when representing the relationship', 'tainacan' ),
|
||||
],
|
||||
'repeated' => [
|
||||
'title' =>__( 'Allow repeated items', 'tainacan' ),
|
||||
'description' => __( 'Allows different items to be related to the same item selected in another collection.', 'tainacan' ),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($this->get_option('collection_id')) && !is_numeric($this->get_option('collection_id'))) {
|
||||
return [
|
||||
'collection_id' => __('Invalid collection ID','tainacan')
|
||||
];
|
||||
} else if( empty($this->get_option('collection_id'))) {
|
||||
return [
|
||||
'collection_id' => __('The related collection is required','tainacan')
|
||||
];
|
||||
}
|
||||
public function validate_options(\Tainacan\Entities\Metadatum $metadatum) {
|
||||
if ( !in_array($metadatum->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
|
||||
return true;
|
||||
|
||||
if (!empty($this->get_option('collection_id')) && !is_numeric($this->get_option('collection_id'))) {
|
||||
return [
|
||||
'collection_id' => __('Invalid collection ID','tainacan')
|
||||
];
|
||||
} else if( empty($this->get_option('collection_id'))) {
|
||||
return [
|
||||
'collection_id' => __('The related collection is required','tainacan')
|
||||
];
|
||||
}
|
||||
// empty is ok
|
||||
if ( !empty($this->get_option('search')) && !is_numeric($this->get_option('search')) ) {
|
||||
return [
|
||||
'search' => __('Search option must be a numeric Metadatum ID','tainacan')
|
||||
];
|
||||
'search' => __('Search option must be a numeric Metadatum ID','tainacan')
|
||||
];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of an Item_Metadata_Entity using a metadatum of this metadatum type as an html string
|
||||
* @param Item_Metadata_Entity $item_metadata
|
||||
|
@ -159,7 +159,7 @@ class Relationship extends Metadata_Type {
|
|||
return $return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function get_item_html($item) {
|
||||
|
||||
$return = '';
|
||||
|
@ -199,7 +199,7 @@ class Relationship extends Metadata_Type {
|
|||
return $return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get related Collection object
|
||||
* @return \Tainacan\Entities\Collection|false The Collection object or false
|
||||
|
@ -218,5 +218,25 @@ class Relationship extends Metadata_Type {
|
|||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the options for this metadatum types, including default values for options
|
||||
* that were not set yet.
|
||||
* @return array Metadatum type options
|
||||
*/
|
||||
public function get_options() {
|
||||
$opt = parent::get_options();
|
||||
if ( isset($opt['search']) && !empty($opt['search']) ) {
|
||||
$search_id = $opt['search'];
|
||||
$metadata = \Tainacan\Repositories\Metadata::get_instance()->fetch($search_id, 'OBJECT');
|
||||
|
||||
$opt = array_merge(['related_primitive_type' => $metadata->get_metadata_type_object()->get_primitive_type()], $opt);
|
||||
|
||||
if ($metadata->get_metadata_type() == 'Tainacan\Metadata_Types\Taxonomy') {
|
||||
$taxonomy_id = $metadata->get_metadata_type_options()['taxonomy_id'];
|
||||
return array_merge(['search_by_tax' => $taxonomy_id], $opt);
|
||||
}
|
||||
}
|
||||
return $opt;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
@input="emitValues()"
|
||||
@focus="clear()"
|
||||
attached
|
||||
:remove-on-keys="[]"
|
||||
:aria-close-label="$i18n.get('remove_value')"
|
||||
:class="{'has-selected': options != undefined && options != []}"
|
||||
:placeholder="$i18n.get('new') + ', ...'"/>
|
||||
|
@ -34,7 +35,7 @@
|
|||
return {
|
||||
optionType: '',
|
||||
optionMessage: '',
|
||||
options: []
|
||||
options: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
<template>
|
||||
<b-field
|
||||
:class="hideCollapses ? 'has-collapses-hidden' : ''"
|
||||
:addons="false"
|
||||
:message="errorMessage"
|
||||
:type="errorMessage ? 'is-danger' : ''">
|
||||
<span
|
||||
class="collapse-handle"
|
||||
@click="$emit('changeCollapse', errorMessage ? true : !isCollapsed )">
|
||||
<span class="icon">
|
||||
@click="!hideCollapses ? $emit('changeCollapse', errorMessage ? true : !isCollapsed ) : ''">
|
||||
<span
|
||||
v-if="!hideCollapses"
|
||||
class="icon">
|
||||
<i
|
||||
:class="{
|
||||
'tainacan-icon-arrowdown' : isCollapsed || errorMessage,
|
||||
|
@ -33,16 +36,19 @@
|
|||
:class="errorMessage ? 'is-danger' : ''">
|
||||
*
|
||||
</span>
|
||||
<span class="metadata-type">
|
||||
<span
|
||||
v-if="!$parent.hideMetadataTypes"
|
||||
class="metadata-type">
|
||||
({{ itemMetadatum.metadatum.metadata_type_object.name }})
|
||||
</span>
|
||||
<help-button
|
||||
<help-button
|
||||
v-if="!$parent.hideHelpButtons"
|
||||
:title="itemMetadatum.metadatum.name"
|
||||
:message="itemMetadatum.metadatum.description"/>
|
||||
</span>
|
||||
<transition name="filter-item">
|
||||
<div
|
||||
v-show="isCollapsed || errorMessage"
|
||||
v-show="hideCollapses || (isCollapsed || errorMessage)"
|
||||
v-if="isTextInputComponent">
|
||||
<component
|
||||
:is="metadatumComponent"
|
||||
|
@ -91,14 +97,15 @@
|
|||
<!-- Non-textual metadata such as taxonomy, relationship and compound manage multiple state in different ways -->
|
||||
<transition name="filter-item">
|
||||
<div
|
||||
v-show="isCollapsed"
|
||||
v-show="hideCollapses || isCollapsed"
|
||||
v-if="!isTextInputComponent">
|
||||
<component
|
||||
:is="metadatumComponent"
|
||||
v-model="values"
|
||||
:item-metadatum="itemMetadatum"
|
||||
@input="changeValue"
|
||||
@blur="performValueChange"/>
|
||||
@blur="performValueChange"
|
||||
:is-last-metadatum="isLastMetadatum" />
|
||||
</div>
|
||||
</transition>
|
||||
</b-field>
|
||||
|
@ -111,7 +118,9 @@
|
|||
name: 'TainacanFormItem',
|
||||
props: {
|
||||
itemMetadatum: Object,
|
||||
isCollapsed: true
|
||||
isCollapsed: true,
|
||||
hideCollapses: false,
|
||||
isLastMetadatum: false
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
@ -162,48 +171,51 @@
|
|||
this.performValueChange();
|
||||
}, 800),
|
||||
performValueChange() {
|
||||
|
||||
|
||||
// Compound metadata do not emit values, only their children.
|
||||
if (this.metadatumComponent == 'tainacan-compound')
|
||||
return;
|
||||
|
||||
if (this.itemMetadatum.value !== null) {
|
||||
|
||||
// This routine avoids calling the API if the value did not changed
|
||||
switch(this.itemMetadatum.value.constructor.name) {
|
||||
switch(this.itemMetadatum.value.constructor.name) {
|
||||
|
||||
// Multivalored Metadata requires checking the whole array
|
||||
case 'Array': {
|
||||
|
||||
let equal = [];
|
||||
let currentValues = [];
|
||||
|
||||
// An array of terms
|
||||
if (this.values.length && this.values[0].constructor.name == 'Object')
|
||||
currentValues = this.values.map(term => term.value)
|
||||
else
|
||||
currentValues = this.values;
|
||||
// Multivalored Metadata requires checking the whole array
|
||||
case 'Array': {
|
||||
|
||||
for (let value of currentValues) {
|
||||
let foundIndex = this.itemMetadatum.value.findIndex(element => value == element.id);
|
||||
if (foundIndex >= 0)
|
||||
equal.push(this.itemMetadatum.value[foundIndex]);
|
||||
let equal = [];
|
||||
let currentValues = [];
|
||||
|
||||
// An array of terms
|
||||
if (this.values.length && this.values[0].constructor.name == 'Object')
|
||||
currentValues = this.values.map(term => term.value)
|
||||
else
|
||||
currentValues = this.values;
|
||||
|
||||
for (let value of currentValues) {
|
||||
let foundIndex = this.itemMetadatum.value.findIndex(element => value == element.id);
|
||||
if (foundIndex >= 0)
|
||||
equal.push(this.itemMetadatum.value[foundIndex]);
|
||||
}
|
||||
|
||||
if (equal.length == currentValues.length && this.itemMetadatum.value.length <= equal.length)
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// A single term value
|
||||
case 'Object':
|
||||
if (this.values.length && this.values[0] == this.itemMetadatum.value.id)
|
||||
return;
|
||||
break;
|
||||
|
||||
if (equal.length == currentValues.length && this.itemMetadatum.value.length <= equal.length)
|
||||
return;
|
||||
|
||||
break;
|
||||
// Any single metadatum value that is not a term
|
||||
default:
|
||||
if (this.values.length && this.values[0] == this.itemMetadatum.value)
|
||||
return;
|
||||
}
|
||||
|
||||
// A single term value
|
||||
case 'Object':
|
||||
if (this.values.length && this.values[0] == this.itemMetadatum.value.id)
|
||||
return;
|
||||
break;
|
||||
|
||||
// Any single metadatum value that is not a term
|
||||
default:
|
||||
if (this.values.length && this.values[0] == this.itemMetadatum.value)
|
||||
return;
|
||||
}
|
||||
|
||||
// If none is the case, the value is update request is sent to the API
|
||||
|
@ -211,7 +223,8 @@
|
|||
itemId: this.itemMetadatum.item.id,
|
||||
metadatumId: this.itemMetadatum.metadatum.id,
|
||||
values: this.values ? this.values : '',
|
||||
parentMetaId: this.itemMetadatum.parent_meta_id
|
||||
parentMetaId: this.itemMetadatum.parent_meta_id,
|
||||
parentId: this.itemMetadatum.metadatum.parent != undefined ? this.itemMetadatum.metadatum.parent : 0
|
||||
});
|
||||
},
|
||||
addValue(){
|
||||
|
@ -236,9 +249,22 @@
|
|||
}
|
||||
|
||||
.field {
|
||||
border-bottom: 1px solid var(--tainacan-gray2);
|
||||
border-bottom: 1px solid var(--tainacan-input-border-color);
|
||||
padding: 10px var(--tainacan-container-padding);
|
||||
|
||||
&.has-collapses-hidden {
|
||||
border-bottom: none;
|
||||
padding: 10px !important;
|
||||
|
||||
.collapse-handle {
|
||||
margin-left: -15px;
|
||||
}
|
||||
|
||||
.child-metadata-inputs {
|
||||
margin-left: 0.25em;
|
||||
}
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 0.875em;
|
||||
font-weight: 500;
|
||||
|
@ -250,7 +276,8 @@
|
|||
.metadata-type {
|
||||
font-size: 0.8125em;
|
||||
font-weight: 400;
|
||||
color: var(--tainacan-gray3);
|
||||
color: var(--tainacan-info-color);
|
||||
opacity: 0.75;
|
||||
top: -0.1em;
|
||||
position: relative;
|
||||
}
|
||||
|
|
|
@ -109,6 +109,7 @@
|
|||
@input="updateSelectedCollections"
|
||||
@focus="clear()"
|
||||
attached
|
||||
:remove-on-keys="[]"
|
||||
:aria-close-label="$i18n.get('remove_value')"
|
||||
:class="{'has-selected': link_filtered_by_collections != undefined && link_filtered_by_collections != []}"
|
||||
:placeholder="$i18n.get('instruction_select_one_or_more_collections')"
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
:has-counter="false" />
|
||||
<checkbox-radio-metadata-input
|
||||
v-else
|
||||
:id="'tainacan-item-metadatum_id-' + itemMetadatum.metadatum.id + (itemMetadatum.parent_meta_id ? ('_parent_meta_id-' + itemMetadatum.parent_meta_id) : '')"
|
||||
:is-modal="false"
|
||||
:parent="0"
|
||||
:taxonomy_id="taxonomyId"
|
||||
|
@ -23,6 +24,7 @@
|
|||
:collection-id="itemMetadatum.metadatum.collection_id"
|
||||
:is-taxonomy="true"
|
||||
:metadatum="itemMetadatum.metadatum"
|
||||
:amount-selected="getComponent == 'tainacan-taxonomy-checkbox' ? value.length : (value ? '1' : '0')"
|
||||
:is-checkbox="getComponent == 'tainacan-taxonomy-checkbox'"
|
||||
@input="(selected) => valueComponent = selected"
|
||||
/>
|
||||
|
@ -85,7 +87,7 @@
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
valueComponent( val ){
|
||||
valueComponent( val ) {
|
||||
this.$emit('input', val);
|
||||
}
|
||||
},
|
||||
|
@ -95,7 +97,7 @@
|
|||
this.taxonomyId = metadata_type_options.taxonomy_id;
|
||||
this.taxonomy = metadata_type_options.taxonomy;
|
||||
|
||||
if (metadata_type_options && metadata_type_options.allow_new_terms && this.itemMetadatum.item)
|
||||
if (this.itemMetadatum.item && this.itemMetadatum.item.id && metadata_type_options && metadata_type_options.allow_new_terms && this.itemMetadatum.item)
|
||||
this.allowNew = metadata_type_options.allow_new_terms == 'yes';
|
||||
|
||||
this.getTermsId();
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
v-model="selected"
|
||||
:data="labels"
|
||||
field="label"
|
||||
:remove-on-keys="[]"
|
||||
:dropdown-position="isLastMetadatum ? 'top' :'auto'"
|
||||
attached
|
||||
ellipsis
|
||||
:aria-close-label="$i18n.get('remove_value')"
|
||||
|
@ -59,6 +61,7 @@
|
|||
disabled: false,
|
||||
allowSelectToCreate: false,
|
||||
maxtags: '',
|
||||
isLastMetadatum: false
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
:placeholder="$i18n.get('instruction_type_search_users')"
|
||||
keep-first
|
||||
open-on-focus
|
||||
:remove-on-keys="[]"
|
||||
:dropdown-position="isLastMetadatum ? 'top' :'auto'"
|
||||
:loading="isLoading || isLoading"
|
||||
:aria-close-label="$i18n.get('remove_value')"
|
||||
:class="{'has-selected': selected != undefined && selected != []}"
|
||||
|
@ -58,6 +60,7 @@ export default {
|
|||
maxtags: undefined,
|
||||
disabled: false,
|
||||
allowNew: true,
|
||||
isLastMetadatum: false
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
|
@ -440,7 +440,7 @@
|
|||
}).then(() => {
|
||||
this.finalizeProcedure(criterion);
|
||||
});
|
||||
} if(procedure.metadatum.id === 'comments'){
|
||||
} else if (procedure.metadatum.id === 'comments') {
|
||||
this.setCommentStatusInBulk({
|
||||
collectionId: this.collectionId,
|
||||
groupId: this.groupId,
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<h2
|
||||
id="exposers-modal-title"
|
||||
v-if="selectedExposer == undefined">
|
||||
{{ itemId ? $i18n.get('label_urls_for_item_page') : $i18n.get('label_urls_for_items_list') }}
|
||||
{{ itemId ? $i18n.get('label_urls_for_item_page') : ($i18n.get('label_urls_for_items_list') + (selectedItems && selectedItems.length ? (' (' + selectedItems.length + ' ' + $i18n.get('items') + ')') : '')) }}
|
||||
</h2>
|
||||
<h2
|
||||
id="exposers-modal-title"
|
||||
|
@ -257,7 +257,8 @@ export default {
|
|||
collectionId: Number,
|
||||
totalItems: Number,
|
||||
itemId: Number,
|
||||
itemURL: String
|
||||
itemURL: String,
|
||||
selectedItems: Array
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
@ -272,7 +273,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
totalPages() {
|
||||
return Math.ceil(Number(this.totalItems)/Number(this.maxItemsPerPage));
|
||||
return this.selectedItems && this.selectedItems.length ? 1 : Math.ceil(Number(this.totalItems)/Number(this.maxItemsPerPage));
|
||||
},
|
||||
exposerBaseURL() {
|
||||
let baseURL = this.collectionId != undefined ? '/collection/' + this.collectionId + '/items/' : '/items/';
|
||||
|
@ -293,6 +294,7 @@ export default {
|
|||
// Removes Admin View Mode
|
||||
if (currentParams.admin_view_mode != undefined)
|
||||
delete currentParams.admin_view_mode;
|
||||
|
||||
|
||||
// Handles pagination of this link
|
||||
delete currentParams.paged;
|
||||
|
@ -301,6 +303,13 @@ export default {
|
|||
else
|
||||
currentParams.perpage = this.maxItemsPerPage;
|
||||
|
||||
// If selectedItems were provided, filters by them
|
||||
if (this.selectedItems && this.selectedItems.length) {
|
||||
currentParams.postin = this.selectedItems;
|
||||
delete currentParams.paged;
|
||||
currentParams.perpage = this.maxItemsPerPage;
|
||||
}
|
||||
|
||||
return tainacan_plugin.tainacan_api_url + baseURL + '?' + qs.stringify(currentParams);
|
||||
},
|
||||
availableExposers() {
|
||||
|
@ -456,7 +465,7 @@ export default {
|
|||
});
|
||||
},
|
||||
getLastItemNumber(page) {
|
||||
let last = (Number(this.maxItemsPerPage*(page - 1)) + Number(this.maxItemsPerPage));
|
||||
let last = (this.selectedItems && this.selectedItems.length) ? this.selectedItems.length : (Number(this.maxItemsPerPage*(page - 1)) + Number(this.maxItemsPerPage));
|
||||
|
||||
return last > this.totalItems ? this.totalItems : last;
|
||||
},
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
class="level-item">
|
||||
<router-link
|
||||
tag="a"
|
||||
:to="{ path: collection && collection.id ? $routerHelper.getCollectionItemsPath(collection.id, '') : '' }"
|
||||
:to="{ path: collection && collection.id ? $routerHelper.getCollectionItemsPath(collection.id, '') : '', query: activeRoute == 'CollectionItemsPage' ? $route.query : '' }"
|
||||
:aria-label="$i18n.get('label_collection_items')">
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-items"/>
|
||||
|
|
|
@ -560,7 +560,7 @@
|
|||
let query = `?order=asc&number=${this.maxNumSearchResultsShow}&search=${this.optionName}&${qs.stringify(query_items)}`;
|
||||
|
||||
let route = `/collection/${this.collectionId}/facets/${this.metadatumId}${query}`;
|
||||
|
||||
|
||||
if (this.collectionId == 'default')
|
||||
route = `/facets/${this.metadatumId}${query}`;
|
||||
|
||||
|
@ -676,7 +676,6 @@
|
|||
let query = `?order=asc&parent=${parent}&number=${this.maxNumOptionsCheckboxFinderColumns}&offset=0&${qs.stringify(query_items)}`
|
||||
|
||||
this.isColumnLoading = true;
|
||||
|
||||
let route = `/collection/${this.collectionId}/facets/${this.metadatumId}${query}`;
|
||||
|
||||
if (this.collectionId == 'default')
|
||||
|
@ -1096,6 +1095,10 @@
|
|||
.tags.is-small {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
section p {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
}
|
||||
|
||||
.tainacan-modal-checkbox-search-results-body {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -227,7 +227,7 @@
|
|||
|
||||
</b-tab-item>
|
||||
|
||||
<b-tab-item :label="isTaxonomy ? $i18n.get('label_selected_terms') : $i18n.get('label_selected_metadatum_values')">
|
||||
<b-tab-item :label="(isTaxonomy ? $i18n.get('label_selected_terms') : $i18n.get('label_selected_metadatum_values')) + (amountSelected !== null && amountSelected !== undefined ? (' (' + amountSelected + ')' ): '') ">
|
||||
|
||||
<div class="modal-card-body tainacan-tags-container">
|
||||
<b-field
|
||||
|
@ -303,7 +303,8 @@
|
|||
isCheckbox: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
}
|
||||
},
|
||||
amountSelected: 0
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -733,7 +734,7 @@
|
|||
margin-bottom: 0 !important;
|
||||
|
||||
ul {
|
||||
padding: none;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
.hidden-tabs-section /deep/ .tabs {
|
||||
|
@ -1017,6 +1018,10 @@
|
|||
.tags.is-small {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
section p {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
}
|
||||
|
||||
.tainacan-modal-checkbox-search-results-body {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</a>
|
||||
<div class="help-tooltip">
|
||||
<div class="help-tooltip-header">
|
||||
<h5>{{ title }}</h5>
|
||||
<h5 class="has-text-color">{{ title }}</h5>
|
||||
</div>
|
||||
<div class="help-tooltip-body">
|
||||
<p v-html="(message != '' && message != undefined) ? message : $i18n.get('info_no_description_provided')"/>
|
||||
|
@ -49,8 +49,7 @@ export default {
|
|||
}
|
||||
.help-tooltip {
|
||||
z-index: 99999999999999999999;
|
||||
color: var(--tainacan-turquoise5);
|
||||
background-color: var(--tainacan-turquoise2);
|
||||
background-color: var(--tainacan-primary);
|
||||
border: none;
|
||||
display: block;
|
||||
border-radius: 5px;
|
||||
|
@ -70,6 +69,8 @@ export default {
|
|||
h5 {
|
||||
font-size: 0.875em;
|
||||
font-weight: bold;
|
||||
color: var(--tainacan-secondary);
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,11 +78,13 @@ export default {
|
|||
padding: 0.5em 1.0em 1.0em 1.0em;
|
||||
|
||||
p {
|
||||
margin: 0 0 0.125em 0;
|
||||
font-size: 0.875em !important;
|
||||
font-weight: normal !important;
|
||||
white-space: normal !important;
|
||||
overflow: visible !important;
|
||||
max-height: 100% !important;
|
||||
color: var(--tainacan-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +98,7 @@ export default {
|
|||
border-style: solid;
|
||||
}
|
||||
&:before {
|
||||
border-color: var(--tainacan-turquoise2) transparent transparent transparent;
|
||||
border-color: var(--tainacan-primary) transparent transparent transparent;
|
||||
border-right-width: 15px;
|
||||
border-top-width: 12px;
|
||||
border-left-width: 15px;
|
||||
|
|
|
@ -13,16 +13,23 @@
|
|||
</div>
|
||||
<div class="help-tooltip-body">
|
||||
<ol>
|
||||
<li
|
||||
v-for="(error, index) of formErrors"
|
||||
:key="index">
|
||||
<a
|
||||
v-if="metadataElements[error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : '')]"
|
||||
@click="metadataElements[error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : '')].scrollIntoView({ behavior: 'smooth', block: 'center' })">
|
||||
{{ getErrorMessage(error.errors) }}
|
||||
</a>
|
||||
<p v-else>{{ getErrorMessage(error.errors) }}</p>
|
||||
</li>
|
||||
<template v-for="(error, index) of formErrors">
|
||||
<li
|
||||
v-if="error.errors.length"
|
||||
:key="index">
|
||||
<a
|
||||
v-if="['thumbnail', 'attachments', 'document'].includes(error.metadatum_id)"
|
||||
@click="metadataElements[error.metadatum_id].scrollIntoView({ behavior: 'smooth', block: 'center' })">
|
||||
{{ getErrorMessage(error.errors) }}
|
||||
</a>
|
||||
<a
|
||||
v-else-if="metadataElements[error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : '')]"
|
||||
@click="metadataElements[error.metadatum_id + (error.parent_meta_id ? ('_parent_meta_id-' + error.parent_meta_id) : '')].scrollIntoView({ behavior: 'smooth', block: 'center' })">
|
||||
{{ getErrorMessage(error.errors) }}
|
||||
</a>
|
||||
<p v-else>{{ getErrorMessage(error.errors) }}</p>
|
||||
</li>
|
||||
</template>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -43,9 +50,13 @@ export default {
|
|||
methods: {
|
||||
getErrorMessage(errors) {
|
||||
let metadatumErrorMessage = '';
|
||||
for (let singleError of errors) {
|
||||
for (let index of Object.keys(singleError))
|
||||
metadatumErrorMessage += singleError[index] + '\n';
|
||||
for (let singleError of errors) {
|
||||
if (typeof singleError != 'string') {
|
||||
for (let index of Object.keys(singleError))
|
||||
metadatumErrorMessage += singleError[index] + '\n';
|
||||
} else {
|
||||
metadatumErrorMessage += singleError;
|
||||
}
|
||||
}
|
||||
return metadatumErrorMessage;
|
||||
},
|
||||
|
@ -99,6 +110,7 @@ export default {
|
|||
h5 {
|
||||
font-size: 0.875em;
|
||||
font-weight: bold;
|
||||
color: var(--tainacan-red2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,15 +123,21 @@ export default {
|
|||
font-weight: normal !important;
|
||||
white-space: normal !important;
|
||||
overflow: visible !important;
|
||||
color: var(--tainacan-red2) !important;
|
||||
}
|
||||
a {
|
||||
color: var(--tainacan-red2);
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:hover {
|
||||
color: var(--tainacan-red2) !important;
|
||||
}
|
||||
ol, ul {
|
||||
margin: 4px 4px;
|
||||
padding-left: 16px;
|
||||
}
|
||||
li {
|
||||
line-height: 0.875em;
|
||||
}
|
||||
}
|
||||
&:before {
|
||||
content: "";
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<div
|
||||
class="is-inline-flex"
|
||||
v-if="filterTags != undefined && filterTags.length > 0">
|
||||
<p style="margin-bottom: 0;"><strong>{{ totalItems }}</strong>{{ ' itens encontrados, ' }}<strong>{{ filterTags.length }}</strong>{{ ' filtros aplicados: ' }} </p>
|
||||
<b-tag
|
||||
v-for="(filterTag, index) of filterTags"
|
||||
:key="index"
|
||||
|
@ -39,11 +40,15 @@
|
|||
}
|
||||
}
|
||||
return flattenTags;
|
||||
},
|
||||
totalItems() {
|
||||
return this.getTotalItems()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapGetters('search',[
|
||||
'getFilterTags'
|
||||
'getFilterTags',
|
||||
'getTotalItems'
|
||||
]),
|
||||
removeMetaQuery({ filterId, value, singleLabel, label, taxonomy, metadatumId }) {
|
||||
this.$eventBusSearch.resetPageOnStore();
|
||||
|
@ -80,6 +85,7 @@
|
|||
&.is-inline-flex {
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-start;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
#button-clear-all {
|
||||
|
|
|
@ -98,4 +98,4 @@ export const CancelToken = axios.CancelToken;
|
|||
export const isCancel = axios.isCancel;
|
||||
export const all = axios.all;
|
||||
|
||||
export default { tainacan, wp, CancelToken, isCancel, all };
|
||||
export default { tainacan, wp, CancelToken, isCancel, all};
|
|
@ -8,10 +8,12 @@ export const eventBusItemMetadata = new Vue({
|
|||
},
|
||||
watch: {
|
||||
errors() {
|
||||
this.$emit('hasErrorsOnForm', this.errors.length > 0);
|
||||
this.$emit('hasErrorsOnForm', this.errors.length > 0 && this.errors[0].errors && this.errors[0].errors.length);
|
||||
|
||||
for (let error of this.errors)
|
||||
this.$emit('updateErrorMessageOf#' + (error.metadatum_id + (error.parent_meta_id ? '-' + error.parent_meta_id : '')), error);
|
||||
if (this.errors.length > 0 && this.errors[0].errors && this.errors[0].errors.length) {
|
||||
for (let error of this.errors)
|
||||
this.$emit('updateErrorMessageOf#' + (error.metadatum_id + (error.parent_meta_id ? '-' + error.parent_meta_id : '')), error);
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -23,7 +25,7 @@ export const eventBusItemMetadata = new Vue({
|
|||
this.$on('remove_group', this.removeItemMetadataGroup);
|
||||
},
|
||||
methods : {
|
||||
updateValue({ itemId, metadatumId, values, parentMetaId }){
|
||||
updateValue({ itemId, metadatumId, values, parentMetaId, parentId }){
|
||||
|
||||
if (itemId) {
|
||||
|
||||
|
@ -65,9 +67,37 @@ export const eventBusItemMetadata = new Vue({
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
// If no itemId is provided, we are probably on an item Submission flow
|
||||
} else {
|
||||
|
||||
if (values.length > 0 && values[0] != undefined && values[0].value) {
|
||||
let onlyValues = values.map((aValueObject) => aValueObject.value);
|
||||
values = JSON.parse(JSON.stringify(onlyValues));
|
||||
}
|
||||
|
||||
this.$store.dispatch('item/updateItemSubmissionMetadatum', {
|
||||
metadatum_id: metadatumId,
|
||||
values: Array.isArray(values[0]) ? values[0] : values,
|
||||
child_group_index: parentMetaId,
|
||||
parent_id: parentId
|
||||
});
|
||||
|
||||
let index = this.errors.findIndex( errorItem => errorItem.metadatum_id == metadatumId && (parentMetaId ? errorItem.parent_meta_id == parentMetaId : true ));
|
||||
let messages = [];
|
||||
|
||||
if ( index >= 0) {
|
||||
Vue.set( this.errors, index, { metadatum_id: metadatumId, parent_meta_id: parentMetaId, errors: messages });
|
||||
this.$emit('updateErrorMessageOf#' + (parentMetaId ? metadatumId + '-' + parentMetaId : metadatumId), this.errors[index]);
|
||||
} else {
|
||||
this.errors.push( { metadatum_id: metadatumId, parent_meta_id: parentMetaId, errors: messages } );
|
||||
this.$emit('updateErrorMessageOf#' + (parentMetaId ? metadatumId + '-' + parentMetaId : metadatumId), this.errors[0]);
|
||||
}
|
||||
|
||||
this.$emit('isUpdatingValue', false);
|
||||
}
|
||||
},
|
||||
removeItemMetadataGroup({ itemId, metadatumId, parentMetaId }) {
|
||||
removeItemMetadataGroup({ itemId, metadatumId, parentMetaId, parentMetadatum }) {
|
||||
|
||||
this.$emit('isUpdatingValue', true);
|
||||
|
||||
|
@ -79,10 +109,21 @@ export const eventBusItemMetadata = new Vue({
|
|||
parent_meta_id: parentMetaId
|
||||
})
|
||||
.then((res) => {
|
||||
this.$emit('hasRemovedItemMetadataGroup', res)
|
||||
this.$emit('hasRemovedItemMetadataGroup', res);
|
||||
this.$emit('isUpdatingValue', false);
|
||||
})
|
||||
.catch(() => this.$emit('isUpdatingValue', false));
|
||||
|
||||
// Item sbmission logic
|
||||
} else if (!itemId) {
|
||||
|
||||
this.$store.dispatch('item/deleteGroupFromItemSubmissionMetadatum', {
|
||||
metadatum_id: metadatumId,
|
||||
child_group_index: parentMetaId
|
||||
});
|
||||
|
||||
this.$emit('hasRemovedItemMetadataGroup', true);
|
||||
this.$emit('isUpdatingValue', false);
|
||||
}
|
||||
},
|
||||
clearAllErrors() {
|
||||
|
|
|
@ -133,7 +133,9 @@ export default {
|
|||
this.$userPrefs.set(viewModeKey, 'table');
|
||||
}
|
||||
}
|
||||
if (this.$route.query.view_mode != ['slideshow'] && this.$route.query['slideshow-from'] != null && this.$route.query['slideshow-from'] != undefined && this.$route.query['slideshow-from'] != false)
|
||||
|
||||
// Emit slideshow-from to start this view mode from index
|
||||
if (this.$route.query.view_mode != 'slideshow' && this.$route.query['slideshow-from'] !== null && this.$route.query['slideshow-from'] !== undefined && this.$route.query['slideshow-from'] !== false)
|
||||
this.$emit('start-slideshow-from-item', this.$route.query['slideshow-from']);
|
||||
|
||||
// Admin View Modes
|
||||
|
|
|
@ -77,7 +77,7 @@ export const dynamicFilterTypeMixin = {
|
|||
|
||||
let url = '';
|
||||
|
||||
if (isRepositoryLevel)
|
||||
if (isRepositoryLevel || this.filter.collection_id == 'default')
|
||||
url = `/facets/${metadatumId}?getSelected=${getSelected}&`;
|
||||
else {
|
||||
if (this.filter.collection_id == 'default' && this.currentCollectionId)
|
||||
|
@ -161,7 +161,7 @@ export const dynamicFilterTypeMixin = {
|
|||
|
||||
let url = '';
|
||||
|
||||
if (isRepositoryLevel)
|
||||
if (isRepositoryLevel || this.filter.collection_id == 'default')
|
||||
url = `/facets/${this.filter.metadatum.metadatum_id}?getSelected=${getSelected}&`;
|
||||
else {
|
||||
if (this.filter.collection_id == 'default' && this.currentCollectionId)
|
||||
|
|
|
@ -38,6 +38,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
|||
if (postQueries.advancedSearch)
|
||||
advancedSearchResults = postQueries.advancedSearch;
|
||||
}
|
||||
|
||||
let query = qs.stringify(postQueries);
|
||||
|
||||
// Guarantees at least empty fetch_only are passed in case none is found
|
||||
|
@ -229,6 +230,19 @@ export const fetchCollectionForExposer = ({ commit }, collectionId) => {
|
|||
});
|
||||
};
|
||||
|
||||
export const fetchCollectionForItemSubmission = ({ commit }, collectionId) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let endpoint = '/collections/' + collectionId + '?fetch_only=name,allows_submission,submission_use_recaptcha';
|
||||
axios.tainacan.get(endpoint)
|
||||
.then(res => {
|
||||
resolve( res.data );
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteCollection = ({ commit }, { collectionId, isPermanently }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let endpoint = '/collections/' + collectionId;
|
||||
|
@ -412,9 +426,9 @@ export const fetchAllCollectionNames = ({ commit }, collectionsIds) => {
|
|||
};
|
||||
|
||||
// Send Files to Item Bulk Addition
|
||||
export const sendFile = ( { commit }, file ) => {
|
||||
export const sendFile = ( { commit }, {itemId, file } ) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
axios.wp.post('/media/', file, {
|
||||
axios.wp.post('/media/?post=' + itemId, file, {
|
||||
headers: { 'Content-Disposition': 'attachment; filename=' + file.name },
|
||||
})
|
||||
.then( res => {
|
||||
|
|
|
@ -279,7 +279,7 @@ export const fetchAttachments = ({ commit }, { page, attachmentsPerPage, itemId,
|
|||
});
|
||||
};
|
||||
|
||||
export const updateThumbnail = ({ commit }, { itemId, thumbnailId }) => {
|
||||
export const updateThumbnail = ({ commit }, { itemId, thumbnailId, thumbnailAlt }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.patch('/items/' + itemId, {
|
||||
_thumbnail_id: thumbnailId
|
||||
|
@ -293,4 +293,98 @@ export const updateThumbnail = ({ commit }, { itemId, thumbnailId }) => {
|
|||
});
|
||||
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const updateThumbnailAlt = ({ commit }, { thumbnailId, thumbnailAlt }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.wp.patch('/media/' + thumbnailId + '?force=true', {
|
||||
alt_text: thumbnailAlt
|
||||
}).then( res => {
|
||||
let thumbnail = res.data;
|
||||
commit('setLastUpdated');
|
||||
resolve( thumbnail );
|
||||
}).catch( error => {
|
||||
reject( error );
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
// Item Submission ======================================================
|
||||
export const clearItemSubmission = ({ commit }) => {
|
||||
commit('clearItemSubmission');
|
||||
}
|
||||
|
||||
export const setItemSubmission = ({ commit }, value) => {
|
||||
commit('setItemSubmission', value);
|
||||
}
|
||||
|
||||
export const setItemSubmissionMetadata = ({ commit }, value) => {
|
||||
commit('setItemSubmissionMetadata', value);
|
||||
}
|
||||
|
||||
export const updateItemSubmission = ({ commit }, { key, value }) => {
|
||||
commit('updateItemSubmission', { key: key, value: value });
|
||||
}
|
||||
|
||||
export const updateItemSubmissionMetadatum = ({ commit }, { metadatum_id, values, child_group_index, parent_id }) => {
|
||||
commit('updateItemSubmissionMetadatum', { metadatum_id: metadatum_id, values: values, child_group_index: child_group_index, parent_id: parent_id });
|
||||
}
|
||||
|
||||
export const deleteGroupFromItemSubmissionMetadatum = ({ commit }, { metadatum_id, child_group_index }) => {
|
||||
commit('deleteGroupFromItemSubmissionMetadatum', { metadatum_id: metadatum_id, child_group_index: child_group_index });
|
||||
}
|
||||
|
||||
export const submitItemSubmission = ({ commit }, { itemSubmission, itemSubmissionMetadata, captchaResponse }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
let item = JSON.parse(JSON.stringify(itemSubmission)); // Use a copy as the next request will need document, attchment and thumbnail
|
||||
|
||||
for (let key of Object.keys(item)) {
|
||||
if (['attachments', 'thumbnail'].includes(key) )
|
||||
delete item[key];
|
||||
else if (key === 'document' && itemSubmission.document_type === 'attachment' )
|
||||
delete item[key];
|
||||
}
|
||||
|
||||
if (captchaResponse)
|
||||
item['g-recaptcha-response'] = captchaResponse;
|
||||
|
||||
axios.tainacan.post('/collection/' + itemSubmission.collection_id + '/items/submission', {...item, metadata: itemSubmissionMetadata } )
|
||||
.then( res => {
|
||||
resolve( res.data.id );
|
||||
}).catch( error => {
|
||||
reject({
|
||||
errors: error.response.data.errors,
|
||||
error_message: error.response.data.error_message
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const finishItemSubmission = ({ commit }, { itemSubmission, fakeItemId }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let config = {
|
||||
headers: { 'content-type': 'multipart/form-data' }
|
||||
}
|
||||
const formData = new FormData();
|
||||
|
||||
for (let key of Object.keys(itemSubmission)) {
|
||||
if (key === 'thumbnail' || (key === 'document' && itemSubmission.document_type === 'attachment') )
|
||||
formData.append(key, itemSubmission[key]);
|
||||
else if (key === 'attachments') {
|
||||
for (let i = 0; i < itemSubmission[key].length; i++)
|
||||
formData.append(key + '[' + i + ']', itemSubmission[key][i]);
|
||||
}
|
||||
}
|
||||
axios.tainacan.post('/collection/' + itemSubmission.collection_id + '/items/submission/' + fakeItemId + '/finish', formData, config )
|
||||
.then( res => {
|
||||
resolve( res.data );
|
||||
}).catch( error => {
|
||||
reject({
|
||||
errors: error.response.data.errors,
|
||||
error_message: error.response.data.error_message
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
|
@ -21,3 +21,11 @@ export const getAttachments = state => {
|
|||
export const getTotalAttachments = state => {
|
||||
return state.totalAttachments;
|
||||
}
|
||||
|
||||
export const getItemSubmission = state => {
|
||||
return state.itemSubmission;
|
||||
}
|
||||
|
||||
export const getItemSubmissionMetadata = state => {
|
||||
return state.itemSubmissionMetadata;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ const state = {
|
|||
attachments: [],
|
||||
lastUpdated: '',
|
||||
comment_status: '',
|
||||
totalAttachments: 0
|
||||
totalAttachments: 0,
|
||||
itemSubmission: {},
|
||||
itemSubmissionMetadata: []
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -147,3 +147,66 @@ export const setLastUpdated = (state, value) => {
|
|||
}
|
||||
}
|
||||
|
||||
export const clearItemSubmission = (state) => {
|
||||
state.itemSubmission = {};
|
||||
}
|
||||
|
||||
export const setItemSubmission = (state, value) => {
|
||||
state.itemSubmission = value;
|
||||
}
|
||||
|
||||
export const setItemSubmissionMetadata = (state, value) => {
|
||||
state.itemSubmissionMetadata = value;
|
||||
}
|
||||
|
||||
export const updateItemSubmission = (state, { key, value }) => {
|
||||
Vue.set(state.itemSubmission, key, value);
|
||||
}
|
||||
|
||||
export const updateItemSubmissionMetadatum = (state, { metadatum_id, values, child_group_index, parent_id }) => {
|
||||
|
||||
let metadata = Array.isArray(state.itemSubmissionMetadata) ? state.itemSubmissionMetadata : [];
|
||||
|
||||
if (parent_id && parent_id > 0) {
|
||||
let existingParentMetadatumIndex = metadata.findIndex((metadatum) => metadatum.metadatum_id == parent_id);
|
||||
|
||||
if (existingParentMetadatumIndex >= 0) {
|
||||
if (metadata[existingParentMetadatumIndex].value && metadata[existingParentMetadatumIndex].value[child_group_index]) {
|
||||
let existingMetadatumIndex = metadata[existingParentMetadatumIndex].value[child_group_index].findIndex((metadatum) => metadatum.metadatum_id == metadatum_id);
|
||||
|
||||
if (existingMetadatumIndex >= 0)
|
||||
metadata[existingParentMetadatumIndex].value[child_group_index][existingMetadatumIndex].value = values;
|
||||
else
|
||||
metadata[existingParentMetadatumIndex].value[child_group_index].push({ metadatum_id: metadatum_id, value: values });
|
||||
} else {
|
||||
metadata[existingParentMetadatumIndex].value = (metadata[existingParentMetadatumIndex].value ? metadata[existingParentMetadatumIndex].value : []);
|
||||
metadata[existingParentMetadatumIndex].value.push([ { metadatum_id: metadatum_id, value: values } ])
|
||||
}
|
||||
} else {
|
||||
metadata.push({ metadatum_id: parent_id, value: [ [ { metadatum_id: metadatum_id, value: values } ] ] });
|
||||
}
|
||||
} else {
|
||||
let existingMetadatumIndex = metadata.findIndex((metadatum) => metadatum.metadatum_id == metadatum_id);
|
||||
|
||||
if (existingMetadatumIndex >= 0)
|
||||
metadata[existingMetadatumIndex].value = values;
|
||||
else
|
||||
metadata.push({ metadatum_id: metadatum_id, value: values });
|
||||
}
|
||||
Vue.set(state, 'itemSubmissionMetadata', metadata);
|
||||
}
|
||||
|
||||
export const deleteGroupFromItemSubmissionMetadatum = (state, { metadatum_id, child_group_index }) => {
|
||||
|
||||
let existingMetadatumIndex = state.itemSubmissionMetadata.findIndex((metadatum) => metadatum.metadatum_id == metadatum_id);
|
||||
|
||||
if (existingMetadatumIndex >= 0) {
|
||||
if (state.itemSubmissionMetadata[existingMetadatumIndex].value[child_group_index]) {
|
||||
let existingMetadatum = state.itemSubmissionMetadata[existingMetadatumIndex];
|
||||
let existingMetadatumValue = existingMetadatum.value;
|
||||
existingMetadatumValue.splice(child_group_index, 1);
|
||||
existingMetadatum.value = existingMetadatumValue;
|
||||
Vue.set(state.itemSubmissionMetadata, existingMetadatumIndex, existingMetadatum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ export const set_postquery = ({ commit }, postquery ) => {
|
|||
|
||||
export const set_advanced_query = ({commit}, advancedSearchQuery) => {
|
||||
commit('removePostQueryAttribute', 'search');
|
||||
commit('removePostQueryAttribute', 's');
|
||||
commit('setAdvancedSearchQuery', advancedSearchQuery);
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ export const getOrderBy = state => {
|
|||
};
|
||||
|
||||
export const getSearchQuery = state => {
|
||||
return state.postquery.search;
|
||||
return state.postquery.search || state.postquery.s;
|
||||
};
|
||||
|
||||
export const getStatus = state => {
|
||||
|
|
|
@ -134,11 +134,13 @@ export const setItemsPerPage = ( state, itemsPerPage ) => {
|
|||
|
||||
export const setSearchQuery = ( state, searchQuery ) => {
|
||||
|
||||
if (searchQuery != '') {
|
||||
if (searchQuery != '')
|
||||
state.postquery.search = searchQuery;
|
||||
} else {
|
||||
else
|
||||
delete state.postquery.search;
|
||||
}
|
||||
|
||||
// In case a s parameter was passed
|
||||
delete state.postquery.s;
|
||||
};
|
||||
|
||||
export const setStatus = ( state, status ) => {
|
||||
|
|
|
@ -1,203 +1,4 @@
|
|||
export default {
|
||||
// customAttachmentsControl: class customAttachmentsControl {
|
||||
|
||||
// constructor(props) {
|
||||
// this.props = props;
|
||||
|
||||
// this.buildAndSetGalleryFrame();
|
||||
// }
|
||||
|
||||
// getGalleryDetailsMediaFrame() {
|
||||
// /**
|
||||
// * Custom gallery details frame.
|
||||
// *
|
||||
// * @see https://github.com/xwp/wp-core-media-widgets/blob/905edbccfc2a623b73a93dac803c5335519d7837/wp-admin/js/widgets/media-gallery-widget.js
|
||||
// * @class GalleryDetailsMediaFrame
|
||||
// * @class
|
||||
// */
|
||||
// return wp.media.view.MediaFrame.Post.extend( {
|
||||
// /**
|
||||
// * Set up gallery toolbar.
|
||||
// *
|
||||
// * @return {void}
|
||||
// */
|
||||
// galleryToolbar() {
|
||||
// const editing = this.state().get( 'editing' );
|
||||
// this.toolbar.set(
|
||||
// new wp.media.view.Toolbar( {
|
||||
// controller: this,
|
||||
// items: {
|
||||
// insert: {
|
||||
// style: 'primary',
|
||||
// text: editing
|
||||
// ? wp.media.view.l10n.updateGallery
|
||||
// : wp.media.view.l10n.insertGallery,
|
||||
// priority: 80,
|
||||
// requires: { library: true },
|
||||
|
||||
// /**
|
||||
// * @fires wp.media.controller.State#update
|
||||
// */
|
||||
// click() {
|
||||
// const controller = this.controller,
|
||||
// state = controller.state();
|
||||
|
||||
// controller.close();
|
||||
// state.trigger(
|
||||
// 'update',
|
||||
// state.get( 'library' )
|
||||
// );
|
||||
|
||||
// // Restore and reset the default state.
|
||||
// controller.setState( controller.options.state );
|
||||
// controller.reset();
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// } )
|
||||
// );
|
||||
// },
|
||||
|
||||
// /**
|
||||
// * Create the default states.
|
||||
// *
|
||||
// * @return {void}
|
||||
// */
|
||||
// createStates: function createStates() {
|
||||
// this.on( 'toolbar:create:main-gallery', this.galleryToolbar, this );
|
||||
|
||||
// this.states.add( [
|
||||
// new wp.media.controller.Library( {
|
||||
// id: 'gallery',
|
||||
// title: wp.media.view.l10n.createGalleryTitle,
|
||||
// priority: 40,
|
||||
// toolbar: 'main-gallery',
|
||||
// filterable: 'unattached',
|
||||
// multiple: 'add',
|
||||
// editable: false,
|
||||
// menu: 'gallery',
|
||||
// describe: true,
|
||||
// autoSelect: true,
|
||||
// syncSelection: false,
|
||||
// selection: this.options.selection,
|
||||
// library: wp.media.query( {
|
||||
// uploadedTo: wp.media.model.settings.post.id,
|
||||
// orderby: 'menuOrder',
|
||||
// order: 'ASC',
|
||||
// posts_per_page: -1,
|
||||
// query: true
|
||||
// } ),
|
||||
// } ),
|
||||
// new wp.media.controller.GalleryEdit( {
|
||||
// library: wp.media.query( {
|
||||
// uploadedTo: wp.media.model.settings.post.id,
|
||||
// orderby: 'menuOrder',
|
||||
// order: 'ASC',
|
||||
// posts_per_page: -1,
|
||||
// query: true
|
||||
// } ),
|
||||
// selection: this.options.selection,
|
||||
// editing: this.options.editing,
|
||||
// menu: 'gallery',
|
||||
// displaySettings: false,
|
||||
// multiple: true,
|
||||
// filterable: 'unattached'
|
||||
// } )
|
||||
// ] );
|
||||
// },
|
||||
// } );
|
||||
// };
|
||||
|
||||
// getAttachmentsCollection() {
|
||||
// return wp.media.query( {
|
||||
// uploadedTo: wp.media.model.settings.post.id,
|
||||
// orderby: 'menuOrder',
|
||||
// order: 'ASC',
|
||||
// posts_per_page: -1,
|
||||
// query: true
|
||||
// } );
|
||||
// };
|
||||
|
||||
// /**
|
||||
// * Sets the Gallery frame and initializes listeners.
|
||||
// *
|
||||
// * @return {void}
|
||||
// */
|
||||
// buildAndSetGalleryFrame() {
|
||||
|
||||
// // If a frame already existed remove it.
|
||||
// if ( this.frame )
|
||||
// this.frame.remove();
|
||||
|
||||
// if ( ! this.GalleryDetailsMediaFrame )
|
||||
// this.GalleryDetailsMediaFrame = this.getGalleryDetailsMediaFrame();
|
||||
|
||||
// const attachments = this.getAttachmentsCollection( );
|
||||
// const selection = new wp.media.model.Selection( attachments.models, {
|
||||
// props: attachments.props.toJSON(),
|
||||
// multiple: true,
|
||||
// } );
|
||||
|
||||
// this.frame = new this.GalleryDetailsMediaFrame( {
|
||||
// state: this.props.existingAttachments && this.props.existingAttachments.length ? 'gallery-edit' : 'gallery',
|
||||
// multiple: true,
|
||||
// selection: selection,
|
||||
// editing: this.props.existingAttachments && this.props.existingAttachments.length ? true : false,
|
||||
// } );
|
||||
// wp.media.frame = this.frame;
|
||||
|
||||
// this.frame.on( 'select', (selected) => this.onSelect(selected));
|
||||
// this.frame.on( 'update', (selected) => this.onUpdate(selected));
|
||||
// this.frame.on( 'onclose', () => this.onClose() );
|
||||
// }
|
||||
|
||||
// onUpdate( selections ) {
|
||||
// const state = this.frame.state();
|
||||
// const selectedImages = selections || state.get( 'selection' );
|
||||
|
||||
// if ( ! selectedImages || ! selectedImages.models.length )
|
||||
// return;
|
||||
|
||||
// this.props.onSelect( selectedImages.models.map( ( model ) => model.toJSON() ));
|
||||
// }
|
||||
|
||||
// onSelect() {
|
||||
// // Get media attachment details from the frame state
|
||||
// const attachments = this.frame.state().get( 'selection' ).toJSON();
|
||||
// this.props.onSelect( attachments );
|
||||
// }
|
||||
|
||||
// onClose() {
|
||||
// const { onClose } = this.props;
|
||||
|
||||
// if ( onClose )
|
||||
// onClose();
|
||||
// }
|
||||
|
||||
// openModal() {
|
||||
// this.buildAndSetGalleryFrame();
|
||||
|
||||
// const frameContent = this.frame.content.get();
|
||||
// if ( frameContent && frameContent.collection ) {
|
||||
// const collection = frameContent.collection;
|
||||
|
||||
// // clean all attachments we have in memory.
|
||||
// collection
|
||||
// .toArray()
|
||||
// .forEach( ( model ) => model.trigger( 'destroy', model ) );
|
||||
|
||||
// // reset has more flag, if library had small amount of items all items may have been loaded before.
|
||||
// collection.mirroring._hasMore = true;
|
||||
|
||||
// // request items
|
||||
// collection.more();
|
||||
// }
|
||||
// // load the images so they are available in the media modal.
|
||||
// this.getAttachmentsCollection().more();
|
||||
|
||||
// this.frame.open();
|
||||
// }
|
||||
// },
|
||||
export default {
|
||||
|
||||
attachmentControl: wp.customize.MediaControl.extend({
|
||||
|
||||
|
@ -247,8 +48,10 @@ export default {
|
|||
|
||||
wp.media.view.settings.post = {
|
||||
id: parseInt(this.params.relatedPostId),
|
||||
wp_customize: 'off'
|
||||
wp_customize: 'off',
|
||||
}
|
||||
wp.media.model.settings.post.nonce = this.params.nonce;
|
||||
wp.media.model.settings.post.id = parseInt(this.params.relatedPostId);
|
||||
|
||||
this.frame = wp.media({
|
||||
states: [
|
||||
|
@ -268,19 +71,26 @@ export default {
|
|||
})
|
||||
]
|
||||
});
|
||||
|
||||
this.frame.$el.addClass( 'tainacan-item-attachments-modal' );
|
||||
|
||||
this.frame.on( 'toolbar:create:main-gallery', this.galleryToolbar, this.frame );
|
||||
|
||||
this.frame.$el.addClass( 'tainacan-item-attachments-modal' );
|
||||
this.frame.$el['tainacan-document-id'] = this.params.document;
|
||||
|
||||
wp.media.view.Attachment.Library = wp.media.view.Attachment.Library.extend({
|
||||
className: function() {
|
||||
return 'attachment ' + ((this.controller.$el['tainacan-document-id'] && (this.model.get('id') == this.controller.$el['tainacan-document-id'])) ? 'tainacan-document-attachment' : '');
|
||||
}
|
||||
});
|
||||
|
||||
this.frame.on( 'select', () => {
|
||||
// Get the attachment from the modal frame.
|
||||
var attachments = this.frame.state().get( 'selection' ).toJSON();
|
||||
|
||||
|
||||
wp.media.view.settings.post.id = {
|
||||
id: this.params.relatedPostId
|
||||
}
|
||||
|
||||
|
||||
this.params.attachments = attachments;
|
||||
this.params.onSave(attachments);
|
||||
});
|
||||
|
@ -292,7 +102,7 @@ export default {
|
|||
|
||||
initFrame: function() {
|
||||
|
||||
var l10n = _wpMediaViewsL10n;
|
||||
var l10n = wp.media.view.l10n = typeof _wpMediaViewsL10n === 'undefined' ? {} : _wpMediaViewsL10n;
|
||||
|
||||
// Same of WordPress wp.media.controller.CustomizeImageCropper, but without `wp_customize: on`
|
||||
var customImageCropper = wp.media.controller.Cropper.extend({
|
||||
|
@ -346,9 +156,9 @@ export default {
|
|||
title: this.params.button_labels.frame_title,
|
||||
library: wp.media.query({
|
||||
type: 'image',
|
||||
uploadedTo: null
|
||||
}),
|
||||
multiple: false,
|
||||
autoSelect: true,
|
||||
date: false,
|
||||
priority: 20,
|
||||
suggestedWidth: this.params.width,
|
||||
|
@ -368,10 +178,10 @@ export default {
|
|||
},
|
||||
// Called on both skippedcrop and cropped states
|
||||
setImageFromAttachment: function( attachment ) {
|
||||
wp.media.view.settings.post = {
|
||||
wp.media.view.settings.post.id = {
|
||||
id: this.params.relatedPostId
|
||||
}
|
||||
this.params.attachment = attachment;
|
||||
this.params.attachments = attachment;
|
||||
this.params.onSave(attachment);
|
||||
}
|
||||
|
||||
|
@ -381,7 +191,7 @@ export default {
|
|||
|
||||
initFrame: function() {
|
||||
|
||||
var l10n = _wpMediaViewsL10n;
|
||||
var l10n = wp.media.view.l10n = typeof _wpMediaViewsL10n === 'undefined' ? {} : _wpMediaViewsL10n;
|
||||
|
||||
// Same of WordPress wp.media.controller.CustomizeImageCropper, but without `wp_customize: on`
|
||||
var customImageCropper = wp.media.controller.Cropper.extend({
|
||||
|
|
|
@ -328,7 +328,8 @@
|
|||
:class="{'tainacan-icon-viewtable' : ( adminViewMode == 'table' || adminViewMode == undefined),
|
||||
'tainacan-icon-viewcards' : adminViewMode == 'cards',
|
||||
'tainacan-icon-viewminiature' : adminViewMode == 'grid',
|
||||
'tainacan-icon-viewrecords' : adminViewMode == 'records' || adminViewMode == 'list',
|
||||
'tainacan-icon-viewrecords' : adminViewMode == 'records',
|
||||
'tainacan-icon-viewlist' : adminViewMode == 'list',
|
||||
'tainacan-icon-viewmasonry' : adminViewMode == 'masonry' }"
|
||||
class="tainacan-icon tainacan-icon-1-25em"/>
|
||||
</span>
|
||||
|
@ -402,7 +403,7 @@
|
|||
:value="'list'"
|
||||
aria-role="listitem">
|
||||
<span class="icon gray-icon">
|
||||
<i class="tainacan-icon tainacan-icon-viewrecords"/>
|
||||
<i class="tainacan-icon tainacan-icon-viewlist"/>
|
||||
</span>
|
||||
<span>{{ $i18n.get('label_list') }}</span>
|
||||
</b-dropdown-item>
|
||||
|
@ -890,14 +891,15 @@
|
|||
trapFocus: true
|
||||
});
|
||||
},
|
||||
openExposersModal() {
|
||||
openExposersModal(selectedItems) {
|
||||
this.$buefy.modal.open({
|
||||
parent: this,
|
||||
component: ExposersModal,
|
||||
hasModalCard: true,
|
||||
props: {
|
||||
collectionId: this.collectionId,
|
||||
totalItems: this.totalItems
|
||||
totalItems: this.totalItems,
|
||||
selectedItems: selectedItems
|
||||
},
|
||||
trapFocus: true
|
||||
})
|
||||
|
|
|
@ -92,6 +92,16 @@
|
|||
:src="thumbPlaceholderPath">
|
||||
</figure>
|
||||
</div>
|
||||
<br>
|
||||
<div
|
||||
v-if="item.thumbnail_id"
|
||||
class="thumbnail-alt-input">
|
||||
<label class="label">{{ $i18n.get('label_thumbnail_alt') }}</label>
|
||||
<help-button
|
||||
:title="$i18n.get('label_thumbnail_alt')"
|
||||
:message="$i18n.get('info_thumbnail_alt')"/>
|
||||
<p> {{ item.thumbnail_alt }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
|
@ -213,7 +223,7 @@
|
|||
class="content">
|
||||
<component
|
||||
:is="itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound' ? 'div' : 'p'"
|
||||
v-html="itemMetadatum.value_as_html != '' ? itemMetadatum.value_as_html : `<p><span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_informed') + `</span></p>`"/>
|
||||
v-html="itemMetadatum.value_as_html != '' ? itemMetadatum.value_as_html : `<p><span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_provided') + `</span></p>`"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -37,7 +37,7 @@ button.link-style:active {
|
|||
color: var(--tainacan-white) !important;
|
||||
}
|
||||
&.is-primary, &:hover, &.is-primary:focus {
|
||||
background: var(--tainacan-turquoise2) !important;
|
||||
background: var(--tainacan-primary) !important;
|
||||
color: var(--tainacan-white) !important;
|
||||
}
|
||||
&.is-success, &.is-success:hover, &.is-success:focus {
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
|
||||
#tainacan-admin-app,
|
||||
.theme-items-list,
|
||||
.tainacan-item-submission-form,
|
||||
.tainacan-modal-content {
|
||||
|
||||
// Some Bulma classes will work with SASS but not with CSS variables
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
&.is-active { background-color: var(--tainacan-primary); }
|
||||
|
||||
.media {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.media-left {
|
||||
|
@ -130,9 +131,6 @@
|
|||
margin-bottom: 0px !important;
|
||||
text-overflow: ellipsis;
|
||||
background-color: var(--tainacan-input-background-color);
|
||||
&:hover {
|
||||
border: none !important;
|
||||
}
|
||||
}
|
||||
.input.has-selected, .input:focus, .input:active {
|
||||
background-color: var(--tainacan-input-background-color);
|
||||
|
|
|
@ -29,6 +29,10 @@ input[type="week"].input {
|
|||
padding-bottom: calc(0.57em - 1px);
|
||||
transition: background-color 0.1s ease, border-color 0.3s ease;
|
||||
|
||||
&.is-danger {
|
||||
border: 1px solid var(--tainacan-danger);
|
||||
}
|
||||
|
||||
&:focus, &:active {
|
||||
box-shadow: none !important;
|
||||
background-color: var(--tainacan-input-background-color);
|
||||
|
|
|
@ -202,6 +202,10 @@
|
|||
.tainacan-header-image-modal,
|
||||
.tainacan-thumbnail-modal,
|
||||
.tainacan-item-attachments-modal {
|
||||
.tainacan-document-attachment {
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
}
|
||||
.media-toolbar button.button:not(.is-small):not(.is-medium):not(.is-large){
|
||||
margin-top: 1em !important;
|
||||
font-size: 0.875rem !important;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
}
|
||||
li {
|
||||
overflow-y: hidden;
|
||||
margin: 0;
|
||||
}
|
||||
a {
|
||||
font-size: 0.8125em;
|
||||
|
@ -24,7 +25,7 @@
|
|||
}
|
||||
}
|
||||
li.is-active a {
|
||||
border-bottom-color: var(--tainacan-turquoise5);
|
||||
border-bottom-color: var(--tainacan-secondary);
|
||||
color: var(--tainacan-black) !important;
|
||||
}
|
||||
.icon:first-child {
|
||||
|
|
|
@ -54,5 +54,34 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.is-danger,
|
||||
&.is-danger:hover,
|
||||
&.is-danger:focus,
|
||||
&.is-danger:active {
|
||||
border-color: var(--tainacan-danger) !important;
|
||||
background-color: var(--tainacan-red1) !important;
|
||||
color: var(--tainacan-danger) !important;
|
||||
}
|
||||
}
|
||||
|
||||
&.is-danger {
|
||||
border-color: var(--tainacan-danger) !important;
|
||||
background-color: var(--tainacan-red1) !important;
|
||||
color: var(--tainacan-danger) !important;
|
||||
|
||||
.tag,
|
||||
.tag:hover,
|
||||
.tag:focus,
|
||||
.tag:active {
|
||||
border-color: var(--tainacan-danger) !important;
|
||||
background-color: var(--tainacan-red1) !important;
|
||||
color: var(--tainacan-danger) !important;
|
||||
}
|
||||
|
||||
&:hover .tag.is-delete:hover,
|
||||
.tag.is-delete:hover {
|
||||
border-color: var(--tainacan-danger) !important;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
.upload-draggable {
|
||||
transition: background ease 0.3s, color ease 0.3s;
|
||||
}
|
||||
|
||||
.upload .upload-draggable:hover.is-primary,
|
||||
.upload-draggable:hover.is-primary,
|
||||
.upload .upload-draggable.is-hovered.is-primary {
|
||||
border-color: var(--tainacan-turquoise5) !important;
|
||||
background: var(--tainacan-turquoise4) !important;
|
||||
color: var(--tainacan-white) !important;
|
||||
border-color: var(--tainacan-secondary) !important;
|
||||
background: var(--tainacan-primary) !important;
|
||||
color: var(--tainacan-secondary) !important;
|
||||
}
|
|
@ -89,7 +89,7 @@ $black-invert: findColorInvert($black);
|
|||
$foreground-color: $black;
|
||||
$background-color: $white;
|
||||
|
||||
@import "../../../../node_modules/bulma/sass/utilities/derived-variables.scss";
|
||||
@import "../../../../node_modules/bulma/sass/utilities/derived-variables.sass";
|
||||
|
||||
// Setup $colors to use as bulma classes
|
||||
$colors: (
|
||||
|
|
|
@ -36,9 +36,12 @@
|
|||
html {
|
||||
overflow-y: hidden;
|
||||
}
|
||||
body.tainacan-admin-page #adminmenumain, body.tainacan-admin-page #wpfooter, body.tainacan-admin-page #wp-auth-check-wrap {
|
||||
body.tainacan-admin-page #adminmenumain, body.tainacan-admin-page #wpfooter {
|
||||
display: none;
|
||||
}
|
||||
body.tainacan-admin-page #wp-auth-check-wrap {
|
||||
z-index: 9999999;
|
||||
}
|
||||
#tainacan-admin-app {
|
||||
background: var(--tainacan-background-color);
|
||||
position: fixed;
|
||||
|
@ -211,7 +214,7 @@ a:hover {
|
|||
.multivalue-separator {
|
||||
display: block;
|
||||
max-height: 1px;
|
||||
width: 60px;
|
||||
width: 80px;
|
||||
background: var(--tainacan-gray2);
|
||||
content: none;
|
||||
color: transparent;
|
||||
|
@ -225,7 +228,7 @@ a:hover {
|
|||
.multivalue-separator {
|
||||
display: block;
|
||||
max-height: 1px;
|
||||
width: 60px;
|
||||
width: 80px;
|
||||
background: var(--tainacan-gray3);
|
||||
content: none;
|
||||
color: transparent;
|
||||
|
@ -248,6 +251,9 @@ a:hover {
|
|||
}
|
||||
}
|
||||
}
|
||||
.taginput-container .input:hover {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
// Buefy notices (toast, snackbar...)
|
||||
.notices {
|
||||
|
|
|
@ -26,6 +26,7 @@ class Admin {
|
|||
add_action( 'init', array( &$this, 'register_user_meta' ) );
|
||||
add_action( 'after_setup_theme', array( &$this, 'load_theme_files'));
|
||||
|
||||
add_action( 'admin_init', array( &$this, 'register_user_setting') );
|
||||
}
|
||||
|
||||
function add_admin_menu() {
|
||||
|
@ -57,6 +58,15 @@ class Admin {
|
|||
array( &$this, 'roles_page' )
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
$this->menu_slug,
|
||||
__('Item Submission', 'tainacan'),
|
||||
__('Item Submission', 'tainacan'),
|
||||
'manage_options',
|
||||
'tainacan_item_submission',
|
||||
array( &$this, 'item_submission' )
|
||||
);
|
||||
|
||||
add_action( 'load-' . $page_suffix, array( &$this, 'load_admin_page' ) );
|
||||
add_action( 'load-' . $roles_page_suffix, array( &$this, 'load_roles_page' ) );
|
||||
}
|
||||
|
@ -242,6 +252,7 @@ class Admin {
|
|||
'repository_name' => get_bloginfo('name'),
|
||||
'api_max_items_per_page' => $TAINACAN_API_MAX_ITEMS_PER_PAGE,
|
||||
'wp_elasticpress' => \Tainacan\Elastic_Press::get_instance()->is_active(),
|
||||
'item_submission_captcha_site_key' => get_option("tnc_option_recaptch_site_key")
|
||||
];
|
||||
|
||||
$maps = [
|
||||
|
@ -319,6 +330,20 @@ class Admin {
|
|||
register_meta( 'user', 'tainacan_prefs', $args );
|
||||
}
|
||||
|
||||
function register_user_setting() {
|
||||
register_setting(
|
||||
'tainacan_item_submission_recaptcha',
|
||||
'tnc_option_recaptch_site_key',
|
||||
'sanitize_text_field'
|
||||
);
|
||||
|
||||
register_setting(
|
||||
'tainacan_item_submission_recaptcha',
|
||||
'tnc_option_recaptch_secret_key',
|
||||
'sanitize_text_field'
|
||||
);
|
||||
}
|
||||
|
||||
function ajax_sample_permalink(){
|
||||
|
||||
$id = $_POST['post_id'];
|
||||
|
@ -380,5 +405,12 @@ class Admin {
|
|||
$check = new System_Check();
|
||||
$check->admin_page();
|
||||
}
|
||||
|
||||
public function item_submission() {
|
||||
require_once('item-submission/class-tainacan-item-submission.php');
|
||||
$submission = new Item_Submission();
|
||||
$submission->admin_page();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ function tainacan_blocks_add_gutenberg_blocks_actions() {
|
|||
add_action('init', 'tainacan_blocks_register_tainacan_collections_list');
|
||||
add_action('init', 'tainacan_blocks_register_tainacan_carousel_collections_list');
|
||||
add_action('init', 'tainacan_blocks_register_tainacan_facets_list');
|
||||
add_action('init', 'tainacan_blocks_register_tainacan_item_submission_form');
|
||||
|
||||
add_action('init', 'tainacan_blocks_add_plugin_settings');
|
||||
|
||||
|
@ -160,6 +161,45 @@ function tainacan_blocks_register_tainacan_dynamic_items_list(){
|
|||
}
|
||||
}
|
||||
|
||||
function tainacan_blocks_register_tainacan_item_submission_form(){
|
||||
global $TAINACAN_BASE_URL;
|
||||
global $TAINACAN_VERSION;
|
||||
|
||||
wp_register_script(
|
||||
'tainacan-item-submission',
|
||||
$TAINACAN_BASE_URL . '/assets/js/item_submission.js',
|
||||
['underscore', 'jcrop', 'media-editor', 'media-views', 'customize-controls'],
|
||||
TAINACAN_VERSION
|
||||
);
|
||||
|
||||
wp_register_script(
|
||||
'item-submission-form',
|
||||
$TAINACAN_BASE_URL . '/assets/js/block_item_submission_form.js',
|
||||
array('wp-blocks', 'wp-element', 'wp-components', 'wp-editor')
|
||||
);
|
||||
|
||||
wp_register_script(
|
||||
'google-recaptcha-script',
|
||||
'https://www.google.com/recaptcha/api.js',
|
||||
[], false, true
|
||||
);
|
||||
wp_enqueue_script('google-recaptcha-script');
|
||||
|
||||
wp_register_style(
|
||||
'item-submission-form',
|
||||
$TAINACAN_BASE_URL . '/assets/css/tainacan-gutenberg-block-item-submission-form.css',
|
||||
array('wp-edit-blocks', 'tainacan-blocks-common-styles')
|
||||
);
|
||||
|
||||
if (function_exists('register_block_type')) {
|
||||
register_block_type( 'tainacan/item-submission-form', array(
|
||||
'editor_script' => 'item-submission-form',
|
||||
'style' => 'item-submission-form',
|
||||
'script' => 'tainacan-item-submission'
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
function tainacan_blocks_register_tainacan_faceted_search(){
|
||||
global $TAINACAN_BASE_URL;
|
||||
global $TAINACAN_VERSION;
|
||||
|
@ -378,8 +418,11 @@ function tainacan_blocks_add_plugin_settings() {
|
|||
wp_localize_script( 'carousel-collections-list', 'tainacan_blocks', $settings );
|
||||
wp_localize_script( 'facets-list', 'tainacan_blocks', $settings );
|
||||
|
||||
// The facet facteded search block uses a different settings object, the same used on the theme items list
|
||||
// The faceded search block uses a different settings object, the same used on the theme items list
|
||||
wp_localize_script( 'tainacan-search', 'tainacan_plugin', \Tainacan\Admin::get_instance()->get_admin_js_localization_params() );
|
||||
|
||||
// The item submission search block uses a different settings object, the same used on the item submission component
|
||||
wp_localize_script( 'tainacan-item-submission', 'tainacan_plugin', \Tainacan\Admin::get_instance()->get_admin_js_localization_params() );
|
||||
}
|
||||
|
||||
function tainacan_blocks_get_common_styles() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import tainacan from '../../js/axios.js';
|
||||
import axios from 'axios';
|
||||
import qs from 'qs';
|
||||
|
||||
const { __ } = wp.i18n;
|
||||
|
||||
|
@ -63,7 +64,24 @@ export default class CollectionModal extends React.Component {
|
|||
if (this.state.collectionPage <= 1)
|
||||
someModalCollections = [];
|
||||
|
||||
let endpoint = '/collections/?perpage=' + this.state.collectionsPerPage + '&paged=' + this.state.collectionPage;
|
||||
let query = {
|
||||
perpage: this.state.collectionsPerPage,
|
||||
paged: this.state.collectionPage
|
||||
}
|
||||
|
||||
if (this.props.filterOptionsBy && Object.keys(this.props.filterOptionsBy).length !== 0) {
|
||||
let metaqueries = [];
|
||||
|
||||
for (let metaquery of Object.keys(this.props.filterOptionsBy)) {
|
||||
metaqueries.push({
|
||||
key: metaquery,
|
||||
value: this.props.filterOptionsBy[metaquery]
|
||||
})
|
||||
}
|
||||
query = {...query, metaquery: metaqueries}
|
||||
}
|
||||
|
||||
let endpoint = '/collections/?' + qs.stringify(query);
|
||||
|
||||
if (this.state.collectionOrderBy == 'date')
|
||||
endpoint += '&orderby=date&order=asc';
|
||||
|
@ -89,7 +107,7 @@ export default class CollectionModal extends React.Component {
|
|||
name: collection.name,
|
||||
id: collection.id,
|
||||
default_view_mode: collection.default_view_mode,
|
||||
enabled_view_modes: collection.enabled_view_modes
|
||||
enabled_view_modes: collection.enabled_view_modes
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -125,7 +143,25 @@ export default class CollectionModal extends React.Component {
|
|||
collections: []
|
||||
});
|
||||
|
||||
let endpoint = '/collections/?perpage=' + this.state.collectionsPerPage;
|
||||
let query = {
|
||||
perpage: this.state.collectionsPerPage,
|
||||
paged: this.state.collectionPage
|
||||
}
|
||||
|
||||
if (this.props.filterOptionsBy && Object.keys(this.props.filterOptionsBy).length !== 0) {
|
||||
let metaqueries = [];
|
||||
|
||||
for (let metaquery of Object.keys(this.props.filterOptionsBy)) {
|
||||
metaqueries.push({
|
||||
key: metaquery,
|
||||
value: this.props.filterOptionsBy[metaquery]
|
||||
})
|
||||
}
|
||||
query = {...query, metaquery: metaqueries}
|
||||
}
|
||||
|
||||
let endpoint = '/collections/?' + qs.stringify(query);
|
||||
|
||||
if (name != undefined && name != '')
|
||||
endpoint += '&search=' + name;
|
||||
|
||||
|
@ -144,7 +180,7 @@ export default class CollectionModal extends React.Component {
|
|||
name: collection.name,
|
||||
id: collection.id + '',
|
||||
default_view_mode: collection.default_view_mode,
|
||||
enabled_view_modes: collection.enabled_view_modes
|
||||
enabled_view_modes: collection.enabled_view_modes
|
||||
}));
|
||||
|
||||
this.setState({
|
||||
|
|
|
@ -255,8 +255,8 @@ registerBlockType('tainacan/faceted-search', {
|
|||
showInlineViewModeOptions,
|
||||
showFullscreenWithViewModes,
|
||||
listType,
|
||||
isCollectionModalOpen,
|
||||
isTermModalOpen,
|
||||
isCollectionModalOpen,
|
||||
backgroundColor,
|
||||
baseFontSize,
|
||||
filtersAreaWidth,
|
||||
|
@ -379,7 +379,7 @@ registerBlockType('tainacan/faceted-search', {
|
|||
defaultViewMode = hideItemsThumbnail ? 'table' : 'masonry';
|
||||
}
|
||||
|
||||
setAttributes({
|
||||
setAttributes({
|
||||
listType: aListType,
|
||||
enabledViewModes: enabledViewModes,
|
||||
defaultViewMode: defaultViewMode
|
||||
|
@ -1235,6 +1235,13 @@ registerBlockType('tainacan/faceted-search', {
|
|||
secondaryColor
|
||||
} = attributes;
|
||||
|
||||
let updatedListType = '' + listType;
|
||||
|
||||
if (updatedListType === '' && collectionId)
|
||||
updatedListType = 'collection';
|
||||
else if (updatedListType === '' && termId && taxonomyId)
|
||||
updatedListType = 'term'
|
||||
|
||||
return <div
|
||||
style={{
|
||||
'font-size': baseFontSize + 'px',
|
||||
|
@ -1256,10 +1263,10 @@ registerBlockType('tainacan/faceted-search', {
|
|||
}}
|
||||
className={ className }>
|
||||
<main
|
||||
term-id={ listType == 'term' ? termId : null }
|
||||
taxonomy={ listType == 'term' ? 'tnc_tax_' + taxonomyId : null }
|
||||
collection-id={ listType == 'collection' ? collectionId : null }
|
||||
default-view-mode={ defaultViewMode != 'none' ? defaultViewMode : (listType == 'collection' ? collectionDefaultViewMode : (hideItemsThumbnail ? 'table' : 'masonry') ) }
|
||||
term-id={ updatedListType == 'term' ? termId : null }
|
||||
taxonomy={ updatedListType == 'term' ? 'tnc_tax_' + taxonomyId : null }
|
||||
collection-id={ updatedListType == 'collection' ? collectionId : null }
|
||||
default-view-mode={ defaultViewMode != 'none' ? defaultViewMode : (updatedListType == 'collection' ? collectionDefaultViewMode : (hideItemsThumbnail ? 'table' : 'masonry') ) }
|
||||
is-forced-view-mode={ defaultViewMode == 'none' ? true : false }
|
||||
enabled-view-modes={ enabledViewModes.toString() }
|
||||
hide-filters = { hideFilters.toString() }
|
||||
|
@ -1286,6 +1293,271 @@ registerBlockType('tainacan/faceted-search', {
|
|||
</div>
|
||||
},
|
||||
deprecated: [
|
||||
{
|
||||
attributes: {
|
||||
termId: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
taxonomyId: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
collectionId: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
defaultViewMode: {
|
||||
type: String,
|
||||
default: 'masonry'
|
||||
},
|
||||
enabledViewModes: {
|
||||
type: Array,
|
||||
default: Object.keys(tainacan_plugin.registered_view_modes)
|
||||
},
|
||||
collectionDefaultViewMode: {
|
||||
type: String,
|
||||
default: 'masonry'
|
||||
},
|
||||
collectionEnabledViewModes: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
hideFilters: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideHideFiltersButton: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideSearch: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideAdvancedSearch: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideDisplayedMetadataButton: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideSortingArea: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideSortByButton: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideExposersButton: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideItemsPerPageButton: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
defaultItemsPerPage: {
|
||||
type: Number,
|
||||
default: 12
|
||||
},
|
||||
hideGoToPageButton: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hidePaginationArea: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showFiltersButtonInsideSearchControl: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
startWithFiltersHidden: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
filtersAsModal: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showInlineViewModeOptions: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showFullscreenWithViewModes: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
listType: {
|
||||
type: String,
|
||||
default: 'collection'
|
||||
},
|
||||
isCollectionModalOpen: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isTermModalOpen: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
backgroundColor: {
|
||||
type: String,
|
||||
default: '#ffffff'
|
||||
},
|
||||
baseFontSize: {
|
||||
type: Number,
|
||||
default: 16
|
||||
},
|
||||
filtersAreaWidth: {
|
||||
type: Number,
|
||||
default: 20
|
||||
},
|
||||
inputColor: {
|
||||
type: String,
|
||||
default: '#1d1d1d'
|
||||
},
|
||||
inputBackgroundColor: {
|
||||
type: String,
|
||||
default: '#ffffff'
|
||||
},
|
||||
inputBorderColor: {
|
||||
type: String,
|
||||
default: '#dbdbdb'
|
||||
},
|
||||
labelColor: {
|
||||
type: String,
|
||||
default: '#454647'
|
||||
},
|
||||
infoColor: {
|
||||
type: String,
|
||||
default: '#555758'
|
||||
},
|
||||
headingColor: {
|
||||
type: String,
|
||||
default: '#000000'
|
||||
},
|
||||
skeletonColor: {
|
||||
type: String,
|
||||
default: '#eeeeee'
|
||||
},
|
||||
itemBackgroundColor: {
|
||||
type: String,
|
||||
default: '#ffffff'
|
||||
},
|
||||
itemHoverBackgroundColor: {
|
||||
type: String,
|
||||
default: '#f2f2f2'
|
||||
},
|
||||
itemHeadingHoverBackgroundColor: {
|
||||
type: String,
|
||||
default: '#dbdbdb'
|
||||
},
|
||||
primaryColor: {
|
||||
type: String,
|
||||
default: '#d9eced'
|
||||
},
|
||||
secondaryColor: {
|
||||
type: String,
|
||||
default: '#298596'
|
||||
}
|
||||
},
|
||||
save({ attributes, className }){
|
||||
const {
|
||||
termId,
|
||||
taxonomyId,
|
||||
collectionId,
|
||||
defaultViewMode,
|
||||
enabledViewModes,
|
||||
collectionDefaultViewMode,
|
||||
collectionEnabledViewModes,
|
||||
hideDisplayedMetadataButton,
|
||||
hideSortingArea,
|
||||
hideFilters,
|
||||
hideHideFiltersButton,
|
||||
hideSearch,
|
||||
hideAdvancedSearch,
|
||||
hideSortByButton,
|
||||
hidePaginationArea,
|
||||
hideExposersButton,
|
||||
hideItemsPerPageButton,
|
||||
defaultItemsPerPage,
|
||||
hideGoToPageButton,
|
||||
showFiltersButtonInsideSearchControl,
|
||||
startWithFiltersHidden,
|
||||
filtersAsModal,
|
||||
showInlineViewModeOptions,
|
||||
showFullscreenWithViewModes,
|
||||
listType,
|
||||
backgroundColor,
|
||||
baseFontSize,
|
||||
filtersAreaWidth,
|
||||
inputColor,
|
||||
inputBackgroundColor,
|
||||
inputBorderColor,
|
||||
labelColor,
|
||||
infoColor,
|
||||
headingColor,
|
||||
skeletonColor,
|
||||
itemBackgroundColor,
|
||||
itemHoverBackgroundColor,
|
||||
itemHeadingHoverBackgroundColor,
|
||||
primaryColor,
|
||||
secondaryColor
|
||||
} = attributes;
|
||||
|
||||
return <div
|
||||
style={{
|
||||
'font-size': baseFontSize + 'px',
|
||||
'--tainacan-base-font-size': baseFontSize + 'px',
|
||||
'--tainacan-background-color': backgroundColor,
|
||||
'--tainacan-filter-menu-width-theme': filtersAreaWidth + '%',
|
||||
'--tainacan-input-color': inputColor,
|
||||
'--tainacan-input-background-color': inputBackgroundColor,
|
||||
'--tainacan-input-border-color': inputBorderColor,
|
||||
'--tainacan-label-color': labelColor,
|
||||
'--tainacan-info-color': infoColor,
|
||||
'--tainacan-heading-color': headingColor,
|
||||
'--tainacan-skeleton-color': skeletonColor,
|
||||
'--tainacan-item-background-color': itemBackgroundColor,
|
||||
'--tainacan-item-hover-background-color': itemHoverBackgroundColor,
|
||||
'--tainacan-item-heading-hover-background-color': itemHeadingHoverBackgroundColor,
|
||||
'--tainacan-primary': primaryColor,
|
||||
'--tainacan-secondary': secondaryColor
|
||||
}}
|
||||
className={ className }>
|
||||
<main
|
||||
term-id={ listType == 'term' ? termId : null }
|
||||
taxonomy={ listType == 'term' ? 'tnc_tax_' + taxonomyId : null }
|
||||
collection-id={ listType == 'collection' ? collectionId : null }
|
||||
default-view-mode={ defaultViewMode != 'none' ? defaultViewMode : (listType == 'collection' ? collectionDefaultViewMode : 'masonry') }
|
||||
is-forced-view-mode={ defaultViewMode == 'none' ? true : false }
|
||||
enabled-view-modes={ enabledViewModes.toString() }
|
||||
hide-filters = { hideFilters.toString() }
|
||||
hide-hide-filters-button= { hideHideFiltersButton.toString() }
|
||||
hide-search = { hideSearch.toString() }
|
||||
hide-advanced-search = { hideAdvancedSearch.toString() }
|
||||
hide-displayed-metadata-button = { hideDisplayedMetadataButton.toString() }
|
||||
hide-pagination-area = { hidePaginationArea.toString() }
|
||||
hide-sorting-area = { hideSortingArea.toString() }
|
||||
hide-sort-by-button = { hideSortByButton.toString() }
|
||||
hide-pagination-area = { hidePaginationArea.toString() }
|
||||
hide-exposers-button = { hideExposersButton.toString() }
|
||||
hide-items-per-page-button = { hideItemsPerPageButton.toString() }
|
||||
default-items-per-page = { defaultItemsPerPage }
|
||||
hide-go-to-page-button = { hideGoToPageButton.toString() }
|
||||
show-filters-button-inside-search-control = { showFiltersButtonInsideSearchControl.toString() }
|
||||
start-with-filters-hidden = { startWithFiltersHidden.toString() }
|
||||
filters-as-modal = { filtersAsModal.toString() }
|
||||
show-inline-view-mode-options = { showInlineViewModeOptions.toString() }
|
||||
show-fullscreen-with-view-modes = { showFullscreenWithViewModes.toString() }
|
||||
id="tainacan-items-page">
|
||||
</main>
|
||||
</div>
|
||||
}
|
||||
},
|
||||
{
|
||||
attributes: {
|
||||
termId: {
|
||||
|
|
|
@ -0,0 +1,855 @@
|
|||
const { registerBlockType } = wp.blocks;
|
||||
|
||||
const { __ } = wp.i18n;
|
||||
|
||||
const { Button, TextControl, TextareaControl, ColorPicker, BaseControl, CheckboxControl, FontSizePicker, HorizontalRule, Spinner, ToggleControl, Placeholder, PanelBody, ToolbarGroup, ToolbarButton } = wp.components;
|
||||
|
||||
const { InspectorControls, BlockControls } = wp.editor;
|
||||
|
||||
import tainacan from '../../js/axios.js';
|
||||
import CollectionModal from '../../tainacan-facets/faceted-search/collection-modal.js';
|
||||
|
||||
registerBlockType('tainacan/item-submission-form', {
|
||||
title: __('Tainacan Item Submission Form', 'tainacan'),
|
||||
icon:
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 10 10"
|
||||
height="24px"
|
||||
width="24px">
|
||||
<g transform="translate(227.4751,-183.8442)">
|
||||
<path
|
||||
fill="#298596"
|
||||
d="m -227.47379,191.95102 c 0.0372,-2.35931 -0.0195,-4.71936 0.0185,-7.07842 0.0356,-0.55424 0.52604,-0.99051 1.07473,-0.99702 0.80102,-0.0806 1.607,0.0149 2.41027,-0.0211 1.66482,0.0101 3.33138,-0.0202 4.99509,0.01 0.58652,0.0617 1.0108,0.60434 0.99243,1.1815 0.0416,0.76157 -0.0361,1.52426 0.008,2.28649 0.0113,1.65577 -0.006,3.31214 -0.009,4.96756 -0.0429,0.59366 -0.57833,1.06966 -1.17191,1.04765 -0.92086,0.0516 -1.84377,-0.0208 -2.7657,-0.006 -1.49072,-0.0194 -2.98293,0.0353 -4.47258,0.009 -0.60954,-0.039 -1.111,-0.56284 -1.07768,-1.17994 -0.004,-0.0728 -0.004,-0.1462 -0.002,-0.21867 z m 1.15668,0.28162 c 2.40388,0 4.80776,0 7.21164,0 0,-2.41394 0,-4.82787 0,-7.24181 -2.40388,0 -4.80776,0 -7.21164,0 0,2.41394 0,4.82787 0,7.24181 z m 0.53308,-0.53308 c 0,-0.83147 0,-1.66293 0,-2.4944 0.82476,0 1.64953,0 2.47429,0 0,0.83147 0,1.66293 0,2.4944 -0.82476,0 -1.64953,0 -2.47429,0 z m 2.45417,-6.18571 c 0,0.83482 0,1.66964 0,2.50446 -0.82141,0 -1.64282,0 -2.46423,0 0,-0.83482 0,-1.66964 0,-2.50446 0.82141,0 1.64282,0 2.46423,0 z m 1.1768,1.67969 c 0,-0.28833 0,-0.57666 0,-0.86499 0.82811,0 1.65623,0 2.48434,0 0,0.28833 0,0.57666 0,0.86499 -0.82811,0 -1.65623,0 -2.48434,0 z m 2.48434,2.76598 c 0,0.28162 0,0.56325 0,0.84487 -0.82811,0 -1.65623,0 -2.48434,0 0,-0.28162 0,-0.56325 0,-0.84487 0.82811,0 1.65623,0 2.48434,0 z m -5.64258,-2.49441 c 0.48614,0 0.97228,0 1.45842,0 0,-0.47273 0,-0.94546 0,-1.41819 -0.48614,0 -0.97228,0 -1.45842,0 0,0.47273 0,0.94546 0,1.41819 z m 0,3.68126 c 0.48949,0 0.97899,0 1.46848,0 0,-0.47273 0,-0.94546 0,-1.41819 -0.48949,0 -0.97899,0 -1.46848,0 0,0.47273 0,0.94546 0,1.41819 z"></path>
|
||||
</g>
|
||||
</svg>,
|
||||
category: 'tainacan-blocks',
|
||||
keywords: [ __( 'item', 'tainacan' ), __( 'submission', 'tainacan' ), __( 'form', 'tainacan' ) ],
|
||||
description: __('A public item submission form, to allow visitors to create items drafts.', 'tainacan'),
|
||||
example: {
|
||||
attributes: {
|
||||
collectionId: 'preview'
|
||||
}
|
||||
},
|
||||
attributes: {
|
||||
collectionId: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
isCollectionModalOpen: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideFileModalButton: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideTextModalButton: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideLinkModalButton: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideThumbnailSection: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideAttachmentsSection: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideHelpButtons: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideMetadataTypes: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showAllowCommentsSection: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideCollapses: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
backgroundColor: {
|
||||
type: Object,
|
||||
default: { r: 255, g: 255, b: 255, a: 0}
|
||||
},
|
||||
baseFontSize: {
|
||||
type: Number,
|
||||
default: 16
|
||||
},
|
||||
inputColor: {
|
||||
type: String,
|
||||
default: '#1d1d1d'
|
||||
},
|
||||
inputBackgroundColor: {
|
||||
type: String,
|
||||
default: '#ffffff'
|
||||
},
|
||||
inputBorderColor: {
|
||||
type: String,
|
||||
default: '#dbdbdb'
|
||||
},
|
||||
labelColor: {
|
||||
type: String,
|
||||
default: '#454647'
|
||||
},
|
||||
infoColor: {
|
||||
type: String,
|
||||
default: '#555758'
|
||||
},
|
||||
primaryColor: {
|
||||
type: String,
|
||||
default: '#d9eced'
|
||||
},
|
||||
secondaryColor: {
|
||||
type: String,
|
||||
default: '#298596'
|
||||
},
|
||||
enabledMetadata: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
collectionMetadata: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
isLoadingCollectionMetadata: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
sentFormHeading: {
|
||||
type: String,
|
||||
default: __( 'Form submitted!', 'tainacan' )
|
||||
},
|
||||
sentFormMessage: {
|
||||
type: String,
|
||||
default: __( 'Thank you. Your item was submitted to the collection.', 'tainacan' )
|
||||
},
|
||||
documentSectionLabel: {
|
||||
type: String,
|
||||
default: __( 'Document', 'tainacan' )
|
||||
},
|
||||
attachmentsSectionLabel: {
|
||||
type: String,
|
||||
default: __( 'Attachments', 'tainacan' )
|
||||
},
|
||||
thumbnailSectionLabel: {
|
||||
type: String,
|
||||
default: __( 'Thumbnail', 'tainacan' )
|
||||
},
|
||||
metadataSectionLabel: {
|
||||
type: String,
|
||||
default: __( 'Metadata', 'tainacan' )
|
||||
}
|
||||
},
|
||||
supports: {
|
||||
align: ['full', 'wide'],
|
||||
html: true,
|
||||
multiple: false
|
||||
},
|
||||
edit({ attributes, setAttributes, className, isSelected, clientId }){
|
||||
let {
|
||||
collectionId,
|
||||
isCollectionModalOpen,
|
||||
hideFileModalButton,
|
||||
hideTextModalButton,
|
||||
hideLinkModalButton,
|
||||
hideThumbnailSection,
|
||||
hideAttachmentsSection,
|
||||
showAllowCommentsSection,
|
||||
hideCollapses,
|
||||
hideHelpButtons,
|
||||
hideMetadataTypes,
|
||||
baseFontSize,
|
||||
backgroundColor,
|
||||
inputColor,
|
||||
inputBackgroundColor,
|
||||
inputBorderColor,
|
||||
labelColor,
|
||||
infoColor,
|
||||
primaryColor,
|
||||
secondaryColor,
|
||||
isLoadingCollectionMetadata,
|
||||
collectionMetadata,
|
||||
enabledMetadata,
|
||||
sentFormHeading,
|
||||
sentFormMessage,
|
||||
documentSectionLabel,
|
||||
attachmentsSectionLabel,
|
||||
thumbnailSectionLabel,
|
||||
metadataSectionLabel
|
||||
} = attributes;
|
||||
|
||||
const fontSizes = [
|
||||
{
|
||||
name: __( 'Tiny', 'tainacan' ),
|
||||
slug: 'tiny',
|
||||
size: 12,
|
||||
},
|
||||
{
|
||||
name: __( 'Small', 'tainacan' ),
|
||||
slug: 'small',
|
||||
size: 14,
|
||||
},
|
||||
{
|
||||
name: __( 'Normal', 'tainacan' ),
|
||||
slug: 'normal',
|
||||
size: 16,
|
||||
},
|
||||
{
|
||||
name: __( 'Big', 'tainacan' ),
|
||||
slug: 'big',
|
||||
size: 18,
|
||||
},
|
||||
{
|
||||
name: __( 'Huge', 'tainacan' ),
|
||||
slug: 'huge',
|
||||
size: 20,
|
||||
},
|
||||
];
|
||||
|
||||
function openCollectionModal() {
|
||||
isCollectionModalOpen = true;
|
||||
setAttributes( {
|
||||
isCollectionModalOpen: isCollectionModalOpen
|
||||
} );
|
||||
}
|
||||
|
||||
function toggleIsEnabledMetadatum(isEnabled, index) {
|
||||
|
||||
enabledMetadata.splice(index, 1, isEnabled);
|
||||
|
||||
setAttributes({
|
||||
enabledMetadata: JSON.parse(JSON.stringify(enabledMetadata))
|
||||
});
|
||||
}
|
||||
|
||||
function loadCollectionMetadata(selectedCollectionId) {
|
||||
isLoadingCollectionMetadata = true;
|
||||
setAttributes({ isLoadingCollectionMetadata, isLoadingCollectionMetadata });
|
||||
|
||||
tainacan.get('/collection/' + selectedCollectionId + '/metadata/?nopaging=1&include_disabled=false&parent=0')
|
||||
.then(response => {
|
||||
collectionMetadata = response.data;
|
||||
enabledMetadata = new Array(response.data.length).fill(true);
|
||||
|
||||
isLoadingCollectionMetadata = false;
|
||||
|
||||
setAttributes({
|
||||
isLoadingCollectionMetadata : isLoadingCollectionMetadata,
|
||||
collectionMetadata: collectionMetadata,
|
||||
enabledMetadata: enabledMetadata
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return collectionId == 'preview' ?
|
||||
<div className={className}>
|
||||
<img
|
||||
width="100%"
|
||||
src={ `${tainacan_blocks.base_url}/assets/images/item-submission-form.png` } />
|
||||
</div>
|
||||
: (
|
||||
<div className={className}>
|
||||
|
||||
{ collectionId != undefined ?
|
||||
<BlockControls>
|
||||
<ToolbarGroup>
|
||||
{ tainacan_blocks.wp_version < '5.5' ?
|
||||
<Button style={{ whiteSpace: 'nowrap' }} onClick={ () => openCollectionModal() }>
|
||||
<p>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="-2 -2 12 12"
|
||||
height="24px"
|
||||
width="24px">
|
||||
<g transform="translate(227.4751,-183.8442)">
|
||||
<path d="m -227.47379,191.95102 c 0.0372,-2.35931 -0.0195,-4.71936 0.0185,-7.07842 0.0356,-0.55424 0.52604,-0.99051 1.07473,-0.99702 0.80102,-0.0806 1.607,0.0149 2.41027,-0.0211 1.66482,0.0101 3.33138,-0.0202 4.99509,0.01 0.58652,0.0617 1.0108,0.60434 0.99243,1.1815 0.0416,0.76157 -0.0361,1.52426 0.008,2.28649 0.0113,1.65577 -0.006,3.31214 -0.009,4.96756 -0.0429,0.59366 -0.57833,1.06966 -1.17191,1.04765 -0.92086,0.0516 -1.84377,-0.0208 -2.7657,-0.006 -1.49072,-0.0194 -2.98293,0.0353 -4.47258,0.009 -0.60954,-0.039 -1.111,-0.56284 -1.07768,-1.17994 -0.004,-0.0728 -0.004,-0.1462 -0.002,-0.21867 z m 1.15668,0.28162 c 2.40388,0 4.80776,0 7.21164,0 0,-2.41394 0,-4.82787 0,-7.24181 -2.40388,0 -4.80776,0 -7.21164,0 0,2.41394 0,4.82787 0,7.24181 z m 0.53308,-0.53308 c 0,-0.83147 0,-1.66293 0,-2.4944 0.82476,0 1.64953,0 2.47429,0 0,0.83147 0,1.66293 0,2.4944 -0.82476,0 -1.64953,0 -2.47429,0 z m 2.45417,-6.18571 c 0,0.83482 0,1.66964 0,2.50446 -0.82141,0 -1.64282,0 -2.46423,0 0,-0.83482 0,-1.66964 0,-2.50446 0.82141,0 1.64282,0 2.46423,0 z m 1.1768,1.67969 c 0,-0.28833 0,-0.57666 0,-0.86499 0.82811,0 1.65623,0 2.48434,0 0,0.28833 0,0.57666 0,0.86499 -0.82811,0 -1.65623,0 -2.48434,0 z m 2.48434,2.76598 c 0,0.28162 0,0.56325 0,0.84487 -0.82811,0 -1.65623,0 -2.48434,0 0,-0.28162 0,-0.56325 0,-0.84487 0.82811,0 1.65623,0 2.48434,0 z m -5.64258,-2.49441 c 0.48614,0 0.97228,0 1.45842,0 0,-0.47273 0,-0.94546 0,-1.41819 -0.48614,0 -0.97228,0 -1.45842,0 0,0.47273 0,0.94546 0,1.41819 z m 0,3.68126 c 0.48949,0 0.97899,0 1.46848,0 0,-0.47273 0,-0.94546 0,-1.41819 -0.48949,0 -0.97899,0 -1.46848,0 0,0.47273 0,0.94546 0,1.41819 z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
</p>
|
||||
{ __('Change target collection', 'tainacan') }
|
||||
</Button>
|
||||
:
|
||||
<ToolbarButton onClick={ () => openCollectionModal() }>
|
||||
<p>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="-2 -2 12 12"
|
||||
height="24px"
|
||||
width="24px">
|
||||
<g transform="translate(227.4751,-183.8442)">
|
||||
<path d="m -227.47379,191.95102 c 0.0372,-2.35931 -0.0195,-4.71936 0.0185,-7.07842 0.0356,-0.55424 0.52604,-0.99051 1.07473,-0.99702 0.80102,-0.0806 1.607,0.0149 2.41027,-0.0211 1.66482,0.0101 3.33138,-0.0202 4.99509,0.01 0.58652,0.0617 1.0108,0.60434 0.99243,1.1815 0.0416,0.76157 -0.0361,1.52426 0.008,2.28649 0.0113,1.65577 -0.006,3.31214 -0.009,4.96756 -0.0429,0.59366 -0.57833,1.06966 -1.17191,1.04765 -0.92086,0.0516 -1.84377,-0.0208 -2.7657,-0.006 -1.49072,-0.0194 -2.98293,0.0353 -4.47258,0.009 -0.60954,-0.039 -1.111,-0.56284 -1.07768,-1.17994 -0.004,-0.0728 -0.004,-0.1462 -0.002,-0.21867 z m 1.15668,0.28162 c 2.40388,0 4.80776,0 7.21164,0 0,-2.41394 0,-4.82787 0,-7.24181 -2.40388,0 -4.80776,0 -7.21164,0 0,2.41394 0,4.82787 0,7.24181 z m 0.53308,-0.53308 c 0,-0.83147 0,-1.66293 0,-2.4944 0.82476,0 1.64953,0 2.47429,0 0,0.83147 0,1.66293 0,2.4944 -0.82476,0 -1.64953,0 -2.47429,0 z m 2.45417,-6.18571 c 0,0.83482 0,1.66964 0,2.50446 -0.82141,0 -1.64282,0 -2.46423,0 0,-0.83482 0,-1.66964 0,-2.50446 0.82141,0 1.64282,0 2.46423,0 z m 1.1768,1.67969 c 0,-0.28833 0,-0.57666 0,-0.86499 0.82811,0 1.65623,0 2.48434,0 0,0.28833 0,0.57666 0,0.86499 -0.82811,0 -1.65623,0 -2.48434,0 z m 2.48434,2.76598 c 0,0.28162 0,0.56325 0,0.84487 -0.82811,0 -1.65623,0 -2.48434,0 0,-0.28162 0,-0.56325 0,-0.84487 0.82811,0 1.65623,0 2.48434,0 z m -5.64258,-2.49441 c 0.48614,0 0.97228,0 1.45842,0 0,-0.47273 0,-0.94546 0,-1.41819 -0.48614,0 -0.97228,0 -1.45842,0 0,0.47273 0,0.94546 0,1.41819 z m 0,3.68126 c 0.48949,0 0.97899,0 1.46848,0 0,-0.47273 0,-0.94546 0,-1.41819 -0.48949,0 -0.97899,0 -1.46848,0 0,0.47273 0,0.94546 0,1.41819 z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
</p>
|
||||
{ __('Change target collection', 'tainacan') }
|
||||
</ToolbarButton>
|
||||
}
|
||||
</ToolbarGroup>
|
||||
</BlockControls>
|
||||
: null }
|
||||
|
||||
<div>
|
||||
|
||||
<InspectorControls>
|
||||
<PanelBody
|
||||
title={ __('Submission feedback', 'tainacan') }
|
||||
initialOpen={ true } >
|
||||
<TextControl
|
||||
label={ __('The heading of the message that will confirm that the submission went well.', 'tainacan') }
|
||||
value={ sentFormHeading }
|
||||
onChange={ ( updatedHeading ) =>{
|
||||
sentFormHeading = updatedHeading;
|
||||
setAttributes({ sentFormHeading: sentFormHeading });
|
||||
} }
|
||||
/>
|
||||
<TextareaControl
|
||||
label={ __('The message that will confirm that the submission went well.', 'tainacan') }
|
||||
help={ __('You may want to inform the user here that the item is under evaluation or that it will be visible after a certain time.', 'tainacan') }
|
||||
value={ sentFormMessage }
|
||||
onChange={ ( updatedMessage ) =>{
|
||||
sentFormMessage = updatedMessage;
|
||||
setAttributes({ sentFormMessage: sentFormMessage });
|
||||
} }
|
||||
/>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
<InspectorControls>
|
||||
<PanelBody
|
||||
title={ __('Section labels', 'tainacan') }
|
||||
initialOpen={ false } >
|
||||
<TextControl
|
||||
label={ __('Document section label', 'tainacan') }
|
||||
value={ documentSectionLabel }
|
||||
onChange={ ( updatedSectionName ) =>{
|
||||
documentSectionLabel = updatedSectionName;
|
||||
setAttributes({ documentSectionLabel: documentSectionLabel });
|
||||
} }
|
||||
/>
|
||||
<TextControl
|
||||
label={ __('Thumbnail section label', 'tainacan') }
|
||||
value={ thumbnailSectionLabel }
|
||||
onChange={ ( updatedSectionName ) =>{
|
||||
thumbnailSectionLabel = updatedSectionName;
|
||||
setAttributes({ thumbnailSectionLabel: thumbnailSectionLabel });
|
||||
} }
|
||||
/>
|
||||
<TextControl
|
||||
label={ __('Attachments section label', 'tainacan') }
|
||||
value={ attachmentsSectionLabel }
|
||||
onChange={ ( updatedSectionName ) =>{
|
||||
attachmentsSectionLabel = updatedSectionName;
|
||||
setAttributes({ attachmentsSectionLabel: attachmentsSectionLabel });
|
||||
} }
|
||||
/>
|
||||
<TextControl
|
||||
label={ __('Metadata section label', 'tainacan') }
|
||||
value={ metadataSectionLabel }
|
||||
onChange={ ( updatedSectionName ) =>{
|
||||
metadataSectionLabel = updatedSectionName;
|
||||
setAttributes({ metadataSectionLabel: metadataSectionLabel });
|
||||
} }
|
||||
/>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
<InspectorControls>
|
||||
<PanelBody
|
||||
title={__('Metadata Input', 'tainacan')}
|
||||
initialOpen={ true } >
|
||||
{ !isLoadingCollectionMetadata ?
|
||||
<BaseControl
|
||||
id="metadata-checkbox-list"
|
||||
label={ __('Metadata input shown on the list', 'tainacan') }
|
||||
help={ __('Uncheck the metadata that you do not want to be shown on the form', 'tainacan') }
|
||||
>
|
||||
<ul id="metadata-checkbox-list">
|
||||
{ enabledMetadata.length ?
|
||||
enabledMetadata.map((isMetadatumEnabled, index) => {
|
||||
return (
|
||||
<li>
|
||||
<CheckboxControl
|
||||
label={ collectionMetadata[index].name + (collectionMetadata[index].required == 'yes' ? ' *' : '') }
|
||||
disabled={ collectionMetadata[index].required == 'yes' }
|
||||
checked={ isMetadatumEnabled ? true : false }
|
||||
help={ collectionMetadata[index].metadata_type_object.name + (collectionMetadata[index].required == 'yes' ? (', ' + __('Required', 'tainacan')) : '' ) + (collectionMetadata[index].collection_id != collectionId ? (' (' + __('Inherited', 'tainacan') + ')' ) : '') }
|
||||
onChange={ (isEnabled) => toggleIsEnabledMetadatum(isEnabled, index) }
|
||||
/>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
:
|
||||
<p>{ __('No public metadata was found in this collection', 'tainacan') }</p>
|
||||
}
|
||||
</ul>
|
||||
</BaseControl>
|
||||
: <Spinner /> }
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
<InspectorControls>
|
||||
<PanelBody
|
||||
title={__('Form elements', 'tainacan')}
|
||||
initialOpen={ true } >
|
||||
<ToggleControl
|
||||
label={__('Hide the Document type file button', 'tainacan')}
|
||||
help={ hideFileModalButton ? __('Do not show the button for uploading a file document', 'tainacan') : __('Toggle to show the button to upload a file document.', 'tainacan')}
|
||||
checked={ hideFileModalButton }
|
||||
onChange={ ( isChecked ) => {
|
||||
hideFileModalButton = isChecked;
|
||||
setAttributes({ hideFileModalButton: isChecked });
|
||||
}
|
||||
}
|
||||
/>
|
||||
<ToggleControl
|
||||
label={__('Hide the Document type text button', 'tainacan')}
|
||||
help={ hideTextModalButton ? __('Do not show the button for setting a text as document.', 'tainacan') : __('Toggle to show the button to set a text as document.', 'tainacan')}
|
||||
checked={ hideTextModalButton }
|
||||
onChange={ ( isChecked ) => {
|
||||
hideTextModalButton = isChecked;
|
||||
setAttributes({ hideTextModalButton: isChecked });
|
||||
}
|
||||
}
|
||||
/>
|
||||
<ToggleControl
|
||||
label={__('Hide the Document type link button', 'tainacan')}
|
||||
help={ hideLinkModalButton ? __('Do not show the button for setting a link as document.', 'tainacan') : __('Toggle to show the button to set a link as document.', 'tainacan')}
|
||||
checked={ hideLinkModalButton }
|
||||
onChange={ ( isChecked ) => {
|
||||
hideLinkModalButton = isChecked;
|
||||
setAttributes({ hideLinkModalButton: isChecked });
|
||||
}
|
||||
}
|
||||
/>
|
||||
<ToggleControl
|
||||
label={__('Hide the thumbnail section', 'tainacan')}
|
||||
help={ hideThumbnailSection ? __('Do not show the thumbnail section.', 'tainacan') : __('Toggle to show the thumbnail section.', 'tainacan')}
|
||||
checked={ hideThumbnailSection }
|
||||
onChange={ ( isChecked ) => {
|
||||
hideThumbnailSection = isChecked;
|
||||
setAttributes({ hideThumbnailSection: isChecked });
|
||||
}
|
||||
}
|
||||
/>
|
||||
<ToggleControl
|
||||
label={__('Hide the attachments section', 'tainacan')}
|
||||
help={ hideAttachmentsSection ? __('Do not show the attachments section.', 'tainacan') : __('Toggle to show the attachments section.', 'tainacan')}
|
||||
checked={ hideAttachmentsSection }
|
||||
onChange={ ( isChecked ) => {
|
||||
hideAttachmentsSection = isChecked;
|
||||
setAttributes({ hideAttachmentsSection: isChecked });
|
||||
}
|
||||
}
|
||||
/>
|
||||
<ToggleControl
|
||||
label={__('Show "allow comments" section', 'tainacan')}
|
||||
help={ showAllowCommentsSection ? __('Show the option to allow comments on the item page.', 'tainacan') : __('Toggle to hide the option to allow comments on the item page.', 'tainacan')}
|
||||
checked={ showAllowCommentsSection }
|
||||
onChange={ ( isChecked ) => {
|
||||
showAllowCommentsSection = isChecked;
|
||||
setAttributes({ showAllowCommentsSection: isChecked });
|
||||
}
|
||||
}
|
||||
/>
|
||||
<ToggleControl
|
||||
label={__('Hide the metadata collapses', 'tainacan')}
|
||||
help={ hideCollapses ? __('Do not show collapsable controls for each metadatum.', 'tainacan') : __('Toggle to show collapsable controls on each metadatum.', 'tainacan')}
|
||||
checked={ hideCollapses }
|
||||
onChange={ ( isChecked ) => {
|
||||
hideCollapses = isChecked;
|
||||
setAttributes({ hideCollapses: isChecked });
|
||||
}
|
||||
}
|
||||
/>
|
||||
<ToggleControl
|
||||
label={__('Hide help buttons', 'tainacan')}
|
||||
help={ hideHelpButtons ? __('Do not show the "?" icon with a help tooltip aside the labels.', 'tainacan') : __('Toggle to show the "?" icon with a help tooltip aside the labels.', 'tainacan')}
|
||||
checked={ hideHelpButtons }
|
||||
onChange={ ( isChecked ) => {
|
||||
hideHelpButtons = isChecked;
|
||||
setAttributes({ hideHelpButtons: isChecked });
|
||||
}
|
||||
}
|
||||
/>
|
||||
<ToggleControl
|
||||
label={__('Hide metadata type', 'tainacan')}
|
||||
help={ hideMetadataTypes ? __('Do not show the metadata type aside the metadata label.', 'tainacan') : __('Toggle to show the metadata type aside the metadata label.', 'tainacan')}
|
||||
checked={ hideMetadataTypes }
|
||||
onChange={ ( isChecked ) => {
|
||||
hideMetadataTypes = isChecked;
|
||||
setAttributes({ hideMetadataTypes: isChecked });
|
||||
}
|
||||
}
|
||||
/>
|
||||
</PanelBody>
|
||||
<PanelBody
|
||||
title={__('Colors and Sizes', 'tainacan')}
|
||||
initialOpen={ false }
|
||||
>
|
||||
<FontSizePicker
|
||||
fontSizes={ fontSizes }
|
||||
value={ baseFontSize }
|
||||
fallbackFontSize={ 16 }
|
||||
onChange={ ( newFontSize ) => {
|
||||
setAttributes( { baseFontSize: newFontSize } );
|
||||
} }
|
||||
/>
|
||||
<HorizontalRule />
|
||||
<BaseControl
|
||||
id="backgroundColorPicker"
|
||||
label={ __('Background color', 'tainacan')}
|
||||
help={ __('The background color of the entire items list', 'tainacan') }>
|
||||
<ColorPicker
|
||||
color={ backgroundColor }
|
||||
onChangeComplete={ (colorValue ) => {
|
||||
backgroundColor = colorValue.rgb;
|
||||
setAttributes({ backgroundColor: backgroundColor });
|
||||
}}
|
||||
/>
|
||||
</BaseControl>
|
||||
<HorizontalRule />
|
||||
<BaseControl
|
||||
id="secondaryColorPicker"
|
||||
label={ __('Link and Active Main color', 'tainacan')}
|
||||
help={ __('The text color links and other action or active state elements, such as select arrows, tooltip contents, etc', 'tainacan') }>
|
||||
<ColorPicker
|
||||
color={ secondaryColor }
|
||||
onChangeComplete={ (colorValue ) => {
|
||||
secondaryColor = colorValue.hex;
|
||||
setAttributes({ secondaryColor: secondaryColor });
|
||||
}}
|
||||
disableAlpha
|
||||
/>
|
||||
</BaseControl>
|
||||
<HorizontalRule />
|
||||
<BaseControl
|
||||
id="primaryColorPicker"
|
||||
label={ __('Tooltips background color', 'tainacan')}
|
||||
help={ __('The tooltips background color and other elements, such as the hide filters button', 'tainacan') }>
|
||||
<ColorPicker
|
||||
color={ primaryColor }
|
||||
onChangeComplete={ (colorValue ) => {
|
||||
primaryColor = colorValue.hex;
|
||||
setAttributes({ primaryColor: primaryColor });
|
||||
}}
|
||||
disableAlpha
|
||||
/>
|
||||
</BaseControl>
|
||||
<HorizontalRule />
|
||||
<BaseControl
|
||||
id="inputBackgroundColorPicker"
|
||||
label={ __('Input Background color', 'tainacan')}
|
||||
help={ __('The background color for input fields', 'tainacan') }>
|
||||
<ColorPicker
|
||||
color={ inputBackgroundColor }
|
||||
onChangeComplete={ (colorValue ) => {
|
||||
inputBackgroundColor = colorValue.hex;
|
||||
setAttributes({ inputBackgroundColor: inputBackgroundColor });
|
||||
}}
|
||||
disableAlpha
|
||||
/>
|
||||
</BaseControl>
|
||||
<HorizontalRule />
|
||||
<BaseControl
|
||||
id="inputColorPicker"
|
||||
label={ __('Input Text color', 'tainacan')}
|
||||
help={ __('The text color for input fields, including dropdowns and buttons', 'tainacan') }>
|
||||
<ColorPicker
|
||||
color={ inputColor }
|
||||
onChangeComplete={ (colorValue ) => {
|
||||
inputColor = colorValue.hex;
|
||||
setAttributes({ inputColor: inputColor });
|
||||
}}
|
||||
disableAlpha
|
||||
/>
|
||||
</BaseControl>
|
||||
<HorizontalRule />
|
||||
<BaseControl
|
||||
id="inputBorderColorPicker"
|
||||
label={ __('Input Border color', 'tainacan')}
|
||||
help={ __('The border color for input fields', 'tainacan') }>
|
||||
<ColorPicker
|
||||
color={ inputBorderColor }
|
||||
onChangeComplete={ (colorValue ) => {
|
||||
inputBorderColor = colorValue.hex;
|
||||
setAttributes({ inputBorderColor: inputBorderColor });
|
||||
}}
|
||||
disableAlpha
|
||||
/>
|
||||
</BaseControl>
|
||||
<HorizontalRule />
|
||||
<BaseControl
|
||||
id="labelColorPicker"
|
||||
label={ __('Label Text color', 'tainacan')}
|
||||
help={ __('The text color for field labels', 'tainacan') }>
|
||||
<ColorPicker
|
||||
color={ labelColor }
|
||||
onChangeComplete={ (colorValue ) => {
|
||||
labelColor = colorValue.hex;
|
||||
setAttributes({ labelColor: labelColor });
|
||||
}}
|
||||
disableAlpha
|
||||
/>
|
||||
</BaseControl>
|
||||
<BaseControl
|
||||
id="infoColorPicker"
|
||||
label={ __('General Info Text color', 'tainacan')}
|
||||
help={ __('The text color for other information such as item metadata, icons, number of pages, etc', 'tainacan') }>
|
||||
<ColorPicker
|
||||
color={ infoColor }
|
||||
onChangeComplete={ (colorValue ) => {
|
||||
infoColor = colorValue.hex;
|
||||
setAttributes({ infoColor: infoColor });
|
||||
}}
|
||||
disableAlpha
|
||||
/>
|
||||
</BaseControl>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
</div>
|
||||
|
||||
{ ( collectionId == undefined ) ? (
|
||||
<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 10 10"
|
||||
height="24px"
|
||||
width="24px">
|
||||
<g transform="translate(227.4751,-183.8442)">
|
||||
<path d="m -227.47379,191.95102 c 0.0372,-2.35931 -0.0195,-4.71936 0.0185,-7.07842 0.0356,-0.55424 0.52604,-0.99051 1.07473,-0.99702 0.80102,-0.0806 1.607,0.0149 2.41027,-0.0211 1.66482,0.0101 3.33138,-0.0202 4.99509,0.01 0.58652,0.0617 1.0108,0.60434 0.99243,1.1815 0.0416,0.76157 -0.0361,1.52426 0.008,2.28649 0.0113,1.65577 -0.006,3.31214 -0.009,4.96756 -0.0429,0.59366 -0.57833,1.06966 -1.17191,1.04765 -0.92086,0.0516 -1.84377,-0.0208 -2.7657,-0.006 -1.49072,-0.0194 -2.98293,0.0353 -4.47258,0.009 -0.60954,-0.039 -1.111,-0.56284 -1.07768,-1.17994 -0.004,-0.0728 -0.004,-0.1462 -0.002,-0.21867 z m 1.15668,0.28162 c 2.40388,0 4.80776,0 7.21164,0 0,-2.41394 0,-4.82787 0,-7.24181 -2.40388,0 -4.80776,0 -7.21164,0 0,2.41394 0,4.82787 0,7.24181 z m 0.53308,-0.53308 c 0,-0.83147 0,-1.66293 0,-2.4944 0.82476,0 1.64953,0 2.47429,0 0,0.83147 0,1.66293 0,2.4944 -0.82476,0 -1.64953,0 -2.47429,0 z m 2.45417,-6.18571 c 0,0.83482 0,1.66964 0,2.50446 -0.82141,0 -1.64282,0 -2.46423,0 0,-0.83482 0,-1.66964 0,-2.50446 0.82141,0 1.64282,0 2.46423,0 z m 1.1768,1.67969 c 0,-0.28833 0,-0.57666 0,-0.86499 0.82811,0 1.65623,0 2.48434,0 0,0.28833 0,0.57666 0,0.86499 -0.82811,0 -1.65623,0 -2.48434,0 z m 2.48434,2.76598 c 0,0.28162 0,0.56325 0,0.84487 -0.82811,0 -1.65623,0 -2.48434,0 0,-0.28162 0,-0.56325 0,-0.84487 0.82811,0 1.65623,0 2.48434,0 z m -5.64258,-2.49441 c 0.48614,0 0.97228,0 1.45842,0 0,-0.47273 0,-0.94546 0,-1.41819 -0.48614,0 -0.97228,0 -1.45842,0 0,0.47273 0,0.94546 0,1.41819 z m 0,3.68126 c 0.48949,0 0.97899,0 1.46848,0 0,-0.47273 0,-0.94546 0,-1.41819 -0.48949,0 -0.97899,0 -1.46848,0 0,0.47273 0,0.94546 0,1.41819 z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
{__('Show an item submission form.', 'tainacan')}
|
||||
</p>
|
||||
<Button
|
||||
isPrimary
|
||||
type="submit"
|
||||
onClick={ () => openCollectionModal() }>
|
||||
{ __('Select a target Collection', 'tainacan')}
|
||||
</Button>
|
||||
|
||||
</Placeholder>
|
||||
) : (
|
||||
|
||||
<div style={{ fontSize: (baseFontSize - 2) + 'px' }}>
|
||||
<div class="preview-warning">
|
||||
{ __('Warning: this is just a demonstration. To see the submission form, either preview or publish your post.', 'tainacan') }
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
'--tainacan-background-color': 'rgba(' + backgroundColor.r + ',' + backgroundColor.g + ',' + backgroundColor.b + ',' + backgroundColor.a + ')',
|
||||
'--tainacan-input-color': inputColor,
|
||||
'--tainacan-input-background-color': inputBackgroundColor,
|
||||
'--tainacan-input-border-color': inputBorderColor,
|
||||
'--tainacan-label-color': labelColor,
|
||||
'--tainacan-info-color': infoColor,
|
||||
'--tainacan-primary': primaryColor,
|
||||
'--tainacan-secondary': secondaryColor
|
||||
}}
|
||||
class="item-submission-form-placeholder">
|
||||
|
||||
<div>
|
||||
{
|
||||
(!hideFileModalButton || !hideTextModalButton || !hideLinkModalButton) ?
|
||||
(
|
||||
<div>
|
||||
{ documentSectionLabel ?
|
||||
<span style={{ display: 'flex', alignItems: 'baseline', marginBottom: '5px' }}><span class="fake-text section-label"></span>{ !hideHelpButtons ? <span class="fake-text fake-help-button"></span> : null }</span>
|
||||
: null }
|
||||
{ [ hideFileModalButton, hideTextModalButton, hideLinkModalButton ].filter((option) => { return option == false }).length > 1 ?
|
||||
<div class="documents-section">
|
||||
{ hideFileModalButton ? null : <span class="fake-circle"><span class="fake-icon"></span></span> }
|
||||
{ hideTextModalButton ? null : <span class="fake-circle"><span class="fake-icon"></span></span> }
|
||||
{ hideLinkModalButton ? null : <span class="fake-circle"><span class="fake-icon"></span></span> }
|
||||
</div>
|
||||
: (
|
||||
(!hideFileModalButton && hideTextModalButton && hideLinkModalButton) ?
|
||||
<div class="fake-image-uploader"></div>
|
||||
: (
|
||||
(hideFileModalButton && !hideTextModalButton && hideLinkModalButton) ?
|
||||
<span class="fake-textarea"></span>
|
||||
: (
|
||||
(hideFileModalButton && hideTextModalButton && !hideLinkModalButton) ?
|
||||
<span class="fake-input" style={{ width: '100%' }}></span>
|
||||
: null
|
||||
)
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
{ !hideThumbnailSection ?
|
||||
(
|
||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
||||
{ !thumbnailSectionLabel ?
|
||||
<span style={{ display: 'flex', alignItems: 'baseline' }}><span class="fake-text section-label"></span>{ !hideHelpButtons ? <span class="fake-text fake-help-button"></span> : null }</span>
|
||||
: null }
|
||||
<div class="fake-switch"><span class="fake-icon"></span><span class="fake-text"></span></div>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
{ !hideAttachmentsSection ?
|
||||
(
|
||||
<div>
|
||||
{ !attachmentsSectionLabel ?
|
||||
<span
|
||||
style={{ position: 'relative' }}
|
||||
class="fake-text section-label">
|
||||
<div class="fake-tooltip"><div class="fake-link"></div></div>
|
||||
</span>
|
||||
: null }
|
||||
<div class="attachments-section">
|
||||
<div class="fake-image-uploader"></div>
|
||||
</div>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
{
|
||||
showAllowCommentsSection ?
|
||||
(
|
||||
<div>
|
||||
<span style={{ display: 'flex', alignItems: 'baseline' }}><span class="fake-text section-label"></span>{ !hideHelpButtons ? <span class="fake-text fake-help-button"></span> : null }</span>
|
||||
<div class="fake-switch"><span class="fake-icon"></span><span class="fake-text"></span></div>
|
||||
</div>
|
||||
) : null }
|
||||
</div>
|
||||
<div style={{ flexGrow: '1' }}>
|
||||
{ metadataSectionLabel ?
|
||||
<div class="fake-text section-label"></div>
|
||||
:null }
|
||||
{ !hideCollapses ? <div class="fake-link"></div> : null }
|
||||
<div class="metadata-section">
|
||||
{ enabledMetadata.length ?
|
||||
enabledMetadata.map( (isEnabled) => {
|
||||
return isEnabled ?
|
||||
<div class={ 'fake-metadata' + (!hideCollapses ? ' has-collapse' : '') }>
|
||||
{ !hideCollapses ? <span class="fake-collapse-arrow"></span> : null }
|
||||
<span style={{ lineHeight: '0em' }}>
|
||||
<span class="fake-text"></span>{ !hideMetadataTypes ? <span class="fake-text fake-text-info"></span> : null }{ !hideHelpButtons ? <span class="fake-text fake-help-button"></span> : null }
|
||||
</span>
|
||||
<span class="fake-input"></span>
|
||||
</div>
|
||||
: null
|
||||
}) :
|
||||
Array(12).fill().map( () => {
|
||||
return <div class={ 'fake-metadata' + (!hideCollapses ? ' has-collapse' : '') }>
|
||||
{ !hideCollapses ? <span class="fake-collapse-arrow"></span> : null }
|
||||
<span class="fake-text"></span>
|
||||
<span class="fake-input"></span>
|
||||
</div>
|
||||
})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-footer">
|
||||
<span class="fake-button outline"><span class="fake-text"></span></span>
|
||||
<span class="fake-text"></span>
|
||||
<span class="fake-button"><span class="fake-text"></span></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
{ isCollectionModalOpen ?
|
||||
<CollectionModal
|
||||
filterOptionsBy={ { allows_submission: 'yes' } }
|
||||
existingCollectionId={ collectionId }
|
||||
onSelectCollection={ ({ collectionId }) => {
|
||||
collectionId = collectionId;
|
||||
setAttributes({
|
||||
collectionId: collectionId,
|
||||
isCollectionModalOpen: false
|
||||
});
|
||||
loadCollectionMetadata(collectionId);
|
||||
}}
|
||||
onCancelSelection={ () => setAttributes({ isCollectionModalOpen: false }) }/>
|
||||
: null
|
||||
}
|
||||
|
||||
</div>
|
||||
);
|
||||
},
|
||||
save({ attributes, className }){
|
||||
const {
|
||||
collectionId,
|
||||
backgroundColor,
|
||||
hideFileModalButton,
|
||||
hideTextModalButton,
|
||||
hideLinkModalButton,
|
||||
hideThumbnailSection,
|
||||
hideAttachmentsSection,
|
||||
showAllowCommentsSection,
|
||||
hideHelpButtons,
|
||||
hideMetadataTypes,
|
||||
hideCollapses,
|
||||
documentSectionLabel,
|
||||
thumbnailSectionLabel,
|
||||
attachmentsSectionLabel,
|
||||
metadataSectionLabel,
|
||||
baseFontSize,
|
||||
inputColor,
|
||||
inputBackgroundColor,
|
||||
inputBorderColor,
|
||||
labelColor,
|
||||
infoColor,
|
||||
primaryColor,
|
||||
secondaryColor,
|
||||
enabledMetadata,
|
||||
sentFormHeading,
|
||||
sentFormMessage,
|
||||
} = attributes;
|
||||
|
||||
return <div
|
||||
style={{
|
||||
'font-size': baseFontSize + 'px',
|
||||
'--tainacan-base-font-size': baseFontSize + 'px',
|
||||
'--tainacan-background-color': 'rgba(' + backgroundColor.r + ',' + backgroundColor.g + ',' + backgroundColor.b + ',' + backgroundColor.a + ')',
|
||||
'--tainacan-input-color': inputColor,
|
||||
'--tainacan-input-background-color': inputBackgroundColor,
|
||||
'--tainacan-input-border-color': inputBorderColor,
|
||||
'--tainacan-label-color': labelColor,
|
||||
'--tainacan-info-color': infoColor,
|
||||
'--tainacan-primary': primaryColor,
|
||||
'--tainacan-secondary': secondaryColor
|
||||
}}
|
||||
className={ className }>
|
||||
<div
|
||||
id="tainacan-item-submission-form"
|
||||
collection-id={ collectionId }
|
||||
hide-file-modal-button={ hideFileModalButton.toString() }
|
||||
hide-text-modal-button={ hideTextModalButton.toString() }
|
||||
hide-link-modal-button={ hideLinkModalButton.toString() }
|
||||
hide-thumbnail-section={ hideThumbnailSection.toString() }
|
||||
hide-attachments-section={ hideAttachmentsSection.toString() }
|
||||
show-allow-comments-section={ showAllowCommentsSection.toString() }
|
||||
hide-help-buttons={ hideHelpButtons.toString() }
|
||||
hide-metadata-types={ hideMetadataTypes.toString() }
|
||||
hide-collapses={ hideCollapses.toString() }
|
||||
enabled-metadata={ enabledMetadata.toString() }
|
||||
sent-form-heading={ sentFormHeading }
|
||||
sent-form-message={ sentFormMessage }
|
||||
document-section-label={ documentSectionLabel }
|
||||
thumbnail-section-label={ thumbnailSectionLabel }
|
||||
attachments-section-label={ attachmentsSectionLabel }
|
||||
metadata-section-label={ metadataSectionLabel } >
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
});
|
|
@ -0,0 +1,303 @@
|
|||
@import '../../gutenberg-blocks-variables.scss';
|
||||
|
||||
#metadata-checkbox-list {
|
||||
margin: 8px 12px 18px 12px;
|
||||
|
||||
.components-base-control__help {
|
||||
margin-left: 33px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--tainacan-block-gray4, $gray4);
|
||||
}
|
||||
}
|
||||
.wp-block-tainacan-item-submission-form {
|
||||
margin: 2em auto;
|
||||
|
||||
// Spinner
|
||||
.spinner-container {
|
||||
min-height: 56px;
|
||||
padding: 1em;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: var(--tainacan-block-gray4, $gray4);
|
||||
}
|
||||
|
||||
.preview-warning {
|
||||
width: 100%;
|
||||
font-size: 0.875em;
|
||||
font-style: italic;
|
||||
color: var(--tainacan-block-gray4, $gray4);
|
||||
text-align: center;
|
||||
margin: 4px auto;
|
||||
}
|
||||
.item-submission-form-placeholder {
|
||||
background-color: var(--tainacan-background-color, white);
|
||||
padding: 0 4.1666667%;
|
||||
font-size: 1.125em;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
flex-direction: column;
|
||||
border-radius: 4px;
|
||||
border: 1px solid rgba(200,200,200, 0.3);
|
||||
overflow: hidden;
|
||||
|
||||
.fake-text {
|
||||
background-color: var(--tainacan-label-color, rgba(200,200,200, 0.3));
|
||||
height: 0.25em;
|
||||
width: 15%;
|
||||
min-width: 1.25em;
|
||||
border-radius: 2px;
|
||||
display: inline-block;
|
||||
|
||||
&.section-label {
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
height: 0.32em;
|
||||
}
|
||||
&.fake-text-info {
|
||||
background-color: var(--tainacan-info-color, rgba(200,200,200, 0.3));
|
||||
width: 5%;
|
||||
opacity: 0.75;
|
||||
margin-left: 6px;
|
||||
}
|
||||
&.fake-help-button {
|
||||
background-color: var(--tainacan-secondary, rgba(200,200,200, 0.3));
|
||||
height: 0.32em;
|
||||
width: 0.32em;
|
||||
min-width: 0.25em;
|
||||
border-radius: 0.2em;
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
.fake-collapse-arrow {
|
||||
position: relative;
|
||||
top: 0.2em;
|
||||
left: -0.75em;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0.2em 0.2em 0 0.2em;
|
||||
border-color: var(--tainacan-secondary, rgba(200,200,200, 0.3)) transparent transparent transparent;
|
||||
}
|
||||
.fake-link {
|
||||
background-color: var(--tainacan-secondary, rgba(200,200,200, 0.3));
|
||||
height: 0.2em;
|
||||
width: 10%;
|
||||
border-radius: 2px;
|
||||
display: inline-block;
|
||||
}
|
||||
.fake-icon {
|
||||
background-color: var(--tainacan-info-color, rgba(200,200,200, 0.3));
|
||||
height: 0.5em;
|
||||
width: 0.5em;
|
||||
min-height: 0.5em;
|
||||
min-width: 0.5em;
|
||||
max-height: 0.5em;
|
||||
max-width: 0.5em;
|
||||
border-radius: 2px;
|
||||
display: inline-block;
|
||||
}
|
||||
.fake-image-uploader {
|
||||
background-size: cover;
|
||||
height: 3em;
|
||||
background-color: var(--tainacan-input-background-color, rgba(200,200,200, 0.3));
|
||||
border: 2px dashed var(--tainacan-input-border-color, rgba(200,200,200, 0.3));
|
||||
width: 100%;
|
||||
border-radius: 2px;
|
||||
display: inline-block;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--tainacan-primary, rgba(200,200,200, 0.1));
|
||||
}
|
||||
}
|
||||
.fake-tooltip {
|
||||
background-color: var(--tainacan-primary, rgba(200,200,200, 0.1));
|
||||
position: absolute;
|
||||
height: 0.75em;
|
||||
width: 4em;
|
||||
border-radius: 2px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
top: -1.0em;
|
||||
left: 1em;
|
||||
|
||||
.fake-link {
|
||||
width: 100%;
|
||||
margin: 0 4px 0 8px;
|
||||
}
|
||||
|
||||
&:before {
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
}
|
||||
&:before {
|
||||
border-color: var(--tainacan-primary) transparent transparent transparent;
|
||||
border-right-width: 6px;
|
||||
border-top-width: 6px;
|
||||
border-left-width: 6px;
|
||||
bottom: -8px;
|
||||
}
|
||||
}
|
||||
.fake-input {
|
||||
background-color: var(--tainacan-input-background-color, rgba(200,200,200, 0.3));
|
||||
height: 1.5em;
|
||||
width: 18%;
|
||||
border: 2px solid var(--tainacan-input-border-color, rgba(200,200,200, 0.3));
|
||||
border-radius: 3px;
|
||||
display: inline-block;
|
||||
}
|
||||
.fake-textarea {
|
||||
background-color: var(--tainacan-input-background-color, rgba(200,200,200, 0.3));
|
||||
height: 2.5em;
|
||||
width: 100%;
|
||||
border: 2px solid var(--tainacan-input-border-color, rgba(200,200,200, 0.3));
|
||||
border-radius: 3px;
|
||||
display: inline-block;
|
||||
}
|
||||
.fake-button {
|
||||
background-color: var(--tainacan-secondary, rgba(200,200,200, 0.3));
|
||||
padding: 0.4em 0.7em;
|
||||
height: 0.95em;
|
||||
width: 10%;
|
||||
max-width: 3.25em;
|
||||
min-width: 1em;
|
||||
margin-left: 6px;
|
||||
border-radius: 3px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: auto;
|
||||
|
||||
.fake-text {
|
||||
background-color: white;
|
||||
width: 95%;
|
||||
margin: 0 2px;
|
||||
}
|
||||
.fake-icon {
|
||||
background-color: white;
|
||||
flex: 1 0 auto;
|
||||
margin: 0 2px;
|
||||
}
|
||||
&.outline {
|
||||
border: 2px solid var(--tainacan-input-border-color rgba(200,200,200, 0.3));
|
||||
background-color: var(--tainacan-background-color, white);
|
||||
|
||||
.fake-text {
|
||||
background-color: var(--tainacan-secondary, rgba(200,200,200, 0.1));
|
||||
}
|
||||
}
|
||||
}
|
||||
.fake-switch {
|
||||
padding: 0.5em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.fake-icon {
|
||||
background-color: var(--tainacan-secondary, rgba(200,200,200, 0.3));
|
||||
width: 1.5em;
|
||||
height: 0.5em;
|
||||
border-radius: 1em;
|
||||
max-height: 1em;
|
||||
max-width: 1em;
|
||||
}
|
||||
.fake-text {
|
||||
margin-left: 0.5em;
|
||||
width: 24%;
|
||||
max-width: 4em;
|
||||
}
|
||||
}
|
||||
.documents-section {
|
||||
display: flex;
|
||||
padding: 0.5em;
|
||||
|
||||
.fake-circle {
|
||||
margin-right: 1.75em;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 3em;
|
||||
height: 3em;
|
||||
border-radius: 100%;
|
||||
background-color: var(--tainacan-input-border-color, rgba(200,200,200, 0.3));
|
||||
|
||||
.fake-icon {
|
||||
background-color: var(--tainacan-secondary, rgba(200,200,200, 0.3));
|
||||
}
|
||||
&:hover {
|
||||
background-color: var(--tainacan-primary, rgba(200,200,200, 0.2));
|
||||
}
|
||||
}
|
||||
}
|
||||
.thumbnail-section {
|
||||
padding: 0.5em;
|
||||
|
||||
.fake-button {
|
||||
position: relative;
|
||||
max-width: 0.85em;
|
||||
min-width: 0.85em;
|
||||
margin-top: -1em;
|
||||
margin-left: 2rem;
|
||||
border-radius: 100%;
|
||||
z-index: 99;
|
||||
padding: 4px;
|
||||
}
|
||||
.fake-icon {
|
||||
max-height: 0.2em;
|
||||
max-width: 0.2em;
|
||||
width: 0.2em;
|
||||
height: 0.2em;
|
||||
min-width: 0.2em;
|
||||
min-height: 0.2em;
|
||||
border-radius: 100%;
|
||||
}
|
||||
}
|
||||
.attachments-section {
|
||||
padding: 0.5em;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.metadata-section {
|
||||
width: 100%;
|
||||
padding: 0.5em 1em;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
flex-direction: column;
|
||||
|
||||
.fake-metadata {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
|
||||
.fake-input {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin: 0.25em 0 0.4em 0;
|
||||
}
|
||||
&.has-collapse {
|
||||
border-bottom: 1px solid var(--tainacan-input-border-color, rgba(200,200,200, 0.3));
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
.form-footer {
|
||||
padding: 1em 0 2em 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
&>.fake-text {
|
||||
background-color: var(--tainacan-info-color, rgba(200,200,200, 0.3));
|
||||
}
|
||||
.fake-button {
|
||||
margin: 0 1em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -178,13 +178,13 @@ registerBlockType('tainacan/search-bar', {
|
|||
(alignment == 'right' ? ' is-aligned-right' : '')
|
||||
}
|
||||
id="tainacan-search-bar-block"
|
||||
action={ tainacan_blocks.site_url + '/' + collectionSlug + '/#/' }
|
||||
action={ tainacan_blocks.site_url + '/' + collectionSlug }
|
||||
method='get'>
|
||||
<input
|
||||
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
|
||||
id="tainacan-search-bar-block_input"
|
||||
label={ __('Search', 'tainacan')}
|
||||
name='search'
|
||||
name='s'
|
||||
placeholder={ placeholderText }
|
||||
/>
|
||||
<button
|
||||
|
@ -223,13 +223,13 @@ registerBlockType('tainacan/search-bar', {
|
|||
(alignment == 'right' ? ' is-aligned-right' : '')
|
||||
}
|
||||
id="tainacan-search-bar-block"
|
||||
action={ tainacan_blocks.site_url + '/' + collectionSlug + '/#/' }
|
||||
action={ tainacan_blocks.site_url + '/' + collectionSlug }
|
||||
method='get'>
|
||||
<input
|
||||
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
|
||||
id="tainacan-search-bar-block_input"
|
||||
label={ __('Search', 'tainacan')}
|
||||
name='search'
|
||||
name='s'
|
||||
placeholder={ placeholderText }
|
||||
/>
|
||||
<button
|
||||
|
@ -621,7 +621,7 @@ registerBlockType('tainacan/search-bar', {
|
|||
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
|
||||
id="tainacan-search-bar-block_input"
|
||||
label={ __('Search', 'tainacan')}
|
||||
name='search'
|
||||
name='s'
|
||||
placeholder={ placeholderText }
|
||||
/>
|
||||
<button
|
||||
|
@ -667,7 +667,7 @@ registerBlockType('tainacan/search-bar', {
|
|||
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
|
||||
id="tainacan-search-bar-block_input"
|
||||
label={ __('Search', 'tainacan')}
|
||||
name='search'
|
||||
name='s'
|
||||
placeholder={ placeholderText }
|
||||
/>
|
||||
<button
|
||||
|
|
|
@ -6,7 +6,7 @@ document.addEventListener("DOMContentLoaded",() => {
|
|||
let input = document.getElementById('tainacan-search-bar-block_input');
|
||||
if (input) {
|
||||
if (input.value)
|
||||
window.location.href = e.target.action + '?search=' + input.value;
|
||||
window.location.href = e.target.action + '?s=' + input.value;
|
||||
return;
|
||||
}
|
||||
}));
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue