Merge branch 'develop' of https://github.com/tainacan/tainacan into develop
This commit is contained in:
commit
766c9e8a68
|
@ -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
|
||||
|
|
|
@ -0,0 +1,234 @@
|
|||
#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.2em;
|
||||
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.25em; }
|
||||
.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 {
|
||||
background-size: cover;
|
||||
background-color: var(--tainacan-gray2, rgba(200, 200, 200, 0.3));
|
||||
height: 3em;
|
||||
width: 3em;
|
||||
min-height: 3em;
|
||||
min-width: 3em;
|
||||
max-height: 3em;
|
||||
max-width: 3em;
|
||||
border-radius: 2px;
|
||||
display: inline-block; }
|
||||
.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: 0.95em;
|
||||
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-button {
|
||||
background-color: var(--tainacan-secondary, rgba(200, 200, 200, 0.3));
|
||||
padding: 0.3em 0.5em;
|
||||
height: 0.8em;
|
||||
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: 2em;
|
||||
height: 2em;
|
||||
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-image {
|
||||
height: 3.5em;
|
||||
width: 3.5em;
|
||||
min-height: 3.5em;
|
||||
min-width: 3.5em;
|
||||
max-height: 3.5em;
|
||||
max-width: 3.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 .attachments-section .fake-image {
|
||||
margin-right: 0.25em;
|
||||
margin-bottom: 0.25em; }
|
||||
.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,KAAK;MACb,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;IAGtB,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,qFAAY;MACR,eAAe,EAAE,KAAK;MACtB,gBAAgB,EAAE,+CAA6C;MAC/D,MAAM,EAAE,GAAG;MACX,KAAK,EAAE,GAAG;MACV,UAAU,EAAE,GAAG;MACf,SAAS,EAAE,GAAG;MACd,UAAU,EAAE,GAAG;MACf,SAAS,EAAE,GAAG;MACd,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,YAAY;IAEzB,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,MAAM;MACd,KAAK,EAAE,GAAG;MACV,MAAM,EAAE,sEAAoE;MAC5E,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,YAAY;IAEzB,sFAAa;MACT,gBAAgB,EAAE,mDAAiD;MACnE,OAAO,EAAE,WAAW;MACpB,MAAM,EAAE,KAAK;MACb,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,wGAAY;QACR,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,KAAK;QACZ,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;MAEpB,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;MAE3B,0GAAY;QACR,YAAY,EAAE,MAAM;QACpB,aAAa,EAAE,MAAM;IAG7B,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"
|
||||
}
|
|
@ -566,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 {
|
||||
|
|
|
@ -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'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -828,6 +851,224 @@ 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()) {
|
||||
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'];
|
||||
|
||||
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 on create 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 on create 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 on create 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
|
|
|
@ -42,7 +42,7 @@ class Media {
|
|||
if( ob_get_level() > 0 ) {
|
||||
ob_flush();
|
||||
}
|
||||
flush();
|
||||
// flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,35 +9,38 @@ 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;
|
||||
|
||||
/**
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Tainacan\Entities\Entity::post_type
|
||||
* @var string
|
||||
|
@ -131,7 +134,7 @@ class Collection extends Entity {
|
|||
'revisions',
|
||||
'page-attributes',
|
||||
'post-formats',
|
||||
'comments'
|
||||
'comments'
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -227,7 +230,7 @@ class Collection extends Entity {
|
|||
return apply_filters("tainacan-collection-get-attachments", $attachments, $exclude, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function get_author_name() {
|
||||
|
@ -242,11 +245,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 +274,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 +433,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 +536,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 +544,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' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -730,7 +760,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 +769,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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 user.', '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' ),
|
||||
|
|
|
@ -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' ) );
|
||||
|
@ -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:
|
||||
|
|
|
@ -458,6 +458,75 @@
|
|||
: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>
|
||||
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
v-if="formHooks != undefined &&
|
||||
|
@ -556,6 +625,9 @@ export default {
|
|||
enabled_view_modes: [],
|
||||
default_view_mode: [],
|
||||
allow_comments: '',
|
||||
allows_submission: 'no',
|
||||
submission_default_status: 'draft',
|
||||
submission_anonymous_user: 'no',
|
||||
hide_items_thumbnail_on_lists: ''
|
||||
},
|
||||
thumbnail: {},
|
||||
|
@ -650,6 +722,9 @@ 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.hide_items_thumbnail_on_lists = this.collection.hide_items_thumbnail_on_lists;
|
||||
|
||||
// Generates CoverPage from current cover_page_id info
|
||||
|
@ -747,6 +822,9 @@ 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,
|
||||
allow_comments: this.form.allow_comments,
|
||||
hide_items_thumbnail_on_lists: this.form.hide_items_thumbnail_on_lists
|
||||
};
|
||||
|
@ -770,6 +848,9 @@ 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.hide_items_thumbnail_on_lists = this.collection.hide_items_thumbnail_on_lists;
|
||||
|
||||
this.isLoading = false;
|
||||
|
@ -824,6 +905,9 @@ 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.hide_items_thumbnail_on_lists = this.collection.hide_items_thumbnail_on_lists;
|
||||
|
||||
// Pre-fill status with publish to incentivate it
|
||||
|
@ -1129,6 +1213,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>
|
||||
|
||||
|
|
|
@ -1571,7 +1571,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 +1637,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 +1669,7 @@ export default {
|
|||
color: var(--tainacan-secondary);
|
||||
margin-bottom: 6px;
|
||||
&:hover {
|
||||
background-color: var(--tainacan-turquoise2);
|
||||
background-color: var(--tainacan-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
@ -1808,7 +1808,7 @@ export default {
|
|||
|
||||
.sequence-progress {
|
||||
height: 5px;
|
||||
background: var(--tainacan-turquoise5);
|
||||
background: var(--tainacan-secondary);
|
||||
width: 0%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
@ -1826,7 +1826,7 @@ export default {
|
|||
|
||||
.sequence-button {
|
||||
background-color: transparent;
|
||||
color: var(--tainacan-turquoise5);
|
||||
color: var(--tainacan-secondary);
|
||||
border: none;
|
||||
|
||||
.icon {
|
||||
|
@ -1837,7 +1837,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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -473,13 +473,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="{
|
||||
|
@ -777,7 +777,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'
|
||||
|
@ -785,14 +785,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'
|
||||
|
@ -800,7 +800,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: {
|
||||
|
@ -808,7 +808,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'
|
||||
|
@ -820,7 +820,7 @@
|
|||
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
|
||||
|
@ -964,7 +964,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 -->
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,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 +50,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">
|
||||
|
@ -137,7 +137,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')
|
||||
|
|
|
@ -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,
|
||||
|
@ -42,7 +45,7 @@
|
|||
</span>
|
||||
<transition name="filter-item">
|
||||
<div
|
||||
v-show="isCollapsed || errorMessage"
|
||||
v-show="hideCollapses || (isCollapsed || errorMessage)"
|
||||
v-if="isTextInputComponent">
|
||||
<component
|
||||
:is="metadatumComponent"
|
||||
|
@ -91,7 +94,7 @@
|
|||
<!-- 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"
|
||||
|
@ -111,7 +114,8 @@
|
|||
name: 'TainacanFormItem',
|
||||
props: {
|
||||
itemMetadatum: Object,
|
||||
isCollapsed: true
|
||||
isCollapsed: true,
|
||||
hideCollapses: false
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
@ -162,48 +166,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 +218,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 +244,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;
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
valueComponent( val ){
|
||||
valueComponent( val ) {
|
||||
this.$emit('input', val);
|
||||
}
|
||||
},
|
||||
|
@ -95,7 +95,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();
|
||||
|
|
|
@ -1096,6 +1096,10 @@
|
|||
.tags.is-small {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
section p {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
}
|
||||
|
||||
.tainacan-modal-checkbox-search-results-body {
|
||||
|
|
|
@ -921,7 +921,7 @@
|
|||
background-color: var(--tainacan-blue1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.tainacan-li-search-results {
|
||||
flex-grow: 0;
|
||||
flex-shrink: 1;
|
||||
|
@ -1166,6 +1166,10 @@
|
|||
.tags.is-small {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
section p {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
}
|
||||
|
||||
.tainacan-modal-checkbox-search-results-body {
|
||||
|
|
|
@ -733,7 +733,7 @@
|
|||
margin-bottom: 0 !important;
|
||||
|
||||
ul {
|
||||
padding: none;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
.hidden-tabs-section /deep/ .tabs {
|
||||
|
@ -1017,6 +1017,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;
|
||||
},
|
||||
|
|
|
@ -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 = 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() {
|
||||
|
|
|
@ -293,4 +293,80 @@ export const updateThumbnail = ({ commit }, { itemId, thumbnailId }) => {
|
|||
});
|
||||
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
// 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 }) => {
|
||||
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];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,7 +292,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({
|
||||
|
@ -381,7 +381,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({
|
||||
|
|
|
@ -213,7 +213,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
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
}
|
||||
li {
|
||||
overflow-y: hidden;
|
||||
margin: 0;
|
||||
}
|
||||
a {
|
||||
font-size: 0.8125em;
|
||||
|
|
|
@ -54,5 +54,14 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,38 @@ 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_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 +411,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';
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -255,7 +255,6 @@ registerBlockType('tainacan/faceted-search', {
|
|||
showInlineViewModeOptions,
|
||||
showFullscreenWithViewModes,
|
||||
listType,
|
||||
isCollectionModalOpen,
|
||||
isTermModalOpen,
|
||||
backgroundColor,
|
||||
baseFontSize,
|
||||
|
|
|
@ -0,0 +1,788 @@
|
|||
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'),
|
||||
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
|
||||
},
|
||||
showAllowCommentsSection: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
hideCollapses: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
backgroundColor: {
|
||||
type: String,
|
||||
default: '#ffffff'
|
||||
},
|
||||
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,
|
||||
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 (
|
||||
<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 }
|
||||
checked={ isMetadatumEnabled ? true : false }
|
||||
help={ collectionMetadata[index].metadata_type_object.name + (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 file submission 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 text submission 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 link submission 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 });
|
||||
}
|
||||
}
|
||||
/>
|
||||
</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.hex;
|
||||
setAttributes({ backgroundColor: backgroundColor });
|
||||
}}
|
||||
disableAlpha
|
||||
/>
|
||||
</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': backgroundColor,
|
||||
'--tainacan-input-color': inputColor,
|
||||
'--tainacan-input-background-color': inputBackgroundColor,
|
||||
'--tainacan-input-border-color': inputBorderColor,
|
||||
'--tainacan-label-color': labelColor,
|
||||
'--tainacan-info-color': infoColor,
|
||||
'--tainacan-primary': primaryColor,
|
||||
'--tainacan-secondary': secondaryColor
|
||||
}}
|
||||
class="item-submission-form-placeholder">
|
||||
|
||||
<div>
|
||||
{
|
||||
(!hideFileModalButton || !hideTextModalButton || !hideLinkModalButton) ?
|
||||
(
|
||||
<div>
|
||||
<span class="fake-text section-label"></span>
|
||||
<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>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
{ !hideThumbnailSection ?
|
||||
(
|
||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
||||
<span class="fake-text section-label"></span>
|
||||
<div class="fake-switch"><span class="fake-icon"></span><span class="fake-text"></span></div>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
{ !hideAttachmentsSection ?
|
||||
(
|
||||
<div>
|
||||
<span
|
||||
style={{ position: 'relative' }}
|
||||
class="fake-text section-label">
|
||||
<div class="fake-tooltip"><div class="fake-link"></div></div>
|
||||
</span>
|
||||
<div class="attachments-section">
|
||||
<div class="fake-image"></div>
|
||||
<div class="fake-image"></div>
|
||||
<div class="fake-image"></div>
|
||||
<div class="fake-image"></div>
|
||||
</div>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
{
|
||||
showAllowCommentsSection ?
|
||||
(
|
||||
<div>
|
||||
<span class="fake-text section-label"></span>
|
||||
<div class="fake-switch"><span class="fake-icon"></span><span class="fake-text"></span></div>
|
||||
</div>
|
||||
) : null }
|
||||
</div>
|
||||
<div style={{ flexGrow: '1' }}>
|
||||
<div class="fake-text section-label"></div>
|
||||
{ !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 class="fake-text"></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,
|
||||
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': backgroundColor,
|
||||
'--tainacan-input-color': inputColor,
|
||||
'--tainacan-input-background-color': inputBackgroundColor,
|
||||
'--tainacan-input-border-color': inputBorderColor,
|
||||
'--tainacan-label-color': labelColor,
|
||||
'--tainacan-info-color': infoColor,
|
||||
'--tainacan-primary': primaryColor,
|
||||
'--tainacan-secondary': secondaryColor
|
||||
}}
|
||||
className={ className }>
|
||||
<div
|
||||
id="tainacan-item-submission-form"
|
||||
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-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,293 @@
|
|||
@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.2em;
|
||||
width: 15%;
|
||||
min-width: 1.25em;
|
||||
border-radius: 2px;
|
||||
display: inline-block;
|
||||
|
||||
&.section-label {
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
height: 0.25em;
|
||||
}
|
||||
}
|
||||
.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 {
|
||||
background-size: cover;
|
||||
background-color: var(--tainacan-gray2, rgba(200,200,200, 0.3));
|
||||
height: 3em;
|
||||
width: 3em;
|
||||
min-height: 3em;
|
||||
min-width: 3em;
|
||||
max-height: 3em;
|
||||
max-width: 3em;
|
||||
border-radius: 2px;
|
||||
display: inline-block;
|
||||
}
|
||||
.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: 0.95em;
|
||||
width: 18%;
|
||||
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.3em 0.5em;
|
||||
height: 0.8em;
|
||||
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: 2em;
|
||||
height: 2em;
|
||||
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-image {
|
||||
height: 3.5em;
|
||||
width: 3.5em;
|
||||
min-height: 3.5em;
|
||||
min-width: 3.5em;
|
||||
max-height: 3.5em;
|
||||
max-width: 3.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;
|
||||
|
||||
.fake-image {
|
||||
margin-right: 0.25em;
|
||||
margin-bottom: 0.25em;
|
||||
}
|
||||
}
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
<template>
|
||||
<item-submission-form
|
||||
:collection-id="$root.collectionId"
|
||||
class="tainacan-item-submission-form"
|
||||
:hide-file-modal-button="$root.hideFileModalButton ? $root.hideFileModalButton : false"
|
||||
:hide-text-modal-button="$root.hideTextModalButton ? $root.hideTextModalButton : false"
|
||||
:hide-link-modal-button="$root.hideLinkModalButton ? $root.hideLinkModalButton : false"
|
||||
:hide-thumbnail-section="$root.hideThumbnailSection ? $root.hideThumbnailSection : false"
|
||||
:hide-attachments-section="$root.hideAttachmentsSection ? $root.hideAttachmentsSection : false"
|
||||
:show-allow-comments-section="$root.showAllowCommentsSection ? $root.showAllowCommentsSection : false"
|
||||
:hide-collapses="$root.hideCollapses ? $root.hideCollapses : false"
|
||||
:enabled-metadata="$root.enabledMetadata ? $root.enabledMetadata : []"
|
||||
:sent-form-heading="$root.sentFormHeading"
|
||||
:sent-form-message="$root.sentFormMessage"
|
||||
:document-section-label="$root.documentSectionLabel"
|
||||
:thumbnail-section-label="$root.thumbnailSectionLabel"
|
||||
:attachments-section-label="$root.attachmentsSectionLabel"
|
||||
:metadata-section-label="$root.metadataSectionLabel" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "ItemSubmission"
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
// TAINACAN Variables
|
||||
@import "../admin/scss/_variables.scss";
|
||||
|
||||
// Bulma imports
|
||||
@import "./scss/item-submission-basics.sass";
|
||||
|
||||
// Buefy imports
|
||||
@import "../../../node_modules/buefy/src/scss/utils/_all.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_datepicker.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_checkbox.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_radio.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_switch.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_upload.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_tag.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_loading.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_dropdown.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_modal.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_dialog.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_notices.scss";
|
||||
@import "../../../node_modules/buefy/src/scss/components/_numberinput.scss";
|
||||
|
||||
// Tainacan imports
|
||||
@import "../admin/scss/_tainacan-form.scss";
|
||||
@import "../admin/scss/_modals.scss";
|
||||
@import "../admin/scss/_buttons.scss";
|
||||
@import "../admin/scss/_inputs.scss";
|
||||
@import "../admin/scss/_checkboxes.scss";
|
||||
@import "../admin/scss/_radios.scss";
|
||||
@import "../admin/scss/_switches.scss";
|
||||
@import "../admin/scss/_pagination.scss";
|
||||
@import "../admin/scss/_tags.scss";
|
||||
@import "../admin/scss/_notices.scss";
|
||||
@import "../admin/scss/_tabs.scss";
|
||||
@import "../admin/scss/_selects.scss";
|
||||
@import "../admin/scss/_dropdown-and-autocomplete.scss";
|
||||
@import "../admin/scss/_tooltips.scss";
|
||||
@import "../admin/scss/_control.scss";
|
||||
@import "../admin/scss/_custom_variables.scss";
|
||||
|
||||
.tainacan-item-submission-form {
|
||||
.tainacan-icon {
|
||||
opacity: 0; // Will make it 1 once window.load is done;
|
||||
}
|
||||
|
||||
a, a:not([href]) {
|
||||
color: var(--tainacan-secondary);
|
||||
}
|
||||
a:hover,
|
||||
a:hover:not([href]) {
|
||||
cursor: pointer;
|
||||
color: var(--tainacan-secondary);
|
||||
text-decoration: underline;
|
||||
}
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
// We need this because bootstrap messes up with this class
|
||||
.dropdown-menu {
|
||||
display: block;
|
||||
}
|
||||
.dropdown.is-inline .dropdown-content {
|
||||
display: flex;
|
||||
border: none;
|
||||
|
||||
.dropdown-item {
|
||||
padding: 0.125em 0.5em !important;
|
||||
|
||||
.gray-icon {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.date-filter-container,
|
||||
.numeric-filter-container {
|
||||
@media screen and (min-width: 1366px) {
|
||||
flex-wrap: nowrap !important;
|
||||
height: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
.column-large-width {
|
||||
.tainacan-compound-group {
|
||||
display: inline-block;
|
||||
font-size: 1.125em;
|
||||
margin-top: -0.25em;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
max-width: 100%;
|
||||
|
||||
& * {
|
||||
display: inline-block;
|
||||
}
|
||||
.label {
|
||||
font-size: 1em;
|
||||
color: var(--tainacan-info-color);
|
||||
&:not(:first-child)::before {
|
||||
content: ', ';
|
||||
font-size: 1em;
|
||||
font-weight: normal;
|
||||
color: var(--tainacan-info-color);
|
||||
display: inline-block;
|
||||
margin-right: 0.35em;
|
||||
margin-left: -0.15em;
|
||||
}
|
||||
&::after {
|
||||
content: ': ';
|
||||
font-size: 1em;
|
||||
color: var(--tainacan-info-color);
|
||||
display: inline-block;
|
||||
margin-right: 0.15em;
|
||||
}
|
||||
}
|
||||
p {
|
||||
font-size: 1em !important;
|
||||
line-height: 1.65em !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
.metadata-value {
|
||||
|
||||
.tainacan-compound-group {
|
||||
margin-left: 2px;
|
||||
padding-left: 0.875em;
|
||||
border-left: 1px solid var(--tainacan-gray2);
|
||||
|
||||
.tainacan-compound-metadatum .label {
|
||||
margin-bottom: 0.25em;
|
||||
font-size: 1em;
|
||||
color: var(--tainacan-info-color);
|
||||
}
|
||||
.tainacan-compound-metadatum p {
|
||||
margin-bottom: 0.75em;
|
||||
font-size: 1em;
|
||||
}
|
||||
.multivalue-separator {
|
||||
display: block;
|
||||
max-height: 1px;
|
||||
width: 60px;
|
||||
background: var(--tainacan-gray2);
|
||||
content: none;
|
||||
color: transparent;
|
||||
margin: 1em auto 1em -0.875em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,182 @@
|
|||
// Main imports
|
||||
import Vue from 'vue';
|
||||
import Buefy from 'buefy';
|
||||
import VTooltip from 'v-tooltip';
|
||||
import cssVars from 'css-vars-ponyfill';
|
||||
import VueTheMask from 'vue-the-mask';
|
||||
import qs from 'qs';
|
||||
|
||||
// Metadata Types
|
||||
import Text from '../../admin/components/metadata-types/text/Text.vue';
|
||||
import Textarea from '../../admin/components/metadata-types/textarea/Textarea.vue';
|
||||
import Selectbox from '../../admin/components/metadata-types/selectbox/Selectbox.vue';
|
||||
import Numeric from '../../admin/components/metadata-types/numeric/Numeric.vue';
|
||||
import Date from '../../admin/components/metadata-types/date/Date.vue';
|
||||
import Relationship from '../../admin/components/metadata-types/relationship/Relationship.vue';
|
||||
import Taxonomy from '../../admin/components/metadata-types/taxonomy/Taxonomy.vue';
|
||||
import Compound from '../../admin/components/metadata-types/compound/Compound.vue';
|
||||
import User from '../../admin/components/metadata-types/user/User.vue';
|
||||
|
||||
// Main components
|
||||
import ItemSubmissionForm from '../pages/item-submission-form.vue';
|
||||
import ItemSubmission from '../item-submission.vue';
|
||||
|
||||
// Remaining imports
|
||||
import TainacanFormItem from '../../admin/components/metadata-types/tainacan-form-item.vue';
|
||||
import HelpButton from '../../admin/components/other/help-button.vue';
|
||||
import store from '../../admin/js/store/store';
|
||||
import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin, StatusHelperPlugin, CommentsStatusHelperPlugin } from '../../admin/js/utilities';
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
// Mount only if the div exists
|
||||
if (document.getElementById('tainacan-item-submission-form')) {
|
||||
|
||||
|
||||
// Display Icons only once everything is loaded
|
||||
function listen(evnt, elem, func) {
|
||||
if (elem.addEventListener) // W3C DOM
|
||||
elem.addEventListener(evnt,func,false);
|
||||
else if (elem.attachEvent) { // IE DOM
|
||||
var r = elem.attachEvent("on"+evnt, func);
|
||||
return r;
|
||||
} else if (document.head) {
|
||||
var iconHideStyle = document.createElement("style");
|
||||
iconHideStyle.innerText = '.tainacan-icon{ opacity: 1 !important; }';
|
||||
document.head.appendChild(iconHideStyle);
|
||||
} else {
|
||||
var iconHideStyle = document.createElement("style");
|
||||
iconHideStyle.innerText = '.tainacan-icon{ opacity: 1 !important; }';
|
||||
document.getElementsByTagName("head")[0].appendChild(iconHideStyle);
|
||||
}
|
||||
}
|
||||
|
||||
/* Registers Extra Vue Plugins passed to the window.tainacan_extra_plugins */
|
||||
if (typeof window.tainacan_extra_plugins != "undefined") {
|
||||
for (let [extraVuePluginName, extraVuePluginObject] of Object.entries(window.tainacan_extra_plugins))
|
||||
Vue.use(extraVuePluginObject);
|
||||
}
|
||||
|
||||
// Configure and Register Plugins
|
||||
Vue.use(Buefy, {
|
||||
defaultTooltipAnimated: true
|
||||
});
|
||||
Vue.use(VTooltip);
|
||||
Vue.use(I18NPlugin);
|
||||
Vue.use(UserPrefsPlugin);
|
||||
Vue.use(StatusHelperPlugin);
|
||||
Vue.use(RouterHelperPlugin);
|
||||
Vue.use(ConsolePlugin, {visual: false});
|
||||
Vue.use(VueTheMask);
|
||||
Vue.use(CommentsStatusHelperPlugin);
|
||||
|
||||
/* Registers Extra Vue Components passed to the window.tainacan_extra_components */
|
||||
if (typeof window.tainacan_extra_components != "undefined") {
|
||||
for (let [extraVueComponentName, extraVueComponentObject] of Object.entries(window.tainacan_extra_components)) {
|
||||
Vue.component(extraVueComponentName, extraVueComponentObject);
|
||||
}
|
||||
}
|
||||
|
||||
/* Metadata */
|
||||
Vue.component('tainacan-text', Text);
|
||||
Vue.component('tainacan-textarea', Textarea);
|
||||
Vue.component('tainacan-selectbox', Selectbox);
|
||||
Vue.component('tainacan-numeric', Numeric);
|
||||
Vue.component('tainacan-date', Date);
|
||||
Vue.component('tainacan-relationship', Relationship);
|
||||
Vue.component('tainacan-taxonomy', Taxonomy);
|
||||
Vue.component('tainacan-compound', Compound);
|
||||
Vue.component('tainacan-user', User);
|
||||
|
||||
/* Main page component */
|
||||
Vue.component('item-submission-form', ItemSubmissionForm);
|
||||
Vue.component('item-submission', ItemSubmission);
|
||||
|
||||
/* Others */
|
||||
Vue.component('tainacan-form-item', TainacanFormItem);
|
||||
Vue.component('help-button', HelpButton);
|
||||
|
||||
const VueItemSubmission = new Vue({
|
||||
store,
|
||||
data: {
|
||||
collectionId: '',
|
||||
hideFileModalButton: false,
|
||||
hideTextModalButton: false,
|
||||
hideLinkModalButton: false,
|
||||
hideThumbnailSection: false,
|
||||
hideAttachmentsSection: false,
|
||||
showAllowCommentsSection: false,
|
||||
hideCollapses: false,
|
||||
enabledMetadata: [],
|
||||
sentFormHeading: '',
|
||||
sentFormMessage: '',
|
||||
documentSectionLabel: '',
|
||||
thumbnailSectionLabel: '',
|
||||
attachmentsSectionLabel: '',
|
||||
metadataSectionLabel: ''
|
||||
},
|
||||
beforeMount () {
|
||||
// Collection source settings
|
||||
if (this.$el.attributes['collection-id'] != undefined)
|
||||
this.collectionId = this.$el.attributes['collection-id'].value;
|
||||
|
||||
// Elements shown on form
|
||||
if (this.$el.attributes['hide-file-modal-button'] != undefined)
|
||||
this.hideFileModalButton = this.isParameterTrue('hide-file-modal-button');
|
||||
if (this.$el.attributes['hide-text-modal-button'] != undefined)
|
||||
this.hideTextModalButton = this.isParameterTrue('hide-text-modal-button');
|
||||
if (this.$el.attributes['hide-link-modal-button'] != undefined)
|
||||
this.hideLinkModalButton = this.isParameterTrue('hide-link-modal-button');
|
||||
if (this.$el.attributes['hide-thumbnail-section'] != undefined)
|
||||
this.hideThumbnailSection = this.isParameterTrue('hide-thumbnail-section');
|
||||
if (this.$el.attributes['hide-attachments-section'] != undefined)
|
||||
this.hideAttachmentsSection = this.isParameterTrue('hide-attachments-section');
|
||||
if (this.$el.attributes['show-allow-comments-section'] != undefined)
|
||||
this.showAllowCommentsSection = this.isParameterTrue('show-allow-comments-section');
|
||||
if (this.$el.attributes['hide-collapses'] != undefined)
|
||||
this.hideCollapses = this.isParameterTrue('hide-collapses');
|
||||
|
||||
// Form sections labels
|
||||
if (this.$el.attributes['document-section-label'] != undefined)
|
||||
this.documentSectionLabel = this.$el.attributes['document-section-label'].value;
|
||||
if (this.$el.attributes['thumbnail-section-label'] != undefined)
|
||||
this.thumbnailSectionLabel = this.$el.attributes['thumbnail-section-label'].value;
|
||||
if (this.$el.attributes['attachments-section-label'] != undefined)
|
||||
this.attachmentsSectionLabel = this.$el.attributes['attachments-section-label'].value;
|
||||
if (this.$el.attributes['metadata-section-label'] != undefined)
|
||||
this.metadataSectionLabel = this.$el.attributes['metadata-section-label'].value;
|
||||
|
||||
// Form submission feedback messages
|
||||
if (this.$el.attributes['sent-form-heading'] != undefined)
|
||||
this.sentFormHeading = this.$el.attributes['sent-form-heading'].value;
|
||||
if (this.$el.attributes['sent-form-message'] != undefined)
|
||||
this.sentFormMessage = this.$el.attributes['sent-form-message'].value;
|
||||
|
||||
// List of metadata
|
||||
if (this.$el.attributes['enabled-metadata'] != undefined && this.$el.attributes['enabled-metadata'].value)
|
||||
this.enabledMetadata = this.$el.attributes['enabled-metadata'].value.split(',');
|
||||
},
|
||||
methods: {
|
||||
isParameterTrue(parameter) {
|
||||
const value = this.$el.attributes[parameter].value;
|
||||
return (value == true || value == 'true' || value == '1' || value == 1) ? true : false;
|
||||
}
|
||||
},
|
||||
render: h => h(ItemSubmission)
|
||||
});
|
||||
|
||||
VueItemSubmission.$mount('#tainacan-item-submission-form');
|
||||
|
||||
listen("load", window, function() {
|
||||
var iconsStyle = document.createElement("style");
|
||||
iconsStyle.setAttribute('type', 'text/css');
|
||||
iconsStyle.innerText = '.tainacan-icon{ opacity: 1 !important; }';
|
||||
document.head.appendChild(iconsStyle);
|
||||
});
|
||||
|
||||
// Initialize Ponyfill for Custom CSS properties
|
||||
cssVars({
|
||||
// Options...
|
||||
});
|
||||
}
|
||||
});
|
|
@ -0,0 +1,739 @@
|
|||
<template>
|
||||
<div v-if="collectionId">
|
||||
<b-loading
|
||||
:is-full-page="false"
|
||||
:active.sync="isLoading"
|
||||
:can-cancel="false"/>
|
||||
<form
|
||||
v-if="!hasSentForm"
|
||||
v-show="!isLoading && !isSubmitting && !isUploading"
|
||||
class="tainacan-form"
|
||||
label-width="120px">
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
v-if="formHooks != undefined &&
|
||||
formHooks['item'] != undefined &&
|
||||
formHooks['item']['begin-left'] != undefined">
|
||||
<form
|
||||
id="form-item-begin-left"
|
||||
class="form-hook-region"
|
||||
v-html="formHooks['item']['begin-left'].join('')"/>
|
||||
</template>
|
||||
|
||||
<!-- Document -------------------------------- -->
|
||||
<template v-if="!hideFileModalButton || !hideTextModalButton || !hideLinkModalButton">
|
||||
<div
|
||||
v-if="documentSectionLabel"
|
||||
class="section-label">
|
||||
<label>{{ documentSectionLabel }}</label>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('items', 'document')"
|
||||
:message="$i18n.getHelperMessage('items', 'document')"/>
|
||||
</div>
|
||||
<div
|
||||
class="section-box document-field"
|
||||
id="tainacan-item-metadatum_id-document">
|
||||
<div v-if="form.document_type != '' && form.document_type != undefined && form.document_type != null && form.document_type != 'empty'">
|
||||
<div v-if="form.document_type == 'attachment'">
|
||||
<b-upload
|
||||
expanded
|
||||
v-if="!form.document"
|
||||
v-model="form.document"
|
||||
drag-drop>
|
||||
<section class="section">
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-36px tainacan-icon-upload" />
|
||||
</span>
|
||||
</p>
|
||||
<p>{{ $i18n.get('instruction_drop_file_or_click_to_upload') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
</b-upload>
|
||||
<div
|
||||
v-else
|
||||
class="files-list">
|
||||
<b-tag
|
||||
rounded
|
||||
closable
|
||||
attached
|
||||
:aria-close-label="$i18n.get('delete')"
|
||||
@close="form.document = ''"
|
||||
:type="formErrors.find(error => error.metadatum_id== 'document') ? 'is-danger' : ''">
|
||||
{{ form.document.name }}
|
||||
</b-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="form.document_type == 'text'">
|
||||
<b-input
|
||||
type="textarea"
|
||||
v-model="form.document" />
|
||||
<br>
|
||||
</div>
|
||||
<div v-if="form.document_type == 'url'">
|
||||
<b-input
|
||||
:placeholder="$i18n.get('instruction_insert_url')"
|
||||
type="url"
|
||||
v-model="form.document" />
|
||||
<br>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="button is-outlined"
|
||||
@click="form.document = ''; form.document_type = 'empty'">
|
||||
{{ $i18n.get('label_switch_document_type') }}
|
||||
</button>
|
||||
</div>
|
||||
<ul v-else>
|
||||
<li v-if="!hideFileModalButton">
|
||||
<button
|
||||
type="button"
|
||||
@click.prevent="form.document_type = 'attachment'">
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-upload"/>
|
||||
</span>
|
||||
</button>
|
||||
<p>{{ $i18n.get('label_file') }}</p>
|
||||
</li>
|
||||
<li v-if="!hideTextModalButton">
|
||||
<button
|
||||
type="button"
|
||||
@click.prevent="form.document_type = 'text'">
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-text"/>
|
||||
</span>
|
||||
</button>
|
||||
<p>{{ $i18n.get('label_text') }}</p>
|
||||
</li>
|
||||
<li v-if="!hideLinkModalButton">
|
||||
<button
|
||||
type="button"
|
||||
@click.prevent="form.document_type = 'url'">
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-url"/>
|
||||
</span>
|
||||
</button>
|
||||
<p>{{ $i18n.get('label_url') }}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<!-- Thumbnail -------------------------------- -->
|
||||
<template v-if="!hideThumbnailSection">
|
||||
<div
|
||||
v-if="thumbnailSectionLabel"
|
||||
class="section-label">
|
||||
<label>{{ thumbnailSectionLabel }}</label>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('items', '_thumbnail_id')"
|
||||
:message="$i18n.getHelperMessage('items', '_thumbnail_id')"/>
|
||||
|
||||
</div>
|
||||
<div class="section-toggle">
|
||||
<p>{{ showThumbnailInput ? $i18n.get('info_thumbnail_custom') : $i18n.get('info_thumbnail_default_from_document') }}</p>
|
||||
<div class="field has-addons">
|
||||
<b-switch
|
||||
id="tainacan-checkbox-show-thumbnail-input"
|
||||
size="is-small"
|
||||
v-model="showThumbnailInput">
|
||||
{{ $i18n.get('label_upload_custom_thumbnail') }}
|
||||
</b-switch>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="!isLoading && showThumbnailInput"
|
||||
class="section-box section-thumbnail"
|
||||
id="tainacan-item-metadatum_id-thumbnail">
|
||||
<b-upload
|
||||
expanded
|
||||
v-if="!form.thumbnail"
|
||||
v-model="form.thumbnail"
|
||||
drag-drop>
|
||||
<section class="section">
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-36px tainacan-icon-upload" />
|
||||
</span>
|
||||
</p>
|
||||
<p>{{ $i18n.get('instruction_drop_file_or_click_to_upload') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
</b-upload>
|
||||
<div
|
||||
v-else
|
||||
class="files-list">
|
||||
<b-tag
|
||||
rounded
|
||||
closable
|
||||
attached
|
||||
:aria-close-label="$i18n.get('delete')"
|
||||
@close="form.thumbnail = null"
|
||||
:type="formErrors.find(error => error.metadatum_id == 'thumbnail') ? 'is-danger' : ''">
|
||||
{{ form.thumbnail.name }}
|
||||
</b-tag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
v-if="formHooks != undefined &&
|
||||
formHooks['item'] != undefined &&
|
||||
formHooks['item']['end-left'] != undefined">
|
||||
<form
|
||||
id="form-item-end-left"
|
||||
class="form-hook-region"
|
||||
v-html="formHooks['item']['end-left'].join('')"/>
|
||||
</template>
|
||||
|
||||
<!-- Attachments ------------------------------------------ -->
|
||||
<template v-if="!hideAttachmentsSection">
|
||||
|
||||
<div class="section-label">
|
||||
<label v-if="attachmentsSectionLabel">
|
||||
<span>{{ attachmentsSectionLabel }}</span>
|
||||
<span class="icon has-text-gray4">
|
||||
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-attachments"/>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="itemSubmission != undefined"
|
||||
class="section-box"
|
||||
id="tainacan-item-metadatum_id-attachments">
|
||||
<b-upload
|
||||
expanded
|
||||
v-model="form.attachments"
|
||||
multiple
|
||||
drag-drop>
|
||||
<section class="section">
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-36px tainacan-icon-upload" />
|
||||
</span>
|
||||
</p>
|
||||
<p>{{ $i18n.get('instruction_drop_file_or_click_to_upload') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
</b-upload>
|
||||
<div
|
||||
v-if="form.attachments && form.attachments.length"
|
||||
class="files-list">
|
||||
<b-tag
|
||||
v-for="(attachment, index) of form.attachments"
|
||||
:key="index"
|
||||
rounded
|
||||
closable
|
||||
attached
|
||||
:aria-close-label="$i18n.get('delete')"
|
||||
@close="form.attachments.splice(index, 1)"
|
||||
:type="formErrors.find(error => error.metadatum_id == 'attachments') ? 'is-danger' : ''">
|
||||
{{ attachment.name }}
|
||||
</b-tag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
v-if="formHooks != undefined &&
|
||||
formHooks['item'] != undefined &&
|
||||
formHooks['item']['begin-right'] != undefined">
|
||||
<form
|
||||
id="form-item-begin-right"
|
||||
class="form-hook-region"
|
||||
v-html="formHooks['item']['begin-right'].join('')"/>
|
||||
</template>
|
||||
|
||||
<!-- Comment Status ------------------------ -->
|
||||
<template v-if="showAllowCommentsSection">
|
||||
<div class="section-label">
|
||||
<label>{{ $i18n.get('label_comments') }}</label>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('items', 'comment_status')"
|
||||
:message="$i18n.getHelperMessage('items', 'comment_status')"/>
|
||||
</div>
|
||||
<div class="section-toggle">
|
||||
<div class="field has-addons">
|
||||
<b-switch
|
||||
id="tainacan-checkbox-comment-status"
|
||||
size="is-small"
|
||||
true-value="open"
|
||||
false-value="closed"
|
||||
v-model="form.comment_status">
|
||||
{{ $i18n.get('label_allow_comments') }}
|
||||
</b-switch>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Metadata from Collection-------------------------------- -->
|
||||
<div class="section-label">
|
||||
<label v-if="metadataSectionLabel">
|
||||
<span>{{ metadataSectionLabel }}</span>
|
||||
<span class="icon has-text-gray4">
|
||||
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-metadata"/>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<a
|
||||
v-if="!hideCollapses"
|
||||
class="collapse-all"
|
||||
@click="toggleCollapseAll()">
|
||||
{{ collapseAll ? $i18n.get('label_collapse_all') : $i18n.get('label_expand_all') }}
|
||||
<span class="icon">
|
||||
<i
|
||||
:class="{ 'tainacan-icon-arrowdown' : collapseAll, 'tainacan-icon-arrowright' : !collapseAll }"
|
||||
class="tainacan-icon tainacan-icon-1-25em"/>
|
||||
</span>
|
||||
</a>
|
||||
<template v-for="(itemMetadatum, index) of metadatumList">
|
||||
<tainacan-form-item
|
||||
:key="index"
|
||||
v-if="enabledMetadata[index] == 'true'"
|
||||
:item-metadatum="itemMetadatum"
|
||||
:hide-collapses="hideCollapses"
|
||||
:is-collapsed="metadataCollapses[index]"
|
||||
@changeCollapse="onChangeCollapse($event, index)"/>
|
||||
</template>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
v-if="formHooks != undefined &&
|
||||
formHooks['item'] != undefined &&
|
||||
formHooks['item']['end-right'] != undefined">
|
||||
<form
|
||||
id="form-item-end-right"
|
||||
class="form-hook-region"
|
||||
v-html="formHooks['item']['end-right'].join('')"/>
|
||||
</template>
|
||||
|
||||
<footer class="form-submission-footer">
|
||||
|
||||
<button
|
||||
@click="onDiscard()"
|
||||
type="button"
|
||||
class="button is-outlined">{{ $i18n.get('cancel') }}</button>
|
||||
|
||||
<!-- Updated and Error Info -->
|
||||
<div class="update-info-section">
|
||||
<p class="footer-message">
|
||||
|
||||
<span class="help is-danger">
|
||||
{{ formErrorMessage }}
|
||||
<item-metadatum-errors-tooltip
|
||||
v-if="formErrors.length && formErrors[0].errors && formErrors[0].errors.length"
|
||||
:form-errors="formErrors" />
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
@click="onSubmit()"
|
||||
type="button"
|
||||
class="button is-secondary">{{ $i18n.get('label_submit') }}</button>
|
||||
</footer>
|
||||
</form>
|
||||
|
||||
<!-- Message displayed when the form is being submitted -->
|
||||
<section
|
||||
v-if="isSubmitting || isUploading"
|
||||
class="section">
|
||||
<div class="content has-text-grey has-text-centered">
|
||||
<br>
|
||||
<p>
|
||||
<span class="icon is-medium">
|
||||
<i class="tainacan-icon tainacan-icon-30px tainacan-icon-updating tainacan-icon-spin"/>
|
||||
</span>
|
||||
</p>
|
||||
<h2>{{ $i18n.get('label_sending_form') }}</h2>
|
||||
<p v-if="isSubmitting">{{ $i18n.get('info_submission_processing') }}</p>
|
||||
<p v-if="isUploading">{{ $i18n.get('info_submission_uploading') }}</p>
|
||||
<br>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Message displayed once the form is submitted -->
|
||||
<section
|
||||
v-if="hasSentForm"
|
||||
class="section">
|
||||
<div class="content has-text-grey has-text-centered">
|
||||
<br>
|
||||
<p>
|
||||
<span class="icon is-medium">
|
||||
<i class="tainacan-icon tainacan-icon-30px tainacan-icon-approvedcircle"/>
|
||||
</span>
|
||||
</p>
|
||||
<h2 v-if="sentFormHeading">{{ sentFormHeading }}</h2>
|
||||
<p v-if="sentFormMessage">{{ sentFormMessage }}</p>
|
||||
<br>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import { eventBusItemMetadata } from '../../admin/js/event-bus-item-metadata';
|
||||
import { formHooks } from '../../admin/js/mixins';
|
||||
import ItemMetadatumErrorsTooltip from '../../admin/components/other/item-metadatum-errors-tooltip.vue';
|
||||
|
||||
export default {
|
||||
name: 'ItemSubmissionForm',
|
||||
components: {
|
||||
ItemMetadatumErrorsTooltip,
|
||||
},
|
||||
mixins: [ formHooks ],
|
||||
props: {
|
||||
collectionId: String,
|
||||
hideFileModalButton: Boolean,
|
||||
hideTextModalButton: Boolean,
|
||||
hideLinkModalButton: Boolean,
|
||||
hideThumbnailSection: Boolean,
|
||||
hideAttachmentsSection: Boolean,
|
||||
showAllowCommentsSection: Boolean,
|
||||
hideCollapses: Boolean,
|
||||
enabledMetadata: Array,
|
||||
sentFormHeading: String,
|
||||
sentFormMessage: String,
|
||||
documentSectionLabel: String,
|
||||
thumbnailSectionLabel: String,
|
||||
attachmentsSectionLabel: String,
|
||||
metadataSectionLabel: String
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
isLoading: false,
|
||||
isSubmitting: false,
|
||||
isUploading: false,
|
||||
metadataCollapses: [],
|
||||
collapseAll: true,
|
||||
form: {
|
||||
collection_id: Number,
|
||||
document: '',
|
||||
document_type: '',
|
||||
comment_status: '',
|
||||
attachments: [],
|
||||
thumbnail: ''
|
||||
},
|
||||
formErrorMessage: '',
|
||||
hasSentForm: false,
|
||||
showThumbnailInput: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
itemSubmission() {
|
||||
return this.getItemSubmission();
|
||||
},
|
||||
itemSubmissionMetadata() {
|
||||
return this.getItemSubmissionMetadata();
|
||||
},
|
||||
metadatumList() {
|
||||
return (this.itemSubmissionMetadata && this.itemSubmissionMetadata.length) ? JSON.parse(JSON.stringify(this.getMetadata().map((metadatum) => { return { metadatum: metadatum, item: {}, value: this.itemSubmissionMetadata.find((aMetadatum) => aMetadatum.metadatum_id == metadatum.id).value } } ))) : [];
|
||||
},
|
||||
formErrors() {
|
||||
return eventBusItemMetadata && eventBusItemMetadata.errors && eventBusItemMetadata.errors.length ? eventBusItemMetadata.errors : []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
// Initialize clear data from store
|
||||
this.clearItemSubmission();
|
||||
|
||||
eventBusItemMetadata.clearAllErrors();
|
||||
this.formErrorMessage = '';
|
||||
this.form.collection_id = this.collectionId;
|
||||
|
||||
// CREATING NEW ITEM SUBMISSION
|
||||
this.createNewItem();
|
||||
|
||||
eventBusItemMetadata.$on('hasErrorsOnForm', (hasErrors) => {
|
||||
if (hasErrors)
|
||||
this.formErrorMessage = this.formErrorMessage ? this.formErrorMessage : this.$i18n.get('info_errors_in_form');
|
||||
else
|
||||
this.formErrorMessage = '';
|
||||
});
|
||||
},
|
||||
beforeDestroy () {
|
||||
eventBusItemMetadata.$off('hasErrorsOnForm');
|
||||
},
|
||||
methods: {
|
||||
...mapActions('item', [
|
||||
'setItemSubmission',
|
||||
'setItemSubmissionMetadata',
|
||||
'submitItemSubmission',
|
||||
'finishItemSubmission',
|
||||
'clearItemSubmission'
|
||||
]),
|
||||
...mapGetters('item',[
|
||||
'getItemSubmission',
|
||||
'getItemSubmissionMetadata',
|
||||
]),
|
||||
...mapActions('metadata',[
|
||||
'fetchMetadata'
|
||||
]),
|
||||
...mapGetters('metadata',[
|
||||
'getMetadata'
|
||||
]),
|
||||
onSubmit() {
|
||||
|
||||
// Puts loading on Item edition
|
||||
this.isSubmitting = true;
|
||||
|
||||
let data = this.form;
|
||||
this.fillExtraFormData(data);
|
||||
this.updateExtraFormData(data);
|
||||
this.setItemSubmission(Object.assign(this.itemSubmission, data));
|
||||
|
||||
// Clear errors so we don't have them duplicated from api
|
||||
eventBusItemMetadata.errors = [];
|
||||
|
||||
this.submitItemSubmission({ itemSubmission: this.itemSubmission, itemSubmissionMetadata: this.itemSubmissionMetadata })
|
||||
.then((fakeItemId) => {
|
||||
|
||||
this.isUploading = true;
|
||||
this.isSubmitting = false;
|
||||
|
||||
if (fakeItemId) {
|
||||
this.finishItemSubmission({ itemSubmission: this.itemSubmission, fakeItemId: fakeItemId })
|
||||
.then(() => {
|
||||
this.hasSentForm = true;
|
||||
this.isUploading = false;
|
||||
})
|
||||
.catch((errors) => {
|
||||
if (errors.errors) {
|
||||
for (let error of errors.errors) {
|
||||
for (let metadatum of Object.keys(error)) {
|
||||
eventBusItemMetadata.errors.push({
|
||||
metadatum_id: metadatum,
|
||||
errors: error[metadatum]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
|
||||
this.isSubmitting = false;
|
||||
this.hasSentForm = false;
|
||||
this.isUploading = false;
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((errors) => {
|
||||
if (errors.errors) {
|
||||
for (let error of errors.errors) {
|
||||
for (let metadatum of Object.keys(error)) {
|
||||
eventBusItemMetadata.errors.push({
|
||||
metadatum_id: metadatum,
|
||||
errors: error[metadatum]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
|
||||
this.isSubmitting = false;
|
||||
this.hasSentForm = false;
|
||||
this.isUploading = false;
|
||||
});
|
||||
},
|
||||
onDiscard() {
|
||||
// Initialize clear data from store
|
||||
this.clearItemSubmission();
|
||||
|
||||
eventBusItemMetadata.clearAllErrors();
|
||||
this.formErrorMessage = '';
|
||||
this.form.collection_id = this.collectionId;
|
||||
|
||||
// CREATING NEW ITEM SUBMISSION
|
||||
this.createNewItem();
|
||||
},
|
||||
createNewItem() {
|
||||
// Puts loading on Draft Item creation
|
||||
this.isLoading = true;
|
||||
|
||||
// Clear errors so we don't have them duplicated from api
|
||||
eventBusItemMetadata.errors = [];
|
||||
|
||||
let data = this.form;
|
||||
|
||||
this.fillExtraFormData(data);
|
||||
this.setItemSubmission(data);
|
||||
|
||||
// Loads metadata
|
||||
this.loadMetadata();
|
||||
},
|
||||
loadMetadata() {
|
||||
// Obtains Item Metadatum
|
||||
this.fetchMetadata({ collectionId: this.collectionId }).then(resp => {
|
||||
resp.request.then((metadata) => {
|
||||
this.metadataCollapses = [];
|
||||
|
||||
for (let i = 0; i < metadata.length; i++) {
|
||||
this.metadataCollapses.push(false);
|
||||
this.metadataCollapses[i] = true;
|
||||
}
|
||||
this.setItemSubmissionMetadata( metadata.map((metadatum) => { return { metadatum_id: metadatum.id, value: null } }) );
|
||||
this.isLoading = false;
|
||||
});
|
||||
});
|
||||
},
|
||||
toggleCollapseAll() {
|
||||
this.collapseAll = !this.collapseAll;
|
||||
|
||||
for (let i = 0; i < this.metadataCollapses.length; i++)
|
||||
this.metadataCollapses[i] = this.collapseAll;
|
||||
|
||||
},
|
||||
onChangeCollapse(event, index) {
|
||||
this.metadataCollapses.splice(index, 1, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.tainacan-item-submission-form {
|
||||
|
||||
.tainacan-form {
|
||||
background-color: var(--tainacan-background-color);
|
||||
padding-left: var(--tainacan-one-column);
|
||||
padding-right: var(--tainacan-one-column);
|
||||
|
||||
@media screen and (max-width: 769px) {
|
||||
max-width: 100%;
|
||||
}
|
||||
.field:not(:last-child) {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.field {
|
||||
padding: 10px 0px 14px 34px;
|
||||
|
||||
}
|
||||
.columns {
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
|
||||
.column {
|
||||
padding: 1em 12px 0 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.collapse-all {
|
||||
font-size: 0.75em;
|
||||
.icon {
|
||||
vertical-align: bottom;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.section-label {
|
||||
position: relative;
|
||||
label {
|
||||
font-size: 1em !important;
|
||||
font-weight: 500 !important;
|
||||
color: var(--tainacan-label-color) !important;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
}
|
||||
|
||||
.section-toggle p {
|
||||
font-size: 0.875em;
|
||||
margin-bottom: 0;
|
||||
padding-left: var(--tainacan-one-column);
|
||||
}
|
||||
|
||||
.section-box {
|
||||
padding: 0 var(--tainacan-one-column);
|
||||
margin-top: 14px;
|
||||
margin-bottom: 32px;
|
||||
|
||||
ul {
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
li {
|
||||
margin-left: 0.25em;
|
||||
margin-right: 1.5em;
|
||||
text-align: center;
|
||||
button {
|
||||
border-radius: 50px;
|
||||
height: 72px;
|
||||
width: 72px;
|
||||
border: none;
|
||||
background-color: var(--tainacan-gray2);
|
||||
color: var(--tainacan-secondary);
|
||||
margin-bottom: 6px;
|
||||
&:hover {
|
||||
background-color: var(--tainacan-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
p {
|
||||
color: var(--tainacan-secondary);
|
||||
font-size: 0.8125em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.document-field {
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
.document-buttons-row {
|
||||
text-align: right;
|
||||
top: -21px;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
.files-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.form-submission-footer {
|
||||
padding: 18px 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 0.875em;
|
||||
|
||||
@keyframes blink {
|
||||
from { color: var(--tainacan-blue5); }
|
||||
to { color: var(--tainacan-info-color); }
|
||||
}
|
||||
|
||||
.footer-message {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 12px;
|
||||
}
|
||||
.update-info-section {
|
||||
color: var(--tainacan-info-color);
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.help {
|
||||
display: inline-block;
|
||||
font-size: 1.0em;
|
||||
margin-top: 0;
|
||||
margin-left: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,12 @@
|
|||
@import "../../../../node_modules/bulma/sass/utilities/_all.sass"
|
||||
@import "../../../../node_modules/bulma/sass/helpers/_all.sass"
|
||||
@import "../../../../node_modules/bulma/sass/form/_all.sass"
|
||||
@import "../../../../node_modules/bulma/sass/components/pagination.sass"
|
||||
@import "../../../../node_modules/bulma/sass/elements/icon.sass"
|
||||
@import "../../../../node_modules/bulma/sass/elements/tag.sass"
|
||||
@import "../../../../node_modules/bulma/sass/elements/image.sass"
|
||||
@import "../../../../node_modules/bulma/sass/components/tabs.sass"
|
||||
@import "../../../../node_modules/bulma/sass/elements/button.sass"
|
||||
@import "../../../../node_modules/bulma/sass/grid/columns.sass"
|
||||
@import "../../../../node_modules/bulma/sass/components/dropdown.sass"
|
||||
@import "../../../../node_modules/bulma/sass/components/modal.sass"
|
|
@ -358,8 +358,8 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_select_all_items' => __( 'Select all items', 'tainacan' ),
|
||||
'label_select_all' => __( 'Select all', 'tainacan' ),
|
||||
'label_untrash_selected_items' => __( 'Restore from trash', 'tainacan' ),
|
||||
'label_value_not_informed' => __( 'Value not informed.', 'tainacan' ),
|
||||
'label_description_not_informed' => __( 'Description not informed.', 'tainacan' ),
|
||||
'label_value_not_provided' => __( 'No value provided.', 'tainacan' ),
|
||||
'label_description_not_provided' => __( 'No description provided.', 'tainacan' ),
|
||||
'label_save_goto_metadata' => __( 'Save and Go to Metadata', 'tainacan' ),
|
||||
'label_save_goto_filter' => __( 'Save and Go to Filters', 'tainacan' ),
|
||||
'label_view_all_collections' => __( 'View all Collections', 'tainacan' ),
|
||||
|
@ -470,6 +470,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_editing_capabilitiy' => __( 'Editing capabilitiy', 'tainacan' ),
|
||||
'label_default_author_user' => __( 'Set the item author as default value', 'tainacan' ),
|
||||
'label_crate_new_item' => __( 'Create new item', 'tainacan' ),
|
||||
'label_submit' => __( 'Submit', 'tainacan' ),
|
||||
'label_know_more' => __( 'Know more', 'tainacan' ),
|
||||
'label_request_details' => __( 'Request details', 'tainacan' ),
|
||||
'label_terms_without_parent' => __( 'Terms without parent', 'tainacan' ),
|
||||
|
@ -479,6 +480,9 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_esc_key' => __( 'ESC', 'tainacan' ),
|
||||
'label_view_selected_items_as' => __( 'View selected items as...', 'tainacan' ),
|
||||
'label_actions_for_the_selection' => __( 'Actions for the selection', 'tainacan' ),
|
||||
'label_upload_custom_thumbnail' => __( 'Upload custom thumbnail', 'tainacan' ),
|
||||
'label_switch_document_type' => __( 'Switch document type', 'tainacan' ),
|
||||
'label_sending_form' => __( 'Sending form...', 'tainacan' ),
|
||||
|
||||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||
|
@ -742,6 +746,10 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'info_gallery_start_transition' => __( 'to start or pause automatic transition after every 3s', 'tainacan' ),
|
||||
'info_gallery_exit' => __( ' to leave the fullscreen gallery view mode', 'tainacan' ),
|
||||
'info_gallery_help_end' => __( 'At any moment, you can also check the item metadata list by clicking on the metadata icon (%1$s) or go directly to the item page, where you will have all its details, by clicking on the eye icon (%2$s).', 'tainacan' ),
|
||||
'info_thumbnail_custom' => __( 'Upload the desired image for the thumbnail', 'tainacan'),
|
||||
'info_thumbnail_default_from_document' => __( 'A thumbnail will be automatically generated from the submitted document file', 'tainacan'),
|
||||
'info_submission_processing' => __( 'Please, wait while the submission is being processed', 'tainacan'),
|
||||
'info_submission_uploading' => __( 'Please, wait while files are uploaded', 'tainacan'),
|
||||
|
||||
// Datepicker months
|
||||
'datepicker_month_january' => __( 'January', 'tainacan' ),
|
||||
|
|
|
@ -89,13 +89,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>`" />
|
||||
<br>
|
||||
<!-- Author and Creation Date-->
|
||||
<!-- <p
|
||||
|
|
|
@ -55,7 +55,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>`)" />
|
||||
<span
|
||||
v-if="isSlideshowViewModeEnabled"
|
||||
v-tooltip="{
|
||||
|
|
|
@ -61,7 +61,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>`)" />
|
||||
<span
|
||||
v-if="isSlideshowViewModeEnabled"
|
||||
v-tooltip="{
|
||||
|
|
|
@ -121,23 +121,23 @@
|
|||
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'
|
||||
}"
|
||||
:aria-label="column.name + ': ' + (item.title != undefined && item.title != '' ? item.title : $i18n.get('label_value_not_informed'))"
|
||||
:aria-label="column.name + ': ' + (item.title != undefined && item.title != '' ? item.title : $i18n.get('label_value_not_provided'))"
|
||||
v-if="!collectionId &&
|
||||
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'
|
||||
|
@ -145,7 +145,7 @@
|
|||
v-if="!collectionId &&
|
||||
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: {
|
||||
|
@ -153,7 +153,7 @@
|
|||
hide: 300,
|
||||
},
|
||||
classes: [ column.metadata_type_object != undefined && column.metadata_type_object.component == 'tainacan-textarea' ? 'metadata-type-textarea' : '' ],
|
||||
content: renderMetadataWithLabel(item.metadata, column) != '' ? renderMetadataWithLabel(item.metadata, column) : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`,
|
||||
content: renderMetadataWithLabel(item.metadata, column) != '' ? renderMetadataWithLabel(item.metadata, column) : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_provided') + `</span>`,
|
||||
html: true,
|
||||
autoHide: false,
|
||||
placement: 'auto-start'
|
||||
|
@ -165,7 +165,7 @@
|
|||
column.metadatum !== 'row_author' &&
|
||||
column.metadatum !== 'row_title' &&
|
||||
column.metadatum !== 'row_description'"
|
||||
v-html="renderMetadataWithLabel(item.metadata, column) != '' ? renderMetadataWithLabel(item.metadata, column) : `<span class='has-text-gray3 is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`"/>
|
||||
v-html="renderMetadataWithLabel(item.metadata, column) != '' ? renderMetadataWithLabel(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
|
||||
|
|
|
@ -0,0 +1,363 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Tests;
|
||||
|
||||
/**
|
||||
* @group api
|
||||
*/
|
||||
class TAINACAN_REST_Items_Submission extends TAINACAN_UnitApiTestCase {
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// collections:
|
||||
$this->col_user_anonymous = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
[
|
||||
'name' => 'Col-1',
|
||||
'description' => 'Col-1',
|
||||
'status' => 'publish',
|
||||
'submission_anonymous_user' => 'yes',
|
||||
'allows_submission' => 'yes'
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
$this->col_user_logged = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
[
|
||||
'name' => 'Col-2',
|
||||
'description' => 'Col-2',
|
||||
'status' => 'publish',
|
||||
'submission_anonymous_user' => 'no',
|
||||
'allows_submission' => 'yes'
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
$this->collections_metadatum = array(
|
||||
$this->col_user_anonymous->get_id() => $this->create_metadatum($this->col_user_anonymous),
|
||||
$this->col_user_logged->get_id() => $this->create_metadatum($this->col_user_logged)
|
||||
);
|
||||
}
|
||||
|
||||
private function create_metadatum(&$collection) {
|
||||
$tax = $this->tainacan_entity_factory->create_entity(
|
||||
'taxonomy',
|
||||
array(
|
||||
'name' => 'tax_test',
|
||||
'collections' => [$collection],
|
||||
'status' => 'publish'
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$this->tainacan_entity_factory->create_entity(
|
||||
'term',
|
||||
array(
|
||||
'taxonomy' => $tax->get_db_identifier(),
|
||||
'name' => 'term-1',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$this->tainacan_entity_factory->create_entity(
|
||||
'term',
|
||||
array(
|
||||
'taxonomy' => $tax->get_db_identifier(),
|
||||
'name' => 'term-2',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$metadatum_compound = $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'metadatum_compound',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Compound',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$metadatum_child1 = $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'metadatum_child1',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'parent' => $metadatum_compound->get_id(),
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Text',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$metadatum_child2 = $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'metadatum_child2',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'parent' => $metadatum_compound->get_id(),
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Text',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$metadatum_compound_multiple = $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'metadatum_compound_multiple',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Compound',
|
||||
'multiple' => 'yes'
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$metadatum_child1_multiple = $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'metadatum_child1_multiple',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'parent' => $metadatum_compound_multiple->get_id(),
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Text',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$metadatum_child2_multiple = $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'metadatum_child2_multiple',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'parent' => $metadatum_compound_multiple->get_id(),
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Text',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$metadatum = array(
|
||||
'text' => $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'text',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Text',
|
||||
),
|
||||
true
|
||||
)->get_id(),
|
||||
|
||||
'textarea' => $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'textarea',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Textarea',
|
||||
),
|
||||
true
|
||||
)->get_id(),
|
||||
|
||||
'numeric' => $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'numeric',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Numeric',
|
||||
),
|
||||
true
|
||||
)->get_id(),
|
||||
|
||||
'date' => $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'date',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Date',
|
||||
),
|
||||
true
|
||||
)->get_id(),
|
||||
|
||||
'selectbox' => $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'selectbox',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Selectbox',
|
||||
'metadata_type_options' => [
|
||||
'options' => ['op1', 'op2', 'op3']
|
||||
]
|
||||
),
|
||||
true
|
||||
)->get_id(),
|
||||
|
||||
'taxonomy' => $this->tainacan_entity_factory->create_entity(
|
||||
'metadatum',
|
||||
array(
|
||||
'name' => 'taxonomy',
|
||||
'status' => 'publish',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
|
||||
'metadata_type_options' => [
|
||||
'taxonomy_id' => $tax->get_id(),
|
||||
'allow_new_terms' => 'no'
|
||||
],
|
||||
),
|
||||
true
|
||||
)->get_id(),
|
||||
|
||||
'compound' => [
|
||||
'parent' => $metadatum_compound->get_id(),
|
||||
'childrens' => [
|
||||
$metadatum_child1->get_id(),
|
||||
$metadatum_child2->get_id()
|
||||
]
|
||||
],
|
||||
|
||||
'compound_multiple' => [
|
||||
'parent' => $metadatum_compound_multiple->get_id(),
|
||||
'childrens' => [
|
||||
$metadatum_child1_multiple->get_id(),
|
||||
$metadatum_child2_multiple->get_id()
|
||||
]
|
||||
]
|
||||
);
|
||||
//relationship?
|
||||
//user?
|
||||
return $metadatum;
|
||||
}
|
||||
|
||||
public function test_submission_item_user_anonymous() {
|
||||
wp_logout();
|
||||
$this->assertEquals($this->col_user_anonymous->get_submission_anonymous_user(), 'yes');
|
||||
$this->assertEquals($this->col_user_logged->get_submission_anonymous_user(), 'no');
|
||||
|
||||
$metadatums = $this->collections_metadatum[$this->col_user_anonymous->get_id()];
|
||||
|
||||
$item_json = json_encode([
|
||||
'title' => 'Item submission',
|
||||
'description' => 'one item send by submission',
|
||||
'metadata' => array(
|
||||
[
|
||||
'metadatum_id' => $metadatums['text'],
|
||||
'value' => 'Text submission'
|
||||
],
|
||||
[
|
||||
'metadatum_id' => $metadatums['textarea'],
|
||||
'value' => 'textarea submission'
|
||||
],
|
||||
[
|
||||
'metadatum_id' => $metadatums['date'],
|
||||
'value' => '2020-12-31'
|
||||
],
|
||||
[
|
||||
'metadatum_id' => $metadatums['numeric'],
|
||||
'value' => 10
|
||||
],
|
||||
[
|
||||
'metadatum_id' => $metadatums['selectbox'],
|
||||
'value' => 'op2'
|
||||
],
|
||||
[
|
||||
'metadatum_id' => $metadatums['taxonomy'],
|
||||
'value' => 'term-1'
|
||||
],
|
||||
[
|
||||
'metadatum_id' => $metadatums['compound']['parent'],
|
||||
'value' => [
|
||||
['metadatum_id' => $metadatums['compound']['childrens'][0], 'value' => 'metadatum_child1'],
|
||||
['metadatum_id' => $metadatums['compound']['childrens'][1], 'value' => 'metadatum_child2']
|
||||
]
|
||||
],
|
||||
[
|
||||
'metadatum_id' => $metadatums['compound_multiple']['parent'],
|
||||
'value' => [
|
||||
[
|
||||
['metadatum_id' => $metadatums['compound_multiple']['childrens'][0], 'value' => 'metadatum_child1_multiple_row_1'],
|
||||
['metadatum_id' => $metadatums['compound_multiple']['childrens'][1], 'value' => 'metadatum_child2_multiple_row_1']
|
||||
],
|
||||
[
|
||||
['metadatum_id' => $metadatums['compound_multiple']['childrens'][0], 'value' => 'metadatum_child1_multiple_row_2'],
|
||||
['metadatum_id' => $metadatums['compound_multiple']['childrens'][1], 'value' => 'metadatum_child2_multiple_row_2']
|
||||
]
|
||||
|
||||
]
|
||||
]
|
||||
)
|
||||
]);
|
||||
|
||||
$request = new \WP_REST_Request('POST', $this->namespace . '/collection/' . $this->col_user_anonymous->get_id() . '/items/submission');
|
||||
$request->set_body($item_json);
|
||||
|
||||
$response = $this->server->dispatch($request);
|
||||
$this->assertEquals(201, $response->get_status());
|
||||
$data = $response->get_data();
|
||||
|
||||
$request = new \WP_REST_Request('POST', $this->namespace . '/collection/' . $this->col_user_logged->get_id() . '/items/submission');
|
||||
$response = $this->server->dispatch($request);
|
||||
$this->assertEquals(401, $response->get_status());
|
||||
}
|
||||
|
||||
public function test_submission_item_user_logged() {
|
||||
// echo "user_id" . $this->user_id;
|
||||
$this->assertEquals($this->col_user_anonymous->get_submission_anonymous_user(), 'yes');
|
||||
$this->assertEquals($this->col_user_logged->get_submission_anonymous_user(), 'no');
|
||||
|
||||
$metadatums = $this->collections_metadatum[$this->col_user_anonymous->get_id()];
|
||||
$item_json = json_encode([
|
||||
'title' => 'Item submission',
|
||||
'description' => 'one item send by submission',
|
||||
'metadata' => array(
|
||||
[
|
||||
'metadatum_id' => $metadatums['text'],
|
||||
'value' => 'Text submission'
|
||||
],
|
||||
[
|
||||
'metadatum_id' => $metadatums['numeric'],
|
||||
'value' => 10
|
||||
]
|
||||
)
|
||||
]);
|
||||
|
||||
$request = new \WP_REST_Request('POST', $this->namespace . '/collection/' . $this->col_user_anonymous->get_id() . '/items/submission');
|
||||
$request->set_body($item_json);
|
||||
|
||||
$response = $this->server->dispatch($request);
|
||||
$this->assertEquals(201, $response->get_status());
|
||||
$data = $response->get_data();
|
||||
|
||||
|
||||
$metadatums = $this->collections_metadatum[$this->col_user_logged->get_id()];
|
||||
$item_json = json_encode([
|
||||
'title' => 'Item submission',
|
||||
'description' => 'one item send by submission',
|
||||
'metadata' => array(
|
||||
[
|
||||
'metadatum_id' => $metadatums['text'],
|
||||
'value' => 'Text submission'
|
||||
],
|
||||
[
|
||||
'metadatum_id' => $metadatums['numeric'],
|
||||
'value' => 10
|
||||
]
|
||||
)
|
||||
]);
|
||||
|
||||
$request = new \WP_REST_Request('POST', $this->namespace . '/collection/' . $this->col_user_logged->get_id() . '/items/submission');
|
||||
$request->set_body($item_json);
|
||||
$response = $this->server->dispatch($request);
|
||||
$this->assertEquals(201, $response->get_status());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -7,6 +7,7 @@ module.exports = {
|
|||
entry: {
|
||||
admin: './src/views/admin/js/main.js',
|
||||
theme_search: './src/views/theme-search/js/theme-main.js',
|
||||
item_submission: './src/views/item-submission/js/item-submission-main.js',
|
||||
roles: './src/views/roles/js/roles-main.js',
|
||||
|
||||
block_terms_list: './src/views/gutenberg-blocks/tainacan-terms/terms-list/index.js',
|
||||
|
@ -29,7 +30,9 @@ module.exports = {
|
|||
|
||||
block_facets_list: './src/views/gutenberg-blocks/tainacan-facets/facets-list/index.js',
|
||||
block_facets_list_theme: './src/views/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme.js',
|
||||
|
||||
|
||||
block_item_submission_form: './src/views/gutenberg-blocks/tainacan-items/item-submission-form/index.js',
|
||||
|
||||
block_faceted_search: './src/views/gutenberg-blocks/tainacan-facets/faceted-search/index.js',
|
||||
|
||||
block_carousel_terms_list: './src/views/gutenberg-blocks/tainacan-terms/carousel-terms-list/index.js',
|
||||
|
|
Loading…
Reference in New Issue