Merge branch 'release/0.13'
This commit is contained in:
commit
7925186017
15
.travis.yml
15
.travis.yml
|
@ -45,21 +45,6 @@ install:
|
||||||
- echo 'if ( php -v|grep -q --only-matching --perl-regexp "5\.\\d+\.\\d+" );then /usr/local/bin/phpunit-5 $@;else /usr/local/bin/phpunit-6 $@;fi;exit $?' |sudo tee -a /usr/local/bin/phpunit > /dev/null
|
- echo 'if ( php -v|grep -q --only-matching --perl-regexp "5\.\\d+\.\\d+" );then /usr/local/bin/phpunit-5 $@;else /usr/local/bin/phpunit-6 $@;fi;exit $?' |sudo tee -a /usr/local/bin/phpunit > /dev/null
|
||||||
- sudo chmod +x /usr/local/bin/phpunit
|
- sudo chmod +x /usr/local/bin/phpunit
|
||||||
script: /usr/local/bin/phpunit # phpunit
|
script: /usr/local/bin/phpunit # phpunit
|
||||||
before_deploy:
|
|
||||||
- echo "Seção executada antes do deploy!"
|
|
||||||
- openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv
|
|
||||||
-in deploy_rsa.enc -out /tmp/deploy_rsa -d
|
|
||||||
- eval "$(ssh-agent -s)"
|
|
||||||
- chmod 600 /tmp/deploy_rsa
|
|
||||||
- ssh-add /tmp/deploy_rsa
|
|
||||||
- echo -e "Host $ssh_host\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
|
||||||
- ssh-add -l
|
|
||||||
deploy:
|
|
||||||
- provider: script
|
|
||||||
script: sshpass -p '$ssh_password' ssh $ssh_user@$ssh_host sh /home/l3p/atualiza_git/atualiza_todos.sh #MECHI AQUI!! #ssh $ssh_user@$ssh_host $script_deploy_tainacan
|
|
||||||
skip_cleanup: true
|
|
||||||
on:
|
|
||||||
branch: develop
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- vendor
|
- vendor
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -72,6 +72,8 @@ rsync -axz --exclude='vendor/bin/phpc*' --exclude='vendor/squizlabs' --exclude='
|
||||||
--exclude='vendor/respect/validation/docs' --exclude='vendor/respect/validation/tests' \
|
--exclude='vendor/respect/validation/docs' --exclude='vendor/respect/validation/tests' \
|
||||||
--exclude='pdf-viewer/pdfjs-dist/web/compressed.tracemonkey-pldi-09.pdf' \
|
--exclude='pdf-viewer/pdfjs-dist/web/compressed.tracemonkey-pldi-09.pdf' \
|
||||||
--exclude='vendor/tecnickcom/tcpdf/fonts' \
|
--exclude='vendor/tecnickcom/tcpdf/fonts' \
|
||||||
|
--exclude='vendor/smalot/pdfparser/src/Smalot/PdfParser/Tests/' \
|
||||||
|
--exclude='vendor/tecnickcom/tcpdf/examples' \
|
||||||
src/* $wp_plugin_dir/
|
src/* $wp_plugin_dir/
|
||||||
|
|
||||||
rm -rf $wp_plugin_dir/scss
|
rm -rf $wp_plugin_dir/scss
|
||||||
|
|
|
@ -31,5 +31,7 @@ sass -E 'UTF-8' --cache-location .tmp/sass-cache-10 src/gutenberg-blocks/tainaca
|
||||||
|
|
||||||
sass -E 'UTF-8' --cache-location .tmp/sass-cache-11 src/gutenberg-blocks/tainacan-facets/facets-list/facets-list.scss:src/assets/css/tainacan-gutenberg-block-facets-list.css
|
sass -E 'UTF-8' --cache-location .tmp/sass-cache-11 src/gutenberg-blocks/tainacan-facets/facets-list/facets-list.scss:src/assets/css/tainacan-gutenberg-block-facets-list.css
|
||||||
|
|
||||||
|
sass -E 'UTF-8' --cache-location .tmp/sass-cache-12 src/gutenberg-blocks/tainacan-terms/carousel-terms-list/carousel-terms-list.scss:src/assets/css/tainacan-gutenberg-block-carousel-terms-list.css
|
||||||
|
|
||||||
echo "Compilação do Sass Concluído!"
|
echo "Compilação do Sass Concluído!"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -1951,9 +1951,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"buefy": {
|
"buefy": {
|
||||||
"version": "0.8.3",
|
"version": "0.8.6",
|
||||||
"resolved": "https://registry.npmjs.org/buefy/-/buefy-0.8.3.tgz",
|
"resolved": "https://registry.npmjs.org/buefy/-/buefy-0.8.6.tgz",
|
||||||
"integrity": "sha512-01aHoCy4LAD08MmUahXC8mVqtGK/kzJ45ysXskwLWILAhyLMqkZ5fvdMKD9Ky6iDsMttPHdwUe2csmdnIx9caw==",
|
"integrity": "sha512-7woxrdwANcnJbe7lofPxkJLGRRGIVwFXOo0kzEpiNB6alQj18NV6UrdAKse+LWCOADz+AeHe5gyc6qdgRjG5mw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bulma": "0.7.5"
|
"bulma": "0.7.5"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"buefy": "^0.8.3",
|
"buefy": "^0.8.6",
|
||||||
"bulma": "^0.7.5",
|
"bulma": "^0.7.5",
|
||||||
"mdi": "^2.2.43",
|
"mdi": "^2.2.43",
|
||||||
"moment": "^2.22.2",
|
"moment": "^2.22.2",
|
||||||
|
|
|
@ -57,6 +57,7 @@ class Admin {
|
||||||
function load_admin_page() {
|
function load_admin_page() {
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_css' ), 90 );
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_css' ), 90 );
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_js' ), 90 );
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_js' ), 90 );
|
||||||
|
add_action( 'admin_enqueue_scripts', array(&$this, 'add_theme_files') );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="tainacan-modal-content this-tainacan-modal-content">
|
<div
|
||||||
|
aria-labelledby="alert-dialog-title"
|
||||||
|
autofocus
|
||||||
|
role="alertdialog"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
|
class="tainacan-modal-content this-tainacan-modal-content"
|
||||||
|
ref="bulkEditionModal">
|
||||||
<header class="tainacan-modal-title">
|
<header class="tainacan-modal-title">
|
||||||
<h2>{{ modalTitle }}
|
<h2>{{ modalTitle }}
|
||||||
<small class="tainacan-total-objects-info">
|
<small class="tainacan-total-objects-info">
|
||||||
|
@ -17,7 +24,7 @@
|
||||||
|
|
||||||
<b-select
|
<b-select
|
||||||
:loading="metadataIsLoading"
|
:loading="metadataIsLoading"
|
||||||
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone, 'hidden-select-arrow': !!bulkEditionProcedures[criterion].metadatumID}"
|
||||||
:disabled="!!bulkEditionProcedures[criterion].metadatumID || metadataIsLoading"
|
:disabled="!!bulkEditionProcedures[criterion].metadatumID || metadataIsLoading"
|
||||||
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last"
|
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last"
|
||||||
:placeholder="$i18n.get('instruction_select_a_metadatum')"
|
:placeholder="$i18n.get('instruction_select_a_metadatum')"
|
||||||
|
@ -40,7 +47,7 @@
|
||||||
</b-select>
|
</b-select>
|
||||||
|
|
||||||
<b-select
|
<b-select
|
||||||
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone, 'hidden-select-arrow': !!bulkEditionProcedures[criterion].action }"
|
||||||
v-if="bulkEditionProcedures[criterion] &&
|
v-if="bulkEditionProcedures[criterion] &&
|
||||||
bulkEditionProcedures[criterion].metadatumID"
|
bulkEditionProcedures[criterion].metadatumID"
|
||||||
:disabled="!!bulkEditionProcedures[criterion].action"
|
:disabled="!!bulkEditionProcedures[criterion].action"
|
||||||
|
@ -118,7 +125,7 @@
|
||||||
v-else-if="bulkEditionProcedures[criterion] &&
|
v-else-if="bulkEditionProcedures[criterion] &&
|
||||||
bulkEditionProcedures[criterion].metadatumID == 'status'">
|
bulkEditionProcedures[criterion].metadatumID == 'status'">
|
||||||
<b-select
|
<b-select
|
||||||
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone, 'hidden-select-arrow': bulkEditionProcedures[criterion].isDone}"
|
||||||
:disabled="bulkEditionProcedures[criterion].isDone"
|
:disabled="bulkEditionProcedures[criterion].isDone"
|
||||||
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-last"
|
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-last"
|
||||||
:placeholder="$i18n.get('instruction_select_a_status2')"
|
:placeholder="$i18n.get('instruction_select_a_status2')"
|
||||||
|
@ -353,6 +360,10 @@
|
||||||
this.groupID = this.getGroupID();
|
this.groupID = this.getGroupID();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.$refs.bulkEditionModal)
|
||||||
|
this.$refs.bulkEditionModal.focus();
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
metadata() {
|
metadata() {
|
||||||
return this.getMetadata();
|
return this.getMetadata();
|
||||||
|
@ -370,10 +381,10 @@
|
||||||
add: this.$i18n.get('add_value'),
|
add: this.$i18n.get('add_value'),
|
||||||
redefine: this.$i18n.get('set_new_value'),
|
redefine: this.$i18n.get('set_new_value'),
|
||||||
remove: this.$i18n.get('remove_value'),
|
remove: this.$i18n.get('remove_value'),
|
||||||
replace: this.$i18n.get('replace_value'),
|
replace: this.$i18n.get('replace_value')
|
||||||
},
|
},
|
||||||
editionActionsForNotMultiple: {
|
editionActionsForNotMultiple: {
|
||||||
redefine: this.$i18n.get('set_new_value'),
|
redefine: this.$i18n.get('set_new_value')
|
||||||
},
|
},
|
||||||
bulkEditionProcedures: {
|
bulkEditionProcedures: {
|
||||||
1: {
|
1: {
|
||||||
|
|
|
@ -204,7 +204,8 @@
|
||||||
ref="enabledViewModesDropdown"
|
ref="enabledViewModesDropdown"
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
:disabled="Object.keys(registeredViewModes).length < 0"
|
:disabled="Object.keys(registeredViewModes).length < 0"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
|
@ -297,7 +298,7 @@
|
||||||
<div class="status-radios">
|
<div class="status-radios">
|
||||||
<b-radio
|
<b-radio
|
||||||
v-model="form.status"
|
v-model="form.status"
|
||||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
v-for="(statusOption, index) of $statusHelper.getStatuses().filter((status) => status.slug != 'draft')"
|
||||||
:key="index"
|
:key="index"
|
||||||
:native-value="statusOption.slug">
|
:native-value="statusOption.slug">
|
||||||
<span class="icon has-text-gray">
|
<span class="icon has-text-gray">
|
||||||
|
|
|
@ -142,7 +142,9 @@
|
||||||
...mapActions('collection', [
|
...mapActions('collection', [
|
||||||
'fetchCollections'
|
'fetchCollections'
|
||||||
]),
|
]),
|
||||||
updateExporterOptions(){
|
runExporter(){
|
||||||
|
this.runButtonLoading = true;
|
||||||
|
|
||||||
let formElement = document.getElementById('exporterOptionsForm');
|
let formElement = document.getElementById('exporterOptionsForm');
|
||||||
let formData = new FormData(formElement);
|
let formData = new FormData(formElement);
|
||||||
|
|
||||||
|
@ -153,21 +155,9 @@
|
||||||
|
|
||||||
let exporterSessionUpdated = {
|
let exporterSessionUpdated = {
|
||||||
body: {
|
body: {
|
||||||
options: options,
|
mapping_selected: this.selectedMapping,
|
||||||
},
|
send_email: this.sendEmail,
|
||||||
id: this.exporterSession.id,
|
options: options
|
||||||
};
|
|
||||||
|
|
||||||
return this.updateExporterSession(exporterSessionUpdated)
|
|
||||||
.then(exporterSessionUpdated => this.verifyError(exporterSessionUpdated));
|
|
||||||
},
|
|
||||||
runExporter(){
|
|
||||||
this.runButtonLoading = true;
|
|
||||||
|
|
||||||
let exporterSessionUpdated = {
|
|
||||||
body: {
|
|
||||||
mapping_selected: this.selectedMapping ? this.selectedMapping : this.selectedMapping,
|
|
||||||
send_email: this.sendEmail
|
|
||||||
},
|
},
|
||||||
id: this.exporterSession.id,
|
id: this.exporterSession.id,
|
||||||
};
|
};
|
||||||
|
@ -179,23 +169,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateExporterSession(exporterSessionUpdated)
|
this.updateExporterSession(exporterSessionUpdated)
|
||||||
.then(exporterSessionUpdated => {
|
.then(() => {
|
||||||
this.verifyError(exporterSessionUpdated);
|
|
||||||
|
|
||||||
this.updateExporterOptions().then(() => {
|
if (!this.formErrorMessage) {
|
||||||
if(!this.formErrorMessage) {
|
|
||||||
this.runExporterSession(this.exporterSession.id)
|
this.runExporterSession(this.exporterSession.id)
|
||||||
.then((bgp) => {
|
.then((bgp) => {
|
||||||
this.runButtonLoading = false;
|
this.runButtonLoading = false;
|
||||||
this.$router.push(this.$routerHelper.getProcessesPage(bgp.bg_process_id));
|
this.$router.push(this.$routerHelper.getProcessesPage(bgp.bg_process_id));
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((error) => {
|
||||||
|
this.formErrorMessage = error.error_message;
|
||||||
this.runButtonLoading = false;
|
this.runButtonLoading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(() => this.runButtonLoading = false);
|
.catch((error) => {
|
||||||
|
this.formErrorMessage = error.error_message;
|
||||||
|
this.runButtonLoading = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
formIsValid(){
|
formIsValid(){
|
||||||
return (
|
return (
|
||||||
|
@ -204,15 +196,6 @@
|
||||||
this.exporterSession.accept_no_mapping) &&
|
this.exporterSession.accept_no_mapping) &&
|
||||||
!this.formErrorMessage
|
!this.formErrorMessage
|
||||||
);
|
);
|
||||||
},
|
|
||||||
verifyError(response){
|
|
||||||
if(response.constructor.name === 'Object' &&
|
|
||||||
(response.data && response.data.status &&
|
|
||||||
response.data.status.toString().split('')[0] != 2) || response.error_message) {
|
|
||||||
this.formErrorMessage = response.data.error_message;
|
|
||||||
} else {
|
|
||||||
this.exporterSession = response.data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created(){
|
created(){
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
{{ metadatum.name }}
|
{{ metadatum.name }}
|
||||||
</span>
|
</span>
|
||||||
<span class="label-details">
|
<span class="label-details">
|
||||||
({{ $i18n.get(metadatum.metadata_type_object.component) }}) <em>{{ (metadatum.collection_id != collectionId) ? $i18n.get('label_inherited') : '' }}</em>
|
({{ metadatum.metadata_type_object.name }}) <em>{{ (metadatum.collection_id != collectionId) ? $i18n.get('label_inherited') : '' }}</em>
|
||||||
</span>
|
</span>
|
||||||
</option>
|
</option>
|
||||||
</b-select>
|
</b-select>
|
||||||
|
@ -92,7 +92,15 @@
|
||||||
<p v-if="(!importerSourceInfo.source_special_fields || importerSourceInfo.source_special_fields.length <= 0)">{{ $i18n.get('info_no_special_fields_available') }}<br></p>
|
<p v-if="(!importerSourceInfo.source_special_fields || importerSourceInfo.source_special_fields.length <= 0)">{{ $i18n.get('info_no_special_fields_available') }}<br></p>
|
||||||
<b-modal
|
<b-modal
|
||||||
@close="onMetadatumEditionCanceled()"
|
@close="onMetadatumEditionCanceled()"
|
||||||
:active.sync="isNewMetadatumModalActive">
|
:active.sync="isNewMetadatumModalActive"
|
||||||
|
trap-focus
|
||||||
|
aria-modal
|
||||||
|
aria-role="dialog">
|
||||||
|
<div
|
||||||
|
autofocus="true"
|
||||||
|
tabindex="-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal>
|
||||||
<b-loading
|
<b-loading
|
||||||
:is-full-page="isFullPage"
|
:is-full-page="isFullPage"
|
||||||
:active.sync="isLoadingMetadatumTypes"/>
|
:active.sync="isLoadingMetadatumTypes"/>
|
||||||
|
@ -147,6 +155,7 @@
|
||||||
:edited-metadatum="editedMetadatum"
|
:edited-metadatum="editedMetadatum"
|
||||||
:is-on-modal="true"/>
|
:is-on-modal="true"/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</b-modal>
|
</b-modal>
|
||||||
<a
|
<a
|
||||||
v-if="collectionId != null && collectionId != undefined && importerSourceInfo.source_metadata.length > 0"
|
v-if="collectionId != null && collectionId != undefined && importerSourceInfo.source_metadata.length > 0"
|
||||||
|
|
|
@ -337,7 +337,8 @@ export default {
|
||||||
this.amountFinished --;
|
this.amountFinished --;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -212,7 +212,10 @@
|
||||||
:can-cancel="false"
|
:can-cancel="false"
|
||||||
:active.sync="isTextModalActive"
|
:active.sync="isTextModalActive"
|
||||||
:width="640"
|
:width="640"
|
||||||
scroll="keep">
|
scroll="keep"
|
||||||
|
trap-focus
|
||||||
|
aria-modal
|
||||||
|
aria-role="dialog">
|
||||||
<div class="tainacan-modal-content">
|
<div class="tainacan-modal-content">
|
||||||
<div class="tainacan-modal-title">
|
<div class="tainacan-modal-title">
|
||||||
<h2>{{ $i18n.get('instruction_write_text') }}</h2>
|
<h2>{{ $i18n.get('instruction_write_text') }}</h2>
|
||||||
|
@ -248,7 +251,12 @@
|
||||||
:can-cancel="false"
|
:can-cancel="false"
|
||||||
:active.sync="isURLModalActive"
|
:active.sync="isURLModalActive"
|
||||||
:width="640"
|
:width="640"
|
||||||
scroll="keep">
|
scroll="keep"
|
||||||
|
trap-focus
|
||||||
|
role="dialog"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
|
aria-role="dialog">
|
||||||
<div class="tainacan-modal-content">
|
<div class="tainacan-modal-content">
|
||||||
<div class="tainacan-modal-title">
|
<div class="tainacan-modal-title">
|
||||||
<h2>{{ $i18n.get('instruction_insert_url') }}</h2>
|
<h2>{{ $i18n.get('instruction_insert_url') }}</h2>
|
||||||
|
@ -1095,7 +1103,8 @@ export default {
|
||||||
this.$console.error(error);
|
this.$console.error(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -1191,7 +1200,8 @@ export default {
|
||||||
this.deleteItem({ itemId: this.itemId, isPermanently: true });
|
this.deleteItem({ itemId: this.itemId, isPermanently: true });
|
||||||
this.$router.push(this.$routerHelper.getCollectionPath(this.form.collectionId))
|
this.$router.push(this.$routerHelper.getCollectionPath(this.form.collectionId))
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadExistingItem() {
|
loadExistingItem() {
|
||||||
|
@ -1372,7 +1382,8 @@ export default {
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
next()
|
next()
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
<span
|
<span
|
||||||
v-if="metadatum.required == 'yes'"
|
v-if="metadatum.required == 'yes'"
|
||||||
class="required-metadatum-asterisk">*</span>
|
class="required-metadatum-asterisk">*</span>
|
||||||
<span class="metadata-type">({{ $i18n.get(metadatum.metadata_type_object.component) }})</span>
|
<span class="metadata-type">({{ metadatum.metadata_type_object.metadata }})</span>
|
||||||
<help-button
|
<help-button
|
||||||
:title="metadatum.name"
|
:title="metadatum.name"
|
||||||
:message="metadatum.description"/>
|
:message="metadatum.description"/>
|
||||||
|
@ -308,7 +308,8 @@ export default {
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
this.$router.push(this.$routerHelper.getCollectionItemsPath(this.collectionId));
|
this.$router.push(this.$routerHelper.getCollectionItemsPath(this.collectionId));
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (status == 'trash') {
|
} else if (status == 'trash') {
|
||||||
|
@ -336,7 +337,8 @@ export default {
|
||||||
this.isTrashingItems = false;
|
this.isTrashingItems = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -274,7 +274,8 @@
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
} else if (this.isEditingTerm) {
|
} else if (this.isEditingTerm) {
|
||||||
this.$buefy.modal.open({
|
this.$buefy.modal.open({
|
||||||
|
@ -287,7 +288,8 @@
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
|
|
|
@ -5,6 +5,15 @@
|
||||||
@submit.prevent="saveEdition(editForm)">
|
@submit.prevent="saveEdition(editForm)">
|
||||||
<div class="tainacan-page-title">
|
<div class="tainacan-page-title">
|
||||||
<h2>{{ $i18n.get("title_term_edition") }}</h2>
|
<h2>{{ $i18n.get("title_term_edition") }}</h2>
|
||||||
|
<a
|
||||||
|
v-if="editForm && editForm.url != undefined && editForm.url!= ''"
|
||||||
|
target="_blank"
|
||||||
|
:href="editForm.url">
|
||||||
|
<span class="icon">
|
||||||
|
<i class="tainacan-icon tainacan-icon-20px tainacan-icon-see"/>
|
||||||
|
</span>
|
||||||
|
<span class="menu-text">{{ $i18n.get('label_view_on_theme') }}</span>
|
||||||
|
</a>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -181,16 +190,6 @@
|
||||||
{{ $i18n.get('cancel') }}
|
{{ $i18n.get('cancel') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="control">
|
|
||||||
<a
|
|
||||||
type="button"
|
|
||||||
v-if="editForm.url != undefined && editForm.url!= ''"
|
|
||||||
class="button is-secondary"
|
|
||||||
target="_blank"
|
|
||||||
:href="editForm.url">
|
|
||||||
{{ $i18n.get('label_view_term') }}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button
|
<button
|
||||||
class="button is-success"
|
class="button is-success"
|
||||||
|
@ -443,16 +442,21 @@
|
||||||
animation-duration: 0.5s;
|
animation-duration: 0.5s;
|
||||||
|
|
||||||
.tainacan-page-title {
|
.tainacan-page-title {
|
||||||
margin-bottom: 35px;
|
margin-bottom: 30px;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: baseline;
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: $blue5;
|
color: $blue5;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
hr{
|
hr {
|
||||||
margin: 3px 0px 4px 0px;
|
margin: 3px 0px 4px 0px;
|
||||||
|
width: 100%;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
background-color: $secondary;
|
background-color: $secondary;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,19 +70,19 @@
|
||||||
class="table-creation column-small-width"
|
class="table-creation column-small-width"
|
||||||
@click="openActivityDetailsModal(activity)"
|
@click="openActivityDetailsModal(activity)"
|
||||||
:label="$i18n.get('label_activity_date')"
|
:label="$i18n.get('label_activity_date')"
|
||||||
:aria-label="$i18n.get('label_activity_date') + ': ' + activity.log_date">
|
:aria-label="$i18n.get('label_activity_date') + ': ' + activity.date">
|
||||||
<p
|
<p
|
||||||
v-tooltip="{
|
v-tooltip="{
|
||||||
delay: {
|
delay: {
|
||||||
show: 500,
|
show: 500,
|
||||||
hide: 300,
|
hide: 300,
|
||||||
},
|
},
|
||||||
content: activity.log_date,
|
content: activity.date,
|
||||||
autoHide: false,
|
autoHide: false,
|
||||||
classes: ['tooltip', 'repository-tooltip'],
|
classes: ['tooltip', 'repository-tooltip'],
|
||||||
placement: 'auto-start'
|
placement: 'auto-start'
|
||||||
}"
|
}"
|
||||||
v-html="activity.log_date"/>
|
v-html="activity.date"/>
|
||||||
</td>
|
</td>
|
||||||
<!-- Approbation -->
|
<!-- Approbation -->
|
||||||
<!--<td-->
|
<!--<td-->
|
||||||
|
@ -125,9 +125,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapActions} from 'vuex';
|
import { mapActions } from 'vuex';
|
||||||
|
|
||||||
import ActivityDetailsModal from '../other/activity/activity-details-modal.vue';
|
import ActivityDetailsModal from '../other/activity-details-modal.vue';
|
||||||
import ThreeStateToggleButton from '../other/three-state-toggle-button.vue';
|
import ThreeStateToggleButton from '../other/three-state-toggle-button.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -154,9 +154,9 @@
|
||||||
'approve',
|
'approve',
|
||||||
'notApprove'
|
'notApprove'
|
||||||
]),
|
]),
|
||||||
getThis(){
|
// getThis(){
|
||||||
return this;
|
// return this;
|
||||||
},
|
// },
|
||||||
approveActivity(activity) {
|
approveActivity(activity) {
|
||||||
this.approve(activity.id)
|
this.approve(activity.id)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
@ -172,12 +172,13 @@
|
||||||
parent: this,
|
parent: this,
|
||||||
component: ActivityDetailsModal,
|
component: ActivityDetailsModal,
|
||||||
props: {
|
props: {
|
||||||
activity: activity,
|
activityId: activity.id,
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
approveActivity: (activityId) => this.approveActivity(activityId),
|
approveActivity: (activityId) => this.approveActivity(activityId),
|
||||||
notApproveActivity: (activityId) => this.notApproveActivity(activityId)
|
notApproveActivity: (activityId) => this.notApproveActivity(activityId)
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -91,7 +91,8 @@ export default {
|
||||||
title: this.$i18n.get('label_warning'),
|
title: this.$i18n.get('label_warning'),
|
||||||
message: this.$i18n.get('info_warning_terms_not_saved'),
|
message: this.$i18n.get('info_warning_terms_not_saved'),
|
||||||
onConfirm: () => { this.removeTerm(); },
|
onConfirm: () => { this.removeTerm(); },
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.removeTerm();
|
this.removeTerm();
|
||||||
|
@ -110,8 +111,9 @@ export default {
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
// If all checks passed, term can be deleted
|
// If all checks passed, term can be deleted
|
||||||
this.$termsListBus.onDeleteBasicTermItem(this.term);
|
this.$termsListBus.onDeleteBasicTermItem(this.term);
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
eventOnEditTerm() {
|
eventOnEditTerm() {
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
v-if="$userCaps.hasCapability('delete_tainacan-collections')"
|
v-if="$userCaps.hasCapability('delete_tainacan-collections')"
|
||||||
:disabled="!isSelectingCollections"
|
:disabled="!isSelectingCollections"
|
||||||
id="bulk-actions-dropdown"
|
id="bulk-actions-dropdown"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
slot="trigger">
|
slot="trigger">
|
||||||
|
@ -54,7 +55,8 @@
|
||||||
|
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
inline
|
inline
|
||||||
:style="{ top: cursorPosY + 'px', left: cursorPosX + 'px' }">
|
:style="{ top: cursorPosY + 'px', left: cursorPosX + 'px' }"
|
||||||
|
trap-focus>
|
||||||
<b-dropdown-item
|
<b-dropdown-item
|
||||||
@click="openCollection()"
|
@click="openCollection()"
|
||||||
v-if="!isOnTrash">
|
v-if="!isOnTrash">
|
||||||
|
@ -387,8 +389,8 @@ export default {
|
||||||
// })
|
// })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
trapFocus: true
|
||||||
});
|
});
|
||||||
this.clearContextMenu();
|
this.clearContextMenu();
|
||||||
},
|
},
|
||||||
|
@ -426,8 +428,9 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.allCollectionsOnPageSelected = false;
|
this.allCollectionsOnPageSelected = false;
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openCollection() {
|
openCollection() {
|
||||||
|
@ -473,48 +476,6 @@ export default {
|
||||||
this.contextMenuCollection = null;
|
this.contextMenuCollection = null;
|
||||||
this.contextMenuIndex = null;
|
this.contextMenuIndex = null;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
// COLUMN RESIZE
|
|
||||||
// This feature is not implemented as it would require whitespace
|
|
||||||
// on table cells to be 'wrap' instead of 'no-wrap'. Once the table
|
|
||||||
// needs a scroll, the minimum size for the columns would be reached
|
|
||||||
// text would start to ellipsis, but the column is not resizible anymore.
|
|
||||||
// (function () {
|
|
||||||
// var thElm;
|
|
||||||
// var startOffset;
|
|
||||||
|
|
||||||
// Array.prototype.forEach.call(
|
|
||||||
// document.querySelectorAll("table th"),
|
|
||||||
// function (th) {
|
|
||||||
// th.style.position = 'relative';
|
|
||||||
|
|
||||||
// var grip = document.createElement('div');
|
|
||||||
// grip.innerHTML = " ";
|
|
||||||
// grip.style.top = 0;
|
|
||||||
// grip.style.right = 0;
|
|
||||||
// grip.style.bottom = 0;
|
|
||||||
// grip.style.width = '5px';
|
|
||||||
// grip.style.position = 'absolute';
|
|
||||||
// grip.style.cursor = 'col-resize';
|
|
||||||
// grip.addEventListener('mousedown', function (e) {
|
|
||||||
// thElm = th;
|
|
||||||
// startOffset = th.offsetWidth - e.pageX;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// th.appendChild(grip);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// document.addEventListener('mousemove', function (e) {
|
|
||||||
// if (thElm) {
|
|
||||||
// thElm.style.width = startOffset + e.pageX + 'px';
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// document.addEventListener('mouseup', function () {
|
|
||||||
// thElm = undefined;
|
|
||||||
// });
|
|
||||||
// })();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
<span
|
<span
|
||||||
v-if="filter.filter_type_object != undefined"
|
v-if="filter.filter_type_object != undefined"
|
||||||
class="label-details">
|
class="label-details">
|
||||||
({{ $i18n.get(filter.filter_type_object.component) }})
|
({{ filter.filter_type_object.name }})
|
||||||
<span
|
<span
|
||||||
class="not-saved"
|
class="not-saved"
|
||||||
v-if="(editForms[filter.id] != undefined && editForms[filter.id].saved != true) ||filter.status == 'auto-draft'">
|
v-if="(editForms[filter.id] != undefined && editForms[filter.id].saved != true) ||filter.status == 'auto-draft'">
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
@input="onChangeEnable($event, index)"/>
|
@input="onChangeEnable($event, index)"/>
|
||||||
<a
|
<a
|
||||||
:style="{ visibility: filter.collection_id != collectionId && !isRepositoryLevel? 'hidden' : 'visible' }"
|
:style="{ visibility: filter.collection_id != collectionId && !isRepositoryLevel? 'hidden' : 'visible' }"
|
||||||
@click.prevent="editFilter(filter)">
|
@click.prevent="toggleFilterEdition(filter.id)">
|
||||||
<span
|
<span
|
||||||
v-tooltip="{
|
v-tooltip="{
|
||||||
content: $i18n.get('edit'),
|
content: $i18n.get('edit'),
|
||||||
|
@ -234,8 +234,15 @@
|
||||||
<b-modal
|
<b-modal
|
||||||
ref="filterTypeModal"
|
ref="filterTypeModal"
|
||||||
:width="680"
|
:width="680"
|
||||||
:active.sync="isSelectingFilterType">
|
:active.sync="isSelectingFilterType"
|
||||||
|
trap-focus
|
||||||
|
aria-modal
|
||||||
|
aria-role="dialog">
|
||||||
<div
|
<div
|
||||||
|
autofocus
|
||||||
|
role="dialog"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
class="tainacan-modal-content"
|
class="tainacan-modal-content"
|
||||||
style="width: auto">
|
style="width: auto">
|
||||||
<header class="tainacan-modal-title">
|
<header class="tainacan-modal-title">
|
||||||
|
@ -353,6 +360,18 @@ export default {
|
||||||
components: {
|
components: {
|
||||||
FilterEditionForm
|
FilterEditionForm
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
'$route.query': {
|
||||||
|
handler(newQuery) {
|
||||||
|
if (newQuery.edit != undefined) {
|
||||||
|
let existingFilterIndex = this.activeFilterList.findIndex((filter) => filter.id == newQuery.edit);
|
||||||
|
if (existingFilterIndex >= 0)
|
||||||
|
this.editFilter(this.activeFilterList[existingFilterIndex])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
},
|
||||||
beforeRouteLeave ( to, from, next ) {
|
beforeRouteLeave ( to, from, next ) {
|
||||||
let hasUnsavedForms = false;
|
let hasUnsavedForms = false;
|
||||||
for (let editForm in this.editForms) {
|
for (let editForm in this.editForms) {
|
||||||
|
@ -371,7 +390,8 @@ export default {
|
||||||
this.onEditionCanceled();
|
this.onEditionCanceled();
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
next()
|
next()
|
||||||
|
@ -509,7 +529,7 @@ export default {
|
||||||
collectionId: this.collectionId,
|
collectionId: this.collectionId,
|
||||||
metadatumId: this.choosenMetadatum.id,
|
metadatumId: this.choosenMetadatum.id,
|
||||||
name: this.choosenMetadatum.name,
|
name: this.choosenMetadatum.name,
|
||||||
filterType: this.selectedFilterType.name,
|
filterType: this.selectedFilterType.className,
|
||||||
status: 'auto-draft',
|
status: 'auto-draft',
|
||||||
isRepositoryLevel: this.isRepositoryLevel,
|
isRepositoryLevel: this.isRepositoryLevel,
|
||||||
newIndex: this.newFilterIndex
|
newIndex: this.newFilterIndex
|
||||||
|
@ -524,7 +544,7 @@ export default {
|
||||||
this.selectedFilterType = {}
|
this.selectedFilterType = {}
|
||||||
this.allowedFilterTypes = [];
|
this.allowedFilterTypes = [];
|
||||||
|
|
||||||
this.editFilter(filter);
|
this.toggleFilterEdition(filter.id);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$console.error(error);
|
this.$console.error(error);
|
||||||
|
@ -559,22 +579,18 @@ export default {
|
||||||
// this.deleteTemporaryFilter(this.newFilterIndex);
|
// this.deleteTemporaryFilter(this.newFilterIndex);
|
||||||
this.newFilterIndex = 0;
|
this.newFilterIndex = 0;
|
||||||
},
|
},
|
||||||
editFilter(filter) {
|
toggleFilterEdition(filterId) {
|
||||||
// Closing collapse
|
// Closing collapse
|
||||||
if (this.openedFilterId == filter.id) {
|
if (this.openedFilterId == filterId) {
|
||||||
this.openedFilterId = '';
|
this.openedFilterId = '';
|
||||||
|
this.$router.push({ query: {}});
|
||||||
|
|
||||||
// Opening collapse
|
// Opening collapse
|
||||||
} else {
|
} else {
|
||||||
|
this.$router.push({ query: { edit: filterId}})
|
||||||
if (this.openedFilterId == '' && this.choosenMetadatum.id != undefined) {
|
|
||||||
this.availableMetadata.push(this.choosenMetadatum);
|
|
||||||
this.choosenMetadatum = {};
|
|
||||||
this.allowedFilterTypes = [];
|
|
||||||
this.selectedFilterType = {};
|
|
||||||
// this.deleteTemporaryFilter(this.newFilterIndex);
|
|
||||||
this.newFilterIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
editFilter(filter) {
|
||||||
this.openedFilterId = filter.id;
|
this.openedFilterId = filter.id;
|
||||||
|
|
||||||
// First time opening
|
// First time opening
|
||||||
|
@ -588,17 +604,18 @@ export default {
|
||||||
this.editForms[this.openedFilterId].saved = false;
|
this.editForms[this.openedFilterId].saved = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onEditionFinished() {
|
onEditionFinished() {
|
||||||
this.formWithErrors = '';
|
this.formWithErrors = '';
|
||||||
delete this.editForms[this.openedFilterId];
|
delete this.editForms[this.openedFilterId];
|
||||||
this.openedFilterId = '';
|
this.openedFilterId = '';
|
||||||
|
this.$router.push({ query: {}});
|
||||||
},
|
},
|
||||||
onEditionCanceled() {
|
onEditionCanceled() {
|
||||||
this.formWithErrors = '';
|
this.formWithErrors = '';
|
||||||
delete this.editForms[this.openedFilterId];
|
delete this.editForms[this.openedFilterId];
|
||||||
this.openedFilterId = '';
|
this.openedFilterId = '';
|
||||||
|
this.$router.push({ query: {}});
|
||||||
},
|
},
|
||||||
getProperPreviewMinHeight() {
|
getProperPreviewMinHeight() {
|
||||||
for (let filterType of this.allowedFilterTypes) {
|
for (let filterType of this.allowedFilterTypes) {
|
||||||
|
@ -610,6 +627,55 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 190;
|
return 190;
|
||||||
|
},
|
||||||
|
refreshFilters() {
|
||||||
|
this.fetchFilters({
|
||||||
|
collectionId: this.collectionId,
|
||||||
|
isRepositoryLevel: this.isRepositoryLevel,
|
||||||
|
isContextEdit: !this.isOnTheme,
|
||||||
|
includeDisabled: true,
|
||||||
|
}).then((resp) => {
|
||||||
|
resp.request
|
||||||
|
.then(() => {
|
||||||
|
|
||||||
|
this.isLoadingMetadatumTypes = true;
|
||||||
|
|
||||||
|
// Checks URL as router watcher would not wait for list to load
|
||||||
|
if (this.$route.query.edit != undefined) {
|
||||||
|
let existingFilterIndex = this.activeFilterList.findIndex((filter) => filter.id == this.$route.query.edit);
|
||||||
|
if (existingFilterIndex >= 0)
|
||||||
|
this.editFilter(this.activeFilterList[existingFilterIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancels previous Request
|
||||||
|
if (this.metadataSearchCancel != undefined)
|
||||||
|
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
||||||
|
|
||||||
|
// Needs to be done after activeFilterList exists to compare and remove chosen metadata.
|
||||||
|
this.fetchMetadata({
|
||||||
|
collectionId: this.collectionId,
|
||||||
|
isRepositoryLevel: this.isRepositoryLevel,
|
||||||
|
isContextEdit: true
|
||||||
|
}).then((resp) => {
|
||||||
|
resp.request
|
||||||
|
.then(() => {
|
||||||
|
this.isLoadingMetadatumTypes = false;
|
||||||
|
this.updateListOfMetadata();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.isLoadingMetadatumTypes = false;
|
||||||
|
});
|
||||||
|
// Search Request Token for cancelling
|
||||||
|
this.metadataSearchCancel = resp.source;
|
||||||
|
})
|
||||||
|
.catch(() => this.isLoadingMetadatumTypes = false);
|
||||||
|
})
|
||||||
|
.catch(() => this.isLoadingFilters = false);
|
||||||
|
|
||||||
|
// Search Request Token for cancelling
|
||||||
|
this.filtersSearchCancel = resp.source;
|
||||||
|
})
|
||||||
|
.catch(() => this.isLoadingFilters = false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -643,52 +709,8 @@ export default {
|
||||||
if (this.filtersSearchCancel != undefined)
|
if (this.filtersSearchCancel != undefined)
|
||||||
this.filtersSearchCancel.cancel('Filters search Canceled.');
|
this.filtersSearchCancel.cancel('Filters search Canceled.');
|
||||||
|
|
||||||
this.fetchFilters({
|
// Loads Filters
|
||||||
collectionId: this.collectionId,
|
this.refreshFilters();
|
||||||
isRepositoryLevel: this.isRepositoryLevel,
|
|
||||||
isContextEdit: !this.isOnTheme,
|
|
||||||
includeDisabled: true,
|
|
||||||
}).then((resp) => {
|
|
||||||
resp.request
|
|
||||||
.then(() => {
|
|
||||||
|
|
||||||
this.isLoadingMetadatumTypes = true;
|
|
||||||
|
|
||||||
// Cancels previous Request
|
|
||||||
if (this.metadataSearchCancel != undefined)
|
|
||||||
this.metadataSearchCancel.cancel('Metadata search Canceled.');
|
|
||||||
|
|
||||||
// Needs to be done after activeFilterList exists to compare and remove chosen metadata.
|
|
||||||
this.fetchMetadata({
|
|
||||||
collectionId: this.collectionId,
|
|
||||||
isRepositoryLevel: this.isRepositoryLevel,
|
|
||||||
isContextEdit: true
|
|
||||||
}).then((resp) => {
|
|
||||||
resp.request
|
|
||||||
.then(() => {
|
|
||||||
this.isLoadingMetadatumTypes = false;
|
|
||||||
this.updateListOfMetadata();
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.isLoadingMetadatumTypes = false;
|
|
||||||
});
|
|
||||||
// Search Request Token for cancelling
|
|
||||||
this.metadataSearchCancel = resp.source;
|
|
||||||
})
|
|
||||||
.catch(() => this.isLoadingMetadatumTypes = false);
|
|
||||||
})
|
|
||||||
.catch(() => this.isLoadingFilters = false);
|
|
||||||
|
|
||||||
// Search Request Token for cancelling
|
|
||||||
this.filtersSearchCancel = resp.source;
|
|
||||||
})
|
|
||||||
.catch(() => this.isLoadingFilters = false);
|
|
||||||
|
|
||||||
// On repository level we also fetch collection filters
|
|
||||||
if (this.isRepositoryLevel) {
|
|
||||||
this.fetchRepositoryCollectionFilters()
|
|
||||||
.catch(() => this.isLoadingFilters = false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtains collection name
|
// Obtains collection name
|
||||||
if (!this.isRepositoryLevel) {
|
if (!this.isRepositoryLevel) {
|
||||||
|
@ -1153,6 +1175,10 @@ export default {
|
||||||
margin-left: -16px;
|
margin-left: -16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.field .collapse-handle {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
input, select, textarea,
|
input, select, textarea,
|
||||||
.input, .tags, .tag {
|
.input, .tags, .tag {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
v-if="items.length > 0 && items[0].current_user_can_edit"
|
v-if="items.length > 0 && items[0].current_user_can_edit"
|
||||||
:disabled="selectedItems.length <= 1"
|
:disabled="selectedItems.length <= 1"
|
||||||
id="bulk-actions-dropdown"
|
id="bulk-actions-dropdown"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
slot="trigger">
|
slot="trigger">
|
||||||
|
@ -85,7 +86,8 @@
|
||||||
|
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
inline
|
inline
|
||||||
:style="{ top: cursorPosY + 'px', left: cursorPosX + 'px' }">
|
:style="{ top: cursorPosY + 'px', left: cursorPosX + 'px' }"
|
||||||
|
trap-focus>
|
||||||
<b-dropdown-item
|
<b-dropdown-item
|
||||||
@click="openItem()"
|
@click="openItem()"
|
||||||
v-if="!isOnTrash && !$route.query.iframemode">
|
v-if="!isOnTrash && !$route.query.iframemode">
|
||||||
|
@ -1030,6 +1032,7 @@ export default {
|
||||||
collectionID: this.$route.params.collectionId,
|
collectionID: this.$route.params.collectionId,
|
||||||
},
|
},
|
||||||
width: 'calc(100% - 8.333333333%)',
|
width: 'calc(100% - 8.333333333%)',
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
sequenceEditSelectedItems() {
|
sequenceEditSelectedItems() {
|
||||||
|
@ -1068,7 +1071,8 @@ export default {
|
||||||
this.$eventBusSearch.loadItems();
|
this.$eventBusSearch.loadItems();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.clearContextMenu();
|
this.clearContextMenu();
|
||||||
|
@ -1099,7 +1103,8 @@ export default {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deleteOneItem(itemId) {
|
deleteOneItem(itemId) {
|
||||||
|
@ -1121,7 +1126,8 @@ export default {
|
||||||
this.$eventBusSearch.loadItems();
|
this.$eventBusSearch.loadItems();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
this.clearContextMenu();
|
this.clearContextMenu();
|
||||||
},
|
},
|
||||||
|
@ -1151,7 +1157,8 @@ export default {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deleteSelectedItems() {
|
deleteSelectedItems() {
|
||||||
|
@ -1189,7 +1196,8 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openItem() {
|
openItem() {
|
||||||
|
|
|
@ -98,19 +98,17 @@
|
||||||
{{ metadatum.name }}
|
{{ metadatum.name }}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="metadatum.id != undefined"
|
v-if="metadatum.id != undefined && metadatum.metadata_type_object"
|
||||||
class="label-details">
|
class="label-details">
|
||||||
({{ $i18n.get(metadatum.metadata_type_object.component) }})
|
({{ metadatum.metadata_type_object.name }})
|
||||||
<em v-if="metadatum.collection_id != collectionId">{{ $i18n.get('label_inherited') }}</em>
|
<em v-if="metadatum.collection_id != collectionId">{{ $i18n.get('label_inherited') }}</em>
|
||||||
<em
|
<em
|
||||||
v-if="metadatum.metadata_type_object &&
|
v-if="metadatum.metadata_type_object.core &&
|
||||||
metadatum.metadata_type_object.core &&
|
|
||||||
metadatum.metadata_type_object.related_mapped_prop == 'title'">
|
metadatum.metadata_type_object.related_mapped_prop == 'title'">
|
||||||
{{ $i18n.get('label_core_title') }}
|
{{ $i18n.get('label_core_title') }}
|
||||||
</em>
|
</em>
|
||||||
<em
|
<em
|
||||||
v-if="metadatum.metadata_type_object &&
|
v-if="metadatum.metadata_type_object.core &&
|
||||||
metadatum.metadata_type_object.core &&
|
|
||||||
metadatum.metadata_type_object.related_mapped_prop == 'description'">
|
metadatum.metadata_type_object.related_mapped_prop == 'description'">
|
||||||
{{ $i18n.get('label_core_description') }}
|
{{ $i18n.get('label_core_description') }}
|
||||||
</em>
|
</em>
|
||||||
|
@ -235,7 +233,7 @@
|
||||||
</div>
|
</div>
|
||||||
</b-tab-item>
|
</b-tab-item>
|
||||||
|
|
||||||
<!-- Exposer --------------- -->
|
<!-- Mapping --------------- -->
|
||||||
<b-tab-item :label="$i18n.get('mapping')">
|
<b-tab-item :label="$i18n.get('mapping')">
|
||||||
<div>
|
<div>
|
||||||
<section
|
<section
|
||||||
|
@ -248,10 +246,9 @@
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p>{{ $i18n.get('info_there_is_no_metadatum') }}</p>
|
<p>{{ $i18n.get('info_there_is_no_metadatum') }}</p>
|
||||||
<p>{{ $i18n.get('info_create_metadata') }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section v-else>
|
||||||
<div class="field is-grouped form-submit">
|
<div class="field is-grouped form-submit">
|
||||||
<b-select
|
<b-select
|
||||||
id="mappers-options-dropdown"
|
id="mappers-options-dropdown"
|
||||||
|
@ -372,8 +369,15 @@
|
||||||
</section>
|
</section>
|
||||||
<b-modal
|
<b-modal
|
||||||
@close="onCancelNewMetadataMapperMetadata"
|
@close="onCancelNewMetadataMapperMetadata"
|
||||||
:active.sync="isMapperMetadataCreating">
|
:active.sync="isMapperMetadataCreating"
|
||||||
|
trap-focus
|
||||||
|
aria-modal
|
||||||
|
aria-role="dialog">
|
||||||
<div
|
<div
|
||||||
|
autofocus
|
||||||
|
role="dialog"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
class="tainacan-modal-content">
|
class="tainacan-modal-content">
|
||||||
<div class="tainacan-modal-title">
|
<div class="tainacan-modal-title">
|
||||||
<h2>{{ $i18n.get('instruction_insert_mapper_metadatum_info') }}</h2>
|
<h2>{{ $i18n.get('instruction_insert_mapper_metadatum_info') }}</h2>
|
||||||
|
@ -527,7 +531,8 @@ export default {
|
||||||
this.onEditionCanceled();
|
this.onEditionCanceled();
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
next()
|
next()
|
||||||
|
@ -594,7 +599,14 @@ export default {
|
||||||
|
|
||||||
},
|
},
|
||||||
addNewMetadatum(newMetadatum, newIndex) {
|
addNewMetadatum(newMetadatum, newIndex) {
|
||||||
this.sendMetadatum({collectionId: this.collectionId, name: newMetadatum.name, metadatumType: newMetadatum.className, status: 'auto-draft', isRepositoryLevel: this.isRepositoryLevel, newIndex: newIndex})
|
this.sendMetadatum({
|
||||||
|
collectionId: this.collectionId,
|
||||||
|
name: newMetadatum.name,
|
||||||
|
metadatumType: newMetadatum.className,
|
||||||
|
status: 'auto-draft',
|
||||||
|
isRepositoryLevel: this.isRepositoryLevel,
|
||||||
|
newIndex: newIndex
|
||||||
|
})
|
||||||
.then((metadatum) => {
|
.then((metadatum) => {
|
||||||
|
|
||||||
if (!this.isRepositoryLevel)
|
if (!this.isRepositoryLevel)
|
||||||
|
@ -626,8 +638,9 @@ export default {
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.$console.log("Error deleting metadatum.")
|
this.$console.log("Error deleting metadatum.")
|
||||||
});
|
});
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
toggleMetadatumEdition(metadatumId) {
|
toggleMetadatumEdition(metadatumId) {
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
position="is-bottom-left"
|
position="is-bottom-left"
|
||||||
:disabled="!isSelecting"
|
:disabled="!isSelecting"
|
||||||
id="bulk-actions-dropdown">
|
id="bulk-actions-dropdown"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
slot="trigger">
|
slot="trigger">
|
||||||
|
@ -389,7 +390,8 @@
|
||||||
// });
|
// });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deleteSelected() {
|
deleteSelected() {
|
||||||
|
@ -427,7 +429,8 @@
|
||||||
}
|
}
|
||||||
this.allOnPageSelected = false;
|
this.allOnPageSelected = false;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getDate(rawDate) {
|
getDate(rawDate) {
|
||||||
|
@ -451,7 +454,8 @@
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
this.updateProcess({ id: this.processes[index].ID, status: 'closed' });
|
this.updateProcess({ id: this.processes[index].ID, status: 'closed' });
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -218,7 +218,8 @@ export default {
|
||||||
title: this.$i18n.get('label_warning'),
|
title: this.$i18n.get('label_warning'),
|
||||||
message: this.$i18n.get('info_warning_terms_not_saved'),
|
message: this.$i18n.get('info_warning_terms_not_saved'),
|
||||||
onConfirm: () => { this.removeTerm(); },
|
onConfirm: () => { this.removeTerm(); },
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.removeTerm();
|
this.removeTerm();
|
||||||
|
@ -258,8 +259,9 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
eventOnChildTermDeleted(parentTermId) {
|
eventOnChildTermDeleted(parentTermId) {
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
v-if="$userCaps.hasCapability('delete_tainacan-taxonomies')"
|
v-if="$userCaps.hasCapability('delete_tainacan-taxonomies')"
|
||||||
:disabled="!isSelecting"
|
:disabled="!isSelecting"
|
||||||
id="bulk-actions-dropdown"
|
id="bulk-actions-dropdown"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
slot="trigger">
|
slot="trigger">
|
||||||
|
@ -267,7 +268,8 @@
|
||||||
// });
|
// });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deleteSelected() {
|
deleteSelected() {
|
||||||
|
@ -305,7 +307,8 @@
|
||||||
}
|
}
|
||||||
this.allOnPageSelected = false;
|
this.allOnPageSelected = false;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onClickTaxonomy($event, taxonomyId, index) {
|
onClickTaxonomy($event, taxonomyId, index) {
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
:disabled="localTerms.length <= 0 || isLoadingTerms || isEditingTerm"
|
:disabled="localTerms.length <= 0 || isLoadingTerms || isEditingTerm"
|
||||||
@input="onChangeOrder(order == 'asc' ? 'desc' : 'asc')"
|
@input="onChangeOrder(order == 'asc' ? 'desc' : 'asc')"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_sorting_direction')"
|
:aria-label="$i18n.get('label_sorting_direction')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -64,8 +65,8 @@
|
||||||
type="search"
|
type="search"
|
||||||
:aria-label="$i18n.get('instruction_search') + ' ' + $i18n.get('terms')"
|
:aria-label="$i18n.get('instruction_search') + ' ' + $i18n.get('terms')"
|
||||||
autocomplete="on"
|
autocomplete="on"
|
||||||
:value="searchQuery"
|
v-model="searchQuery"
|
||||||
@keyup.enter="searchQuery = $event.target.value;searchTerms(0)"
|
@keyup.enter="searchTerms(0)"
|
||||||
:disabled="isEditingTerm">
|
:disabled="isEditingTerm">
|
||||||
<span
|
<span
|
||||||
@click="searchTerms(0)"
|
@click="searchTerms(0)"
|
||||||
|
|
|
@ -61,7 +61,8 @@
|
||||||
ref="advancedSearchShortcut"
|
ref="advancedSearchShortcut"
|
||||||
class="advanced-search-header-dropdown"
|
class="advanced-search-header-dropdown"
|
||||||
position="is-bottom-left"
|
position="is-bottom-left"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<a
|
<a
|
||||||
class="advanced-search-text"
|
class="advanced-search-text"
|
||||||
slot="trigger">
|
slot="trigger">
|
||||||
|
|
|
@ -130,7 +130,8 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
sourceCollection: this.collectionId,
|
sourceCollection: this.collectionId,
|
||||||
hideWhenManualCollection: true
|
hideWhenManualCollection: true
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,790 @@
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
autofocus
|
||||||
|
role="dialog"
|
||||||
|
class="tainacan-modal-content"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
|
ref="activityDetailsModal">
|
||||||
|
<header
|
||||||
|
v-if="!isLoadingActivity"
|
||||||
|
class="tainacan-modal-title">
|
||||||
|
<h2>{{ activity.title ? activity.title : $i18n.get('activity') }}</h2>
|
||||||
|
<hr>
|
||||||
|
<p>{{ activityCreationDate + ', ' + $i18n.get('info_by_inner') }} <strong> {{ activity.user_name }}</strong></p>
|
||||||
|
</header>
|
||||||
|
<b-loading
|
||||||
|
:is-full-page="false"
|
||||||
|
:active.sync="isLoadingActivity"
|
||||||
|
:can-cancel="false"/>
|
||||||
|
<div
|
||||||
|
v-if="!isLoadingActivity"
|
||||||
|
class="modal-card-body">
|
||||||
|
<div class="content">
|
||||||
|
<p v-if="activity.description"><strong>{{ $i18n.get('label_activity_description') }}:</strong> {{ activity.description }}</p>
|
||||||
|
<p v-if="activity.object">
|
||||||
|
<strong>{{ $i18n.get('label_related_to') }}: </strong>
|
||||||
|
<span v-html="relatedToLink" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- LEGACY LOG API RETURN -->
|
||||||
|
<div v-if="activity.legacy != undefined && activity.legacy == true">
|
||||||
|
<template v-for="(diff, attributeName, index) in activity.log_diffs">
|
||||||
|
<div
|
||||||
|
:key="index"
|
||||||
|
class="columns">
|
||||||
|
<!-- OLD -->
|
||||||
|
<div class="column is-6">
|
||||||
|
|
||||||
|
<!-- Thumbnail -->
|
||||||
|
<div
|
||||||
|
class="content"
|
||||||
|
v-if="attributeName == 'thumbnail'">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ attributeName }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<picture>
|
||||||
|
<img
|
||||||
|
width="150px"
|
||||||
|
:src="diff.old ? diff.old : placeholderSquareImage"
|
||||||
|
:alt="attributeName">
|
||||||
|
</picture>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="attributeName == 'attachments'"
|
||||||
|
class="content">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ attributeName }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
class="tainacan-attachments-in-modal"
|
||||||
|
v-if="diff.old.length">
|
||||||
|
<template v-for="(attachment, anotherIndex) in diff.old">
|
||||||
|
<file-item
|
||||||
|
:key="anotherIndex"
|
||||||
|
:modal-on-click="false"
|
||||||
|
:show-name="true"
|
||||||
|
:file="{
|
||||||
|
title: { rendered: attachment.title },
|
||||||
|
guid: { rendered: attachment.url },
|
||||||
|
mime_type: attachment.mime_type,
|
||||||
|
media_type: attachment.mime_type.includes('image') ? 'image' : 'other'
|
||||||
|
}"/>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<p>{{ infoEmpty }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="content"
|
||||||
|
v-if="!['thumbnail', 'attachments'].includes(attributeName)">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ attributeName.replace(/_/g, ' ') }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- Is array with length 1 -->
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-if="(diff.old instanceof Array) &&
|
||||||
|
(diff.old.length == 1) &&
|
||||||
|
!(diff.old[0] instanceof Object)">
|
||||||
|
{{ diff.old.toString() }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="attributeName == 'metadata_order'"
|
||||||
|
class="content">
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-for="(diffContent, diffTitle) in diff.old"
|
||||||
|
:key="diffTitle">
|
||||||
|
{{ diff.old ? `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` : infoEmpty }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="attributeName == 'filters_order'"
|
||||||
|
class="content">
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-for="(diffContent, diffTitle) in diff.old"
|
||||||
|
:key="diffTitle">
|
||||||
|
{{ diff.old ? `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` : infoEmpty }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="attributeName == 'metadata_type_options'"
|
||||||
|
class="content">
|
||||||
|
<p class="tainacan-p-break">
|
||||||
|
{{ diff.old ?
|
||||||
|
`Taxonomy ID: ${diff.old.taxonomy_id};
|
||||||
|
Input type: ${diff.old.input_type};
|
||||||
|
Allow new terms: ${diff.old.allow_new_terms}` : infoEmpty }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-else>
|
||||||
|
{{ diff.old ? (diff.old instanceof Array && !diff.old.length) ? infoEmpty : diff.old.toString().replace(/,/g, ' ') : infoEmpty }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- NEW -->
|
||||||
|
<div class="column is-6">
|
||||||
|
|
||||||
|
<!-- Thumbnail -->
|
||||||
|
<div
|
||||||
|
class="content"
|
||||||
|
v-if="attributeName == 'thumbnail'">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ attributeName }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<picture>
|
||||||
|
<img
|
||||||
|
width="150px"
|
||||||
|
:src="diff.new ? diff.new : placeholderSquareImage"
|
||||||
|
:alt="attributeName">
|
||||||
|
</picture>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="attributeName == 'attachments'"
|
||||||
|
class="content">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ attributeName }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
class="tainacan-attachments-in-modal"
|
||||||
|
v-if="diff.new.length">
|
||||||
|
<template v-for="(attachment, index) in diff.new">
|
||||||
|
<file-item
|
||||||
|
:key="index"
|
||||||
|
:modal-on-click="false"
|
||||||
|
:show-name="true"
|
||||||
|
:file="{
|
||||||
|
title: { rendered: attachment.title },
|
||||||
|
guid: { rendered: attachment.url },
|
||||||
|
mime_type: attachment.mime_type,
|
||||||
|
media_type: attachment.mime_type.includes('image') ? 'image' : 'other'
|
||||||
|
}"/>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<p>{{ infoEmpty }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="content"
|
||||||
|
v-if="!['thumbnail', 'attachments'].includes(attributeName)">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ attributeName.replace(/_/g, ' ') }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- Is array with length 1 -->
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-if="(diff.new instanceof Array) &&
|
||||||
|
(diff.new.length == 1) &&
|
||||||
|
!(diff.new[0] instanceof Object)">
|
||||||
|
{{ diff.new.toString() }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="attributeName == 'metadata_order'"
|
||||||
|
class="content">
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-for="(diffContent, diffTitle) in diff.new"
|
||||||
|
:key="diffTitle">
|
||||||
|
{{ `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="attributeName == 'filters_order'"
|
||||||
|
class="content">
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-for="(diffContent, diffTitle) in diff.new"
|
||||||
|
:key="diffTitle">
|
||||||
|
{{ `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="attributeName == 'metadata_type_options'"
|
||||||
|
class="content">
|
||||||
|
<p class="tainacan-p-break">
|
||||||
|
{{ `Taxonomy ID: ${diff.new.taxonomy_id};
|
||||||
|
Input type: ${diff.new.input_type};
|
||||||
|
Allow new terms: ${diff.new.allow_new_terms}` }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-else>
|
||||||
|
{{ diff.new ? (diff.new instanceof Array && !diff.new.length) ? infoEmpty : diff.new.toString().replace(/,/g, ' ') : infoEmpty }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- NEW LOG API RETURN -->
|
||||||
|
<div v-else>
|
||||||
|
<div class="columns">
|
||||||
|
<!-- OLD -->
|
||||||
|
<div class="column is-6">
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="activity.action == 'update-thumbnail'"
|
||||||
|
class="content">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ $i18n.get('label_thumbnail') }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-if="activity.old_value && activity.old_value.thumb && activity.old_value.thumb[0]"
|
||||||
|
class="tainacan-p-break">
|
||||||
|
<img
|
||||||
|
style="margin: 12px 0; max-width: 150px;"
|
||||||
|
:alt="$i18n.get('label_thumbnail')"
|
||||||
|
:src="activity.old_value.thumb[0]" >
|
||||||
|
</p>
|
||||||
|
<p v-else>{{ infoEmpty }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="activity.action == 'new-attachment'"
|
||||||
|
class="content">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ $i18n.get('label_attachment') }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<div v-if="activity.old_value.url">
|
||||||
|
<file-item
|
||||||
|
:modal-on-click="false"
|
||||||
|
:show-name="true"
|
||||||
|
:file="{
|
||||||
|
title: { rendered: activity.old_value.title },
|
||||||
|
guid: { rendered: activity.old_value.url },
|
||||||
|
mime_type: activity.old_value.mime_type,
|
||||||
|
media_type: activity.old_value.mime_type.includes('image') ? 'image' : 'other'
|
||||||
|
}"/>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<p>{{ infoEmpty }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="activity.action == 'update-document'"
|
||||||
|
class="content">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ $i18n.get('label_document') }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
:key="index"
|
||||||
|
v-for="(attributeValue, attributeName, index) of activity.old_value">
|
||||||
|
<p
|
||||||
|
v-if="attributeName == 'thumb' && attributeValue[0]"
|
||||||
|
class="tainacan-p-break">
|
||||||
|
<img
|
||||||
|
style="margin: 12px 0; max-width: 150px;"
|
||||||
|
:alt="$i18n.get('label_document')"
|
||||||
|
:src="attributeValue[0]" >
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-else
|
||||||
|
v-html="`<strong>` + attributeName + `: </strong>` + (attributeValue ? attributeValue : infoEmpty)"
|
||||||
|
class="tainacan-p-break" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="content"
|
||||||
|
v-if="activity.action == 'update-metadata-order' || activity.action == 'update-filters-order'">
|
||||||
|
<div
|
||||||
|
:key="index"
|
||||||
|
v-for="(attributeValue, attributeName, index) in activity.old_value">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ attributeName }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-for="(diffContent, diffTitle) in attributeValue"
|
||||||
|
:key="diffTitle"
|
||||||
|
v-html="attributeValue ? `ID: ${diffContent.id} <span class='is-italic'>(${diffContent.enabled ? $i18n.get('label_enabled') : $i18n.get('label_disabled')})</span>` : infoEmpty " />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="content"
|
||||||
|
v-if="activity.action == 'update'">
|
||||||
|
<div
|
||||||
|
:key="index"
|
||||||
|
v-for="(attributeValue, attributeName, index) in activity.old_value">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ attributeName }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- Is array with length 1 -->
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-if="(attributeValue instanceof Array) &&
|
||||||
|
(attributeValue.length == 1) &&
|
||||||
|
!(attributeValue[0] instanceof Object)">
|
||||||
|
{{ attributeValue.toString() }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="attributeName == 'metadata_type_options'"
|
||||||
|
class="content">
|
||||||
|
<p
|
||||||
|
:key="innerIndex"
|
||||||
|
v-for="(innerValue, innerName, innerIndex) of attributeValue"
|
||||||
|
class="tainacan-p-break">
|
||||||
|
<strong>{{ innerName + ': ' }}</strong>{{ innerValue ? innerValue : infoEmpty }}
|
||||||
|
<br>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-else
|
||||||
|
v-html="(!attributeValue || (attributeValue instanceof Array && !attributeValue.length)) ? infoEmpty : (attributeValue instanceof Array ? attributeValue.join(`<span class='multivalue-separator'>|</span>`) : attributeValue)" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="content"
|
||||||
|
v-if="activity.action == 'update-metadata-value'">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ activity.metadata && activity.metadata.name ? activity.metadata.name : $i18n.get('metadatum') }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-html="!activity.old_value ? infoEmpty : (activity.old_value instanceof Array ? activity.old_value.join(`<span class='multivalue-separator'>|</span>`) : activity.old_value)" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- NEW -->
|
||||||
|
<div class="column is-6">
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="activity.action == 'update-thumbnail'"
|
||||||
|
class="content">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ $i18n.get('label_thumbnail') }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-if="activity.new_value && activity.new_value.thumb && activity.new_value.thumb[0]"
|
||||||
|
class="tainacan-p-break">
|
||||||
|
<img
|
||||||
|
style="margin: 12px 0; max-width: 150px;"
|
||||||
|
:alt="$i18n.get('label_thumbnail')"
|
||||||
|
:src="activity.new_value.thumb[0]" >
|
||||||
|
</p>
|
||||||
|
<p v-else>{{ infoEmpty }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="activity.action == 'new-attachment'"
|
||||||
|
class="content">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ $i18n.get('label_attachment') }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<div v-if="activity.new_value.url">
|
||||||
|
<file-item
|
||||||
|
:modal-on-click="false"
|
||||||
|
:show-name="true"
|
||||||
|
:file="{
|
||||||
|
title: { rendered: activity.new_value.title },
|
||||||
|
guid: { rendered: activity.new_value.url },
|
||||||
|
mime_type: activity.new_value.mime_type,
|
||||||
|
media_type: activity.new_value.mime_type.includes('image') ? 'image' : 'other'
|
||||||
|
}"/>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<p>{{ infoEmpty }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="activity.action == 'update-document'"
|
||||||
|
class="content">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ $i18n.get('label_document') }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
:key="index"
|
||||||
|
v-for="(attributeValue, attributeName, index) of activity.new_value">
|
||||||
|
<p
|
||||||
|
v-if="attributeName == 'thumb' && attributeValue[0]"
|
||||||
|
class="tainacan-p-break">
|
||||||
|
<img
|
||||||
|
style="margin: 12px 0; max-width: 150px;"
|
||||||
|
:alt="$i18n.get('label_document')"
|
||||||
|
:src="attributeValue[0]" >
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-else
|
||||||
|
v-html="`<strong>` + attributeName + `: </strong>` + (attributeValue ? attributeValue : infoEmpty)"
|
||||||
|
class="tainacan-p-break" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="content"
|
||||||
|
v-if="activity.action == 'update-metadata-order' || activity.action == 'update-filters-order'">
|
||||||
|
<div
|
||||||
|
:key="index"
|
||||||
|
v-for="(attributeValue, attributeName, index) in activity.new_value">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ attributeName }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-for="(diffContent, diffTitle) in attributeValue"
|
||||||
|
:key="diffTitle"
|
||||||
|
v-html="attributeValue ? `ID: ${diffContent.id} <span class='is-italic'>(${diffContent.enabled ? $i18n.get('label_enabled') : $i18n.get('label_disabled')})</span>` : infoEmpty " />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
:key="index"
|
||||||
|
v-for="(attributeValue, attributeName, index) in activity.new_value">
|
||||||
|
<div
|
||||||
|
class="content"
|
||||||
|
v-if="activity.action == 'update'">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ attributeName }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="attributeName == 'metadata_type_options'"
|
||||||
|
class="content">
|
||||||
|
<p
|
||||||
|
:key="innerIndex"
|
||||||
|
v-for="(innerValue, innerName, innerIndex) of attributeValue"
|
||||||
|
class="tainacan-p-break">
|
||||||
|
<strong>{{ innerName + ': ' }}</strong>{{ innerValue ? innerValue : infoEmpty }}
|
||||||
|
<br>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="attributeName == 'header_image_id'"
|
||||||
|
class="content">
|
||||||
|
<p class="tainacan-p-break">
|
||||||
|
{{ attributeValue ? attributeValue : infoEmpty }}
|
||||||
|
<br>
|
||||||
|
<img
|
||||||
|
style="margin: 12px 0; max-width: 160px;"
|
||||||
|
v-if="activity.terms && activity.terms.header_image"
|
||||||
|
:alt="$i18n.get('label_header_image')"
|
||||||
|
:src="activity.terms.header_image" >
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-else
|
||||||
|
v-html="(!attributeValue || (attributeValue instanceof Array && !attributeValue.length)) ? infoEmpty : (attributeValue instanceof Array ? attributeValue.join(`<span class='multivalue-separator'>|</span>`) : attributeValue)" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="content"
|
||||||
|
v-if="activity.action == 'update-metadata-value'">
|
||||||
|
<p class="is-capitalized has-text-blue5 has-text-weight-bold">
|
||||||
|
{{ activity.metadata && activity.metadata.name ? activity.metadata.name : $i18n.get('metadatum') }}
|
||||||
|
<small class="has-text-gray4 has-text-weight-normal"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
class="tainacan-p-break"
|
||||||
|
v-html="!activity.new_value ? infoEmpty : (activity.new_value instanceof Array ? activity.new_value.join(`<span class='multivalue-separator'>|</span>`) : activity.new_value)" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
<div class="control">
|
||||||
|
<button
|
||||||
|
class="button is-outlined"
|
||||||
|
type="button"
|
||||||
|
@click="$parent.close()">
|
||||||
|
{{ $i18n.get('close') }}
|
||||||
|
</button>
|
||||||
|
<div class="buttons is-pulled-right">
|
||||||
|
<!--<button-->
|
||||||
|
<!--v-if="activity.status != 'publish'"-->
|
||||||
|
<!--@click="notApproveActivity"-->
|
||||||
|
<!--type="button"-->
|
||||||
|
<!--class="button is-danger">-->
|
||||||
|
<!--<b-icon-->
|
||||||
|
<!--size="is-small"-->
|
||||||
|
<!--icon="close"/>-->
|
||||||
|
<!--<span>{{ $i18n.get('not_approve_item') }}</span>-->
|
||||||
|
<!--</button>-->
|
||||||
|
<!--<button-->
|
||||||
|
<!--v-if="activity.status != 'publish'"-->
|
||||||
|
<!--@click="approveActivity"-->
|
||||||
|
<!--type="button"-->
|
||||||
|
<!--class="button is-secondary">-->
|
||||||
|
<!--<b-icon-->
|
||||||
|
<!--size="is-small"-->
|
||||||
|
<!--icon="check"/>-->
|
||||||
|
<!--<span>{{ $i18n.get('approve_item') }}</span>-->
|
||||||
|
<!--</button>-->
|
||||||
|
|
||||||
|
<!--<button-->
|
||||||
|
<!--v-if="activity.status == 'publish'"-->
|
||||||
|
<!--@click="notApproveActivity"-->
|
||||||
|
<!--type="button"-->
|
||||||
|
<!--class="button is-blue5">-->
|
||||||
|
<!--<b-icon-->
|
||||||
|
<!--custom-class="mdi-flip-h"-->
|
||||||
|
<!--size="is-small"-->
|
||||||
|
<!--icon="share"/>-->
|
||||||
|
<!--<span>{{ $i18n.get('undo') }}</span>-->
|
||||||
|
<!--</button>-->
|
||||||
|
|
||||||
|
<!-- <button
|
||||||
|
v-if="activity.status == 'publish'"
|
||||||
|
@click="$parent.close()"
|
||||||
|
type="button"
|
||||||
|
class="button is-secondary">
|
||||||
|
<span>OK</span>
|
||||||
|
</button> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapActions, mapGetters } from 'vuex';
|
||||||
|
import moment from 'moment';
|
||||||
|
import FileItem from './file-item.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "ActivityDetailsModal",
|
||||||
|
props: {
|
||||||
|
activityId: String
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
infoEmpty: `[ ${this.$i18n.get('info_empty').toLowerCase()} ]`,
|
||||||
|
dateFormat: '',
|
||||||
|
activityCreationDate: '',
|
||||||
|
placeholderSquareImage: `${tainacan_plugin.base_url}/admin/images/placeholder_square.png`,
|
||||||
|
isLoadingActivity: false,
|
||||||
|
adminFullURL: tainacan_plugin.admin_url + 'admin.php?page=tainacan_admin#',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
FileItem
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'$route' (to, from) {
|
||||||
|
if (to !== from)
|
||||||
|
this.$parent.close();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
activity() {
|
||||||
|
return this.getActivity();
|
||||||
|
},
|
||||||
|
relatedToLink() {
|
||||||
|
switch(this.activity.object_type) {
|
||||||
|
case 'Tainacan\\Entities\\Collection':
|
||||||
|
return `${ this.$i18n.get('collection') }
|
||||||
|
<a href="${ this.adminFullURL + this.$routerHelper.getCollectionPath(this.activity.object_id) }">${ this.activity.object.name }</a>
|
||||||
|
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-collections"/></span>`;
|
||||||
|
case 'Tainacan\\Entities\\Taxonomy':
|
||||||
|
return `${ this.$i18n.get('taxonomy') }
|
||||||
|
<a href="${ this.adminFullURL + this.$routerHelper.getTaxonomyPath(this.activity.object_id) }">${ this.activity.object.name }</a>
|
||||||
|
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-taxonomies"/></span>`;
|
||||||
|
case 'Tainacan\\Entities\\Metadatum':
|
||||||
|
return `${ this.$i18n.get('metadatum') }
|
||||||
|
<a href="${ this.adminFullURL + (this.activity.object.collection_id == 'default' ? this.$routerHelper.getMetadataEditPath(this.activity.object_id) : this.$routerHelper.getCollectionMetadataEditPath(this.activity.object.collection_id, this.activity.object_id)) }">${ this.activity.object.name }</a>
|
||||||
|
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-metadata"/></span>`;
|
||||||
|
case 'Tainacan\\Entities\\Filter':
|
||||||
|
return `${ this.$i18n.get('filter') }
|
||||||
|
<a href="${ this.adminFullURL + (this.activity.object.collection_id == 'default' ? this.$routerHelper.getFilterEditPath(this.activity.object_id) : this.$routerHelper.getCollectionFilterEditPath(this.activity.object.collection_id, this.activity.object_id)) }">${ this.activity.object.name }</a>
|
||||||
|
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-filters"/></span>`;
|
||||||
|
case 'Tainacan\\Entities\\Term':
|
||||||
|
return `${ this.$i18n.get('term') }
|
||||||
|
<a href="${ this.adminFullURL + this.$routerHelper.getTermEditPath(this.activity.object.taxonomy.replace( /^\D+/g, ''), this.activity.object_id) }">${ this.activity.object.name }</a>
|
||||||
|
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-terms"/></span>`;
|
||||||
|
case 'Tainacan\\Entities\\Item':
|
||||||
|
return `${ this.$i18n.get('item') }
|
||||||
|
<a href="${ this.adminFullURL + this.$routerHelper.getItemEditPath(this.activity.object.collection_id, this.activity.object_id) }">${ this.activity.object.title }</a>
|
||||||
|
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-items"/></span>`;
|
||||||
|
case 'Tainacan\\Entities\\Item_Metadata_Entity':
|
||||||
|
return `${ this.$i18n.get('item') }
|
||||||
|
<a href="${ this.adminFullURL + this.$routerHelper.getItemEditPath(this.activity.object.collection_id, this.activity.item.id) }">${ this.activity.item.title }</a>
|
||||||
|
<span class="icon has-text-gray3"> <i class="tainacan-icon tainacan-icon-20px tainacan-icon-items"/></span>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.loadActivity();
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.$refs.activityDetailsModal)
|
||||||
|
this.$refs.activityDetailsModal.focus()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions('activity', [
|
||||||
|
'fetchActivity'
|
||||||
|
]),
|
||||||
|
...mapGetters('activity', [
|
||||||
|
'getActivity'
|
||||||
|
]),
|
||||||
|
approveActivity(){
|
||||||
|
this.$emit('approveActivity', this.activity.id);
|
||||||
|
},
|
||||||
|
notApproveActivity(){
|
||||||
|
this.$emit('notApproveActivity', this.activity.id);
|
||||||
|
},
|
||||||
|
loadActivity() {
|
||||||
|
this.isLoadingActivity = true;
|
||||||
|
this.fetchActivity(this.activityId)
|
||||||
|
.then(() => {
|
||||||
|
this.isLoadingActivity = false;
|
||||||
|
|
||||||
|
let locale = navigator.language;
|
||||||
|
|
||||||
|
moment.locale(locale);
|
||||||
|
|
||||||
|
let localeData = moment.localeData();
|
||||||
|
this.dateFormat = localeData.longDateFormat('lll');
|
||||||
|
|
||||||
|
let logDate = this.activity.log_date;
|
||||||
|
|
||||||
|
let date = moment(logDate).format(this.dateFormat);
|
||||||
|
|
||||||
|
if (date != 'Invalid date') {
|
||||||
|
this.activityCreationDate = date;
|
||||||
|
} else {
|
||||||
|
this.activityCreationDate = this.$i18n.get('info_unknown_date');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => this.isLoadingActivity = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
|
@import "../../scss/_variables.scss";
|
||||||
|
|
||||||
|
.tainacan-modal-title {
|
||||||
|
align-self: baseline;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tainacan-modal-content {
|
||||||
|
width: auto;
|
||||||
|
min-height: 500px;
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-card-body {
|
||||||
|
min-height: 300px;
|
||||||
|
padding: 0;
|
||||||
|
.columns {
|
||||||
|
margin: 6px $page-side-padding 0 $page-side-padding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tainacan-attachments-in-modal {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
flex-direction: row;
|
||||||
|
align-content: baseline;
|
||||||
|
resize: vertical;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
height: 200px;
|
||||||
|
border: 1px solid $gray3;
|
||||||
|
|
||||||
|
&>div {
|
||||||
|
margin: 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tainacan-p-overflow {
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
max-width: 150px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.is-capitalized {
|
||||||
|
margin-bottom: 0.125rem;
|
||||||
|
}
|
||||||
|
.tainacan-p-break {
|
||||||
|
word-break: break-word;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tainacan-figure {
|
||||||
|
width: 150px;
|
||||||
|
height: 150px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,401 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="tainacan-modal-content">
|
|
||||||
<header class="tainacan-modal-title">
|
|
||||||
<h2>{{ $i18n.get('activity') }}</h2>
|
|
||||||
<hr>
|
|
||||||
</header>
|
|
||||||
<div class="modal-card-body">
|
|
||||||
<div class="content">
|
|
||||||
<p><strong>{{ $i18n.get('label_activity_description') }}:</strong> {{ activity.description }}</p>
|
|
||||||
<p><strong>{{ $i18n.get('label_activity_creation_date') }}:</strong> {{ activityCreationDate }}</p>
|
|
||||||
<p><strong>{{ $i18n.get('label_activity_author') }}:</strong> {{ activity.user_name }}</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<template v-for="(diff, attributeName, index) in activity.log_diffs">
|
|
||||||
<div
|
|
||||||
:key="index"
|
|
||||||
class="columns">
|
|
||||||
|
|
||||||
<!-- OLD -->
|
|
||||||
<div class="column is-6">
|
|
||||||
|
|
||||||
<!-- Thumbnail -->
|
|
||||||
<div
|
|
||||||
class="content"
|
|
||||||
v-if="attributeName == 'thumbnail'">
|
|
||||||
<p class="is-capitalized has-text-blue5">
|
|
||||||
{{ attributeName }}
|
|
||||||
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
|
||||||
</p>
|
|
||||||
<div>
|
|
||||||
<picture>
|
|
||||||
<img
|
|
||||||
width="150px"
|
|
||||||
:src="diff.old ? diff.old : placeholderSquareImage"
|
|
||||||
:alt="attributeName">
|
|
||||||
</picture>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="attributeName == 'attachments'"
|
|
||||||
class="content">
|
|
||||||
<p class="is-capitalized has-text-blue5">
|
|
||||||
{{ attributeName }}
|
|
||||||
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
|
||||||
</p>
|
|
||||||
<div
|
|
||||||
class="tainacan-attachments-in-modal"
|
|
||||||
v-if="diff.old.length">
|
|
||||||
<template v-for="(attachment, anotherIndex) in diff.old">
|
|
||||||
<file-item
|
|
||||||
:key="anotherIndex"
|
|
||||||
:modal-on-click="false"
|
|
||||||
:show-name="true"
|
|
||||||
:file="{
|
|
||||||
title: { rendered: attachment.title },
|
|
||||||
guid: { rendered: attachment.url },
|
|
||||||
mime_type: attachment.mime_type,
|
|
||||||
media_type: attachment.mime_type.includes('image') ? 'image' : 'other'
|
|
||||||
}"/>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<p>{{ infoEmpty }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="content"
|
|
||||||
v-if="!['thumbnail', 'attachments'].includes(attributeName)">
|
|
||||||
<p class="is-capitalized has-text-blue5">
|
|
||||||
{{ attributeName.replace(/_/g, ' ') }}
|
|
||||||
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_before')})` }}</small>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<!-- Is array with length 1 -->
|
|
||||||
<p
|
|
||||||
class="tainacan-p-break"
|
|
||||||
v-if="(diff.old instanceof Array) &&
|
|
||||||
(diff.old.length == 1) &&
|
|
||||||
!(diff.old[0] instanceof Object)">
|
|
||||||
{{ diff.old.toString() }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-else-if="attributeName == 'metadata_order'"
|
|
||||||
class="content">
|
|
||||||
<p
|
|
||||||
class="tainacan-p-break"
|
|
||||||
v-for="(diffContent, diffTitle) in diff.old"
|
|
||||||
:key="diffTitle">
|
|
||||||
{{ diff.old ? `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` : infoEmpty }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-else-if="attributeName == 'filters_order'"
|
|
||||||
class="content">
|
|
||||||
<p
|
|
||||||
class="tainacan-p-break"
|
|
||||||
v-for="(diffContent, diffTitle) in diff.old"
|
|
||||||
:key="diffTitle">
|
|
||||||
{{ diff.old ? `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` : infoEmpty }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-else-if="attributeName == 'metadata_type_options'"
|
|
||||||
class="content">
|
|
||||||
<p class="tainacan-p-break">
|
|
||||||
{{ diff.old ?
|
|
||||||
`Taxonomy ID: ${diff.old.taxonomy_id};
|
|
||||||
Input type: ${diff.old.input_type};
|
|
||||||
Allow new terms: ${diff.old.allow_new_terms}` : infoEmpty }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- -->
|
|
||||||
<p
|
|
||||||
class="tainacan-p-break"
|
|
||||||
v-else>
|
|
||||||
{{ diff.old ? (diff.old instanceof Array && !diff.old.length) ? infoEmpty : diff.old.toString().replace(/,/g, ' ') : infoEmpty }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- NEW -->
|
|
||||||
<div class="column is-6">
|
|
||||||
|
|
||||||
<!-- Thumbnail -->
|
|
||||||
<div
|
|
||||||
class="content"
|
|
||||||
v-if="attributeName == 'thumbnail'">
|
|
||||||
<p class="is-capitalized has-text-blue5">
|
|
||||||
{{ attributeName }}
|
|
||||||
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
|
||||||
</p>
|
|
||||||
<div>
|
|
||||||
<picture>
|
|
||||||
<img
|
|
||||||
width="150px"
|
|
||||||
:src="diff.new ? diff.new : placeholderSquareImage"
|
|
||||||
:alt="attributeName">
|
|
||||||
</picture>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="attributeName == 'attachments'"
|
|
||||||
class="content">
|
|
||||||
<p class="is-capitalized has-text-blue5">
|
|
||||||
{{ attributeName }}
|
|
||||||
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
|
||||||
</p>
|
|
||||||
<div
|
|
||||||
class="tainacan-attachments-in-modal"
|
|
||||||
v-if="diff.new.length">
|
|
||||||
<template v-for="(attachment, index) in diff.new">
|
|
||||||
<file-item
|
|
||||||
:key="index"
|
|
||||||
:modal-on-click="false"
|
|
||||||
:show-name="true"
|
|
||||||
:file="{
|
|
||||||
title: { rendered: attachment.title },
|
|
||||||
guid: { rendered: attachment.url },
|
|
||||||
mime_type: attachment.mime_type,
|
|
||||||
media_type: attachment.mime_type.includes('image') ? 'image' : 'other'
|
|
||||||
}"/>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<p>{{ infoEmpty }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="content"
|
|
||||||
v-if="!['thumbnail', 'attachments'].includes(attributeName)">
|
|
||||||
<p class="is-capitalized has-text-blue5">
|
|
||||||
{{ attributeName.replace(/_/g, ' ') }}
|
|
||||||
<small class="has-text-gray4"> {{ `(${$i18n.get('info_logs_after')})` }}</small>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<!-- Is array with length 1 -->
|
|
||||||
<p
|
|
||||||
class="tainacan-p-break"
|
|
||||||
v-if="(diff.new instanceof Array) &&
|
|
||||||
(diff.new.length == 1) &&
|
|
||||||
!(diff.new[0] instanceof Object)">
|
|
||||||
{{ diff.new.toString() }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-else-if="attributeName == 'metadata_order'"
|
|
||||||
class="content">
|
|
||||||
<p
|
|
||||||
class="tainacan-p-break"
|
|
||||||
v-for="(diffContent, diffTitle) in diff.new"
|
|
||||||
:key="diffTitle">
|
|
||||||
{{ `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-else-if="attributeName == 'filters_order'"
|
|
||||||
class="content">
|
|
||||||
<p
|
|
||||||
class="tainacan-p-break"
|
|
||||||
v-for="(diffContent, diffTitle) in diff.new"
|
|
||||||
:key="diffTitle">
|
|
||||||
{{ `ID: ${diffContent.id} | Enabled: ${diffContent.enabled}` }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-else-if="attributeName == 'metadata_type_options'"
|
|
||||||
class="content">
|
|
||||||
<p class="tainacan-p-break">
|
|
||||||
{{ `Taxonomy ID: ${diff.new.taxonomy_id};
|
|
||||||
Input type: ${diff.new.input_type};
|
|
||||||
Allow new terms: ${diff.new.allow_new_terms}` }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- -->
|
|
||||||
<p
|
|
||||||
class="tainacan-p-break"
|
|
||||||
v-else>
|
|
||||||
{{ diff.new ? (diff.new instanceof Array && !diff.new.length) ? infoEmpty : diff.new.toString().replace(/,/g, ' ') : infoEmpty }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<footer>
|
|
||||||
<div class="control">
|
|
||||||
<button
|
|
||||||
class="button is-outlined"
|
|
||||||
type="button"
|
|
||||||
@click="$parent.close()">
|
|
||||||
{{ $i18n.get('close') }}
|
|
||||||
</button>
|
|
||||||
<div class="buttons is-pulled-right">
|
|
||||||
<!--<button-->
|
|
||||||
<!--v-if="activity.status != 'publish'"-->
|
|
||||||
<!--@click="notApproveActivity"-->
|
|
||||||
<!--type="button"-->
|
|
||||||
<!--class="button is-danger">-->
|
|
||||||
<!--<b-icon-->
|
|
||||||
<!--size="is-small"-->
|
|
||||||
<!--icon="close"/>-->
|
|
||||||
<!--<span>{{ $i18n.get('not_approve_item') }}</span>-->
|
|
||||||
<!--</button>-->
|
|
||||||
<!--<button-->
|
|
||||||
<!--v-if="activity.status != 'publish'"-->
|
|
||||||
<!--@click="approveActivity"-->
|
|
||||||
<!--type="button"-->
|
|
||||||
<!--class="button is-secondary">-->
|
|
||||||
<!--<b-icon-->
|
|
||||||
<!--size="is-small"-->
|
|
||||||
<!--icon="check"/>-->
|
|
||||||
<!--<span>{{ $i18n.get('approve_item') }}</span>-->
|
|
||||||
<!--</button>-->
|
|
||||||
|
|
||||||
<!--<button-->
|
|
||||||
<!--v-if="activity.status == 'publish'"-->
|
|
||||||
<!--@click="notApproveActivity"-->
|
|
||||||
<!--type="button"-->
|
|
||||||
<!--class="button is-blue5">-->
|
|
||||||
<!--<b-icon-->
|
|
||||||
<!--custom-class="mdi-flip-h"-->
|
|
||||||
<!--size="is-small"-->
|
|
||||||
<!--icon="share"/>-->
|
|
||||||
<!--<span>{{ $i18n.get('undo') }}</span>-->
|
|
||||||
<!--</button>-->
|
|
||||||
|
|
||||||
<!-- <button
|
|
||||||
v-if="activity.status == 'publish'"
|
|
||||||
@click="$parent.close()"
|
|
||||||
type="button"
|
|
||||||
class="button is-secondary">
|
|
||||||
<span>OK</span>
|
|
||||||
</button> -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import moment from 'moment';
|
|
||||||
import FileItem from '../file-item.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "ActivityDetailsModal",
|
|
||||||
props: {
|
|
||||||
activity: Object
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
infoEmpty: `[${this.$i18n.get('info_empty').toLowerCase()}]`,
|
|
||||||
dateFormat: '',
|
|
||||||
activityCreationDate: '',
|
|
||||||
placeholderSquareImage: `${tainacan_plugin.base_url}/admin/images/placeholder_square.png`,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
FileItem
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
|
|
||||||
let locale = navigator.language;
|
|
||||||
|
|
||||||
moment.locale(locale);
|
|
||||||
|
|
||||||
let localeData = moment.localeData();
|
|
||||||
this.dateFormat = localeData.longDateFormat('lll');
|
|
||||||
|
|
||||||
let logDate = this.activity.log_date;
|
|
||||||
|
|
||||||
let date = moment(logDate).format(this.dateFormat);
|
|
||||||
|
|
||||||
if (date != 'Invalid date') {
|
|
||||||
this.activityCreationDate = date;
|
|
||||||
} else {
|
|
||||||
this.activityCreationDate = this.$i18n.get('info_unknown_date');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
approveActivity(){
|
|
||||||
this.$emit('approveActivity', this.activity.id);
|
|
||||||
},
|
|
||||||
notApproveActivity(){
|
|
||||||
this.$emit('notApproveActivity', this.activity.id);
|
|
||||||
},
|
|
||||||
undo(){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
|
|
||||||
@import "../../scss/_variables.scss";
|
|
||||||
|
|
||||||
.tainacan-modal-title {
|
|
||||||
align-self: baseline;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tainacan-modal-content {
|
|
||||||
width: auto;
|
|
||||||
min-height: 600px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-card-body {
|
|
||||||
min-height: 400px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tainacan-attachments-in-modal {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
flex-direction: row;
|
|
||||||
align-content: baseline;
|
|
||||||
resize: vertical;
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
height: 200px;
|
|
||||||
border: 1px solid $gray3;
|
|
||||||
|
|
||||||
&>div {
|
|
||||||
margin: 0.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.tainacan-p-overflow {
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
max-width: 150px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tainacan-p-break {
|
|
||||||
word-break: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tainacan-figure {
|
|
||||||
width: 150px;
|
|
||||||
height: 150px;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,5 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<form action="">
|
<form
|
||||||
|
action=""
|
||||||
|
autofocus
|
||||||
|
role="dialog"
|
||||||
|
class="tainacan-modal-content"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
|
ref="availableExportersModal">
|
||||||
<div
|
<div
|
||||||
class="tainacan-modal-content"
|
class="tainacan-modal-content"
|
||||||
style="width: auto">
|
style="width: auto">
|
||||||
|
@ -77,6 +84,9 @@
|
||||||
this.$console.log(error);
|
this.$console.log(error);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.$refs.availableExportersModal)
|
||||||
|
this.$refs.availableExportersModal.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<form action="">
|
<form
|
||||||
|
action=""
|
||||||
|
autofocus
|
||||||
|
role="dialog"
|
||||||
|
class="tainacan-modal-content"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
|
ref="availableImportersModal">
|
||||||
<div
|
<div
|
||||||
class="tainacan-modal-content"
|
class="tainacan-modal-content"
|
||||||
style="width: auto">
|
style="width: auto">
|
||||||
|
@ -79,6 +86,9 @@ export default {
|
||||||
this.$console.log(error);
|
this.$console.log(error);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.$refs.availableImportersModal)
|
||||||
|
this.$refs.availableImportersModal.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="tainacan-modal-content">
|
<div
|
||||||
|
autofocus
|
||||||
|
role="dialog"
|
||||||
|
class="tainacan-modal-content"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
|
ref="checkboxRadioModal">
|
||||||
<header class="tainacan-modal-title">
|
<header class="tainacan-modal-title">
|
||||||
<h2 v-if="isFilter">{{ $i18n.get('filter') }} <em>{{ filter.name }}</em></h2>
|
<h2 v-if="isFilter">{{ $i18n.get('filter') }} <em>{{ filter.name }}</em></h2>
|
||||||
<h2 v-else>{{ $i18n.get('metadatum') }} <em>{{ metadatum.name }}</em></h2>
|
<h2 v-else>{{ $i18n.get('metadatum') }} <em>{{ metadatum.name }}</em></h2>
|
||||||
|
@ -131,7 +137,7 @@
|
||||||
</b-field>
|
</b-field>
|
||||||
<li v-if="finderColumn.children.length">
|
<li v-if="finderColumn.children.length">
|
||||||
<div
|
<div
|
||||||
v-if="totalRemaining[key].remaining === true || (finderColumn.length < totalRemaining[key].remaining)"
|
v-if="shouldShowMoreButton(key)"
|
||||||
@click="getMoreOptions(finderColumn, key)"
|
@click="getMoreOptions(finderColumn, key)"
|
||||||
class="tainacan-show-more">
|
class="tainacan-show-more">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
|
@ -200,7 +206,7 @@
|
||||||
</b-tab-item>
|
</b-tab-item>
|
||||||
</b-tabs>
|
</b-tabs>
|
||||||
<!--<pre>{{ hierarchicalPath }}</pre>-->
|
<!--<pre>{{ hierarchicalPath }}</pre>-->
|
||||||
<!-- <pre>{{ totalRemaining }}</pre> -->
|
<!--<pre>{{ totalRemaining }}</pre>-->
|
||||||
<!--<pre>{{ selected }}</pre>-->
|
<!--<pre>{{ selected }}</pre>-->
|
||||||
<!--<pre>{{ options }}</pre>-->
|
<!--<pre>{{ options }}</pre>-->
|
||||||
<!--<pre>{{ searchResults }}</pre>-->
|
<!--<pre>{{ searchResults }}</pre>-->
|
||||||
|
@ -272,11 +278,11 @@
|
||||||
<script>
|
<script>
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
import { tainacan as axios, isCancel } from '../../../js/axios/axios';
|
import { tainacan as axios, isCancel } from '../../../js/axios/axios';
|
||||||
import { filter_type_mixin } from '../../../classes/filter-types/filter-types-mixin';
|
import { dynamicFilterTypeMixin } from '../../../classes/filter-types/filter-types-mixin';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CheckboxFilterModal',
|
name: 'CheckboxFilterModal',
|
||||||
mixins: [ filter_type_mixin ],
|
mixins: [ dynamicFilterTypeMixin ],
|
||||||
props: {
|
props: {
|
||||||
isFilter: {
|
isFilter: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -286,8 +292,8 @@
|
||||||
parent: Number,
|
parent: Number,
|
||||||
taxonomy_id: Number,
|
taxonomy_id: Number,
|
||||||
taxonomy: String,
|
taxonomy: String,
|
||||||
collection_id: Number,
|
collectionId: Number,
|
||||||
metadatum_id: Number,
|
metadatumId: Number,
|
||||||
metadatum: Object,
|
metadatum: Object,
|
||||||
selected: Array,
|
selected: Array,
|
||||||
isTaxonomy: {
|
isTaxonomy: {
|
||||||
|
@ -295,7 +301,7 @@
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
metadatum_type: String,
|
metadatum_type: String,
|
||||||
metadatum_object: Object,
|
query: Object,
|
||||||
isRepositoryLevel: Boolean,
|
isRepositoryLevel: Boolean,
|
||||||
isCheckbox: {
|
isCheckbox: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -318,7 +324,6 @@
|
||||||
maxNumSearchResultsShow: 20,
|
maxNumSearchResultsShow: 20,
|
||||||
maxNumOptionsCheckboxFinderColumns: 100,
|
maxNumOptionsCheckboxFinderColumns: 100,
|
||||||
checkboxListOffset: 0,
|
checkboxListOffset: 0,
|
||||||
collection: this.collection_id,
|
|
||||||
isCheckboxListLoading: false,
|
isCheckboxListLoading: false,
|
||||||
isSearchingLoading: false,
|
isSearchingLoading: false,
|
||||||
noMorePage: 0,
|
noMorePage: 0,
|
||||||
|
@ -345,7 +350,14 @@
|
||||||
this.getOptions(0);
|
this.getOptions(0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.$refs.checkboxRadioModal)
|
||||||
|
this.$refs.checkboxRadioModal.focus()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
shouldShowMoreButton(key) {
|
||||||
|
return this.totalRemaining[key].remaining === true || (this.finderColumns[key].children.length < this.totalRemaining[key].remaining);
|
||||||
|
},
|
||||||
fetchSelectedLabels() {
|
fetchSelectedLabels() {
|
||||||
|
|
||||||
let selected = this.selected instanceof Array ? this.selected : [this.selected];
|
let selected = this.selected instanceof Array ? this.selected : [this.selected];
|
||||||
|
@ -443,7 +455,7 @@
|
||||||
if ( this.metadatum_type === 'Tainacan\\Metadata_Types\\Relationship' )
|
if ( this.metadatum_type === 'Tainacan\\Metadata_Types\\Relationship' )
|
||||||
promise = this.getValuesRelationship( this.optionName, this.isRepositoryLevel, [], offset, this.maxNumOptionsCheckboxList, true);
|
promise = this.getValuesRelationship( this.optionName, this.isRepositoryLevel, [], offset, this.maxNumOptionsCheckboxList, true);
|
||||||
else
|
else
|
||||||
promise = this.getValuesPlainText( this.metadatum_id, this.optionName, this.isRepositoryLevel, [], offset, this.maxNumOptionsCheckboxList, true);
|
promise = this.getValuesPlainText( this.metadatumId, this.optionName, this.isRepositoryLevel, [], offset, this.maxNumOptionsCheckboxList, true);
|
||||||
|
|
||||||
promise.request
|
promise.request
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
@ -486,10 +498,10 @@
|
||||||
if (!this.isFilter)
|
if (!this.isFilter)
|
||||||
query += '&hideempty=0';
|
query += '&hideempty=0';
|
||||||
|
|
||||||
let route = `/collection/${this.collection_id}/facets/${this.metadatum_id}${query}`;
|
let route = `/collection/${this.collectionId}/facets/${this.metadatumId}${query}`;
|
||||||
|
|
||||||
if(this.collection_id == 'default' || this.collection_id == 'filter_in_repository'){
|
if(this.collectionId == 'default'){
|
||||||
route = `/facets/${this.metadatum_id}${query}`
|
route = `/facets/${this.metadatumId}${query}`
|
||||||
}
|
}
|
||||||
|
|
||||||
axios.get(route)
|
axios.get(route)
|
||||||
|
@ -609,10 +621,10 @@
|
||||||
|
|
||||||
this.isColumnLoading = true;
|
this.isColumnLoading = true;
|
||||||
|
|
||||||
let route = `/collection/${this.collection_id}/facets/${this.metadatum_id}${query}`;
|
let route = `/collection/${this.collectionId}/facets/${this.metadatumId}${query}`;
|
||||||
|
|
||||||
if(this.collection_id == 'default' || this.collection_id == 'filter_in_repository'){
|
if (this.collectionId == 'default'){
|
||||||
route = `/facets/${this.metadatum_id}${query}`
|
route = `/facets/${this.metadatumId}${query}`
|
||||||
}
|
}
|
||||||
|
|
||||||
axios.get(route)
|
axios.get(route)
|
||||||
|
@ -646,10 +658,10 @@
|
||||||
|
|
||||||
this.isColumnLoading = true;
|
this.isColumnLoading = true;
|
||||||
|
|
||||||
let route = `/collection/${this.collection_id}/facets/${this.metadatum_id}${query}`;
|
let route = `/collection/${this.collectionId}/facets/${this.metadatumId}${query}`;
|
||||||
|
|
||||||
if(this.collection_id == 'default' || this.collection_id == 'filter_in_repository'){
|
if (this.collectionId == 'default'){
|
||||||
route = `/facets/${this.metadatum_id}${query}`
|
route = `/facets/${this.metadatumId}${query}`
|
||||||
}
|
}
|
||||||
|
|
||||||
axios.get(route)
|
axios.get(route)
|
||||||
|
@ -674,21 +686,21 @@
|
||||||
applyFilter() {
|
applyFilter() {
|
||||||
this.$parent.close();
|
this.$parent.close();
|
||||||
|
|
||||||
if(this.isTaxonomy && this.isFilter){
|
if (this.isTaxonomy && this.isFilter) {
|
||||||
this.$eventBusSearch.$emit('input', {
|
this.$eventBusSearch.$emit('input', {
|
||||||
filter: 'checkbox',
|
filter: 'checkbox',
|
||||||
taxonomy: this.taxonomy,
|
taxonomy: this.taxonomy,
|
||||||
compare: 'IN',
|
compare: 'IN',
|
||||||
metadatum_id: this.metadatum_id,
|
metadatum_id: this.metadatumId ? this.metadatumId : this.filter.metatadum_id,
|
||||||
collection_id: this.collection_id,
|
collection_id: this.collectionId ? this.collectionId : this.filter.collection_id,
|
||||||
terms: this.selected
|
terms: this.selected
|
||||||
});
|
});
|
||||||
} else if(this.isFilter) {
|
} else if(this.isFilter) {
|
||||||
this.$eventBusSearch.$emit('input', {
|
this.$eventBusSearch.$emit('input', {
|
||||||
filter: 'checkbox',
|
filter: 'checkbox',
|
||||||
compare: 'IN',
|
compare: 'IN',
|
||||||
metadatum_id: this.metadatum_id,
|
metadatum_id: this.metadatumId ? this.metadatumId : this.filter.metatadum_id,
|
||||||
collection_id: this.collection_id ? this.collection_id : this.filter.collection_id,
|
collection_id: this.collectionId ? this.collectionId : this.filter.collection_id,
|
||||||
value: this.selected,
|
value: this.selected,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<form action="">
|
<form
|
||||||
|
action=""
|
||||||
|
autofocus
|
||||||
|
role="dialog"
|
||||||
|
class="tainacan-modal-content"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
|
ref="collectionsModal">
|
||||||
<div
|
<div
|
||||||
class="tainacan-modal-content"
|
class="tainacan-modal-content"
|
||||||
style="width: auto">
|
style="width: auto">
|
||||||
|
@ -18,14 +25,20 @@
|
||||||
:key="index"
|
:key="index"
|
||||||
@click="onSelectCollection(collection)">
|
@click="onSelectCollection(collection)">
|
||||||
<h4>{{ collection.name }}</h4>
|
<h4>{{ collection.name }}</h4>
|
||||||
<p>{{ collection.length > 200 ? (collection.description.substring(0,197) + '...') : collection.description }}</p>
|
<p>{{ collection.description.length > 200 ? (collection.description.substring(0,197) + '...') : collection.description }}</p>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="collections.length <= 0"
|
||||||
|
class="block">
|
||||||
|
<p class="has-text-gray">
|
||||||
|
{{ $i18n.get('info_no_collection_created') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<b-loading
|
<b-loading
|
||||||
:is-full-page="false"
|
:is-full-page="false"
|
||||||
:active.sync="isLoading"
|
:active.sync="isLoading"
|
||||||
:can-cancel="false"/>
|
:can-cancel="false"/>
|
||||||
</div>
|
|
||||||
|
|
||||||
<footer class="field is-grouped form-submit">
|
<footer class="field is-grouped form-submit">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
|
@ -74,6 +87,9 @@ export default {
|
||||||
this.$console.log(error);
|
this.$console.log(error);
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.$refs.collectionsModal)
|
||||||
|
this.$refs.collectionsModal.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
aria-labelledby="alert-dialog-title"
|
aria-labelledby="alert-dialog-title"
|
||||||
aria-modal="true"
|
aria-modal
|
||||||
|
autofocus
|
||||||
role="alertdialog"
|
role="alertdialog"
|
||||||
class="tainacan-form dialog">
|
class="tainacan-form dialog"
|
||||||
|
ref="customDialog">
|
||||||
<div
|
<div
|
||||||
class="modal-card"
|
class="modal-card"
|
||||||
style="width: auto">
|
style="width: auto">
|
||||||
|
@ -87,6 +89,10 @@
|
||||||
changeNeverShowMessageAgain($event) {
|
changeNeverShowMessageAgain($event) {
|
||||||
this.$userPrefs.set('neverShow' + this.messageKeyForUserPrefs + 'Dialog', $event);
|
this.$userPrefs.set('neverShow' + this.messageKeyForUserPrefs + 'Dialog', $event);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.$refs.customDialog)
|
||||||
|
this.$refs.customDialog.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
<!-- Preview Modal ----------------- -->
|
<!-- Preview Modal ----------------- -->
|
||||||
<b-modal
|
<b-modal
|
||||||
:active.sync="isPreviewModalActive"
|
:active.sync="isPreviewModalActive"
|
||||||
scroll="keep">
|
scroll="keep"
|
||||||
|
trap-focus
|
||||||
|
aria-modal
|
||||||
|
aria-role="dialog">
|
||||||
<!-- <div class="tainacan-modal-content">
|
<!-- <div class="tainacan-modal-content">
|
||||||
<div class="tainacan-modal-title">
|
<div class="tainacan-modal-title">
|
||||||
<h2>{{ $i18n.get('label_document') }}</h2>
|
<h2>{{ $i18n.get('label_document') }}</h2>
|
||||||
|
@ -21,6 +24,10 @@
|
||||||
<hr>
|
<hr>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div
|
<div
|
||||||
|
autofocus
|
||||||
|
role="dialog"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
class="is-flex rendered-content"
|
class="is-flex rendered-content"
|
||||||
v-html="documentHtml" />
|
v-html="documentHtml" />
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
|
@ -32,10 +39,14 @@
|
||||||
export default {
|
export default {
|
||||||
name: 'DocumentItem',
|
name: 'DocumentItem',
|
||||||
props: {
|
props: {
|
||||||
documentHtml: String,
|
documentHtml: String
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
isPreviewModalActive: false
|
isPreviewModalActive: false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
aria-labelledby="exposers-modal-title"
|
aria-labelledby="exposers-modal-title"
|
||||||
|
autofocus
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
class="tainacan-modal-content"
|
class="tainacan-modal-content"
|
||||||
style="width: auto">
|
style="width: auto"
|
||||||
|
ref="exposersModal">
|
||||||
<header class="tainacan-modal-title">
|
<header class="tainacan-modal-title">
|
||||||
<h2
|
<h2
|
||||||
id="exposers-modal-title"
|
id="exposers-modal-title"
|
||||||
|
@ -469,6 +472,9 @@ export default {
|
||||||
|
|
||||||
if (this.itemId)
|
if (this.itemId)
|
||||||
this.shouldRespectFetchOnly = false;
|
this.shouldRespectFetchOnly = false;
|
||||||
|
|
||||||
|
if (this.$refs.exposersModal)
|
||||||
|
this.$refs.exposersModal.focus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -32,8 +32,16 @@
|
||||||
<b-modal
|
<b-modal
|
||||||
:active.sync="isPreviewModalActive"
|
:active.sync="isPreviewModalActive"
|
||||||
:width="1024"
|
:width="1024"
|
||||||
scroll="keep">
|
scroll="keep"
|
||||||
<div class="tainacan-modal-content">
|
trap-focus
|
||||||
|
aria-modal
|
||||||
|
aria-role="dialog">
|
||||||
|
<div
|
||||||
|
autofocus
|
||||||
|
role="dialog"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
|
class="tainacan-modal-content">
|
||||||
<div class="tainacan-modal-title">
|
<div class="tainacan-modal-title">
|
||||||
<h2 v-if="file.title != undefined">{{ file.title.rendered }}</h2>
|
<h2 v-if="file.title != undefined">{{ file.title.rendered }}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -54,7 +54,7 @@ export default {
|
||||||
display: block;
|
display: block;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
min-width: 250px;
|
min-width: 250px;
|
||||||
min-width: 250px;
|
max-width: 100%;
|
||||||
transition: margin-bottom 0.2s ease, opacity 0.3s ease;
|
transition: margin-bottom 0.2s ease, opacity 0.3s ease;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: calc(100% - 6px);
|
bottom: calc(100% - 6px);
|
||||||
|
@ -76,6 +76,7 @@ export default {
|
||||||
padding: 0.8em 1.0em 1.0em 1.0em;
|
padding: 0.8em 1.0em 1.0em 1.0em;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
aria-labelledby="alert-dialog-title"
|
aria-labelledby="alert-dialog-title"
|
||||||
aria-modal="true"
|
autofocus
|
||||||
role="alertdialog"
|
role="alertdialog"
|
||||||
class="tainacan-form dialog">
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
|
class="tainacan-form dialog"
|
||||||
|
ref="itemCopyDialog">
|
||||||
<div
|
<div
|
||||||
class="modal-card"
|
class="modal-card"
|
||||||
style="width: auto">
|
style="width: auto">
|
||||||
|
@ -183,6 +186,10 @@
|
||||||
this.isCreatingBulkEditGroup = false;
|
this.isCreatingBulkEditGroup = false;
|
||||||
this.isCreatingSequenceEditGroup = false;
|
this.isCreatingSequenceEditGroup = false;
|
||||||
this.copyCount = 1;
|
this.copyCount = 1;
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.$refs.itemCopyDialog)
|
||||||
|
this.$refs.itemCopyDialog.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
v-if="collections && collections.length"
|
||||||
class="block">
|
class="block">
|
||||||
<div
|
<div
|
||||||
v-for="(collection, key) in collections"
|
v-for="(collection, key) in collections"
|
||||||
|
@ -26,11 +27,18 @@
|
||||||
<b-checkbox
|
<b-checkbox
|
||||||
v-model="collectionsIdsToFilter"
|
v-model="collectionsIdsToFilter"
|
||||||
:native-value="collection.id"
|
:native-value="collection.id"
|
||||||
@input="apply_filter">
|
@input="applyFilter">
|
||||||
{{ collection.name }}
|
{{ collection.name }}
|
||||||
</b-checkbox>
|
</b-checkbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="block">
|
||||||
|
<p class="has-text-gray">
|
||||||
|
{{ $i18n.get('info_no_collection_created') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</b-collapse>
|
</b-collapse>
|
||||||
</b-field>
|
</b-field>
|
||||||
</template>
|
</template>
|
||||||
|
@ -60,7 +68,7 @@
|
||||||
Array.isArray(routeQueries.metaquery[0].value)){
|
Array.isArray(routeQueries.metaquery[0].value)){
|
||||||
this.collectionsIdsToFilter = routeQueries.metaquery[0].value;
|
this.collectionsIdsToFilter = routeQueries.metaquery[0].value;
|
||||||
|
|
||||||
this.apply_filter();
|
this.applyFilter();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
|
@ -84,7 +92,7 @@
|
||||||
...mapGetters('collection', [
|
...mapGetters('collection', [
|
||||||
'getCollections',
|
'getCollections',
|
||||||
]),
|
]),
|
||||||
apply_filter(){
|
applyFilter(){
|
||||||
this.$eventBusSearch.$emit( 'input', {
|
this.$eventBusSearch.$emit( 'input', {
|
||||||
filter: 'checkbox',
|
filter: 'checkbox',
|
||||||
metadatum_id: 'collection_id',
|
metadatum_id: 'collection_id',
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
|
<transition name="filter-item">
|
||||||
<div
|
<div
|
||||||
class="is-inline-flex"
|
class="is-inline-flex"
|
||||||
v-if="filterTags != undefined && filterTags.length > 0">
|
v-if="filterTags != undefined && filterTags.length > 0">
|
||||||
|
@ -7,8 +8,8 @@
|
||||||
:key="index"
|
:key="index"
|
||||||
attached
|
attached
|
||||||
closable
|
closable
|
||||||
@close="removeMetaQuery(filterTag.filterId, filterTag.value, filterTag.singleValue)">
|
@close="removeMetaQuery(filterTag)">
|
||||||
{{ filterTag.singleValue != undefined ? filterTag.singleValue : filterTag.value }}
|
{{ filterTag.singleLabel != undefined ? filterTag.singleLabel : filterTag.label }}
|
||||||
</b-tag>
|
</b-tag>
|
||||||
<button
|
<button
|
||||||
@click="clearAllFilters()"
|
@click="clearAllFilters()"
|
||||||
|
@ -17,9 +18,10 @@
|
||||||
{{ $i18n.get('label_clear_filters') }}
|
{{ $i18n.get('label_clear_filters') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapActions } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'FiltersTagsList',
|
name: 'FiltersTagsList',
|
||||||
|
@ -31,9 +33,9 @@
|
||||||
let tags = this.getFilterTags();
|
let tags = this.getFilterTags();
|
||||||
let flattenTags = [];
|
let flattenTags = [];
|
||||||
for (let tag of tags) {
|
for (let tag of tags) {
|
||||||
if (Array.isArray(tag.value)) {
|
if (Array.isArray(tag.label)) {
|
||||||
for (let valueTag of tag.value)
|
for (let i = 0; i < tag.label.length; i++)
|
||||||
flattenTags.push({filterId: tag.filterId, value: tag, singleValue: valueTag});
|
flattenTags.push({filterId: tag.filterId, label: tag.label, singleLabel: tag.label[i], value: tag.value[i], taxonomy: tag.taxonomy, metadatumId: tag.metadatumId});
|
||||||
} else {
|
} else {
|
||||||
flattenTags.push(tag);
|
flattenTags.push(tag);
|
||||||
}
|
}
|
||||||
|
@ -43,22 +45,22 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapGetters('search',[
|
...mapGetters('search',[
|
||||||
'getPostQuery',
|
|
||||||
'getFilterTags'
|
'getFilterTags'
|
||||||
]),
|
]),
|
||||||
...mapActions('metadata',[
|
removeMetaQuery({ filterId, value, singleLabel, label, taxonomy, metadatumId }) {
|
||||||
'fetchMetadatum'
|
this.$eventBusSearch.removeMetaFromFilterTag({
|
||||||
]),
|
filterId: filterId,
|
||||||
removeMetaQuery(filterId, value, singleValue) {
|
singleLabel: singleLabel,
|
||||||
if (singleValue != undefined)
|
label: label,
|
||||||
this.$eventBusSearch.removeMetaFromFilterTag({ filterId: filterId, singleValue: singleValue });
|
value: value,
|
||||||
else
|
taxonomy: taxonomy,
|
||||||
this.$eventBusSearch.removeMetaFromFilterTag({ filterId: filterId, value: value });
|
metadatumId: metadatumId
|
||||||
|
});
|
||||||
},
|
},
|
||||||
clearAllFilters() {
|
clearAllFilters() {
|
||||||
// this.$eventBusSearch.clearAllFilters();
|
// this.$eventBusSearch.clearAllFilters();
|
||||||
for (let tag of this.filterTags) {
|
for (let tag of this.filterTags) {
|
||||||
this.removeMetaQuery(tag.filterId, tag.value, tag.singleValue);
|
this.removeMetaQuery(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,8 @@
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
position="is-top-right"
|
position="is-top-right"
|
||||||
@change="onPageChange"
|
@change="onPageChange"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
aria-labelledby="go-to-page-dropdown"
|
aria-labelledby="go-to-page-dropdown"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
|
|
@ -1,254 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="table-container">
|
|
||||||
<div class="selection-control">
|
|
||||||
<div class="field select-all is-pulled-left">
|
|
||||||
<span>
|
|
||||||
<b-checkbox disabled>{{ $i18n.get('label_select_all_items_page') }}</b-checkbox>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="field is-pulled-right">
|
|
||||||
<b-dropdown
|
|
||||||
position="is-bottom-left"
|
|
||||||
disabled>
|
|
||||||
<button
|
|
||||||
class="button is-white"
|
|
||||||
slot="trigger">
|
|
||||||
<span>{{ $i18n.get('label_bulk_actions') }}</span>
|
|
||||||
<span class="icon">
|
|
||||||
<i class="tainacan-icon tainacan-icon-20px tainacan-icon-arrowdown"/>
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
</b-dropdown>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="table-wrapper">
|
|
||||||
<table
|
|
||||||
v-if="viewMode == 'table'"
|
|
||||||
class="tainacan-table">
|
|
||||||
<thead>
|
|
||||||
<th class="skeleton column-default-width" />
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr
|
|
||||||
class="skeleton"
|
|
||||||
:key="item"
|
|
||||||
v-for="item in itemsPerPage">
|
|
||||||
<td class="column-default-width"/>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div
|
|
||||||
v-if="viewMode == 'cards' || viewMode == 'grid'"
|
|
||||||
:class="{
|
|
||||||
'tainacan-cards-container': viewMode == 'cards',
|
|
||||||
'tainacan-grid-container': viewMode == 'grid'
|
|
||||||
}">
|
|
||||||
<div
|
|
||||||
:key="item"
|
|
||||||
v-for="item in itemsPerPage"
|
|
||||||
class="skeleton"
|
|
||||||
:class="{
|
|
||||||
'tainacan-card': viewMode == 'cards',
|
|
||||||
'tainacan-grid-item': viewMode == 'grid'
|
|
||||||
}"/>
|
|
||||||
</div>
|
|
||||||
<masonry
|
|
||||||
:cols="getMasonryColsSettings()"
|
|
||||||
:gutter="viewMode == 'masonry' ? 25 : 30"
|
|
||||||
v-if="viewMode == 'masonry' || viewMode == 'records'"
|
|
||||||
:class="{
|
|
||||||
'tainacan-masonry-container': viewMode == 'masonry',
|
|
||||||
'tainacan-records-container': viewMode == 'records'
|
|
||||||
}">
|
|
||||||
<div
|
|
||||||
:key="item"
|
|
||||||
v-for="item in itemsPerPage"
|
|
||||||
:style="{'min-height': randomHeightForMasonryItem() + 'px' }"
|
|
||||||
class="skeleton"
|
|
||||||
:class="{
|
|
||||||
'tainacan-masonry-item': viewMode == 'masonry',
|
|
||||||
'tainacan-record': viewMode == 'records'
|
|
||||||
}"/>
|
|
||||||
</masonry>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { mapGetters } from 'vuex';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'SkeletonItemsList',
|
|
||||||
computed: {
|
|
||||||
itemsPerPage(){
|
|
||||||
return this.getItemsPerPage();
|
|
||||||
},
|
|
||||||
viewMode() {
|
|
||||||
return this.getAdminViewMode();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
...mapGetters('search', [
|
|
||||||
'getItemsPerPage',
|
|
||||||
'getAdminViewMode',
|
|
||||||
]),
|
|
||||||
getMasonryColsSettings() {
|
|
||||||
if (this.viewMode == 'masonry')
|
|
||||||
return { default: 7, 1919: 6, 1407: 5, 1215: 4, 1023: 3, 767: 2, 343: 1 }
|
|
||||||
else
|
|
||||||
return { default: 4, 1919: 3, 1407: 2, 1215: 2, 1023: 1, 767: 1, 343: 1 }
|
|
||||||
|
|
||||||
},
|
|
||||||
randomHeightForMasonryItem() {
|
|
||||||
let min = 255;
|
|
||||||
let max = 255;
|
|
||||||
|
|
||||||
if (this.viewMode == 'masonry') {
|
|
||||||
min = 140;
|
|
||||||
max = 420;
|
|
||||||
} else if (this.viewMode == 'records') {
|
|
||||||
min = 380;
|
|
||||||
max = 480;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.floor(Math.random()*(max-min+1)+min);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
|
|
||||||
@import '../../scss/_variables.scss';
|
|
||||||
|
|
||||||
// Selection Area
|
|
||||||
.selection-control {
|
|
||||||
|
|
||||||
padding: 6px 0px 0px 12px;
|
|
||||||
background: white;
|
|
||||||
height: 40px;
|
|
||||||
|
|
||||||
.select-all {
|
|
||||||
color: $gray4;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
&:hover {
|
|
||||||
color: $gray4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cards View Mode
|
|
||||||
.tainacan-cards-container {
|
|
||||||
min-height: 50vh;
|
|
||||||
padding: 0;
|
|
||||||
display: -ms-grid;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, 455px);
|
|
||||||
grid-gap: 0px;
|
|
||||||
justify-content: space-evenly;
|
|
||||||
animation-name: item-appear;
|
|
||||||
animation-duration: 0.5s;
|
|
||||||
|
|
||||||
@media screen and (max-width: 480px) {
|
|
||||||
width: 91.666666667%;
|
|
||||||
grid-template-columns: repeat(auto-fill, 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.tainacan-card {
|
|
||||||
padding: 0px;
|
|
||||||
flex-basis: 0;
|
|
||||||
margin: 15px;
|
|
||||||
max-width: 425px;
|
|
||||||
min-width: 425px;
|
|
||||||
min-height: 210px;
|
|
||||||
max-height: 210px;
|
|
||||||
|
|
||||||
@media screen and (max-width: 480px) {
|
|
||||||
max-width: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
min-height: 171px;
|
|
||||||
max-height: 171px;
|
|
||||||
|
|
||||||
img {
|
|
||||||
width: 130px !important;
|
|
||||||
height: 130px !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Thumbnails (Grid) View Mode
|
|
||||||
.tainacan-grid-container {
|
|
||||||
min-height: 50vh;
|
|
||||||
padding: 0;
|
|
||||||
display: -ms-grid;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, 285px);
|
|
||||||
grid-gap: 0px;
|
|
||||||
justify-content: space-evenly;
|
|
||||||
animation-name: appear;
|
|
||||||
animation-duration: 0.5s;
|
|
||||||
|
|
||||||
.tainacan-grid-item {
|
|
||||||
max-width: 255px;
|
|
||||||
min-height: 300px;
|
|
||||||
flex-basis: 0;
|
|
||||||
margin: 15px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Masonry View Mode
|
|
||||||
.tainacan-masonry-container {
|
|
||||||
min-height: 50vh;
|
|
||||||
padding: 0;
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
flex-grow: 1;
|
|
||||||
flex-shrink: 1;
|
|
||||||
justify-content: space-evenly;
|
|
||||||
animation-name: item-appear;
|
|
||||||
animation-duration: 0.5s;
|
|
||||||
|
|
||||||
.tainacan-masonry-item {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
flex-basis: 0;
|
|
||||||
margin-bottom: 25px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Records View Mode
|
|
||||||
.tainacan-records-container {
|
|
||||||
min-height: 50vh;
|
|
||||||
padding: 0;
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
flex-grow: 1;
|
|
||||||
flex-shrink: 1;
|
|
||||||
justify-content: space-evenly;
|
|
||||||
animation-name: item-appear;
|
|
||||||
animation-duration: 0.5s;
|
|
||||||
|
|
||||||
.tainacan-record {
|
|
||||||
background-color: #f6f6f6;
|
|
||||||
padding: 0px;
|
|
||||||
flex-basis: 0;
|
|
||||||
margin: 0 auto 30px auto;
|
|
||||||
width: 100%;
|
|
||||||
max-width: 425px;
|
|
||||||
min-height: 100px;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Table View Mode
|
|
||||||
table.tainacan-table {
|
|
||||||
border-spacing: 6px !important;
|
|
||||||
th { height: 38px; }
|
|
||||||
td { height: 52px; }
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
|
@ -23,18 +23,20 @@ import FormRelationship from '../../classes/metadata-types/relationship/FormRela
|
||||||
import FormTaxonomy from '../../classes/metadata-types/taxonomy/FormTaxonomy.vue';
|
import FormTaxonomy from '../../classes/metadata-types/taxonomy/FormTaxonomy.vue';
|
||||||
import FormSelectbox from '../../classes/metadata-types/selectbox/FormSelectbox.vue';
|
import FormSelectbox from '../../classes/metadata-types/selectbox/FormSelectbox.vue';
|
||||||
|
|
||||||
import FilterCustomInterval from '../../classes/filter-types/custom-interval/CustomInterval.vue';
|
|
||||||
import FilterNumeric from '../../classes/filter-types/numeric/Numeric.vue';
|
import FilterNumeric from '../../classes/filter-types/numeric/Numeric.vue';
|
||||||
import FilterDate from '../../classes/filter-types/date/Date.vue';
|
import FilterDate from '../../classes/filter-types/date/Date.vue';
|
||||||
import FilterSelectbox from '../../classes/filter-types/selectbox/Selectbox.vue';
|
import FilterSelectbox from '../../classes/filter-types/selectbox/Selectbox.vue';
|
||||||
import FilterAutocomplete from '../../classes/filter-types/autocomplete/Autocomplete.vue';
|
import FilterAutocomplete from '../../classes/filter-types/autocomplete/Autocomplete.vue';
|
||||||
import FilterCheckbox from '../../classes/filter-types/checkbox/Checkbox.vue';
|
import FilterCheckbox from '../../classes/filter-types/checkbox/Checkbox.vue';
|
||||||
import FilterTaginput from '../../classes/filter-types/taginput/Taginput.vue';
|
import FilterTaginput from '../../classes/filter-types/taginput/Taginput.vue';
|
||||||
|
import FilterNumericInterval from '../../classes/filter-types/numeric-interval/NumericInterval.vue';
|
||||||
|
import FilterDateInterval from '../../classes/filter-types/date-interval/DateInterval.vue';
|
||||||
|
|
||||||
import FilterTaxonomyCheckbox from '../../classes/filter-types/taxonomy/Checkbox.vue';
|
import FilterTaxonomyCheckbox from '../../classes/filter-types/taxonomy/Checkbox.vue';
|
||||||
import FilterTaxonomyTaginput from '../../classes/filter-types/taxonomy/Taginput.vue';
|
import FilterTaxonomyTaginput from '../../classes/filter-types/taxonomy/Taginput.vue';
|
||||||
|
|
||||||
import FormNumeric from '../../classes/filter-types/numeric/FormNumeric.vue';
|
import FormNumeric from '../../classes/filter-types/numeric/FormNumeric.vue';
|
||||||
|
import FormNumericInterval from '../../classes/filter-types/numeric-interval/FormNumericInterval.vue';
|
||||||
// import FormDate from '../../classes/filter-types/date/FormDate.vue';
|
// import FormDate from '../../classes/filter-types/date/FormDate.vue';
|
||||||
|
|
||||||
import TainacanFormItem from '../../classes/metadata-types/tainacan-form-item.vue';
|
import TainacanFormItem from '../../classes/metadata-types/tainacan-form-item.vue';
|
||||||
|
@ -50,6 +52,10 @@ import eventBusSearch from '../../js/event-bus-search';
|
||||||
import termsListBus from './terms-list-bus.js';
|
import termsListBus from './terms-list-bus.js';
|
||||||
import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin, UserCapabilitiesPlugin, StatusHelperPlugin } from './utilities';
|
import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin, UserCapabilitiesPlugin, StatusHelperPlugin } from './utilities';
|
||||||
|
|
||||||
|
import FilterNumericListInterval from '../../classes/filter-types/numeric-list-interval/NumericListInterval.vue';
|
||||||
|
import FormNumericListInterval from '../../classes/filter-types/numeric-list-interval/FormNumericListInterval.vue';
|
||||||
|
|
||||||
|
|
||||||
// Configure and Register Plugins
|
// Configure and Register Plugins
|
||||||
Vue.use(Buefy, {
|
Vue.use(Buefy, {
|
||||||
defaultTooltipAnimated: true
|
defaultTooltipAnimated: true
|
||||||
|
@ -80,7 +86,6 @@ Vue.component('tainacan-form-item', TainacanFormItem);
|
||||||
Vue.component('tainacan-filter-item', TainacanFiltersList);
|
Vue.component('tainacan-filter-item', TainacanFiltersList);
|
||||||
|
|
||||||
/* Filters */
|
/* Filters */
|
||||||
Vue.component('tainacan-filter-custom-interval', FilterCustomInterval);
|
|
||||||
Vue.component('tainacan-filter-numeric', FilterNumeric);
|
Vue.component('tainacan-filter-numeric', FilterNumeric);
|
||||||
Vue.component('tainacan-filter-date', FilterDate);
|
Vue.component('tainacan-filter-date', FilterDate);
|
||||||
Vue.component('tainacan-filter-selectbox', FilterSelectbox);
|
Vue.component('tainacan-filter-selectbox', FilterSelectbox);
|
||||||
|
@ -89,8 +94,14 @@ Vue.component('tainacan-filter-checkbox', FilterCheckbox);
|
||||||
Vue.component('tainacan-filter-taginput', FilterTaginput);
|
Vue.component('tainacan-filter-taginput', FilterTaginput);
|
||||||
Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox);
|
Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox);
|
||||||
Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput);
|
Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput);
|
||||||
|
Vue.component('tainacan-filter-numeric-interval', FilterNumericInterval);
|
||||||
|
Vue.component('tainacan-filter-numeric-list-interval', FilterNumericListInterval);
|
||||||
|
Vue.component('tainacan-filter-date-interval', FilterDateInterval);
|
||||||
|
|
||||||
/* Filter Metadata Option forms */
|
/* Filter Metadata Option forms */
|
||||||
Vue.component('tainacan-filter-form-numeric', FormNumeric);
|
Vue.component('tainacan-filter-form-numeric', FormNumeric);
|
||||||
|
Vue.component('tainacan-filter-form-numeric-interval', FormNumericInterval);
|
||||||
|
Vue.component('tainacan-filter-form-numeric-list-interval', FormNumericListInterval);
|
||||||
// Vue.component('tainacan-filter-form-date', FormDate);
|
// Vue.component('tainacan-filter-form-date', FormDate);
|
||||||
|
|
||||||
/* Others */
|
/* Others */
|
||||||
|
|
|
@ -5,16 +5,16 @@ import VTooltip from 'v-tooltip';
|
||||||
import VueMasonry from 'vue-masonry-css';
|
import VueMasonry from 'vue-masonry-css';
|
||||||
|
|
||||||
// Custom elements
|
// Custom elements
|
||||||
import FilterCustomInterval from '../../classes/filter-types/custom-interval/CustomInterval.vue';
|
|
||||||
import FilterNumeric from '../../classes/filter-types/numeric/Numeric.vue';
|
import FilterNumeric from '../../classes/filter-types/numeric/Numeric.vue';
|
||||||
import FilterDate from '../../classes/filter-types/date/Date.vue';
|
import FilterDate from '../../classes/filter-types/date/Date.vue';
|
||||||
import FilterSelectbox from '../../classes/filter-types/selectbox/Selectbox.vue';
|
import FilterSelectbox from '../../classes/filter-types/selectbox/Selectbox.vue';
|
||||||
import FilterAutocomplete from '../../classes/filter-types/autocomplete/Autocomplete.vue';
|
import FilterAutocomplete from '../../classes/filter-types/autocomplete/Autocomplete.vue';
|
||||||
import FilterCheckbox from '../../classes/filter-types/checkbox/Checkbox.vue';
|
import FilterCheckbox from '../../classes/filter-types/checkbox/Checkbox.vue';
|
||||||
import FilterTaginput from '../../classes/filter-types/taginput/Taginput.vue';
|
import FilterTaginput from '../../classes/filter-types/taginput/Taginput.vue';
|
||||||
|
|
||||||
import FilterTaxonomyCheckbox from '../../classes/filter-types/taxonomy/Checkbox.vue';
|
import FilterTaxonomyCheckbox from '../../classes/filter-types/taxonomy/Checkbox.vue';
|
||||||
import FilterTaxonomyTaginput from '../../classes/filter-types/taxonomy/Taginput.vue';
|
import FilterTaxonomyTaginput from '../../classes/filter-types/taxonomy/Taginput.vue';
|
||||||
|
import FilterNumericInterval from '../../classes/filter-types/numeric-interval/NumericInterval.vue';
|
||||||
|
import FilterNumericListInterval from '../../classes/filter-types/numeric-list-interval/NumericListInterval.vue';
|
||||||
|
|
||||||
import TaincanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue';
|
import TaincanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue';
|
||||||
import ItemsPage from '../pages/lists/items-page.vue';
|
import ItemsPage from '../pages/lists/items-page.vue';
|
||||||
|
@ -43,11 +43,9 @@ Vue.use(RouterHelperPlugin);
|
||||||
Vue.use(StatusHelperPlugin);
|
Vue.use(StatusHelperPlugin);
|
||||||
Vue.use(ConsolePlugin, {visual: false});
|
Vue.use(ConsolePlugin, {visual: false});
|
||||||
|
|
||||||
|
|
||||||
Vue.component('tainacan-filter-item', TaincanFiltersList);
|
Vue.component('tainacan-filter-item', TaincanFiltersList);
|
||||||
|
|
||||||
/* Filters */
|
/* Filters */
|
||||||
Vue.component('tainacan-filter-custom-interval', FilterCustomInterval);
|
|
||||||
Vue.component('tainacan-filter-numeric', FilterNumeric);
|
Vue.component('tainacan-filter-numeric', FilterNumeric);
|
||||||
Vue.component('tainacan-filter-date', FilterDate);
|
Vue.component('tainacan-filter-date', FilterDate);
|
||||||
Vue.component('tainacan-filter-selectbox', FilterSelectbox);
|
Vue.component('tainacan-filter-selectbox', FilterSelectbox);
|
||||||
|
@ -56,6 +54,8 @@ Vue.component('tainacan-filter-checkbox', FilterCheckbox);
|
||||||
Vue.component('tainacan-filter-taginput', FilterTaginput);
|
Vue.component('tainacan-filter-taginput', FilterTaginput);
|
||||||
Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox);
|
Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox);
|
||||||
Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput);
|
Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput);
|
||||||
|
Vue.component('tainacan-filter-numeric-interval', FilterNumericInterval);
|
||||||
|
Vue.component('tainacan-filter-numeric-list-interval', FilterNumericListInterval);
|
||||||
|
|
||||||
/* Others */
|
/* Others */
|
||||||
Vue.component('items-page', ItemsPage);
|
Vue.component('items-page', ItemsPage);
|
||||||
|
|
|
@ -227,9 +227,6 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
|
||||||
getFiltersPath(query) {
|
getFiltersPath(query) {
|
||||||
return '/filters/?' + qs.stringify(query);
|
return '/filters/?' + qs.stringify(query);
|
||||||
},
|
},
|
||||||
getMetadataPath(query) {
|
|
||||||
return '/metadata/?' + qs.stringify(query);
|
|
||||||
},
|
|
||||||
getActivitiesPath(query) {
|
getActivitiesPath(query) {
|
||||||
return '/activities/?' + qs.stringify(query);
|
return '/activities/?' + qs.stringify(query);
|
||||||
},
|
},
|
||||||
|
@ -302,14 +299,23 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
|
||||||
getItemEditPath(collectionId, itemId) {
|
getItemEditPath(collectionId, itemId) {
|
||||||
return '/collections/' + collectionId + '/items/' + itemId + '/edit';
|
return '/collections/' + collectionId + '/items/' + itemId + '/edit';
|
||||||
},
|
},
|
||||||
getFilterEditPath(id) {
|
getMetadataEditPath(metadatumId) {
|
||||||
return '/filters/' + id + '/edit';
|
return '/metadata/?edit=' + metadatumId;
|
||||||
|
},
|
||||||
|
getFilterEditPath(filterId) {
|
||||||
|
return '/filters/?edit=' + filterId;
|
||||||
|
},
|
||||||
|
getCollectionMetadataEditPath(collectionId, metadatumId) {
|
||||||
|
return '/collections/' + collectionId + '/metadata/?edit=' + metadatumId;
|
||||||
|
},
|
||||||
|
getCollectionFilterEditPath(collectionId, filterId) {
|
||||||
|
return '/collections/' + collectionId + '/filters/?edit=' + filterId;
|
||||||
},
|
},
|
||||||
getTaxonomyEditPath(id, isRecent) {
|
getTaxonomyEditPath(id, isRecent) {
|
||||||
return isRecent != undefined ? '/taxonomies/' + id + '/edit?recent=true' : '/taxonomies/' + id + '/edit';
|
return isRecent != undefined ? '/taxonomies/' + id + '/edit?recent=true' : '/taxonomies/' + id + '/edit';
|
||||||
},
|
},
|
||||||
getTermEditPath(taxonomyId, termId) {
|
getTermEditPath(taxonomyId, termId) {
|
||||||
return '/taxonomies/' + taxonomyId + '/terms/' + termId + '/edit';
|
return '/taxonomies/' + taxonomyId + '/edit?tab=terms';
|
||||||
},
|
},
|
||||||
getImporterEditionPath(importerType) {
|
getImporterEditionPath(importerType) {
|
||||||
return '/importers/' + importerType;
|
return '/importers/' + importerType;
|
||||||
|
|
|
@ -140,7 +140,7 @@
|
||||||
{{ $i18n.getWithVariables('label_view_all_%s_collections', [collectionsTotal]) }}
|
{{ $i18n.getWithVariables('label_view_all_%s_collections', [collectionsTotal]) }}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="collectionsTotal != undefined && collectionsTotal == 1"
|
v-if="collectionsTotal != undefined && collectionsTotal <= 1"
|
||||||
class="menu-text">
|
class="menu-text">
|
||||||
{{ $i18n.get('label_view_collections_list') }}
|
{{ $i18n.get('label_view_collections_list') }}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -28,6 +28,75 @@
|
||||||
:active.sync="isLoading"
|
:active.sync="isLoading"
|
||||||
:can-cancel="false"/>
|
:can-cancel="false"/>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="tab != 'processes'"
|
||||||
|
class="sub-header">
|
||||||
|
|
||||||
|
<b-field class="header-item">
|
||||||
|
<b-datepicker
|
||||||
|
ref="datepicker"
|
||||||
|
:placeholder="$i18n.get('instruction_filter_activities_date')"
|
||||||
|
v-model="searchDates"
|
||||||
|
range
|
||||||
|
@input="searchActivities()"
|
||||||
|
:date-formatter="(date) => dateFormatter(date)"
|
||||||
|
:date-parser="(date) => dateParser(date)"
|
||||||
|
size="is-small"
|
||||||
|
icon="calendar-today"
|
||||||
|
:years-range="[-50, 3]"
|
||||||
|
:day-names="[
|
||||||
|
$i18n.get('datepicker_short_sunday'),
|
||||||
|
$i18n.get('datepicker_short_monday'),
|
||||||
|
$i18n.get('datepicker_short_tuesday'),
|
||||||
|
$i18n.get('datepicker_short_wednesday'),
|
||||||
|
$i18n.get('datepicker_short_thursday'),
|
||||||
|
$i18n.get('datepicker_short_friday'),
|
||||||
|
$i18n.get('datepicker_short_saturday')
|
||||||
|
]"
|
||||||
|
:month-names="[
|
||||||
|
$i18n.get('datepicker_month_january'),
|
||||||
|
$i18n.get('datepicker_month_february'),
|
||||||
|
$i18n.get('datepicker_month_march'),
|
||||||
|
$i18n.get('datepicker_month_april'),
|
||||||
|
$i18n.get('datepicker_month_may'),
|
||||||
|
$i18n.get('datepicker_month_june'),
|
||||||
|
$i18n.get('datepicker_month_july'),
|
||||||
|
$i18n.get('datepicker_month_august'),
|
||||||
|
$i18n.get('datepicker_month_september'),
|
||||||
|
$i18n.get('datepicker_month_october'),
|
||||||
|
$i18n.get('datepicker_month_november'),
|
||||||
|
$i18n.get('datepicker_month_december')
|
||||||
|
]"/>
|
||||||
|
<p
|
||||||
|
class="control"
|
||||||
|
v-if="searchDates && searchDates.length != 0">
|
||||||
|
<button
|
||||||
|
class="button"
|
||||||
|
@click="clearSearchDates()">
|
||||||
|
<span class="icon"><i class="tainacan-icon tainacan-icon-close"/></span>
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</b-field>
|
||||||
|
|
||||||
|
<b-field class="header-item">
|
||||||
|
<div class="control has-icons-right is-small is-clearfix">
|
||||||
|
<input
|
||||||
|
class="input is-small"
|
||||||
|
:placeholder="$i18n.get('instruction_search')"
|
||||||
|
type="search"
|
||||||
|
:aria-label="$i18n.get('instruction_search') + ' ' + $i18n.get('activities')"
|
||||||
|
autocomplete="on"
|
||||||
|
v-model="searchQuery"
|
||||||
|
@keyup.enter="searchActivities()">
|
||||||
|
<span
|
||||||
|
@click="searchActivities()"
|
||||||
|
class="icon is-right">
|
||||||
|
<i class="tainacan-icon tainacan-icon-search" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</b-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
<activities-list
|
<activities-list
|
||||||
v-if="tab != 'processes'"
|
v-if="tab != 'processes'"
|
||||||
:is-loading="isLoading"
|
:is-loading="isLoading"
|
||||||
|
@ -149,11 +218,13 @@
|
||||||
<script>
|
<script>
|
||||||
import ActivitiesList from "../../components/lists/activities-list.vue";
|
import ActivitiesList from "../../components/lists/activities-list.vue";
|
||||||
import ProcessesList from "../../components/lists/processes-list.vue";
|
import ProcessesList from "../../components/lists/processes-list.vue";
|
||||||
|
import { dateInter } from "../../../admin/js/mixins";
|
||||||
import { mapActions, mapGetters } from 'vuex';
|
import { mapActions, mapGetters } from 'vuex';
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ActivitiesPage',
|
name: 'ActivitiesPage',
|
||||||
|
mixins: [ dateInter ],
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
@ -165,6 +236,8 @@
|
||||||
isRepositoryLevel: false,
|
isRepositoryLevel: false,
|
||||||
tab: '',
|
tab: '',
|
||||||
isItemLevel: false,
|
isItemLevel: false,
|
||||||
|
searchQuery: '',
|
||||||
|
searchDates: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -237,10 +310,15 @@
|
||||||
loadActivities() {
|
loadActivities() {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
|
|
||||||
|
let dataInit = this.searchDates && this.searchDates[0] ? moment(this.searchDates[0]).format('YYYY-MM-DD') : null;
|
||||||
|
let dataEnd = this.searchDates && this.searchDates[1] ? moment(this.searchDates[1]).format('YYYY-MM-DD') : null;
|
||||||
|
|
||||||
if(this.isRepositoryLevel) {
|
if(this.isRepositoryLevel) {
|
||||||
this.fetchActivities({
|
this.fetchActivities({
|
||||||
'page': this.activitiesPage,
|
'page': this.activitiesPage,
|
||||||
'activitiesPerPage': this.activitiesPerPage
|
'activitiesPerPage': this.activitiesPerPage,
|
||||||
|
'search': this.searchQuery,
|
||||||
|
'searchDates': [dataInit, dataEnd]
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
@ -253,7 +331,9 @@
|
||||||
this.fetchCollectionActivities({
|
this.fetchCollectionActivities({
|
||||||
'page': this.activitiesPage,
|
'page': this.activitiesPage,
|
||||||
'activitiesPerPage': this.activitiesPerPage,
|
'activitiesPerPage': this.activitiesPerPage,
|
||||||
'collectionId': this.$route.params.collectionId
|
'collectionId': this.$route.params.collectionId,
|
||||||
|
'search': this.searchQuery,
|
||||||
|
'searchDates': [dataInit, dataEnd]
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
@ -266,7 +346,9 @@
|
||||||
this.fetchItemActivities({
|
this.fetchItemActivities({
|
||||||
'page': this.activitiesPage,
|
'page': this.activitiesPage,
|
||||||
'activitiesPerPage': this.activitiesPerPage,
|
'activitiesPerPage': this.activitiesPerPage,
|
||||||
'itemId': this.$route.params.itemId
|
'itemId': this.$route.params.itemId,
|
||||||
|
'search': this.searchQuery,
|
||||||
|
'searchDates': [dataInit, dataEnd]
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
@ -300,6 +382,25 @@
|
||||||
getLastProcessesNumber() {
|
getLastProcessesNumber() {
|
||||||
let last = (Number(this.processesPerPage * (this.processesPage - 1)) + Number(this.processesPerPage));
|
let last = (Number(this.processesPerPage * (this.processesPage - 1)) + Number(this.processesPerPage));
|
||||||
return last > this.total ? this.total : last;
|
return last > this.total ? this.total : last;
|
||||||
|
},
|
||||||
|
searchActivities() {
|
||||||
|
this.activitiesPage = 1;
|
||||||
|
this.loadActivities();
|
||||||
|
},
|
||||||
|
clearSearchDates() {
|
||||||
|
this.searchDates = null;
|
||||||
|
this.searchActivities();
|
||||||
|
},
|
||||||
|
dateFormatter(dateObject) {
|
||||||
|
if (dateObject == null || dateObject.length == 0 || dateObject[0] == null || dateObject[1] == null)
|
||||||
|
return "";
|
||||||
|
return moment(dateObject[0], moment.ISO_8601).format(this.dateFormat) + " - " + moment(dateObject[1], moment.ISO_8601).format(this.dateFormat);
|
||||||
|
},
|
||||||
|
dateParser(dateString) {
|
||||||
|
return [
|
||||||
|
moment(dateString[0], this.dateFormat).toDate(),
|
||||||
|
moment(dateString[1], this.dateFormat).toDate()
|
||||||
|
];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -357,15 +458,60 @@
|
||||||
@import '../../scss/_variables.scss';
|
@import '../../scss/_variables.scss';
|
||||||
|
|
||||||
.sub-header {
|
.sub-header {
|
||||||
min-height: $header-height;
|
min-height: $subheader-height;
|
||||||
height: $header-height;
|
height: $header-height;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
|
display: inline-flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
.header-item {
|
.header-item {
|
||||||
display: inline-block;
|
margin-bottom: 0 !important;
|
||||||
padding-right: 8em;
|
|
||||||
|
&:not(:last-child) {
|
||||||
|
padding-right: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: normal;
|
||||||
|
margin-top: 3px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
height: 1.95rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field {
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gray-icon, .gray-icon .icon {
|
||||||
|
color: $gray4 !important;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
.gray-icon .icon i::before,
|
||||||
|
.gray-icon i::before {
|
||||||
|
font-size: 1.3125rem !important;
|
||||||
|
max-width: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
pointer-events: all;
|
||||||
|
cursor: pointer;
|
||||||
|
color: $blue5;
|
||||||
|
height: 27px;
|
||||||
|
font-size: 18px !important;
|
||||||
|
height: 1.75rem !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 769px) {
|
@media screen and (max-width: 769px) {
|
||||||
|
@ -373,8 +519,8 @@
|
||||||
margin-top: -0.5em;
|
margin-top: -0.5em;
|
||||||
padding-top: 0.9em;
|
padding-top: 0.9em;
|
||||||
|
|
||||||
.header-item {
|
.header-item:not(:last-child) {
|
||||||
padding-right: 0.5em;
|
padding-right: 0.2em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
<div class="header-item">
|
<div class="header-item">
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
aria-role="list"
|
aria-role="list"
|
||||||
id="collection-creation-options-dropdown">
|
id="collection-creation-options-dropdown"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-secondary"
|
class="button is-secondary"
|
||||||
slot="trigger">
|
slot="trigger">
|
||||||
|
@ -62,7 +63,8 @@
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
:disabled="collections.length <= 0 || isLoading"
|
:disabled="collections.length <= 0 || isLoading"
|
||||||
@input="onChangeOrder(order == 'asc' ? 'desc' : 'asc')"
|
@input="onChangeOrder(order == 'asc' ? 'desc' : 'asc')"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_sorting_direction')"
|
:aria-label="$i18n.get('label_sorting_direction')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -120,6 +122,25 @@
|
||||||
</option>
|
</option>
|
||||||
</b-select>
|
</b-select>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
|
||||||
|
<!-- Textual Search -------------->
|
||||||
|
<b-field class="header-item">
|
||||||
|
<div class="control has-icons-right is-small is-clearfix">
|
||||||
|
<input
|
||||||
|
class="input is-small"
|
||||||
|
:placeholder="$i18n.get('instruction_search')"
|
||||||
|
type="search"
|
||||||
|
:aria-label="$i18n.get('instruction_search') + ' ' + $i18n.get('collections')"
|
||||||
|
autocomplete="on"
|
||||||
|
v-model="searchQuery"
|
||||||
|
@keyup.enter="searchCollections()">
|
||||||
|
<span
|
||||||
|
@click="searchCollections()"
|
||||||
|
class="icon is-right">
|
||||||
|
<i class="tainacan-icon tainacan-icon-search" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</b-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="above-subheader">
|
<div class="above-subheader">
|
||||||
|
@ -139,11 +160,11 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
v-for="(statusOption, index) of $statusHelper.getStatuses().filter((status) => status.slug != 'draft')"
|
||||||
:key="index"
|
:key="index"
|
||||||
@click="onChangeTab(statusOption.slug)"
|
@click="onChangeTab(statusOption.slug)"
|
||||||
:class="{ 'is-active': status == statusOption.slug}"
|
:class="{ 'is-active': status == statusOption.slug}"
|
||||||
:style="{ marginRight: statusOption.slug == 'private' ? 'auto' : '', marginLeft: statusOption.slug == 'draft' ? 'auto' : '' }"
|
:style="{ marginRight: statusOption.slug == 'private' ? 'auto' : '', marginLeft: statusOption.slug == 'trash' ? 'auto' : '' }"
|
||||||
v-tooltip="{
|
v-tooltip="{
|
||||||
content: $i18n.getWithVariables('info_%s_tab_' + statusOption.slug,[$i18n.get('collections')]),
|
content: $i18n.getWithVariables('info_%s_tab_' + statusOption.slug,[$i18n.get('collections')]),
|
||||||
autoHide: true,
|
autoHide: true,
|
||||||
|
@ -195,7 +216,8 @@
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
:disabled="isLoadingMetadatumMappers"
|
:disabled="isLoadingMetadatumMappers"
|
||||||
id="collection-creation-options-dropdown"
|
id="collection-creation-options-dropdown"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-secondary"
|
class="button is-secondary"
|
||||||
slot="trigger">
|
slot="trigger">
|
||||||
|
@ -307,6 +329,7 @@ export default {
|
||||||
status: '',
|
status: '',
|
||||||
order: 'desc',
|
order: 'desc',
|
||||||
ordeBy: 'date',
|
ordeBy: 'date',
|
||||||
|
searchQuery: '',
|
||||||
sortingOptions: [
|
sortingOptions: [
|
||||||
{ label: this.$i18n.get('label_title'), value: 'title' },
|
{ label: this.$i18n.get('label_title'), value: 'title' },
|
||||||
{ label: this.$i18n.get('label_creation_date'), value: 'date' },
|
{ label: this.$i18n.get('label_creation_date'), value: 'date' },
|
||||||
|
@ -402,7 +425,8 @@ export default {
|
||||||
status: this.status,
|
status: this.status,
|
||||||
contextEdit: true,
|
contextEdit: true,
|
||||||
order: this.order,
|
order: this.order,
|
||||||
orderby: this.orderBy
|
orderby: this.orderBy,
|
||||||
|
search: this.searchQuery
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
@ -421,9 +445,14 @@ export default {
|
||||||
this.$buefy.modal.open({
|
this.$buefy.modal.open({
|
||||||
parent: this,
|
parent: this,
|
||||||
component: AvailableImportersModal,
|
component: AvailableImportersModal,
|
||||||
hasModalCard: true
|
hasModalCard: true,
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
searchCollections() {
|
||||||
|
this.page = 1;
|
||||||
|
this.loadCollections();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.collectionsPerPage = this.$userPrefs.get('collections_per_page');
|
this.collectionsPerPage = this.$userPrefs.get('collections_per_page');
|
||||||
|
@ -469,18 +498,23 @@ export default {
|
||||||
@import '../../scss/_variables.scss';
|
@import '../../scss/_variables.scss';
|
||||||
|
|
||||||
.sub-header {
|
.sub-header {
|
||||||
min-height: $subheader-height;
|
min-height: $header-height;
|
||||||
height: $header-height;
|
height: auto;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.header-item {
|
.header-item {
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
&:not(:last-child) {
|
&:not(:last-child) {
|
||||||
padding-right: 0.5em;
|
padding-right: 0.5em;
|
||||||
}
|
}
|
||||||
|
@ -493,9 +527,13 @@ export default {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:not(:first-child) {
|
||||||
.button {
|
.button {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
height: 1.95rem !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.field {
|
.field {
|
||||||
|
@ -511,14 +549,23 @@ export default {
|
||||||
font-size: 1.3125rem !important;
|
font-size: 1.3125rem !important;
|
||||||
max-width: 26px;
|
max-width: 26px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
pointer-events: all;
|
||||||
|
cursor: pointer;
|
||||||
|
color: $blue5;
|
||||||
|
height: 27px;
|
||||||
|
font-size: 18px !important;
|
||||||
|
height: 1.75rem !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 769px) {
|
@media screen and (max-width: 769px) {
|
||||||
height: 60px;
|
height: 120px;
|
||||||
margin-top: -0.5em;
|
margin-top: -0.5em;
|
||||||
padding-top: 0.9em;
|
padding-top: 0.9em;
|
||||||
|
|
||||||
.header-item {
|
.header-item:not(:last-child) {
|
||||||
padding-right: 0.2em;
|
padding-right: 0.2em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,8 @@
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
id="item-creation-options-dropdown"
|
id="item-creation-options-dropdown"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-secondary"
|
class="button is-secondary"
|
||||||
slot="trigger">
|
slot="trigger">
|
||||||
|
@ -306,7 +307,8 @@
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
:disabled="totalItems <= 0 || adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry'"
|
:disabled="totalItems <= 0 || adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry'"
|
||||||
class="show metadata-options-dropdown"
|
class="show metadata-options-dropdown"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_displayed_metadata')"
|
:aria-label="$i18n.get('label_displayed_metadata')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -348,7 +350,8 @@
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
@input="onChangeOrder()"
|
@input="onChangeOrder()"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_sorting_direction')"
|
:aria-label="$i18n.get('label_sorting_direction')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -395,7 +398,8 @@
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
@input="onChangeOrderBy($event)"
|
@input="onChangeOrderBy($event)"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_sorting')"
|
:aria-label="$i18n.get('label_sorting')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -431,7 +435,8 @@
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
position="is-bottom-left"
|
position="is-bottom-left"
|
||||||
:aria-label="$i18n.get('label_view_mode')"
|
:aria-label="$i18n.get('label_view_mode')"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="registeredViewModes[viewMode] != undefined ? registeredViewModes[viewMode].label : $i18n.get('label_visualization')"
|
:aria-label="registeredViewModes[viewMode] != undefined ? registeredViewModes[viewMode].label : $i18n.get('label_visualization')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -472,7 +477,8 @@
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
position="is-bottom-left"
|
position="is-bottom-left"
|
||||||
:aria-label="$i18n.get('label_view_mode')"
|
:aria-label="$i18n.get('label_view_mode')"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_view_mode')"
|
:aria-label="$i18n.get('label_view_mode')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -699,9 +705,6 @@
|
||||||
<div
|
<div
|
||||||
v-if="(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].skeleton_template != undefined)"
|
v-if="(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].skeleton_template != undefined)"
|
||||||
v-html="registeredViewModes[viewMode].skeleton_template"/>
|
v-html="registeredViewModes[viewMode].skeleton_template"/>
|
||||||
|
|
||||||
<!-- Admin view modes skeleton -->
|
|
||||||
<!-- <skeleton-items-list v-if="!isOnTheme"/> -->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Alert if custom metada is being used for sorting -->
|
<!-- Alert if custom metada is being used for sorting -->
|
||||||
|
@ -788,13 +791,20 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
v-if="!isSortingByCustomMetadata && !hasFiltered && (status == undefined || status == '') && !$route.query.iframemode"
|
v-if="!isRepositoryLevel && !isSortingByCustomMetadata && !hasFiltered && (status == undefined || status == '') && !$route.query.iframemode"
|
||||||
id="button-create-item"
|
id="button-create-item"
|
||||||
tag="button"
|
tag="button"
|
||||||
class="button is-secondary"
|
class="button is-secondary"
|
||||||
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">
|
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">
|
||||||
{{ $i18n.getFrom('items', 'add_new') }}
|
{{ $i18n.getFrom('items', 'add_new') }}
|
||||||
</router-link>
|
</router-link>
|
||||||
|
<button
|
||||||
|
v-else-if="isRepositoryLevel && !isSortingByCustomMetadata && !hasFiltered && (status == undefined || status == '') && !$route.query.iframemode"
|
||||||
|
id="button-create-item"
|
||||||
|
class="button is-secondary"
|
||||||
|
@click="onOpenCollectionsModal">
|
||||||
|
{{ $i18n.get('add_one_item') }}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -811,12 +821,20 @@
|
||||||
role="region"
|
role="region"
|
||||||
aria-labelledby="filters-label-landmark-modal"
|
aria-labelledby="filters-label-landmark-modal"
|
||||||
id="filters-mobile-modal"
|
id="filters-mobile-modal"
|
||||||
ref="filters-mobile-modal"
|
|
||||||
class="tainacan-form is-hidden-tablet"
|
class="tainacan-form is-hidden-tablet"
|
||||||
:active.sync="isFilterModalActive"
|
:active.sync="isFilterModalActive"
|
||||||
:width="736"
|
:width="736"
|
||||||
animation="slide-menu">
|
animation="slide-menu"
|
||||||
<div class="modal-inner-content">
|
trap-focus
|
||||||
|
aria-modal
|
||||||
|
aria-role="dialog">
|
||||||
|
<div
|
||||||
|
ref="filters-mobile-modal"
|
||||||
|
class="modal-inner-content"
|
||||||
|
autofocus="true"
|
||||||
|
tabindex="-1"
|
||||||
|
aria-modal
|
||||||
|
role="dialog">
|
||||||
<h3
|
<h3
|
||||||
id="filters-label-landmark-modal"
|
id="filters-label-landmark-modal"
|
||||||
class="has-text-weight-semibold">
|
class="has-text-weight-semibold">
|
||||||
|
@ -881,7 +899,6 @@
|
||||||
import FiltersTagsList from '../../components/search/filters-tags-list.vue';
|
import FiltersTagsList from '../../components/search/filters-tags-list.vue';
|
||||||
import FiltersItemsList from '../../components/search/filters-items-list.vue';
|
import FiltersItemsList from '../../components/search/filters-items-list.vue';
|
||||||
import Pagination from '../../components/search/pagination.vue'
|
import Pagination from '../../components/search/pagination.vue'
|
||||||
import SkeletonItemsList from '../../components/search/skeleton-items-list.vue'
|
|
||||||
import AdvancedSearch from '../../components/advanced-search/advanced-search.vue';
|
import AdvancedSearch from '../../components/advanced-search/advanced-search.vue';
|
||||||
import AvailableImportersModal from '../../components/other/available-importers-modal.vue';
|
import AvailableImportersModal from '../../components/other/available-importers-modal.vue';
|
||||||
import ExposersModal from '../../components/other/exposers-modal.vue';
|
import ExposersModal from '../../components/other/exposers-modal.vue';
|
||||||
|
@ -1015,7 +1032,6 @@
|
||||||
ItemsList,
|
ItemsList,
|
||||||
FiltersTagsList,
|
FiltersTagsList,
|
||||||
FiltersItemsList,
|
FiltersItemsList,
|
||||||
SkeletonItemsList,
|
|
||||||
Pagination,
|
Pagination,
|
||||||
AdvancedSearch,
|
AdvancedSearch,
|
||||||
ExposersModal
|
ExposersModal
|
||||||
|
@ -1035,6 +1051,14 @@
|
||||||
orderByName() {
|
orderByName() {
|
||||||
if (this.isSortingByCustomMetadata)
|
if (this.isSortingByCustomMetadata)
|
||||||
this.hasAnOpenAlert = true;
|
this.hasAnOpenAlert = true;
|
||||||
|
},
|
||||||
|
isFilterModalActive() {
|
||||||
|
if (this.isFilterModalActive) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.$refs['filters-mobile-modal'])
|
||||||
|
this.$refs['filters-mobile-modal'].focus();
|
||||||
|
}, 800);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -1097,7 +1121,8 @@
|
||||||
props: {
|
props: {
|
||||||
targetCollection: this.collectionId,
|
targetCollection: this.collectionId,
|
||||||
hideWhenManualCollection: true
|
hideWhenManualCollection: true
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openExposersModal() {
|
openExposersModal() {
|
||||||
|
@ -1108,14 +1133,16 @@
|
||||||
props: {
|
props: {
|
||||||
collectionId: this.collectionId,
|
collectionId: this.collectionId,
|
||||||
totalItems: this.totalItems
|
totalItems: this.totalItems
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onOpenCollectionsModal() {
|
onOpenCollectionsModal() {
|
||||||
this.$buefy.modal.open({
|
this.$buefy.modal.open({
|
||||||
parent: this,
|
parent: this,
|
||||||
component: CollectionsModal,
|
component: CollectionsModal,
|
||||||
hasModalCard: true
|
hasModalCard: true,
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
updateSearch() {
|
updateSearch() {
|
||||||
|
@ -1489,7 +1516,8 @@
|
||||||
hideCancel: true,
|
hideCancel: true,
|
||||||
showNeverShowAgainOption: offerCheckbox && tainacan_plugin.user_caps != undefined && tainacan_plugin.user_caps.length != undefined && tainacan_plugin.user_caps.length > 0,
|
showNeverShowAgainOption: offerCheckbox && tainacan_plugin.user_caps != undefined && tainacan_plugin.user_caps.length != undefined && tainacan_plugin.user_caps.length > 0,
|
||||||
messageKeyForUserPrefs: 'ItemsHiddenDueSorting'
|
messageKeyForUserPrefs: 'ItemsHiddenDueSorting'
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
adjustSearchControlHeight: _.debounce( function() {
|
adjustSearchControlHeight: _.debounce( function() {
|
||||||
|
@ -1974,7 +2002,7 @@
|
||||||
|
|
||||||
.loading-container {
|
.loading-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 200px;
|
min-height: 50vh;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2034,10 +2062,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-container {
|
.table-container {
|
||||||
padding-left: 4.166666667%;
|
padding-left: $page-side-padding;
|
||||||
padding-right: 4.166666667%;
|
padding-right: $page-side-padding;
|
||||||
min-height: 50vh;
|
min-height: 50vh;
|
||||||
//height: calc(100% - 82px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-area {
|
.pagination-area {
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
:disabled="taxonomies.length <= 0 || isLoading"
|
:disabled="taxonomies.length <= 0 || isLoading"
|
||||||
@input="onChangeOrder(order == 'asc' ? 'desc' : 'asc')"
|
@input="onChangeOrder(order == 'asc' ? 'desc' : 'asc')"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_sorting_direction')"
|
:aria-label="$i18n.get('label_sorting_direction')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -83,6 +84,25 @@
|
||||||
</option>
|
</option>
|
||||||
</b-select>
|
</b-select>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
|
||||||
|
<!-- Textual Search -------------->
|
||||||
|
<b-field class="header-item">
|
||||||
|
<div class="control has-icons-right is-small is-clearfix">
|
||||||
|
<input
|
||||||
|
class="input is-small"
|
||||||
|
:placeholder="$i18n.get('instruction_search')"
|
||||||
|
type="search"
|
||||||
|
:aria-label="$i18n.get('instruction_search') + ' ' + $i18n.get('taxonomies')"
|
||||||
|
autocomplete="on"
|
||||||
|
v-model="searchQuery"
|
||||||
|
@keyup.enter="searchTaxonomies()">
|
||||||
|
<span
|
||||||
|
@click="searchTaxonomies()"
|
||||||
|
class="icon is-right">
|
||||||
|
<i class="tainacan-icon tainacan-icon-search" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</b-field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="above-subheader">
|
<div class="above-subheader">
|
||||||
|
@ -230,6 +250,7 @@
|
||||||
status: '',
|
status: '',
|
||||||
order: 'asc',
|
order: 'asc',
|
||||||
ordeBy: 'date',
|
ordeBy: 'date',
|
||||||
|
searchQuery: '',
|
||||||
sortingOptions: [
|
sortingOptions: [
|
||||||
{ label: this.$i18n.get('label_title'), value: 'title' },
|
{ label: this.$i18n.get('label_title'), value: 'title' },
|
||||||
{ label: this.$i18n.get('label_creation_date'), value: 'date' },
|
{ label: this.$i18n.get('label_creation_date'), value: 'date' },
|
||||||
|
@ -304,7 +325,8 @@
|
||||||
taxonomiesPerPage: this.taxonomiesPerPage,
|
taxonomiesPerPage: this.taxonomiesPerPage,
|
||||||
status: this.status,
|
status: this.status,
|
||||||
order: this.order,
|
order: this.order,
|
||||||
orderby: this.orderBy
|
orderby: this.orderBy,
|
||||||
|
search: this.searchQuery
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
@ -317,6 +339,10 @@
|
||||||
getLastTaxonomyNumber() {
|
getLastTaxonomyNumber() {
|
||||||
let last = (Number(this.taxonomiesPerPage * (this.page - 1)) + Number(this.taxonomiesPerPage));
|
let last = (Number(this.taxonomiesPerPage * (this.page - 1)) + Number(this.taxonomiesPerPage));
|
||||||
return last > this.total ? this.total : last;
|
return last > this.total ? this.total : last;
|
||||||
|
},
|
||||||
|
searchTaxonomies() {
|
||||||
|
this.page = 1;
|
||||||
|
this.load();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -370,10 +396,15 @@
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.header-item {
|
.header-item {
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
&:not(:last-child) {
|
&:not(:last-child) {
|
||||||
padding-right: 0.5em;
|
padding-right: 0.5em;
|
||||||
}
|
}
|
||||||
|
@ -386,9 +417,13 @@
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:not(:first-child) {
|
||||||
.button {
|
.button {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
height: 1.95rem !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.field {
|
.field {
|
||||||
|
@ -404,10 +439,19 @@
|
||||||
font-size: 1.3125rem !important;
|
font-size: 1.3125rem !important;
|
||||||
max-width: 26px;
|
max-width: 26px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
pointer-events: all;
|
||||||
|
cursor: pointer;
|
||||||
|
color: $blue5;
|
||||||
|
height: 27px;
|
||||||
|
font-size: 18px !important;
|
||||||
|
height: 1.75rem !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 769px) {
|
@media screen and (max-width: 769px) {
|
||||||
height: 60px;
|
height: 160px;
|
||||||
margin-top: -0.5em;
|
margin-top: -0.5em;
|
||||||
padding-top: 0.9em;
|
padding-top: 0.9em;
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,8 @@
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
id="item-creation-options-dropdown"
|
id="item-creation-options-dropdown"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-secondary"
|
class="button is-secondary"
|
||||||
slot="trigger">
|
slot="trigger">
|
||||||
|
@ -283,7 +284,8 @@
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
:disabled="totalItems <= 0 || adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry'"
|
:disabled="totalItems <= 0 || adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry'"
|
||||||
class="show metadata-options-dropdown"
|
class="show metadata-options-dropdown"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_displayed_metadata')"
|
:aria-label="$i18n.get('label_displayed_metadata')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -325,7 +327,8 @@
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
@input="onChangeOrder()"
|
@input="onChangeOrder()"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_sorting_direction')"
|
:aria-label="$i18n.get('label_sorting_direction')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -372,7 +375,8 @@
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
@input="onChangeOrderBy($event)"
|
@input="onChangeOrderBy($event)"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_sorting')"
|
:aria-label="$i18n.get('label_sorting')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -408,7 +412,8 @@
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
position="is-bottom-left"
|
position="is-bottom-left"
|
||||||
:aria-label="$i18n.get('label_view_mode')"
|
:aria-label="$i18n.get('label_view_mode')"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
:aria-label="registeredViewModes[viewMode] != undefined ? registeredViewModes[viewMode].label : $i18n.get('label_visualization')"
|
:aria-label="registeredViewModes[viewMode] != undefined ? registeredViewModes[viewMode].label : $i18n.get('label_visualization')"
|
||||||
|
@ -449,7 +454,8 @@
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
position="is-bottom-left"
|
position="is-bottom-left"
|
||||||
:aria-label="$i18n.get('label_view_mode')"
|
:aria-label="$i18n.get('label_view_mode')"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
:aria-label="$i18n.get('label_view_mode')"
|
:aria-label="$i18n.get('label_view_mode')"
|
||||||
|
@ -676,8 +682,6 @@
|
||||||
v-if="(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].skeleton_template != undefined)"
|
v-if="(registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].skeleton_template != undefined)"
|
||||||
v-html="registeredViewModes[viewMode].skeleton_template"/>
|
v-html="registeredViewModes[viewMode].skeleton_template"/>
|
||||||
|
|
||||||
<!-- Admin view modes skeleton -->
|
|
||||||
<!-- <skeleton-items-list v-if="!isOnTheme"/> -->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Alert if custom metada is being used for sorting -->
|
<!-- Alert if custom metada is being used for sorting -->
|
||||||
|
@ -791,8 +795,16 @@
|
||||||
class="tainacan-form is-hidden-tablet"
|
class="tainacan-form is-hidden-tablet"
|
||||||
:active.sync="isFilterModalActive"
|
:active.sync="isFilterModalActive"
|
||||||
:width="736"
|
:width="736"
|
||||||
animation="slide-menu">
|
animation="slide-menu"
|
||||||
<div class="modal-inner-content">
|
trap-focus
|
||||||
|
aria-modal
|
||||||
|
aria-role="dialog">
|
||||||
|
<div
|
||||||
|
autofocus="true"
|
||||||
|
tabindex="-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal
|
||||||
|
class="modal-inner-content">
|
||||||
<h3
|
<h3
|
||||||
id="filters-label-landmark-modal"
|
id="filters-label-landmark-modal"
|
||||||
class="has-text-weight-semibold">
|
class="has-text-weight-semibold">
|
||||||
|
@ -989,6 +1001,14 @@
|
||||||
orderByName() {
|
orderByName() {
|
||||||
if (this.isSortingByCustomMetadata)
|
if (this.isSortingByCustomMetadata)
|
||||||
this.hasAnOpenAlert = true;
|
this.hasAnOpenAlert = true;
|
||||||
|
},
|
||||||
|
isFilterModalActive() {
|
||||||
|
if (this.isFilterModalActive) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.$refs['filters-mobile-modal'])
|
||||||
|
this.$refs['filters-mobile-modal'].focus();
|
||||||
|
}, 800);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -1047,7 +1067,8 @@
|
||||||
props: {
|
props: {
|
||||||
targetCollection: this.collectionId,
|
targetCollection: this.collectionId,
|
||||||
hideWhenManualCollection: true
|
hideWhenManualCollection: true
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openExposersModal() {
|
openExposersModal() {
|
||||||
|
@ -1058,15 +1079,16 @@
|
||||||
props: {
|
props: {
|
||||||
collectionId: this.collectionId,
|
collectionId: this.collectionId,
|
||||||
totalItems: this.totalItems
|
totalItems: this.totalItems
|
||||||
}
|
},
|
||||||
})
|
trapFocus: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
updateSearch() {
|
updateSearch() {
|
||||||
this.$eventBusSearch.setSearchQuery(this.futureSearchQuery);
|
this.$eventBusSearch.setSearchQuery(this.futureSearchQuery);
|
||||||
},
|
},
|
||||||
onChangeOrderBy(metadatum) {
|
onChangeOrderBy(metadatum) {
|
||||||
this.$eventBusSearch.setOrderBy(metadatum);
|
this.$eventBusSearch.setOrderBy(metadatum);
|
||||||
this.showItemsHiddingDueSorting();
|
this.showItemsHiddingDueSortingDialog();
|
||||||
},
|
},
|
||||||
onChangeOrder() {
|
onChangeOrder() {
|
||||||
this.order == 'DESC' ? this.$eventBusSearch.setOrder('ASC') : this.$eventBusSearch.setOrder('DESC');
|
this.order == 'DESC' ? this.$eventBusSearch.setOrder('ASC') : this.$eventBusSearch.setOrder('DESC');
|
||||||
|
@ -1419,7 +1441,8 @@
|
||||||
hideCancel: true,
|
hideCancel: true,
|
||||||
showNeverShowAgainOption: offerCheckbox && tainacan_plugin.user_caps != undefined && tainacan_plugin.user_caps.length != undefined && tainacan_plugin.user_caps.length > 0,
|
showNeverShowAgainOption: offerCheckbox && tainacan_plugin.user_caps != undefined && tainacan_plugin.user_caps.length != undefined && tainacan_plugin.user_caps.length > 0,
|
||||||
messageKeyForUserPrefs: 'ItemsHiddenDueSorting'
|
messageKeyForUserPrefs: 'ItemsHiddenDueSorting'
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
adjustSearchControlHeight: _.debounce( function() {
|
adjustSearchControlHeight: _.debounce( function() {
|
||||||
|
@ -1535,7 +1558,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showItemsHiddingDueSorting();
|
this.showItemsHiddingDueSortingDialog();
|
||||||
|
|
||||||
// Watches window resize to adjust filter's top position and compression on mobile
|
// Watches window resize to adjust filter's top position and compression on mobile
|
||||||
this.adjustSearchControlHeight();
|
this.adjustSearchControlHeight();
|
||||||
|
@ -1895,7 +1918,7 @@
|
||||||
|
|
||||||
.loading-container {
|
.loading-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 200px;
|
min-height: 50vh;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1915,8 +1938,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-container {
|
.table-container {
|
||||||
padding-left: 4.166666667%;
|
padding-left: $page-side-padding;
|
||||||
padding-right: 4.166666667%;
|
padding-right: $page-side-padding;
|
||||||
min-height: 50vh;
|
min-height: 50vh;
|
||||||
//height: calc(100% - 82px);
|
//height: calc(100% - 82px);
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,8 +384,9 @@
|
||||||
itemId: this.itemId,
|
itemId: this.itemId,
|
||||||
itemURL: this.item.url,
|
itemURL: this.item.url,
|
||||||
totalItems: 1,
|
totalItems: 1,
|
||||||
}
|
},
|
||||||
})
|
trapFocus: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&.is-mobile-modal {
|
&.is-mobile-modal {
|
||||||
@media screen and (max-width: 1088px) {
|
@media screen and (max-width: 768px) {
|
||||||
.dropdown-content {
|
.dropdown-content {
|
||||||
max-height: 100vh;
|
max-height: 100vh;
|
||||||
}
|
}
|
||||||
|
@ -183,3 +183,166 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.datepicker {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.datepicker-content {
|
||||||
|
height: auto;
|
||||||
|
|
||||||
|
input {
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
.dropdown-item {
|
||||||
|
background-color: white !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.datepicker-header {
|
||||||
|
.pagination {
|
||||||
|
a>span>i:before {
|
||||||
|
display: inline-block;
|
||||||
|
font: normal normal normal 20px/1 "TainacanIcons";
|
||||||
|
font-size: inherit;
|
||||||
|
text-rendering: auto;
|
||||||
|
vertical-align: middle;
|
||||||
|
line-height: inherit;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
color: $secondary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-previous {
|
||||||
|
border: none;
|
||||||
|
flex-grow: 0;
|
||||||
|
|
||||||
|
&>span>i:before {
|
||||||
|
content: 'previous';
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-next {
|
||||||
|
border: none;
|
||||||
|
flex-grow: 0;
|
||||||
|
|
||||||
|
&>span>i:before {
|
||||||
|
content: 'next';
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.datepicker-table {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
|
||||||
|
.datepicker-cell {
|
||||||
|
border: none !important;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
|
||||||
|
&.is-selectable.is-first-hovered,
|
||||||
|
&.is-selectable.is-last-hovered {
|
||||||
|
color: $gray4 !important;
|
||||||
|
background-color: $gray3 !important;
|
||||||
|
}
|
||||||
|
&.is-today,
|
||||||
|
&.is-today:hover {
|
||||||
|
color: $gray4 !important;
|
||||||
|
background-color: $turquoise1;
|
||||||
|
}
|
||||||
|
&.is-selected,
|
||||||
|
&.is-selected:hover {
|
||||||
|
color: white !important;
|
||||||
|
background-color: $turquoise5 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.datepicker-months {
|
||||||
|
width: auto;
|
||||||
|
|
||||||
|
.datepicker-cell {
|
||||||
|
height: 2rem;
|
||||||
|
width: 50%;
|
||||||
|
padding: 0.3rem 0.25rem !important;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 768px) {
|
||||||
|
|
||||||
|
.datepicker-header {
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
padding-top: 0.15rem;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
.pagination-list {
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
|
||||||
|
.field.has-addons {
|
||||||
|
width: 100% !important;
|
||||||
|
|
||||||
|
.control {
|
||||||
|
height: 24px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-previous {
|
||||||
|
margin: 0;
|
||||||
|
height: 24px;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
order: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-next {
|
||||||
|
margin: 0;
|
||||||
|
height: 24px;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item {
|
||||||
|
padding: 0.8rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu {
|
||||||
|
min-width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.datepicker-table {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select {
|
||||||
|
select {
|
||||||
|
display: unset;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-content {
|
||||||
|
border-radius: 2px !important;
|
||||||
|
padding: 0px;
|
||||||
|
max-height: inherit !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,7 +22,7 @@
|
||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
text-decoration: none !important;
|
text-decoration: none !important;
|
||||||
}
|
}
|
||||||
&[disabled] {
|
&[disabled=disabled] {
|
||||||
background-color: white !important;
|
background-color: white !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,8 +132,14 @@
|
||||||
&:focus>option:checked, &:focus>option:hover {
|
&:focus>option:checked, &:focus>option:hover {
|
||||||
background-color: $turquoise1 !important;
|
background-color: $turquoise1 !important;
|
||||||
}
|
}
|
||||||
|
&[disabled=disabled] {
|
||||||
|
border: 1px solid $gray1 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
.hidden-select-arrow .select::after {
|
||||||
|
color: transparent !important;
|
||||||
|
}
|
||||||
.dropdown {
|
.dropdown {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
.dropdown-trigger { width: 100% }
|
.dropdown-trigger { width: 100% }
|
||||||
|
@ -177,13 +183,13 @@
|
||||||
|
|
||||||
h4 {
|
h4 {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #298596;
|
color: $turquoise5;
|
||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
}
|
}
|
||||||
hr {
|
hr {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
background-color: #298596;
|
background-color: $turquoise5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -111,8 +111,9 @@ $addColors: (
|
||||||
);
|
);
|
||||||
$colors: map-merge($colors, $addColors);
|
$colors: map-merge($colors, $addColors);
|
||||||
|
|
||||||
// Small size
|
// Bulma Variables
|
||||||
$size-small: 0.85em; // 0.75em on Bulma.
|
$size-small: 0.85em; // 0.75em on Bulma.
|
||||||
|
$dropdown-mobile-breakpoint: $tablet;
|
||||||
|
|
||||||
// Tainacan Header and side menus
|
// Tainacan Header and side menus
|
||||||
$header-height: 52px;
|
$header-height: 52px;
|
||||||
|
|
|
@ -78,12 +78,14 @@ body.tainacan-admin-page #adminmenumain, body.tainacan-admin-page #wpfooter, bod
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
animation: none;
|
animation: none;
|
||||||
height: 50px;
|
height: 46px;
|
||||||
width: 50px;
|
width: 46px;
|
||||||
|
background-size: initial;
|
||||||
}
|
}
|
||||||
.loading-overlay.is-full-page .loading-icon::after {
|
.loading-overlay.is-full-page .loading-icon::after {
|
||||||
height: 50px;
|
height: 46px;
|
||||||
width: 50px;
|
width: 46px;
|
||||||
|
background-size: initial;
|
||||||
top: calc(50% - 25px);
|
top: calc(50% - 25px);
|
||||||
left: calc(50% - 25px);
|
left: calc(50% - 25px);
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,9 @@ return apply_filters( 'tainacan-admin-i18n', [
|
||||||
'title_exporter_page' => __( 'Exporter', 'tainacan'),
|
'title_exporter_page' => __( 'Exporter', 'tainacan'),
|
||||||
|
|
||||||
// Labels (used mainly on Aria Labels and Inputs)
|
// Labels (used mainly on Aria Labels and Inputs)
|
||||||
|
'label' => __( 'Label', 'tainacan' ),
|
||||||
'label_clean' => __( 'Clear', 'tainacan' ),
|
'label_clean' => __( 'Clear', 'tainacan' ),
|
||||||
|
'label_none' => __( 'None', 'tainacan' ),
|
||||||
'label_clear_filters' => __( 'Clear filters', 'tainacan' ),
|
'label_clear_filters' => __( 'Clear filters', 'tainacan' ),
|
||||||
'label_and' => __( 'and', 'tainacan' ),
|
'label_and' => __( 'and', 'tainacan' ),
|
||||||
'label_selected' => __( 'Selected', 'tainacan' ),
|
'label_selected' => __( 'Selected', 'tainacan' ),
|
||||||
|
@ -434,6 +436,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
||||||
'label_day' => __( 'Day', 'tainacan' ),
|
'label_day' => __( 'Day', 'tainacan' ),
|
||||||
'label_month' => __( 'Month', 'tainacan' ),
|
'label_month' => __( 'Month', 'tainacan' ),
|
||||||
'label_year' => __( 'Year', 'tainacan' ),
|
'label_year' => __( 'Year', 'tainacan' ),
|
||||||
|
'label_related_to' => __( 'Related to', 'tainacan' ),
|
||||||
|
|
||||||
// Instructions. More complex sentences to guide user and placeholders
|
// Instructions. More complex sentences to guide user and placeholders
|
||||||
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||||
|
@ -478,10 +481,13 @@ return apply_filters( 'tainacan-admin-i18n', [
|
||||||
'instruction_click_or_drag_metadatum_create' => __( 'Click or drag and drop to create a new metadatum', 'tainacan' ),
|
'instruction_click_or_drag_metadatum_create' => __( 'Click or drag and drop to create a new metadatum', 'tainacan' ),
|
||||||
'instruction_drag_and_drop_filter_sort' => __( 'Drag and drop to change filter order', 'tainacan' ),
|
'instruction_drag_and_drop_filter_sort' => __( 'Drag and drop to change filter order', 'tainacan' ),
|
||||||
'instruction_drag_and_drop_metadatum_sort' => __( 'Drag and drop to change metadatum order', 'tainacan' ),
|
'instruction_drag_and_drop_metadatum_sort' => __( 'Drag and drop to change metadatum order', 'tainacan' ),
|
||||||
|
'instruction_filter_activities_date' => __( 'Range of dates', 'tainacan'),
|
||||||
'instruction_select_a_date' => __( 'Select a date', 'tainacan' ),
|
'instruction_select_a_date' => __( 'Select a date', 'tainacan' ),
|
||||||
'instruction_select_a_month' => __( 'Select a month', 'tainacan' ),
|
'instruction_select_a_month' => __( 'Select a month', 'tainacan' ),
|
||||||
'instruction_type_value_year' => __( 'Type year value', 'tainacan' ),
|
'instruction_type_value_year' => __( 'Type year value', 'tainacan' ),
|
||||||
'instruction_select_the_amount_of_copies' => __( 'Select the amount of copies of the item that you want to create', 'tainacan'),
|
'instruction_select_the_amount_of_copies' => __( 'Select the amount of copies of the item that you want to create', 'tainacan'),
|
||||||
|
'instruction_select_a_interval' => __( 'Select an interval', 'tainacan'),
|
||||||
|
|
||||||
|
|
||||||
// Info. Other feedback to user.
|
// Info. Other feedback to user.
|
||||||
'info_items_tab_all' => __( 'Every published item, including those visible only to editors.', 'tainacan' ),
|
'info_items_tab_all' => __( 'Every published item, including those visible only to editors.', 'tainacan' ),
|
||||||
|
@ -527,7 +533,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
||||||
'info_no_terms_created_on_taxonomy' => __( 'No term was created for this taxonomy.', 'tainacan' ),
|
'info_no_terms_created_on_taxonomy' => __( 'No term was created for this taxonomy.', 'tainacan' ),
|
||||||
'info_no_terms_found' => __( 'No term was found here', 'tainacan' ),
|
'info_no_terms_found' => __( 'No term was found here', 'tainacan' ),
|
||||||
'info_no_more_terms_found' => __( 'No more terms found', 'tainacan' ),
|
'info_no_more_terms_found' => __( 'No more terms found', 'tainacan' ),
|
||||||
'info_no_item_created' => __( 'No item was created in this collection.', 'tainacan' ),
|
'info_no_item_created' => __( 'No item was created so far.', 'tainacan' ),
|
||||||
'info_no_page_found' => __( 'No page was found with this name.', 'tainacan' ),
|
'info_no_page_found' => __( 'No page was found with this name.', 'tainacan' ),
|
||||||
'info_no_user_found' => __( 'No user was found with this name.', 'tainacan' ),
|
'info_no_user_found' => __( 'No user was found with this name.', 'tainacan' ),
|
||||||
'info_no_item_found_filter' => __( 'No item was found here with these filters.', 'tainacan' ),
|
'info_no_item_found_filter' => __( 'No item was found here with these filters.', 'tainacan' ),
|
||||||
|
@ -577,7 +583,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
||||||
'info_warning_taxonomy_not_saved' => __( 'Are you sure? The taxonomy is not saved, changes will be lost.', 'tainacan' ),
|
'info_warning_taxonomy_not_saved' => __( 'Are you sure? The taxonomy is not saved, changes will be lost.', 'tainacan' ),
|
||||||
'info_warning_terms_not_saved' => __( 'Are you sure? There are terms not saved, changes will be lost.', 'tainacan' ),
|
'info_warning_terms_not_saved' => __( 'Are you sure? There are terms not saved, changes will be lost.', 'tainacan' ),
|
||||||
'info_warning_orphan_terms' => __( 'Are you sure? This term is parent of other terms. These will be converted to root terms.', 'tainacan' ),
|
'info_warning_orphan_terms' => __( 'Are you sure? This term is parent of other terms. These will be converted to root terms.', 'tainacan' ),
|
||||||
'info_no_activities' => __( 'No activities', 'tainacan' ),
|
'info_no_activities' => __( 'No activities yet.', 'tainacan' ),
|
||||||
'info_logs_before' => __( 'Before', 'tainacan' ),
|
'info_logs_before' => __( 'Before', 'tainacan' ),
|
||||||
'info_logs_after' => __( 'After', 'tainacan' ),
|
'info_logs_after' => __( 'After', 'tainacan' ),
|
||||||
'info_there_is_no_metadatum' => __( 'There is no metadata here yet.', 'tainacan' ),
|
'info_there_is_no_metadatum' => __( 'There is no metadata here yet.', 'tainacan' ),
|
||||||
|
@ -605,11 +611,11 @@ return apply_filters( 'tainacan-admin-i18n', [
|
||||||
'info_updated_at' => __( 'Updated at', 'tainacan' ),
|
'info_updated_at' => __( 'Updated at', 'tainacan' ),
|
||||||
'info_editing_metadata_values' => __( 'Editing metadata values...', 'tainacan' ),
|
'info_editing_metadata_values' => __( 'Editing metadata values...', 'tainacan' ),
|
||||||
'info_updating_metadata_values' => __( 'Updating metadata values...', 'tainacan' ),
|
'info_updating_metadata_values' => __( 'Updating metadata values...', 'tainacan' ),
|
||||||
'info_type_to_add_items' => __( 'Add items...', 'tainacan' ),
|
'info_type_to_add_items' => __( 'Add items to filter...', 'tainacan' ),
|
||||||
'info_type_to_search_items' => __( 'Search items...', 'tainacan' ),
|
'info_type_to_search_items' => __( 'Search items...', 'tainacan' ),
|
||||||
'info_type_to_add_terms' => __( 'Add terms...', 'tainacan' ),
|
'info_type_to_add_terms' => __( 'Add terms to filter...', 'tainacan' ),
|
||||||
'info_type_to_search_metadata' => __( 'Search metadata...', 'tainacan' ),
|
'info_type_to_search_metadata' => __( 'Search metadata...', 'tainacan' ),
|
||||||
'info_type_to_add_metadata' => __( 'Add metadata...', 'tainacan' ),
|
'info_type_to_add_metadata' => __( 'Add metadata to filter...', 'tainacan' ),
|
||||||
'info_visibility_helper' => __( 'How the item will be available to visualization.', 'tainacan' ),
|
'info_visibility_helper' => __( 'How the item will be available to visualization.', 'tainacan' ),
|
||||||
'info_errors_in_form' => __( 'There are errors in the form', 'tainacan' ),
|
'info_errors_in_form' => __( 'There are errors in the form', 'tainacan' ),
|
||||||
'info_no_document_to_item' => __( 'No document was uploaded to this item.', 'tainacan' ),
|
'info_no_document_to_item' => __( 'No document was uploaded to this item.', 'tainacan' ),
|
||||||
|
@ -657,28 +663,9 @@ return apply_filters( 'tainacan-admin-i18n', [
|
||||||
'info_await_while_item_copy' => __( 'Please wait while copy is being created...', 'tainacan'),
|
'info_await_while_item_copy' => __( 'Please wait while copy is being created...', 'tainacan'),
|
||||||
'info_await_while_item_copies' => __( 'Please wait while copies are being created. This may take a while...', 'tainacan'),
|
'info_await_while_item_copies' => __( 'Please wait while copies are being created. This may take a while...', 'tainacan'),
|
||||||
'info_expose_only_displayed_metadata' => __( 'By checking this option, only metatada that are displayed on the current list will be exposed', 'tainacan' ),
|
'info_expose_only_displayed_metadata' => __( 'By checking this option, only metatada that are displayed on the current list will be exposed', 'tainacan' ),
|
||||||
|
'info_initial_value' => __( 'Initial value', 'tainacan' ),
|
||||||
// Tainacan Metadatum Types
|
'info_final_value' => __( 'Final value', 'tainacan' ),
|
||||||
'tainacan-text' => __( 'Text', 'tainacan' ),
|
'info_show_interval_on_tag' => __( 'Show applied interval on tags', 'tainacan' ),
|
||||||
'tainacan-textarea' => __( 'Text area', 'tainacan' ),
|
|
||||||
'tainacan-date' => __( 'Date', 'tainacan' ),
|
|
||||||
'tainacan-numeric' => __( 'Numeric', 'tainacan' ),
|
|
||||||
'tainacan-selectbox' => __( 'Select box', 'tainacan' ),
|
|
||||||
'tainacan-relationship' => __( 'Relationship', 'tainacan' ),
|
|
||||||
'tainacan-taxonomy' => __( 'Taxonomy', 'tainacan' ),
|
|
||||||
'tainacan-compound' => __( 'Compound', 'tainacan' ),
|
|
||||||
|
|
||||||
// Tainacan Filter Types
|
|
||||||
'tainacan-filter-custom-interval' => __( 'Custom Interval', 'tainacan' ),
|
|
||||||
'tainacan-filter-numeric' => __( 'Numeric', 'tainacan' ),
|
|
||||||
'tainacan-filter-date' => __( 'Date', 'tainacan' ),
|
|
||||||
'tainacan-filter-selectbox' => __( 'Select Box', 'tainacan' ),
|
|
||||||
'tainacan-filter-autocomplete' => __( 'Autocomplete', 'tainacan' ),
|
|
||||||
'tainacan-filter-taginput' => __( 'Tag Input', 'tainacan' ),
|
|
||||||
'tainacan-filter-checkbox' => __( 'Check Box', 'tainacan' ),
|
|
||||||
'tainacan-filter-taxonomy-taginput' => __( 'Taxonomy Tag Input', 'tainacan' ),
|
|
||||||
'tainacan-filter-taxonomy-checkbox' => __( 'Taxonomy Check Box', 'tainacan' ),
|
|
||||||
'tainacan-filter-taxonomy-selectbox' => __( 'Taxonomy Select Box', 'tainacan' ),
|
|
||||||
|
|
||||||
// Datepicker months
|
// Datepicker months
|
||||||
'datepicker_month_january' => __( 'January', 'tainacan' ),
|
'datepicker_month_january' => __( 'January', 'tainacan' ),
|
||||||
|
|
|
@ -153,7 +153,37 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.metadata-alert {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin: 6px $page-side-padding;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 4px 12px;
|
||||||
|
color: $yellow2;
|
||||||
|
background: $yellow1;
|
||||||
|
animation-name: appear;
|
||||||
|
animation-duration: 0.5s;
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
&>div {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.button,
|
||||||
|
.button:hover,
|
||||||
|
.button:active,
|
||||||
|
.button:focus {
|
||||||
|
background: none;
|
||||||
|
color:$yellow2;
|
||||||
|
font-weight: bold;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.search-control {
|
.search-control {
|
||||||
justify-content: flex-start !important;
|
justify-content: flex-start !important;
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
'name' => 'title',
|
'name' => 'title',
|
||||||
'title' => 'title',
|
'title' => 'title',
|
||||||
'id' => 'p',
|
'id' => 'p',
|
||||||
'authorid' => 'author_id',
|
'authorid' => 'author',
|
||||||
'authorname' => 'author_name',
|
'authorname' => 'author_name',
|
||||||
'search' => 's',
|
'search' => 's',
|
||||||
'searchterm' => 'search',
|
'searchterm' => 'search',
|
||||||
|
@ -92,7 +92,8 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
'metatype' => 'meta_type',
|
'metatype' => 'meta_type',
|
||||||
'hierarchical' => 'hierarchical',
|
'hierarchical' => 'hierarchical',
|
||||||
'exclude' => 'exclude',
|
'exclude' => 'exclude',
|
||||||
'excludetree' => 'exclude_tree'
|
'excludetree' => 'exclude_tree',
|
||||||
|
'include' => 'include'
|
||||||
];
|
];
|
||||||
|
|
||||||
$meta_query = [
|
$meta_query = [
|
||||||
|
@ -164,6 +165,7 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
$terms = get_terms([
|
$terms = get_terms([
|
||||||
'taxonomy' => $tax_query['taxonomy'],
|
'taxonomy' => $tax_query['taxonomy'],
|
||||||
'fields' => 'ids',
|
'fields' => 'ids',
|
||||||
|
'hide_empty' => isset($args['hide_empty']) ? $args['hide_empty'] : true,
|
||||||
'search' => $tax_query['terms']
|
'search' => $tax_query['terms']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
$terms = get_terms([
|
$terms = get_terms([
|
||||||
'taxonomy' => $tax_query['taxonomy'],
|
'taxonomy' => $tax_query['taxonomy'],
|
||||||
'fields' => 'ids',
|
'fields' => 'ids',
|
||||||
|
'hide_empty' => isset($args['hide_empty']) ? $args['hide_empty'] : true,
|
||||||
'search' => $tax_query['terms']
|
'search' => $tax_query['terms']
|
||||||
]);
|
]);
|
||||||
if ($terms) {
|
if ($terms) {
|
||||||
|
@ -260,6 +263,23 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the fetch_only param
|
||||||
|
*
|
||||||
|
* @param string $object_name
|
||||||
|
*
|
||||||
|
* @return array|void
|
||||||
|
*/
|
||||||
|
public function get_fetch_only_param(){
|
||||||
|
return [
|
||||||
|
'fetch_only' => array(
|
||||||
|
'type' => 'string/array',
|
||||||
|
'description' => __( 'Fetch only specific attribute. The specifics attributes are the same in schema.', 'tainacan' ),
|
||||||
|
//TODO: explicar o fetch only meta.. cabe aqui?
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the common params
|
* Return the common params
|
||||||
*
|
*
|
||||||
|
@ -267,21 +287,32 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
*
|
*
|
||||||
* @return array|void
|
* @return array|void
|
||||||
*/
|
*/
|
||||||
public function get_collection_params($object_name = null){
|
public function get_wp_query_params(){
|
||||||
|
|
||||||
$query_params['id'] = array(
|
$query_params['id'] = array(
|
||||||
'description' => __("Limit result to $object_name with specific id."),
|
'description' => __("Limit result to objects with specific id.", 'tainacan'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$query_params['context'] = array(
|
||||||
|
'type' => 'string',
|
||||||
|
'default' => 'view',
|
||||||
|
'description' => 'The context in which the request is made.',
|
||||||
|
'enum' => array(
|
||||||
|
'view',
|
||||||
|
'edit'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
$query_params['search'] = array(
|
$query_params['search'] = array(
|
||||||
'description' => __( 'Limit results to those matching a string.' ),
|
'description' => __( 'Limit results to those matching a string.', 'tainacan' ),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'sanitize_callback' => 'sanitize_text_field',
|
'sanitize_callback' => 'sanitize_text_field',
|
||||||
'validate_callback' => 'rest_validate_request_arg',
|
'validate_callback' => 'rest_validate_request_arg',
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params['authorid'] = array(
|
$query_params['authorid'] = array(
|
||||||
'description' => __("Limit result set to $object_name assigned to specific authors by id."),
|
'description' => __("Limit result set to objects assigned to specific authors by id.", 'tainacan'),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'items' => array(
|
'items' => array(
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
|
@ -289,12 +320,12 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params['authorname'] = array(
|
$query_params['authorname'] = array(
|
||||||
'description' => __("Limit result set to $object_name assigned to specific authors by name"),
|
'description' => __("Limit result set to objects assigned to specific authors by name", 'tainacan'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params['status'] = array(
|
$query_params['status'] = array(
|
||||||
'description' => __("Limit result set to $object_name assigned one or more statuses."),
|
'description' => __("Limit result set to objects assigned one or more statuses.", 'tainacan'),
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'items' => array(
|
'items' => array(
|
||||||
'enum' => array_merge(array_keys(get_post_stati()), array('any')),
|
'enum' => array_merge(array_keys(get_post_stati()), array('any')),
|
||||||
|
@ -303,19 +334,19 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params['offset'] = array(
|
$query_params['offset'] = array(
|
||||||
'description' => __( "Offset the result set by a specific number of $object_name." ),
|
'description' => __( "Offset the result set by a specific number of objects.", 'tainacan' ),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params['order'] = array(
|
$query_params['order'] = array(
|
||||||
'description' => __( 'Order sort attribute ascending or descending.' ),
|
'description' => __( 'Order sort attribute ascending or descending.', 'tainacan' ),
|
||||||
'type' => 'string/array',
|
'type' => 'string/array',
|
||||||
'default' => 'desc',
|
'default' => 'desc',
|
||||||
'enum' => array( 'asc', 'desc' ),
|
'enum' => array( 'asc', 'desc', 'ASC', 'DESC' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params['orderby'] = array(
|
$query_params['orderby'] = array(
|
||||||
'description' => __( "Sort $object_name by object attribute." ),
|
'description' => __( "Sort objects by object attribute.", 'tainacan' ),
|
||||||
'type' => 'string/array',
|
'type' => 'string/array',
|
||||||
'default' => 'date',
|
'default' => 'date',
|
||||||
'enum' => array(
|
'enum' => array(
|
||||||
|
@ -335,13 +366,13 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params['perpage'] = array(
|
$query_params['perpage'] = array(
|
||||||
'description' => __( "Maximum number of $object_name to be returned in result set." ),
|
'description' => __( "Maximum number of objects to be returned in result set.", 'tainacan' ),
|
||||||
'type' => 'numeric',
|
'type' => 'numeric',
|
||||||
'default' => 10,
|
'default' => 10,
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params['paged'] = array(
|
$query_params['paged'] = array(
|
||||||
'description' => __("Show the $object_name that would normally show up just on page X"),
|
'description' => __("The results page to be return.", 'tainacan'),
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -369,8 +400,26 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
),
|
),
|
||||||
'metacompare' => array(
|
'metacompare' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __('Operator to test the meta_value. Possible values are =, !=, >, >=, <, <=, LIKE, NOT LIKE, IN, NOT IN, BETWEEN, NOT BETWEEN, NOT EXISTS, REGEXP, NOT REGEXP or RLIKE.'),
|
'description' => __('Operator to test the metavalue'),
|
||||||
'default' => '=',
|
'default' => '=',
|
||||||
|
'enum' => array(
|
||||||
|
'=',
|
||||||
|
'!=',
|
||||||
|
'>',
|
||||||
|
'>=',
|
||||||
|
'<',
|
||||||
|
'<=',
|
||||||
|
'LIKE',
|
||||||
|
'NOT LIKE',
|
||||||
|
'IN',
|
||||||
|
'NOT IN',
|
||||||
|
'BETWEEN',
|
||||||
|
'NOT BETWEEN',
|
||||||
|
'NOT EXISTS',
|
||||||
|
'REGEXP',
|
||||||
|
'NOT REGEXP',
|
||||||
|
'RLIKE'
|
||||||
|
)
|
||||||
),
|
),
|
||||||
'metaquery' => array(
|
'metaquery' => array(
|
||||||
'description' => __('Limits result set to items that have specific custom metadata'),
|
'description' => __('Limits result set to items that have specific custom metadata'),
|
||||||
|
@ -388,8 +437,24 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
),
|
),
|
||||||
'compare' => array(
|
'compare' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __('Operator to test. Possible values are =, !=, >, >=, <, <=, LIKE, NOT LIKE, IN, NOT IN, BETWEEN, NOT BETWEEN, EXISTS and NOT EXISTS.'),
|
'description' => __('Operator to test.'),
|
||||||
'default' => '='
|
'default' => '=',
|
||||||
|
'enum' => array(
|
||||||
|
'=',
|
||||||
|
'!=',
|
||||||
|
'>',
|
||||||
|
'>=',
|
||||||
|
'<',
|
||||||
|
'<=',
|
||||||
|
'LIKE',
|
||||||
|
'NOT LIKE',
|
||||||
|
'IN',
|
||||||
|
'NOT IN',
|
||||||
|
'BETWEEN',
|
||||||
|
'NOT BETWEEN',
|
||||||
|
'EXISTS',
|
||||||
|
'NOT EXISTS'
|
||||||
|
)
|
||||||
),
|
),
|
||||||
'relation' => array(
|
'relation' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
|
@ -439,8 +504,24 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
),
|
),
|
||||||
'compare' => array(
|
'compare' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __('Operator to test. Possible values are =, !=, >, >=, <, <=, LIKE, NOT LIKE, IN, NOT IN, BETWEEN, NOT BETWEEN, EXISTS and NOT EXISTS.'),
|
'description' => __('Operator to test.'),
|
||||||
'default' => '='
|
'default' => '=',
|
||||||
|
'enum' => array(
|
||||||
|
'=',
|
||||||
|
'!=',
|
||||||
|
'>',
|
||||||
|
'>=',
|
||||||
|
'<',
|
||||||
|
'<=',
|
||||||
|
'LIKE',
|
||||||
|
'NOT LIKE',
|
||||||
|
'IN',
|
||||||
|
'NOT IN',
|
||||||
|
'BETWEEN',
|
||||||
|
'NOT BETWEEN',
|
||||||
|
'EXISTS',
|
||||||
|
'NOT EXISTS'
|
||||||
|
)
|
||||||
),
|
),
|
||||||
'dayofweek' => array('type' => 'array'),
|
'dayofweek' => array('type' => 'array'),
|
||||||
'inclusive' => array(
|
'inclusive' => array(
|
||||||
|
@ -470,7 +551,14 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
),
|
),
|
||||||
'metadatum' => array(
|
'metadatum' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __('Select taxonomy term by. Possible values are term_id, name, slug or term_taxonomy_id. Default value is term_id.')
|
'default' => 'term_id',
|
||||||
|
'description' => __('Select taxonomy term by'),
|
||||||
|
'enum' => array(
|
||||||
|
'term_id',
|
||||||
|
'name',
|
||||||
|
'slug',
|
||||||
|
'term_taxonomy_id'
|
||||||
|
)
|
||||||
),
|
),
|
||||||
'terms' => array(
|
'terms' => array(
|
||||||
'type' => 'int/string/array',
|
'type' => 'int/string/array',
|
||||||
|
@ -478,13 +566,24 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
),
|
),
|
||||||
'operator' => array(
|
'operator' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __('Operator to test. Possible values are IN, NOT IN, AND, EXISTS and NOT EXISTS'),
|
'description' => __('Operator to test.'),
|
||||||
'default' => 'IN'
|
'default' => 'IN',
|
||||||
|
'enum' => array(
|
||||||
|
'IN',
|
||||||
|
'NOT IN',
|
||||||
|
'AND',
|
||||||
|
'EXISTS',
|
||||||
|
'NOT EXISTS'
|
||||||
|
)
|
||||||
),
|
),
|
||||||
'relation' => array(
|
'relation' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __('The logical relationship between each inner taxonomy array when there is more than one. Possible values are AND, OR. Do not use with a single inner taxonomy array.'),
|
'description' => __('The logical relationship between each inner taxonomy array when there is more than one. Do not use with a single inner taxonomy array.'),
|
||||||
'default' => 'AND'
|
'default' => 'AND',
|
||||||
|
'enum' => array(
|
||||||
|
'AND',
|
||||||
|
'OR'
|
||||||
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'type' => 'array'
|
'type' => 'array'
|
||||||
|
@ -492,6 +591,54 @@ class REST_Controller extends \WP_REST_Controller {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_repository_schema( \Tainacan\Repositories\Repository $repository ) {
|
||||||
|
|
||||||
|
$schema = [];
|
||||||
|
|
||||||
|
$map = $repository->get_map();
|
||||||
|
|
||||||
|
foreach ($map as $mapped => $value){
|
||||||
|
$schema[$mapped] = [
|
||||||
|
'description' => $value['description'],
|
||||||
|
'type' => $value['type']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $schema;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_permissions_schema() {
|
||||||
|
|
||||||
|
return [
|
||||||
|
'current_user_can_edit' => [
|
||||||
|
'description' => esc_html__('Whether current user can edit this object', 'tainacan'),
|
||||||
|
'type' => 'boolean',
|
||||||
|
'context' => 'edit'
|
||||||
|
],
|
||||||
|
'current_user_can_delete' => [
|
||||||
|
'description' => esc_html__('Whether current user can delete this object', 'tainacan'),
|
||||||
|
'type' => 'boolean',
|
||||||
|
'context' => 'edit'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_base_properties_schema() {
|
||||||
|
return [
|
||||||
|
|
||||||
|
'id' => [
|
||||||
|
'description' => esc_html__( 'Unique identifier for the object.', 'tainacan' ),
|
||||||
|
'type' => 'integer',
|
||||||
|
'context' => array( 'view', 'edit' ),
|
||||||
|
'readonly' => true
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -42,23 +42,33 @@ class REST_Background_Processes_Controller extends REST_Controller {
|
||||||
],
|
],
|
||||||
'all_users' => [
|
'all_users' => [
|
||||||
'type' => 'bool',
|
'type' => 'bool',
|
||||||
'description' => __( 'Whether to return processes from all users (if current user is admin). Default false.', 'tainacan' ),
|
'description' => __( 'Whether to return processes from all users (if current user is admin).', 'tainacan' ),
|
||||||
|
'default' => false,
|
||||||
],
|
],
|
||||||
'status' => [
|
'status' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( '"open" returns only processes currently running. "closed" returns only finished or aborted. "all" returns all. Default "all"', 'tainacan' ),
|
'description' => __( '"open" returns only processes currently running. "closed" returns only finished or aborted. "all" returns all.', 'tainacan' ),
|
||||||
|
'default' => 'all',
|
||||||
|
'enum' => array(
|
||||||
|
'open',
|
||||||
|
'closed',
|
||||||
|
'all'
|
||||||
|
)
|
||||||
],
|
],
|
||||||
'perpage' => [
|
'perpage' => [
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => __( 'Number of processes to return per page. Default 10', 'tainacan' ),
|
'description' => __( 'Number of processes to return per page', 'tainacan' ),
|
||||||
|
'default' => 10,
|
||||||
],
|
],
|
||||||
'paged' => [
|
'paged' => [
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => __( 'Page to retrieve. Default 1', 'tainacan' ),
|
'description' => __( 'Page to retrieve', 'tainacan' ),
|
||||||
|
'default' => 1
|
||||||
],
|
],
|
||||||
'recent' => [
|
'recent' => [
|
||||||
'type' => 'bool',
|
'type' => 'bool',
|
||||||
'description' => __( 'Returns only processes created or updated recently', 'tainacan' ),
|
'description' => __( 'Returns only processes created or updated recently', 'tainacan' ),
|
||||||
|
'default' => false
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -82,6 +92,10 @@ class REST_Background_Processes_Controller extends REST_Controller {
|
||||||
'status' => [
|
'status' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( '"open" or "closed" ', 'tainacan' ),
|
'description' => __( '"open" or "closed" ', 'tainacan' ),
|
||||||
|
'enum' => array(
|
||||||
|
'open',
|
||||||
|
'closed'
|
||||||
|
)
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -141,7 +155,7 @@ class REST_Background_Processes_Controller extends REST_Controller {
|
||||||
$user_q = $wpdb->prepare("AND user_id = %d", $request['user_id']);
|
$user_q = $wpdb->prepare("AND user_id = %d", $request['user_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($user_q['all_users']) && $user_q['all_users'] ) {
|
if ( isset($request['all_users']) && $request['all_users'] ) {
|
||||||
$user_q = "";
|
$user_q = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -455,9 +455,6 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
||||||
* @return array|void
|
* @return array|void
|
||||||
*/
|
*/
|
||||||
public function get_create_params($object_name = null) {
|
public function get_create_params($object_name = null) {
|
||||||
$query_params['context']['default'] = 'view';
|
|
||||||
|
|
||||||
array_merge($query_params, parent::get_collection_params('item'));
|
|
||||||
|
|
||||||
$query_params['title'] = array(
|
$query_params['title'] = array(
|
||||||
'description' => __('Limits the result set to items with a specific title'),
|
'description' => __('Limits the result set to items with a specific title'),
|
||||||
|
@ -477,7 +474,11 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
||||||
'description' => __( 'Whether to use the current query to select posts', 'tainacan' ),
|
'description' => __( 'Whether to use the current query to select posts', 'tainacan' ),
|
||||||
];
|
];
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_meta_queries_params());
|
$query_params = array_merge(
|
||||||
|
$query_params,
|
||||||
|
parent::get_wp_query_params(),
|
||||||
|
parent::get_meta_queries_params()
|
||||||
|
);
|
||||||
|
|
||||||
return $query_params;
|
return $query_params;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class REST_Collections_Controller extends REST_Controller {
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_collection_params(),
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::CREATABLE,
|
'methods' => \WP_REST_Server::CREATABLE,
|
||||||
|
@ -51,13 +51,15 @@ class REST_Collections_Controller extends REST_Controller {
|
||||||
'permission_callback' => array($this, 'create_item_permissions_check'),
|
'permission_callback' => array($this, 'create_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
|
||||||
),
|
),
|
||||||
|
'schema' => [$this, 'get_schema'],
|
||||||
));
|
));
|
||||||
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<collection_id>[\d]+)', array(
|
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<collection_id>[\d]+)', array(
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_item'),
|
'callback' => array($this, 'get_item'),
|
||||||
'permission_callback' => array($this, 'get_item_permissions_check'),
|
'permission_callback' => array($this, 'get_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE),
|
'args' => $this->get_wp_query_params(),
|
||||||
|
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::EDITABLE,
|
'methods' => \WP_REST_Server::EDITABLE,
|
||||||
|
@ -71,11 +73,12 @@ class REST_Collections_Controller extends REST_Controller {
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
||||||
'args' => array(
|
'args' => array(
|
||||||
'permanently' => array(
|
'permanently' => array(
|
||||||
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection'),
|
'description' => __('To delete permanently, you can pass \'permanently\' as 1. By default this will only trash collection'),
|
||||||
'default' => 'false'
|
'default' => '0',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
'schema' => [$this, 'get_schema'],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,16 +477,19 @@ class REST_Collections_Controller extends REST_Controller {
|
||||||
public function get_endpoint_args_for_item_schema( $method = null ) {
|
public function get_endpoint_args_for_item_schema( $method = null ) {
|
||||||
$endpoint_args = [];
|
$endpoint_args = [];
|
||||||
if($method === \WP_REST_Server::READABLE) {
|
if($method === \WP_REST_Server::READABLE) {
|
||||||
$endpoint_args['fetch_only'] = array(
|
|
||||||
'type' => 'string/array',
|
$endpoint_args['name'] = array(
|
||||||
'description' => __( 'Fetch only specific attribute. The specifics attributes are the same in schema.' ),
|
'description' => __('Limits the result set to collections with a specific name'),
|
||||||
|
'type' => 'string',
|
||||||
);
|
);
|
||||||
|
|
||||||
$endpoint_args['context'] = array(
|
$endpoint_args = array_merge(
|
||||||
'type' => 'string',
|
$endpoint_args,
|
||||||
'default' => 'view',
|
parent::get_wp_query_params(),
|
||||||
'items' => array( 'view, edit' )
|
parent::get_fetch_only_param(),
|
||||||
|
parent::get_meta_queries_params()
|
||||||
);
|
);
|
||||||
|
|
||||||
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
||||||
$map = $this->collections_repository->get_map();
|
$map = $this->collections_repository->get_map();
|
||||||
|
|
||||||
|
@ -502,27 +508,28 @@ class REST_Collections_Controller extends REST_Controller {
|
||||||
return $endpoint_args;
|
return $endpoint_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function get_schema() {
|
||||||
*
|
$schema = [
|
||||||
* Return the queries supported when getting a collection of objects
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
||||||
*
|
'title' => 'collection',
|
||||||
* @param null $object_name
|
'type' => 'object'
|
||||||
*
|
];
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_collection_params($object_name = null) {
|
|
||||||
$query_params['context']['default'] = 'view';
|
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_collection_params('collection'));
|
$main_schema = parent::get_repository_schema( $this->collections_repository );
|
||||||
|
$permissions_schema = parent::get_permissions_schema();
|
||||||
|
|
||||||
$query_params['name'] = array(
|
// transformation done in $this->prepare_item_for_response()
|
||||||
'description' => __('Limits the result set to collections with a specific name'),
|
$main_schema['moderators'] = $main_schema['moderators_ids'];
|
||||||
'type' => 'string',
|
$main_schema['moderators']['contex'] = 'edit';
|
||||||
|
|
||||||
|
$schema['properties'] = array_merge(
|
||||||
|
parent::get_base_properties_schema(),
|
||||||
|
$main_schema,
|
||||||
|
$permissions_schema
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_meta_queries_params());
|
return $schema;
|
||||||
|
|
||||||
return $query_params;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,336 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Tainacan\API\EndPoints;
|
|
||||||
|
|
||||||
use \Tainacan\API\REST_Controller;
|
|
||||||
use Tainacan\Entities;
|
|
||||||
use Tainacan\Repositories;
|
|
||||||
use Tainacan\Entities\Entity;
|
|
||||||
use Tainacan\Tests\TAINACAN_REST_Collections_Controller;
|
|
||||||
|
|
||||||
class REST_Export_Controller extends REST_Controller {
|
|
||||||
private $item_metadata_repository;
|
|
||||||
private $items_repository;
|
|
||||||
private $collection_repository;
|
|
||||||
private $metadatum_repository;
|
|
||||||
|
|
||||||
public function __construct() {
|
|
||||||
$this->rest_base = 'export';
|
|
||||||
parent::__construct();
|
|
||||||
add_action('init', array(&$this, 'init_objects'), 11);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize objects after post_type register
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function init_objects() {
|
|
||||||
$this->metadatum_repository = Repositories\Metadata::get_instance();
|
|
||||||
$this->item_metadata_repository = Repositories\Item_Metadata::get_instance();
|
|
||||||
$this->items_repository = Repositories\Items::get_instance();
|
|
||||||
$this->collection_repository = Repositories\Collections::get_instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If POST on metadatum/collection/<collection_id>, then
|
|
||||||
* a metadatum will be created in matched collection and all your item will receive this metadatum
|
|
||||||
*
|
|
||||||
* If POST on metadatum/item/<item_id>, then a value will be added in a metadatum and metadatum passed
|
|
||||||
* id body of requisition
|
|
||||||
*
|
|
||||||
* Both of GETs return the metadatum of matched objects
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function register_routes() {
|
|
||||||
register_rest_route($this->namespace, '/' . $this->rest_base. '/collection/(?P<collection_id>[\d]+)',
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
|
||||||
'callback' => array($this, 'get_items'),
|
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
register_rest_route($this->namespace, '/' . $this->rest_base. '/item/(?P<item_id>[\d]+)',
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
|
||||||
'callback' => array($this, 'get_item'),
|
|
||||||
'permission_callback' => array($this, 'get_item_permissions_check'),
|
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
register_rest_route($this->namespace, '/' . $this->rest_base,
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
|
||||||
'callback' => array($this, 'get_items'),
|
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
|
||||||
'args' => $this->get_collection_params(),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \WP_REST_Request $request
|
|
||||||
*
|
|
||||||
* @return \WP_Error|\WP_REST_Response
|
|
||||||
*/
|
|
||||||
public function get_item( $request ) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \WP_REST_Request $request
|
|
||||||
*
|
|
||||||
* @return bool|\WP_Error
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function get_item_permissions_check( $request ) {
|
|
||||||
if(isset($request['collection_id'])) {
|
|
||||||
$collection = $this->collection_repository->fetch($request['collection_id']);
|
|
||||||
if($collection instanceof Entities\Collection) {
|
|
||||||
if (! $collection->can_read()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} elseif(isset($request['item_id'])) {
|
|
||||||
$item = $this->items_repository->fetch($request['item_id']);
|
|
||||||
if($item instanceof Entities\Item) {
|
|
||||||
if (! $item->can_read()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else { // Exporting all
|
|
||||||
$dummy = new Entities\Collection();
|
|
||||||
return current_user_can($dummy->get_capabilities()->read); // Need to check Colletion by collection
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Tainacan\Entities\Item $item
|
|
||||||
* @param \WP_REST_Request $request
|
|
||||||
*
|
|
||||||
* @return array|\WP_Error|\WP_REST_Response
|
|
||||||
*/
|
|
||||||
public function prepare_item_for_response( $item, $request ) {
|
|
||||||
$items_metadata = $item->get_metadata();
|
|
||||||
|
|
||||||
$prepared_item = [];
|
|
||||||
|
|
||||||
foreach ($items_metadata as $item_metadata){
|
|
||||||
$prepared_item[] = $item_metadata->_toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $prepared_item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param \WP_REST_Request $request
|
|
||||||
* @param \WP_Query|Entities\Item $query
|
|
||||||
* @param array $args
|
|
||||||
* @return \WP_Error|number
|
|
||||||
*/
|
|
||||||
public function export($request, $query, $args) {
|
|
||||||
|
|
||||||
$type = \Tainacan\Exposers_Handler::request_has_type($request);
|
|
||||||
$path = wp_upload_dir();
|
|
||||||
$path = $path['path'];
|
|
||||||
$filename = $path.date('YmdHis').'-tainacan-export.'.$type->get_extension();
|
|
||||||
$pid = -1;
|
|
||||||
|
|
||||||
$log = \Tainacan\Entities\Log::create(
|
|
||||||
__('Export Process', 'tainacan'),
|
|
||||||
__('Exporting Data', 'tainacan').'\nArgs: '.print_r($args, true),
|
|
||||||
['file' => $filename],
|
|
||||||
[],
|
|
||||||
'processing'
|
|
||||||
);
|
|
||||||
|
|
||||||
$body = json_decode( $request->get_body(), true );
|
|
||||||
$background = ! (isset($body['export-background']) && $body['export-background'] == false);
|
|
||||||
if( $background ) {
|
|
||||||
$pid = pcntl_fork();
|
|
||||||
} else {
|
|
||||||
$pid = true;
|
|
||||||
}
|
|
||||||
if ($pid === -1) {
|
|
||||||
$error = new \WP_Error('could not fork');
|
|
||||||
$log = \Tainacan\Entities\Log::create(
|
|
||||||
__('Export Process Error', 'tainacan'),
|
|
||||||
__('Exporting Error', 'tainacan').'\\nArgs: '.print_r($args, true).'\\nError: could not fork',
|
|
||||||
$error,
|
|
||||||
[],
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
remove_filter( 'rest_request_after_callbacks', [\Tainacan\Exposers_Handler::get_instance(), 'rest_request_after_callbacks'], 10, 3 ); //exposer mapping
|
|
||||||
remove_filter( 'tainacan-rest-response', [\Tainacan\Exposers_Handler::get_instance(), 'rest_response'], 10, 2 ); // exposer types
|
|
||||||
return $log;
|
|
||||||
} elseif ($pid) { // we are the parent or run at foreground
|
|
||||||
try {
|
|
||||||
ignore_user_abort(true);
|
|
||||||
set_time_limit(0);
|
|
||||||
ini_set("memory_limit", "256M");
|
|
||||||
|
|
||||||
if($background) { // wait for child to respond and exit and reconnect database if is forked
|
|
||||||
$status = null;
|
|
||||||
pcntl_wait($status);
|
|
||||||
global $wpdb;
|
|
||||||
$wpdb->db_connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = [];
|
|
||||||
if(isset($request['collection_id'])) { // One Colletion
|
|
||||||
$collection_id = $request['collection_id'];
|
|
||||||
$items = $query;
|
|
||||||
if ($items->have_posts()) {
|
|
||||||
while ( $items->have_posts() ) { //TODO write line by line
|
|
||||||
$items->the_post();
|
|
||||||
|
|
||||||
$item = new Entities\Item($items->post);
|
|
||||||
|
|
||||||
$prepared_item = $this->prepare_item_for_response($item, $request);
|
|
||||||
|
|
||||||
array_push($response, $prepared_item);
|
|
||||||
}
|
|
||||||
wp_reset_postdata();
|
|
||||||
}
|
|
||||||
} elseif (isset($request['item_id'])) { // One Item
|
|
||||||
|
|
||||||
$item = new Entities\Item($request['item_id']);
|
|
||||||
if($item->get_id() > 0) {
|
|
||||||
$prepared_item = $this->prepare_item_for_response($item, $request);
|
|
||||||
|
|
||||||
$response = [$prepared_item];
|
|
||||||
}
|
|
||||||
} else { // Export All
|
|
||||||
$collections = $query;
|
|
||||||
$collection_controller = new REST_Collections_Controller();
|
|
||||||
if ($collections->have_posts()) {
|
|
||||||
while ($collections->have_posts()) {
|
|
||||||
$collections->the_post();
|
|
||||||
$collection_id = $collections->post->ID;
|
|
||||||
$collection = \Tainacan\Repositories\Repository::get_entity_by_post($collections->post);
|
|
||||||
|
|
||||||
$prepared_collection = $collection_controller->prepare_item_for_response($collection, $request);
|
|
||||||
|
|
||||||
$prepared_items = [];
|
|
||||||
|
|
||||||
$items = $this->items_repository->fetch($args, $collection_id, 'WP_Query');
|
|
||||||
if ($items->have_posts()) {
|
|
||||||
while ( $items->have_posts() ) { //TODO write line by line
|
|
||||||
$items->the_post();
|
|
||||||
|
|
||||||
$item = new Entities\Item($items->post);
|
|
||||||
|
|
||||||
$prepared_item = $this->prepare_item_for_response($item, $request);
|
|
||||||
|
|
||||||
array_push($prepared_items, $prepared_item);
|
|
||||||
}
|
|
||||||
wp_reset_postdata();
|
|
||||||
}
|
|
||||||
|
|
||||||
$prepared_collection['items'] = $prepared_items;
|
|
||||||
array_push($prepared_collection, $response);
|
|
||||||
}
|
|
||||||
wp_reset_postdata();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$rest_response = new \WP_REST_Response(apply_filters('tainacan-rest-response', $response, $request));
|
|
||||||
$data = $rest_response->get_data();
|
|
||||||
file_put_contents($filename, is_string($data) ? $data : print_r($data, true));
|
|
||||||
|
|
||||||
if($background) {
|
|
||||||
$log->set_status('publish');
|
|
||||||
$logs = \Tainacan\Repositories\Logs::get_instance();
|
|
||||||
$logs->update($log);
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
return $rest_response->get_data();
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
if($background) {
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // we are the child
|
|
||||||
|
|
||||||
remove_filter( 'rest_request_after_callbacks', [\Tainacan\Exposers_Handler::get_instance(), 'rest_request_after_callbacks'], 10, 3 ); //exposer mapping
|
|
||||||
remove_filter( 'tainacan-rest-response', [\Tainacan\Exposers_Handler::get_instance(), 'rest_response'], 10, 2 ); // exposer types
|
|
||||||
return $log;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \WP_REST_Request $request
|
|
||||||
*
|
|
||||||
* @return \WP_Error|\WP_REST_Response
|
|
||||||
*/
|
|
||||||
public function get_items( $request ) {
|
|
||||||
$args = $this->prepare_filters($request); // TODO default args
|
|
||||||
$rest_response = new \WP_REST_Response([], 200); // TODO error, empty response
|
|
||||||
|
|
||||||
if(isset($request['collection_id'])) { // One Colletion
|
|
||||||
$collection_id = $request['collection_id'];
|
|
||||||
$items = $this->items_repository->fetch($args, $collection_id, 'WP_Query');
|
|
||||||
|
|
||||||
$response = $this->export($request, $items, $args);
|
|
||||||
|
|
||||||
$total_items = $items->found_posts;
|
|
||||||
$ret = $response instanceof Entity ? $response->__toArray() : $response;
|
|
||||||
$rest_response = new \WP_REST_Response($ret, 200);
|
|
||||||
|
|
||||||
$rest_response->header('X-WP-Total', (int) $total_items);
|
|
||||||
} elseif (isset($request['item_id'])) { // One Item
|
|
||||||
|
|
||||||
$item = new Entities\Item($request['item_id']);
|
|
||||||
if($item->get_id() > 0) {
|
|
||||||
$response = $this->export($request, $item, $args);
|
|
||||||
|
|
||||||
$total_items = 1;
|
|
||||||
$max_pages = 1;
|
|
||||||
|
|
||||||
$rest_response = new \WP_REST_Response($response->__toArray(), 200);
|
|
||||||
|
|
||||||
$rest_response->header('X-WP-Total', 1);
|
|
||||||
$rest_response->header('X-WP-TotalPages', 1);
|
|
||||||
}
|
|
||||||
} else { // Export All
|
|
||||||
$Tainacan_Collection = \Tainacan\Repositories\Collections::get_instance();
|
|
||||||
$collections = $Tainacan_Collection->fetch(['post_status' => 'publish'], 'WP_Query');
|
|
||||||
|
|
||||||
$response = $this->export($request, $collections, $args);
|
|
||||||
$total_items = $collections->found_posts;
|
|
||||||
$ret = $response instanceof Entity ? $response->__toArray() : $response;
|
|
||||||
$rest_response = new \WP_REST_Response($ret, 200);
|
|
||||||
|
|
||||||
$rest_response->header('X-WP-Total', (int) $total_items);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rest_response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \WP_REST_Request $request
|
|
||||||
*
|
|
||||||
* @return bool|\WP_Error
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function get_items_permissions_check( $request ) {
|
|
||||||
return $this->get_item_permissions_check($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -68,7 +68,7 @@ class REST_Exporters_Controller extends REST_Controller {
|
||||||
],
|
],
|
||||||
'options' => [
|
'options' => [
|
||||||
'type' => 'array/object',
|
'type' => 'array/object',
|
||||||
'description' => __( 'The importer options', 'tainacan' ),
|
'description' => __( 'The exporter options', 'tainacan' ),
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -121,6 +121,7 @@ class REST_Exporters_Controller extends REST_Controller {
|
||||||
|
|
||||||
if ($object = $Tainacan_Exporter_Handler->initialize_exporter($slug)) {
|
if ($object = $Tainacan_Exporter_Handler->initialize_exporter($slug)) {
|
||||||
$response = $object->_to_Array();
|
$response = $object->_to_Array();
|
||||||
|
$Tainacan_Exporter_Handler->save_exporter_instance($object);
|
||||||
return new \WP_REST_Response($response, 201);
|
return new \WP_REST_Response($response, 201);
|
||||||
} else {
|
} else {
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
|
@ -146,13 +147,14 @@ class REST_Exporters_Controller extends REST_Controller {
|
||||||
foreach ($body as $att => $value) {
|
foreach ($body as $att => $value) {
|
||||||
$attributes[$att] = $value;
|
$attributes[$att] = $value;
|
||||||
}
|
}
|
||||||
|
global $Tainacan_Exporter_Handler;
|
||||||
|
$exporter = $Tainacan_Exporter_Handler->get_exporter_instance_by_session_id($session_id);
|
||||||
|
|
||||||
$importer = $_SESSION['tainacan_exporter'][$session_id];
|
if($exporter) {
|
||||||
if($importer) {
|
|
||||||
foreach ($body as $att => $value) {
|
foreach ($body as $att => $value) {
|
||||||
if ($att == 'collection') {
|
if ($att == 'collection') {
|
||||||
if (is_array($value) && isset($value['id'])) {
|
if (is_array($value) && isset($value['id'])) {
|
||||||
$importer->add_collection($value);
|
$exporter->add_collection($value);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
|
@ -162,17 +164,18 @@ class REST_Exporters_Controller extends REST_Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$method = 'set_' . $att;
|
$method = 'set_' . $att;
|
||||||
if (method_exists($importer, $method)) {
|
if (method_exists($exporter, $method)) {
|
||||||
$importer->$method($value);
|
$exporter->$method($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $importer->_to_Array();
|
$response = $exporter->_to_Array();
|
||||||
|
$Tainacan_Exporter_Handler->save_exporter_instance($exporter);
|
||||||
return new \WP_REST_Response( $response, 200 );
|
return new \WP_REST_Response( $response, 200 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
'error_message' => __('Importer Session not found', 'tainacan' ),
|
'error_message' => __('Exporter Session not found', 'tainacan' ),
|
||||||
'session_id' => $session_id
|
'session_id' => $session_id
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
@ -192,7 +195,8 @@ class REST_Exporters_Controller extends REST_Controller {
|
||||||
*/
|
*/
|
||||||
public function run($request) {
|
public function run($request) {
|
||||||
$session_id = $request['session_id'];
|
$session_id = $request['session_id'];
|
||||||
$exporter = $_SESSION['tainacan_exporter'][$session_id];
|
global $Tainacan_Exporter_Handler;
|
||||||
|
$exporter = $Tainacan_Exporter_Handler->get_exporter_instance_by_session_id($session_id);
|
||||||
|
|
||||||
if(!$exporter) {
|
if(!$exporter) {
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
|
@ -212,6 +216,7 @@ class REST_Exporters_Controller extends REST_Controller {
|
||||||
$response = [
|
$response = [
|
||||||
'bg_process_id' => $process->ID
|
'bg_process_id' => $process->ID
|
||||||
];
|
];
|
||||||
|
$Tainacan_Exporter_Handler->delete_exporter_instance($exporter);
|
||||||
return new \WP_REST_Response( $response, 200 );
|
return new \WP_REST_Response( $response, 200 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,9 @@ class REST_Filter_Types_Controller extends REST_Controller {
|
||||||
'className' => [
|
'className' => [
|
||||||
'type' => 'string'
|
'type' => 'string'
|
||||||
],
|
],
|
||||||
|
'name' => [
|
||||||
|
'type' => 'string'
|
||||||
|
],
|
||||||
'component' => [
|
'component' => [
|
||||||
'type' => 'string'
|
'type' => 'string'
|
||||||
],
|
],
|
||||||
|
@ -56,7 +59,6 @@ class REST_Filter_Types_Controller extends REST_Controller {
|
||||||
$filter_type = new $name();
|
$filter_type = new $name();
|
||||||
|
|
||||||
$filter_arr = $filter_type->_toArray();
|
$filter_arr = $filter_type->_toArray();
|
||||||
$filter_arr['name'] = $item;
|
|
||||||
|
|
||||||
return $filter_arr;
|
return $filter_arr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,34 +44,37 @@ class REST_Filters_Controller extends REST_Controller {
|
||||||
'permission_callback' => array($this, 'create_item_permissions_check'),
|
'permission_callback' => array($this, 'create_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE)
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE)
|
||||||
),
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
));
|
));
|
||||||
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base, array(
|
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base, array(
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_collection_params()
|
'args' => $this->get_wp_query_params()
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::CREATABLE,
|
'methods' => \WP_REST_Server::CREATABLE,
|
||||||
'callback' => array($this, 'create_item'),
|
'callback' => array($this, 'create_item'),
|
||||||
'permission_callback' => array($this, 'create_item_permissions_check'),
|
'permission_callback' => array($this, 'create_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE)
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE)
|
||||||
)
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
));
|
));
|
||||||
register_rest_route($this->namespace, '/' . $this->rest_base, array(
|
register_rest_route($this->namespace, '/' . $this->rest_base, array(
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_collection_params()
|
'args' => $this->get_wp_query_params()
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::CREATABLE,
|
'methods' => \WP_REST_Server::CREATABLE,
|
||||||
'callback' => array($this, 'create_item'),
|
'callback' => array($this, 'create_item'),
|
||||||
'permission_callback' => array($this, 'create_item_permissions_check'),
|
'permission_callback' => array($this, 'create_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE)
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE)
|
||||||
)
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
));
|
));
|
||||||
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<filter_id>[\d]+)', array(
|
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<filter_id>[\d]+)', array(
|
||||||
array(
|
array(
|
||||||
|
@ -80,8 +83,8 @@ class REST_Filters_Controller extends REST_Controller {
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
||||||
'args' => array(
|
'args' => array(
|
||||||
'permanently' => array(
|
'permanently' => array(
|
||||||
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection'),
|
'description' => __('To delete permanently, you can pass \'permanently\' as 1. By default this will only trash collection'),
|
||||||
'default' => 'false'
|
'default' => '0'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -96,7 +99,8 @@ class REST_Filters_Controller extends REST_Controller {
|
||||||
'callback' => array($this, 'get_item'),
|
'callback' => array($this, 'get_item'),
|
||||||
'permission_callback' => array($this, 'get_item_permissions_check'),
|
'permission_callback' => array($this, 'get_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE)
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE)
|
||||||
)
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,13 +122,11 @@ class REST_Filters_Controller extends REST_Controller {
|
||||||
if(empty($received_type)){
|
if(empty($received_type)){
|
||||||
throw new \InvalidArgumentException('The type can\'t be empty');
|
throw new \InvalidArgumentException('The type can\'t be empty');
|
||||||
} elseif(!strrchr($received_type, '_')){
|
} elseif(!strrchr($received_type, '_')){
|
||||||
$received_type = ucfirst(strtolower($received_type));
|
$type = ucfirst(strtolower($received_type));
|
||||||
} else {
|
} else {
|
||||||
$received_type = ucwords(strtolower($received_type), '_');
|
$type = ucwords(strtolower($received_type), '_\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = "Tainacan\Filter_Types\\$received_type";
|
|
||||||
|
|
||||||
$filter_type = new $type();
|
$filter_type = new $type();
|
||||||
|
|
||||||
foreach ($filter as $attribute => $value){
|
foreach ($filter as $attribute => $value){
|
||||||
|
@ -148,7 +150,7 @@ class REST_Filters_Controller extends REST_Controller {
|
||||||
|
|
||||||
$filter_obj->set_metadatum_id($body['metadatum_id']);
|
$filter_obj->set_metadatum_id($body['metadatum_id']);
|
||||||
} else {
|
} else {
|
||||||
$filter_obj->set_collection_id( 'filter_in_repository' );
|
$filter_obj->set_collection_id( 'default' );
|
||||||
|
|
||||||
if(!isset($body['metadatum_id'])){
|
if(!isset($body['metadatum_id'])){
|
||||||
throw new \InvalidArgumentException('You need provide a metadatum id');
|
throw new \InvalidArgumentException('You need provide a metadatum id');
|
||||||
|
@ -375,7 +377,7 @@ class REST_Filters_Controller extends REST_Controller {
|
||||||
if(!isset($request['collection_id'])) {
|
if(!isset($request['collection_id'])) {
|
||||||
$args['meta_query'][] = [
|
$args['meta_query'][] = [
|
||||||
'key' => 'collection_id',
|
'key' => 'collection_id',
|
||||||
'value' => 'filter_in_repository',
|
'value' => 'default',
|
||||||
'compare' => '='
|
'compare' => '='
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -467,10 +469,9 @@ class REST_Filters_Controller extends REST_Controller {
|
||||||
public function get_endpoint_args_for_item_schema( $method = null ) {
|
public function get_endpoint_args_for_item_schema( $method = null ) {
|
||||||
$endpoint_args = [];
|
$endpoint_args = [];
|
||||||
if($method === \WP_REST_Server::READABLE) {
|
if($method === \WP_REST_Server::READABLE) {
|
||||||
$endpoint_args['context'] = array(
|
$endpoint_args = array_merge(
|
||||||
'type' => 'string',
|
$endpoint_args,
|
||||||
'default' => 'view',
|
parent::get_wp_query_params()
|
||||||
'items' => array( 'view, edit' )
|
|
||||||
);
|
);
|
||||||
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
||||||
$map = $this->filter_repository->get_map();
|
$map = $this->filter_repository->get_map();
|
||||||
|
@ -495,19 +496,45 @@ class REST_Filters_Controller extends REST_Controller {
|
||||||
*
|
*
|
||||||
* @return array|void
|
* @return array|void
|
||||||
*/
|
*/
|
||||||
public function get_collection_params( $object_name = null ) {
|
public function get_wp_query_params() {
|
||||||
$query_params['context']['default'] = 'view';
|
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_collection_params('filter'));
|
|
||||||
|
|
||||||
$query_params['name'] = array(
|
$query_params['name'] = array(
|
||||||
'description' => __('Limits the result set to filters with a specific name'),
|
'description' => __('Limits the result set to filters with a specific name'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_meta_queries_params());
|
$query_params = array_merge(
|
||||||
|
$query_params,
|
||||||
|
parent::get_wp_query_params(),
|
||||||
|
parent::get_meta_queries_params()
|
||||||
|
);
|
||||||
|
|
||||||
return $query_params;
|
return $query_params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_schema() {
|
||||||
|
$schema = [
|
||||||
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
||||||
|
'title' => 'filter',
|
||||||
|
'type' => 'object'
|
||||||
|
];
|
||||||
|
|
||||||
|
$main_schema = parent::get_repository_schema( $this->filter_repository );
|
||||||
|
$permissions_schema = parent::get_permissions_schema();
|
||||||
|
|
||||||
|
// $collection_scheme = parent::get_repository_schema( $this->collection_repository );
|
||||||
|
// $metadatum_scheme = parent::get_repository_schema( $this->metadatum_repository );
|
||||||
|
|
||||||
|
$schema['properties'] = array_merge(
|
||||||
|
parent::get_base_properties_schema(),
|
||||||
|
$main_schema,
|
||||||
|
$permissions_schema
|
||||||
|
// $collection_scheme,
|
||||||
|
// $metadatum_scheme
|
||||||
|
);
|
||||||
|
|
||||||
|
return $schema;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -165,6 +165,7 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
|
|
||||||
if ($object = $Tainacan_Importer_Handler->initialize_importer($slug)) {
|
if ($object = $Tainacan_Importer_Handler->initialize_importer($slug)) {
|
||||||
$response = $object->_to_Array();
|
$response = $object->_to_Array();
|
||||||
|
$Tainacan_Importer_Handler->save_importer_instance($object);
|
||||||
return new \WP_REST_Response($response, 201);
|
return new \WP_REST_Response($response, 201);
|
||||||
} else {
|
} else {
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
|
@ -193,7 +194,8 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
$attributes[$att] = $value;
|
$attributes[$att] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$importer = $_SESSION['tainacan_importer'][$session_id];
|
global $Tainacan_Importer_Handler;
|
||||||
|
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
|
||||||
|
|
||||||
if($importer) {
|
if($importer) {
|
||||||
|
|
||||||
|
@ -218,6 +220,7 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $importer->_to_Array();
|
$response = $importer->_to_Array();
|
||||||
|
$Tainacan_Importer_Handler->save_importer_instance($importer);
|
||||||
return new \WP_REST_Response( $response, 200 );
|
return new \WP_REST_Response( $response, 200 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -237,7 +240,8 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
|
|
||||||
public function source_info( $request ) {
|
public function source_info( $request ) {
|
||||||
$session_id = $request['session_id'];
|
$session_id = $request['session_id'];
|
||||||
$importer = $_SESSION['tainacan_importer'][$session_id];
|
global $Tainacan_Importer_Handler;
|
||||||
|
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
|
||||||
|
|
||||||
if(!$importer) {
|
if(!$importer) {
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
|
@ -263,7 +267,7 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
if ( method_exists($importer, 'get_source_special_fields') ) {
|
if ( method_exists($importer, 'get_source_special_fields') ) {
|
||||||
$response['source_special_fields'] = $importer->get_source_special_fields();
|
$response['source_special_fields'] = $importer->get_source_special_fields();
|
||||||
}
|
}
|
||||||
|
$Tainacan_Importer_Handler->save_importer_instance($importer);
|
||||||
return new \WP_REST_Response( $response, 200 );
|
return new \WP_REST_Response( $response, 200 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -271,7 +275,8 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
public function get_saved_mapping( $request ){
|
public function get_saved_mapping( $request ){
|
||||||
$session_id = $request['session_id'];
|
$session_id = $request['session_id'];
|
||||||
$collection_id = $request['collection_id'];
|
$collection_id = $request['collection_id'];
|
||||||
$importer = $_SESSION['tainacan_importer'][$session_id];
|
global $Tainacan_Importer_Handler;
|
||||||
|
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
|
||||||
$response = false;
|
$response = false;
|
||||||
|
|
||||||
if(!$importer) {
|
if(!$importer) {
|
||||||
|
@ -290,7 +295,8 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
|
|
||||||
public function get_item( $request ) {
|
public function get_item( $request ) {
|
||||||
$session_id = $request['session_id'];
|
$session_id = $request['session_id'];
|
||||||
$importer = $_SESSION['tainacan_importer'][$session_id];
|
global $Tainacan_Importer_Handler;
|
||||||
|
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
|
||||||
|
|
||||||
if(!$importer) {
|
if(!$importer) {
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
|
@ -306,7 +312,8 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
|
|
||||||
public function add_file( $request ) {
|
public function add_file( $request ) {
|
||||||
$session_id = $request['session_id'];
|
$session_id = $request['session_id'];
|
||||||
$importer = $_SESSION['tainacan_importer'][$session_id];
|
global $Tainacan_Importer_Handler;
|
||||||
|
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
|
||||||
|
|
||||||
if(!$importer) {
|
if(!$importer) {
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
|
@ -320,6 +327,7 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
|
|
||||||
if ( isset($files['file']) && $importer->add_file($files['file']) ) {
|
if ( isset($files['file']) && $importer->add_file($files['file']) ) {
|
||||||
$response = $importer->_to_Array();
|
$response = $importer->_to_Array();
|
||||||
|
$Tainacan_Importer_Handler->save_importer_instance($importer);
|
||||||
return new \WP_REST_Response( $response, 200 );
|
return new \WP_REST_Response( $response, 200 );
|
||||||
} else {
|
} else {
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
|
@ -335,7 +343,8 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
|
|
||||||
public function run($request) {
|
public function run($request) {
|
||||||
$session_id = $request['session_id'];
|
$session_id = $request['session_id'];
|
||||||
$importer = $_SESSION['tainacan_importer'][$session_id];
|
global $Tainacan_Importer_Handler;
|
||||||
|
$importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
|
||||||
|
|
||||||
if(!$importer) {
|
if(!$importer) {
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
|
@ -358,6 +367,7 @@ class REST_Importers_Controller extends REST_Controller {
|
||||||
$response = [
|
$response = [
|
||||||
'bg_process_id' => $process->ID
|
'bg_process_id' => $process->ID
|
||||||
];
|
];
|
||||||
|
$Tainacan_Importer_Handler->delete_importer_instance($importer);
|
||||||
return new \WP_REST_Response( $response, 200 );
|
return new \WP_REST_Response( $response, 200 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_collection_params(),
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -268,7 +268,12 @@ class REST_Item_Metadata_Controller extends REST_Controller {
|
||||||
public function get_endpoint_args_for_item_schema( $method = null ) {
|
public function get_endpoint_args_for_item_schema( $method = null ) {
|
||||||
$endpoint_args = [];
|
$endpoint_args = [];
|
||||||
|
|
||||||
if ($method === \WP_REST_Server::EDITABLE) {
|
if($method === \WP_REST_Server::READABLE) {
|
||||||
|
$endpoint_args = array_merge(
|
||||||
|
$endpoint_args,
|
||||||
|
$this->get_wp_query_params()
|
||||||
|
);
|
||||||
|
} elseif ($method === \WP_REST_Server::EDITABLE) {
|
||||||
$endpoint_args['values'] = [
|
$endpoint_args['values'] = [
|
||||||
'type' => 'array/string/object/integer',
|
'type' => 'array/string/object/integer',
|
||||||
'items' => [
|
'items' => [
|
||||||
|
@ -289,8 +294,16 @@ class REST_Item_Metadata_Controller extends REST_Controller {
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_collection_params($object_name = null) {
|
public function get_wp_query_params() {
|
||||||
$query_params['context']['default'] = 'view';
|
$query_params['context'] = array(
|
||||||
|
'type' => 'string',
|
||||||
|
'default' => 'view',
|
||||||
|
'description' => 'The context in which the request is made.',
|
||||||
|
'enum' => array(
|
||||||
|
'view',
|
||||||
|
'edit'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return $query_params;
|
return $query_params;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_collection_params(),
|
'args' => $this->get_wp_query_params(),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::CREATABLE,
|
'methods' => \WP_REST_Server::CREATABLE,
|
||||||
|
@ -80,8 +80,8 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
||||||
'args' => array(
|
'args' => array(
|
||||||
'permanently' => array(
|
'permanently' => array(
|
||||||
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection', 'tainacan'),
|
'description' => __('To delete permanently, you can pass \'permanently\' as 1. By default this will only trash collection', 'tainacan'),
|
||||||
'default' => 'false'
|
'default' => '0'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -94,7 +94,7 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_collection_params(),
|
'args' => $this->get_wp_query_params(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -757,15 +757,18 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
$endpoint_args = [];
|
$endpoint_args = [];
|
||||||
|
|
||||||
if($method === \WP_REST_Server::READABLE) {
|
if($method === \WP_REST_Server::READABLE) {
|
||||||
$endpoint_args['fetch_only'] = array(
|
|
||||||
'type' => 'string/array',
|
|
||||||
'description' => __( 'Fetch only specific attribute. The specifics attributes are the same in schema.' ),
|
|
||||||
);
|
|
||||||
|
|
||||||
$endpoint_args['context'] = array(
|
$endpoint_args['context'] = array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'default' => 'view',
|
'default' => 'view',
|
||||||
'items' => array( 'view, edit' )
|
'description' => 'The context in which the request is made.',
|
||||||
|
'enum' => array(
|
||||||
|
'view',
|
||||||
|
'edit'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$endpoint_args = array_merge(
|
||||||
|
$endpoint_args,
|
||||||
|
parent::get_fetch_only_param()
|
||||||
);
|
);
|
||||||
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
||||||
$map = $this->items_repository->get_map();
|
$map = $this->items_repository->get_map();
|
||||||
|
@ -790,17 +793,17 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
*
|
*
|
||||||
* @return array|void
|
* @return array|void
|
||||||
*/
|
*/
|
||||||
public function get_collection_params($object_name = null) {
|
public function get_wp_query_params() {
|
||||||
$query_params['context']['default'] = 'view';
|
|
||||||
|
|
||||||
array_merge($query_params, parent::get_collection_params('item'));
|
|
||||||
|
|
||||||
$query_params['title'] = array(
|
$query_params['title'] = array(
|
||||||
'description' => __('Limits the result set to items with a specific title'),
|
'description' => __('Limits the result set to items with a specific title'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_meta_queries_params());
|
$query_params = array_merge(
|
||||||
|
$query_params,
|
||||||
|
parent::get_wp_query_params(),
|
||||||
|
parent::get_meta_queries_params()
|
||||||
|
);
|
||||||
|
|
||||||
return $query_params;
|
return $query_params;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,7 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->rest_base = 'logs';
|
$this->rest_base = 'logs';
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
add_action('init', array($this, 'init_objects'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function init_objects(){
|
|
||||||
$this->logs_repository = Repositories\Logs::get_instance();
|
$this->logs_repository = Repositories\Logs::get_instance();
|
||||||
$this->log = new Entities\Log();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register_routes() {
|
public function register_routes() {
|
||||||
|
@ -32,8 +27,9 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_collection_params()
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE)
|
||||||
)
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<log_id>[\d]+)',
|
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<log_id>[\d]+)',
|
||||||
|
@ -42,17 +38,19 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_item'),
|
'callback' => array($this, 'get_item'),
|
||||||
'permission_callback' => array($this, 'get_item_permissions_check'),
|
'permission_callback' => array($this, 'get_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE)
|
'args' => array(
|
||||||
)
|
'context' => array(
|
||||||
)
|
'type' => 'string',
|
||||||
);
|
'default' => 'view',
|
||||||
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<log_id>[\d]+)/approve',
|
'description' => 'The context in which the request is made.',
|
||||||
array(
|
'enum' => array(
|
||||||
array(
|
'view',
|
||||||
'methods' => \WP_REST_Server::EDITABLE,
|
'edit'
|
||||||
'callback' => array($this, 'approve_item'),
|
|
||||||
'permission_callback' => array($this, 'approve_item_permissions_check'),
|
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base,
|
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base,
|
||||||
|
@ -62,7 +60,8 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::READABLE)
|
'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::READABLE)
|
||||||
)
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/' . $this->rest_base,
|
register_rest_route($this->namespace, '/item/(?P<item_id>[\d]+)/' . $this->rest_base,
|
||||||
|
@ -72,7 +71,52 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::READABLE)
|
'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::READABLE)
|
||||||
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
|
);
|
||||||
|
register_rest_route($this->namespace, '/filter/(?P<filter_id>[\d]+)/' . $this->rest_base,
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
|
'callback' => array($this, 'get_items'),
|
||||||
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
|
'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::READABLE)
|
||||||
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
register_rest_route($this->namespace, '/metadatum/(?P<metadatum_id>[\d]+)/' . $this->rest_base,
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
|
'callback' => array($this, 'get_items'),
|
||||||
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
|
'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::READABLE)
|
||||||
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
register_rest_route($this->namespace, '/taxonomy/(?P<taxonomy_id>[\d]+)/' . $this->rest_base,
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
|
'callback' => array($this, 'get_items'),
|
||||||
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
|
'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::READABLE)
|
||||||
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
register_rest_route($this->namespace, '/term/(?P<term_id>[\d]+)/' . $this->rest_base,
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
|
'callback' => array($this, 'get_items'),
|
||||||
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
|
'args' => $this->get_endpoint_args_for_item_schema( \WP_REST_Server::READABLE)
|
||||||
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -86,12 +130,120 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
public function prepare_item_for_response( $item, $request ) {
|
public function prepare_item_for_response( $item, $request ) {
|
||||||
if(!empty($item)){
|
if(!empty($item)){
|
||||||
|
|
||||||
|
// Hanle logs created before 1.0
|
||||||
|
if ( !empty( get_post_meta($item->get_id(), 'value', true) ) && !empty( get_post_meta($item->get_id(), 'log_diffs', true) ) ) {
|
||||||
|
return $this->prepare_legacy_item_for_response($item, $request);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request['log_id']) {
|
||||||
|
|
||||||
|
|
||||||
|
$item_array = $item->_toArray();
|
||||||
|
|
||||||
|
$related_object = true;
|
||||||
|
|
||||||
|
if ($item_array['item_id']) {
|
||||||
|
$item = Repositories\Items::get_instance()->fetch( (int) $item_array['item_id'] );
|
||||||
|
if ($item instanceof Entities\Item ) {
|
||||||
|
$item_array['item'] = $item->_toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($item_array['collection_id']) {
|
||||||
|
$collection = Repositories\Collections::get_instance()->fetch( (int) $item_array['collection_id'] );
|
||||||
|
if ($collection instanceof Entities\Item ) {
|
||||||
|
$item_array['collection'] = $collection->_toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $item_array['object_id'] ) {
|
||||||
|
|
||||||
|
if ( $item_array['object_type'] == 'Tainacan\Entities\Term' ) {
|
||||||
|
$related_entity = Repositories\Terms::get_instance()->fetch( (int) $item_array['object_id'] );
|
||||||
|
} else {
|
||||||
|
$related_post = get_post($item_array['object_id']);
|
||||||
|
$related_entity = Repository::get_entity_by_post( $related_post );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($related_entity instanceof Entities\Entity ) {
|
||||||
|
$item_array[ 'object' ] = $related_entity->_toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $item_array['action'] == 'new-attachment' ) {
|
||||||
|
if ( isset($item_array['new_value']['id']) ) {
|
||||||
|
$item_array['new_value']['url'] = wp_get_attachment_url($item_array['new_value']['id']);
|
||||||
|
$item_array['new_value']['thumb'] = wp_get_attachment_image_src($item_array['new_value']['id'], 'thumbnail');
|
||||||
|
}
|
||||||
|
} elseif ( $item_array['action'] == 'update-document' ) {
|
||||||
|
if ( isset( $item_array['new_value']['document'] ) && is_numeric( $item_array['new_value']['document'] ) ) {
|
||||||
|
$item_array['new_value']['url'] = wp_get_attachment_url($item_array['new_value']['document']);
|
||||||
|
$item_array['new_value']['thumb'] = wp_get_attachment_image_src($item_array['new_value']['document'], 'thumbnail');
|
||||||
|
}
|
||||||
|
if ( isset( $item_array['old_value']['document'] ) && is_numeric( $item_array['old_value']['document'] ) ) {
|
||||||
|
$item_array['old_value']['url'] = wp_get_attachment_url($item_array['old_value']['document']);
|
||||||
|
$item_array['old_value']['thumb'] = wp_get_attachment_image_src($item_array['old_value']['document'], 'thumbnail');
|
||||||
|
}
|
||||||
|
} elseif ( $item_array['action'] == 'update-thumbnail' ) {
|
||||||
|
if ( isset( $item_array['new_value']['_thumbnail_id'] ) ) {
|
||||||
|
$item_array['new_value']['url'] = wp_get_attachment_url($item_array['new_value']['_thumbnail_id']);
|
||||||
|
$item_array['new_value']['thumb'] = wp_get_attachment_image_src($item_array['new_value']['_thumbnail_id'], 'thumbnail');
|
||||||
|
}
|
||||||
|
if ( isset( $item_array['old_value']['_thumbnail_id'] ) ) {
|
||||||
|
$item_array['old_value']['url'] = wp_get_attachment_url($item_array['old_value']['_thumbnail_id']);
|
||||||
|
$item_array['old_value']['thumb'] = wp_get_attachment_image_src($item_array['old_value']['_thumbnail_id'], 'thumbnail');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// translate
|
||||||
|
if (isset($related_entity) && $related_entity instanceof Entities\Entity ) {
|
||||||
|
|
||||||
|
$map = $related_entity->get_repository()->get_map();
|
||||||
|
|
||||||
|
foreach ( $map as $slug => $m ) {
|
||||||
|
|
||||||
|
if ( isset($item_array['new_value'][$slug]) ) {
|
||||||
|
$item_array['new_value'][$m['title']] = $item_array['new_value'][$slug];
|
||||||
|
unset($item_array['new_value'][$slug]);
|
||||||
|
}
|
||||||
|
if ( isset($item_array['old_value'][$slug]) ) {
|
||||||
|
$item_array['old_value'][$m['title']] = $item_array['old_value'][$slug];
|
||||||
|
unset($item_array['old_value'][$slug]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item_array;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(!isset($request['fetch_only'])) {
|
||||||
|
$item_array = $item->_toArray();
|
||||||
|
return $item_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributes_to_filter = $request['fetch_only'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->filter_object_by_attributes($item, $attributes_to_filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function prepare_legacy_item_for_response($item, $request) {
|
||||||
if(!isset($request['fetch_only'])) {
|
if(!isset($request['fetch_only'])) {
|
||||||
$item_array = $item->_toArray();
|
$item_array = $item->_toArray();
|
||||||
|
|
||||||
unset($item_array['value']);
|
unset($item_array['value']);
|
||||||
unset($item_array['old_value']);
|
unset($item_array['old_value']);
|
||||||
|
|
||||||
|
$item_array['legacy'] = true;
|
||||||
|
|
||||||
return $item_array;
|
return $item_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +252,6 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
return $this->filter_object_by_attributes($item, $attributes_to_filter);
|
return $this->filter_object_by_attributes($item, $attributes_to_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \WP_REST_Request $request
|
* @param \WP_REST_Request $request
|
||||||
*
|
*
|
||||||
|
@ -114,91 +263,28 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
$args = $this->prepare_filters( $request );
|
$args = $this->prepare_filters( $request );
|
||||||
|
|
||||||
|
|
||||||
if ($request['item_id']){
|
if ($request['item_id']) {
|
||||||
$item_id = $request['item_id'];
|
$args['item_id'] = $request['item_id'];
|
||||||
|
} elseif ($request['collection_id']) {
|
||||||
$item_repository = Repositories\Items::get_instance();
|
$args['collection_id'] = $request['collection_id'];
|
||||||
|
} elseif ($request['filter_id']) {
|
||||||
$item = $item_repository->fetch($item_id);
|
$args['object_type'] = 'Tainacan\Entities\Filter';
|
||||||
|
$args['object_id'] = $request['filter_id'];
|
||||||
if(!$item){
|
} elseif ($request['metadatum_id']) {
|
||||||
return new \WP_REST_Response([
|
$args['object_type'] = 'Tainacan\Entities\Metadatum';
|
||||||
'error_message' => __('An item with this ID does not exist', 'tainacan'),
|
$args['object_id'] = $request['metadatum_id'];
|
||||||
'item_id' => $item
|
} elseif ($request['taxonomy_id']) {
|
||||||
], 400);
|
$args['object_type'] = 'Tainacan\Entities\Taxonomy';
|
||||||
|
$args['object_id'] = $request['taxonomy_id'];
|
||||||
|
} elseif ($request['term_id']) {
|
||||||
|
$args['object_type'] = 'Tainacan\Entities\Term';
|
||||||
|
$args['object_id'] = $request['term_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($args &&
|
$logs = Repositories\Logs::get_instance()->fetch($args);
|
||||||
array_key_exists('meta_query', $args) &&
|
|
||||||
array_key_exists('relation', $args['meta_query'])){
|
|
||||||
|
|
||||||
$metaq = $args['meta_query'];
|
|
||||||
|
|
||||||
unset($args['meta_query']);
|
|
||||||
|
|
||||||
$args['meta_query'][] = $metaq;
|
|
||||||
$args['meta_query']['relation'] = 'AND';
|
|
||||||
|
|
||||||
} elseif($args &&
|
|
||||||
array_key_exists('meta_query', $args)){
|
|
||||||
$args['meta_query']['relation'] = 'AND';
|
|
||||||
}
|
|
||||||
|
|
||||||
$args = array_merge_recursive(array(
|
|
||||||
'meta_query' => array(
|
|
||||||
'item_clause' => array(
|
|
||||||
'key' => 'item_id',
|
|
||||||
'value' => $item_id,
|
|
||||||
'compare' => '='
|
|
||||||
)
|
|
||||||
)
|
|
||||||
), $args);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($request['collection_id']){
|
|
||||||
$collection_id = $request['collection_id'];
|
|
||||||
|
|
||||||
$collection_repository = Repositories\Collections::get_instance();
|
|
||||||
|
|
||||||
$collection = $collection_repository->fetch($collection_id);
|
|
||||||
|
|
||||||
if(!$collection){
|
|
||||||
return new \WP_REST_Response([
|
|
||||||
'error_message' => __('A collection with this ID does not exist', 'tainacan'),
|
|
||||||
'collection_id' => $collection_id
|
|
||||||
], 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($args &&
|
|
||||||
array_key_exists('meta_query', $args) &&
|
|
||||||
array_key_exists('relation', $args['meta_query'])){
|
|
||||||
|
|
||||||
$metaq = $args['meta_query'];
|
|
||||||
|
|
||||||
unset($args['meta_query']);
|
|
||||||
|
|
||||||
$args['meta_query'][] = $metaq;
|
|
||||||
$args['meta_query']['relation'] = 'AND';
|
|
||||||
|
|
||||||
} elseif($args &&
|
|
||||||
array_key_exists('meta_query', $args)){
|
|
||||||
$args['meta_query']['relation'] = 'AND';
|
|
||||||
}
|
|
||||||
|
|
||||||
$args = array_merge_recursive(array(
|
|
||||||
'meta_query' => array(
|
|
||||||
'collection_clause' => array(
|
|
||||||
'key' => 'collection_id',
|
|
||||||
'value' => $collection_id,
|
|
||||||
'compare' => '='
|
|
||||||
)
|
|
||||||
)
|
|
||||||
), $args);
|
|
||||||
}
|
|
||||||
|
|
||||||
$logs = $this->logs_repository->fetch($args);
|
|
||||||
|
|
||||||
$response = [];
|
$response = [];
|
||||||
|
|
||||||
if($logs->have_posts()){
|
if($logs->have_posts()){
|
||||||
while ($logs->have_posts()){
|
while ($logs->have_posts()){
|
||||||
$logs->the_post();
|
$logs->the_post();
|
||||||
|
@ -228,6 +314,7 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
* @return bool|\WP_Error
|
* @return bool|\WP_Error
|
||||||
*/
|
*/
|
||||||
public function get_items_permissions_check( $request ) {
|
public function get_items_permissions_check( $request ) {
|
||||||
|
return true;
|
||||||
return current_user_can('read');
|
return current_user_can('read');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +326,7 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
public function get_item( $request ) {
|
public function get_item( $request ) {
|
||||||
$log_id = $request['log_id'];
|
$log_id = $request['log_id'];
|
||||||
|
|
||||||
$log = $this->logs_repository->fetch($log_id);
|
$log = Repositories\Logs::get_instance()->fetch($log_id);
|
||||||
|
|
||||||
$prepared_log = $this->prepare_item_for_response( $log, $request );
|
$prepared_log = $this->prepare_item_for_response( $log, $request );
|
||||||
|
|
||||||
|
@ -252,7 +339,8 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
* @return bool|\WP_Error
|
* @return bool|\WP_Error
|
||||||
*/
|
*/
|
||||||
public function get_item_permissions_check( $request ) {
|
public function get_item_permissions_check( $request ) {
|
||||||
$log = $this->logs_repository->fetch($request['log_id']);
|
return true;
|
||||||
|
$log = Repositories\Logs::get_instance()->fetch($request['log_id']);
|
||||||
|
|
||||||
if(($log instanceof Entities\Log)) {
|
if(($log instanceof Entities\Log)) {
|
||||||
if('edit' === $request['context'] && !$log->can_read()) {
|
if('edit' === $request['context'] && !$log->can_read()) {
|
||||||
|
@ -265,52 +353,6 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \WP_REST_Request $request
|
|
||||||
*
|
|
||||||
* @return bool|\WP_Error
|
|
||||||
*/
|
|
||||||
public function approve_item_permissions_check( $request ) {
|
|
||||||
$log = $this->logs_repository->fetch($request['log_id']);
|
|
||||||
|
|
||||||
if($log instanceof Entities\Log){
|
|
||||||
if($log->can_read()) {
|
|
||||||
$entity = $log->get_value();
|
|
||||||
|
|
||||||
if($entity instanceof Entities\Entity) {
|
|
||||||
if($entity instanceof Entities\Item_Metadata_Entity) {
|
|
||||||
$item = $entity->get_item();
|
|
||||||
return $item->can_edit();
|
|
||||||
} // TODO for other entities types
|
|
||||||
else {
|
|
||||||
return $entity->can_edit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new \WP_Error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* approve a logged modification
|
|
||||||
* @param \WP_REST_Request $request
|
|
||||||
*
|
|
||||||
* @return \WP_Error|\WP_REST_Response
|
|
||||||
*/
|
|
||||||
public function approve_item($request) {
|
|
||||||
$log = $this->logs_repository->fetch($request['log_id']);
|
|
||||||
|
|
||||||
if($log instanceof Entities\Log){
|
|
||||||
$entity = $log->approve();
|
|
||||||
$prepared_entity = $this->prepare_item_for_response( $entity, $request );
|
|
||||||
|
|
||||||
return new \WP_REST_Response($prepared_entity, 200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $method
|
* @param string $method
|
||||||
*
|
*
|
||||||
|
@ -319,37 +361,32 @@ class REST_Logs_Controller extends REST_Controller {
|
||||||
public function get_endpoint_args_for_item_schema( $method = null ) {
|
public function get_endpoint_args_for_item_schema( $method = null ) {
|
||||||
$endpoint_args = [];
|
$endpoint_args = [];
|
||||||
if($method === \WP_REST_Server::READABLE) {
|
if($method === \WP_REST_Server::READABLE) {
|
||||||
$endpoint_args['context'] = array(
|
$endpoint_args = array_merge(
|
||||||
'type' => 'string',
|
$endpoint_args,
|
||||||
'default' => 'view',
|
parent::get_wp_query_params()
|
||||||
'items' => array( 'view' )
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $endpoint_args;
|
return $endpoint_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function get_schema() {
|
||||||
*
|
$schema = [
|
||||||
* Return the queries supported when getting a collection of objects
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
||||||
*
|
'title' => 'log',
|
||||||
* @param null $object_name
|
'type' => 'object'
|
||||||
*
|
];
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_collection_params($object_name = null) {
|
|
||||||
$query_params['context']['default'] = 'view';
|
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_collection_params('log'));
|
$main_schema = parent::get_repository_schema( $this->logs_repository );
|
||||||
|
$permissions_schema = parent::get_permissions_schema();
|
||||||
|
|
||||||
$query_params['title'] = array(
|
$schema['properties'] = array_merge(
|
||||||
'description' => __('Limits the result set to a log with a specific title'),
|
parent::get_base_properties_schema(),
|
||||||
'type' => 'string',
|
$main_schema,
|
||||||
|
$permissions_schema
|
||||||
);
|
);
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_meta_queries_params());
|
return $schema;
|
||||||
|
|
||||||
return $query_params;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,24 +44,34 @@ class REST_Metadata_Controller extends REST_Controller {
|
||||||
public function register_routes() {
|
public function register_routes() {
|
||||||
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base . '/(?P<metadatum_id>[\d]+)',
|
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base . '/(?P<metadatum_id>[\d]+)',
|
||||||
array(
|
array(
|
||||||
|
array(
|
||||||
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
|
'callback' => array($this, 'get_item'),
|
||||||
|
'permission_callback' => array($this, 'get_item_permissions_check'),
|
||||||
|
'args' => array(
|
||||||
|
'context' => array(
|
||||||
|
'type' => 'string',
|
||||||
|
'default' => 'view',
|
||||||
|
'description' => 'The context in which the request is made.',
|
||||||
|
'enum' => array(
|
||||||
|
'view',
|
||||||
|
'edit'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::EDITABLE,
|
'methods' => \WP_REST_Server::EDITABLE,
|
||||||
'callback' => array($this, 'update_item'),
|
'callback' => array($this, 'update_item'),
|
||||||
'permission_callback' => array($this, 'update_item_permissions_check'),
|
'permission_callback' => array($this, 'update_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE)
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE)
|
||||||
),
|
),
|
||||||
// ENDPOINT X. THIS ENDPOINT DO THE SAME THING OF ENDPOINT Z. I hope in a brief future it function changes.
|
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::DELETABLE,
|
'methods' => \WP_REST_Server::DELETABLE,
|
||||||
'callback' => array($this, 'delete_item'),
|
'callback' => array($this, 'delete_item'),
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
||||||
),
|
),
|
||||||
array(
|
'schema' => [$this, 'get_schema']
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
|
||||||
'callback' => array($this, 'get_item'),
|
|
||||||
'permission_callback' => array($this, 'get_item_permissions_check'),
|
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base,
|
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base,
|
||||||
|
@ -70,7 +80,7 @@ class REST_Metadata_Controller extends REST_Controller {
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_collection_params(),
|
'args' => $this->get_wp_query_params(),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::CREATABLE,
|
'methods' => \WP_REST_Server::CREATABLE,
|
||||||
|
@ -78,31 +88,43 @@ class REST_Metadata_Controller extends REST_Controller {
|
||||||
'permission_callback' => array($this, 'create_item_permissions_check'),
|
'permission_callback' => array($this, 'create_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
|
||||||
),
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
register_rest_route($this->namespace, '/' . $this->rest_base,
|
register_rest_route($this->namespace, '/' . $this->rest_base,
|
||||||
array(
|
array(
|
||||||
|
array(
|
||||||
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
|
'callback' => array($this, 'get_items'),
|
||||||
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
|
'args' => $this->get_wp_query_params(),
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::CREATABLE,
|
'methods' => \WP_REST_Server::CREATABLE,
|
||||||
'callback' => array($this, 'create_item'),
|
'callback' => array($this, 'create_item'),
|
||||||
'permission_callback' => array($this, 'create_item_permissions_check'),
|
'permission_callback' => array($this, 'create_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE),
|
||||||
),
|
),
|
||||||
array(
|
'schema' => [$this, 'get_schema'],
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
|
||||||
'callback' => array($this, 'get_items'),
|
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
|
||||||
'args' => $this->get_collection_params(),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
register_rest_route($this->namespace, '/'. $this->rest_base . '/(?P<metadatum_id>[\d]+)',
|
register_rest_route($this->namespace, '/'. $this->rest_base . '/(?P<metadatum_id>[\d]+)',
|
||||||
array(
|
array(
|
||||||
// ENDPOINT Z.
|
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::DELETABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'delete_item'),
|
'callback' => array($this, 'get_item'),
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check')
|
'permission' => array($this, 'get_item_permissions_check'),
|
||||||
|
'args' => array(
|
||||||
|
'context' => array(
|
||||||
|
'type' => 'string',
|
||||||
|
'default' => 'view',
|
||||||
|
'description' => 'The context in which the request is made.',
|
||||||
|
'enum' => array(
|
||||||
|
'view',
|
||||||
|
'edit'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::EDITABLE,
|
'methods' => \WP_REST_Server::EDITABLE,
|
||||||
|
@ -111,11 +133,11 @@ class REST_Metadata_Controller extends REST_Controller {
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE)
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE)
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::DELETABLE,
|
||||||
'callback' => array($this, 'get_item'),
|
'callback' => array($this, 'delete_item'),
|
||||||
'permission' => array($this, 'get_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check')
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE)
|
),
|
||||||
)
|
'schema' => [$this, 'get_schema'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -536,10 +558,10 @@ class REST_Metadata_Controller extends REST_Controller {
|
||||||
*
|
*
|
||||||
* @return array|void
|
* @return array|void
|
||||||
*/
|
*/
|
||||||
public function get_collection_params( $object_name = null ) {
|
public function get_wp_query_params() {
|
||||||
$query_params['context']['default'] = 'view';
|
$query_params['context']['default'] = 'view';
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_collection_params('metadatum'));
|
$query_params = array_merge($query_params, parent::get_wp_query_params());
|
||||||
|
|
||||||
$query_params['name'] = array(
|
$query_params['name'] = array(
|
||||||
'description' => __('Limits the result set to metadata with a specific name'),
|
'description' => __('Limits the result set to metadata with a specific name'),
|
||||||
|
@ -560,10 +582,9 @@ class REST_Metadata_Controller extends REST_Controller {
|
||||||
public function get_endpoint_args_for_item_schema( $method = null ) {
|
public function get_endpoint_args_for_item_schema( $method = null ) {
|
||||||
$endpoint_args = [];
|
$endpoint_args = [];
|
||||||
if($method === \WP_REST_Server::READABLE) {
|
if($method === \WP_REST_Server::READABLE) {
|
||||||
$endpoint_args['context'] = array(
|
$endpoint_args = array_merge(
|
||||||
'type' => 'string',
|
$endpoint_args,
|
||||||
'default' => 'view',
|
parent::get_wp_query_params()
|
||||||
'items' => array( 'view, edit' )
|
|
||||||
);
|
);
|
||||||
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
||||||
$map = $this->metadatum_repository->get_map();
|
$map = $this->metadatum_repository->get_map();
|
||||||
|
@ -582,6 +603,32 @@ class REST_Metadata_Controller extends REST_Controller {
|
||||||
|
|
||||||
return $endpoint_args;
|
return $endpoint_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_schema() {
|
||||||
|
$schema = [
|
||||||
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
||||||
|
'title' => 'metadatum',
|
||||||
|
'type' => 'object'
|
||||||
|
];
|
||||||
|
|
||||||
|
$main_schema = parent::get_repository_schema( $this->metadatum_repository );
|
||||||
|
$permissions_schema = parent::get_permissions_schema();
|
||||||
|
|
||||||
|
// $item_metadata_scheme = parent::get_repository_schema( $this->item_metadata_repository );
|
||||||
|
// $item_scheme = parent::get_repository_schema( $this->item_repository );
|
||||||
|
// $collection_scheme = parent::get_repository_schema( $this->collection_repository );
|
||||||
|
|
||||||
|
$schema['properties'] = array_merge(
|
||||||
|
parent::get_base_properties_schema(),
|
||||||
|
$main_schema,
|
||||||
|
$permissions_schema
|
||||||
|
// $item_metadata_scheme,
|
||||||
|
// $item_scheme,
|
||||||
|
// $collection_scheme
|
||||||
|
);
|
||||||
|
|
||||||
|
return $schema;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -36,14 +36,15 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_collection_params()
|
'args' => $this->get_wp_query_params()
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::CREATABLE,
|
'methods' => \WP_REST_Server::CREATABLE,
|
||||||
'callback' => array($this, 'create_item'),
|
'callback' => array($this, 'create_item'),
|
||||||
'permission_callback' => array($this, 'create_item_permissions_check'),
|
'permission_callback' => array($this, 'create_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE)
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::CREATABLE)
|
||||||
)
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
register_rest_route(
|
register_rest_route(
|
||||||
|
@ -53,7 +54,21 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_item'),
|
'callback' => array($this, 'get_item'),
|
||||||
'permission_callback' => array($this, 'get_item_permissions_check'),
|
'permission_callback' => array($this, 'get_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE)
|
'args' => array(
|
||||||
|
'context' => array(
|
||||||
|
'type' => 'string',
|
||||||
|
'default' => 'view',
|
||||||
|
'description' => 'The context in which the request is made.',
|
||||||
|
'enum' => array(
|
||||||
|
'view',
|
||||||
|
'edit'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'fetch_only' => array(
|
||||||
|
'type' => 'string/array',
|
||||||
|
'description' => __( 'Fetch only specific attribute. The specifics attributes are the same in schema.', 'tainacan' ),
|
||||||
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'methods' => \WP_REST_Server::DELETABLE,
|
'methods' => \WP_REST_Server::DELETABLE,
|
||||||
|
@ -61,8 +76,8 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
||||||
'args' => array(
|
'args' => array(
|
||||||
'permanently' => array(
|
'permanently' => array(
|
||||||
'description' => __('To delete permanently, you can pass \'permanently\' as true. By default this will only trash collection'),
|
'description' => __('To delete permanently, you can pass \'permanently\' as 1. By default this will only trash collection'),
|
||||||
'default' => 'false',
|
'default' => '0',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -71,7 +86,8 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
||||||
'callback' => array($this, 'update_item'),
|
'callback' => array($this, 'update_item'),
|
||||||
'permission_callback' => array($this, 'update_item_permissions_check'),
|
'permission_callback' => array($this, 'update_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE)
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE)
|
||||||
)
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
register_rest_route(
|
register_rest_route(
|
||||||
|
@ -82,7 +98,8 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
||||||
'callback' => array($this, 'update_item'),
|
'callback' => array($this, 'update_item'),
|
||||||
'permission_callback' => array($this, 'update_item_permissions_check'),
|
'permission_callback' => array($this, 'update_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE)
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::EDITABLE)
|
||||||
)
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -449,15 +466,10 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
||||||
public function get_endpoint_args_for_item_schema( $method = null ) {
|
public function get_endpoint_args_for_item_schema( $method = null ) {
|
||||||
$endpoint_args = [];
|
$endpoint_args = [];
|
||||||
if($method === \WP_REST_Server::READABLE) {
|
if($method === \WP_REST_Server::READABLE) {
|
||||||
$endpoint_args['fetch_only'] = array(
|
$endpoint_args = array_merge(
|
||||||
'type' => 'string/array',
|
$endpoint_args,
|
||||||
'description' => __( 'Fetch only specific attribute. The specifics attributes are the same in schema.' ),
|
parent::get_wp_query_params(),
|
||||||
);
|
parent::get_fetch_only_param()
|
||||||
|
|
||||||
$endpoint_args['context'] = array(
|
|
||||||
'type' => 'string',
|
|
||||||
'default' => 'view',
|
|
||||||
'items' => array( 'view, edit' )
|
|
||||||
);
|
);
|
||||||
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
||||||
$map = $this->taxonomy_repository->get_map();
|
$map = $this->taxonomy_repository->get_map();
|
||||||
|
@ -485,10 +497,10 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_collection_params($object_name = null) {
|
public function get_wp_query_params() {
|
||||||
$query_params['context']['default'] = 'view';
|
$query_params['context']['default'] = 'view';
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_collection_params('tax'));
|
$query_params = array_merge($query_params, parent::get_wp_query_params());
|
||||||
|
|
||||||
$query_params['name'] = array(
|
$query_params['name'] = array(
|
||||||
'description' => __('Limits the result set to a taxonomy with a specific name.'),
|
'description' => __('Limits the result set to a taxonomy with a specific name.'),
|
||||||
|
@ -499,6 +511,26 @@ class REST_Taxonomies_Controller extends REST_Controller {
|
||||||
|
|
||||||
return $query_params;
|
return $query_params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_schema() {
|
||||||
|
$schema = [
|
||||||
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
||||||
|
'title' => 'taxonomy',
|
||||||
|
'type' => 'object'
|
||||||
|
];
|
||||||
|
|
||||||
|
$main_schema = parent::get_repository_schema( $this->taxonomy_repository );
|
||||||
|
$permissions_schema = parent::get_permissions_schema();
|
||||||
|
|
||||||
|
$schema['properties'] = array_merge(
|
||||||
|
parent::get_base_properties_schema(),
|
||||||
|
$main_schema,
|
||||||
|
$permissions_schema
|
||||||
|
);
|
||||||
|
|
||||||
|
return $schema;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -44,8 +44,9 @@ class REST_Terms_Controller extends REST_Controller {
|
||||||
'methods' => \WP_REST_Server::READABLE,
|
'methods' => \WP_REST_Server::READABLE,
|
||||||
'callback' => array($this, 'get_items'),
|
'callback' => array($this, 'get_items'),
|
||||||
'permission_callback' => array($this, 'get_items_permissions_check'),
|
'permission_callback' => array($this, 'get_items_permissions_check'),
|
||||||
'args' => $this->get_collection_params()
|
'args' => $this->get_wp_query_params()
|
||||||
)
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
register_rest_route($this->namespace,'/taxonomy/(?P<taxonomy_id>[\d]+)/'. $this->rest_base . '/(?P<term_id>[\d]+)' ,
|
register_rest_route($this->namespace,'/taxonomy/(?P<taxonomy_id>[\d]+)/'. $this->rest_base . '/(?P<term_id>[\d]+)' ,
|
||||||
|
@ -55,8 +56,9 @@ class REST_Terms_Controller extends REST_Controller {
|
||||||
'callback' => array($this, 'delete_item'),
|
'callback' => array($this, 'delete_item'),
|
||||||
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
'permission_callback' => array($this, 'delete_item_permissions_check'),
|
||||||
'args' => [
|
'args' => [
|
||||||
'info' => [
|
'permanently' => [
|
||||||
'description' => __('Delete term permanently.')
|
'description' => __('Delete term permanently.'),
|
||||||
|
'default' => '1'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
@ -71,7 +73,8 @@ class REST_Terms_Controller extends REST_Controller {
|
||||||
'callback' => array($this, 'get_item'),
|
'callback' => array($this, 'get_item'),
|
||||||
'permission_callback' => array($this, 'get_item_permissions_check'),
|
'permission_callback' => array($this, 'get_item_permissions_check'),
|
||||||
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE)
|
'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE)
|
||||||
)
|
),
|
||||||
|
'schema' => [$this, 'get_schema']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -418,10 +421,9 @@ class REST_Terms_Controller extends REST_Controller {
|
||||||
public function get_endpoint_args_for_item_schema( $method = null ) {
|
public function get_endpoint_args_for_item_schema( $method = null ) {
|
||||||
$endpoint_args = [];
|
$endpoint_args = [];
|
||||||
if($method === \WP_REST_Server::READABLE) {
|
if($method === \WP_REST_Server::READABLE) {
|
||||||
$endpoint_args['context'] = array(
|
$endpoint_args = array_merge(
|
||||||
'type' => 'string',
|
$endpoint_args,
|
||||||
'default' => 'view',
|
parent::get_wp_query_params()
|
||||||
'items' => array( 'view, edit' )
|
|
||||||
);
|
);
|
||||||
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
} elseif ($method === \WP_REST_Server::CREATABLE || $method === \WP_REST_Server::EDITABLE) {
|
||||||
$map = $this->terms_repository->get_map();
|
$map = $this->terms_repository->get_map();
|
||||||
|
@ -449,10 +451,10 @@ class REST_Terms_Controller extends REST_Controller {
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_collection_params($object_name = null) {
|
public function get_wp_query_params() {
|
||||||
$query_params['context']['default'] = 'view';
|
$query_params['context']['default'] = 'view';
|
||||||
|
|
||||||
$query_params = array_merge($query_params, parent::get_collection_params('term'));
|
$query_params = array_merge($query_params, parent::get_wp_query_params());
|
||||||
|
|
||||||
$query_params['name'] = array(
|
$query_params['name'] = array(
|
||||||
'description' => __('Limits the result set to terms with a specific name'),
|
'description' => __('Limits the result set to terms with a specific name'),
|
||||||
|
@ -463,6 +465,28 @@ class REST_Terms_Controller extends REST_Controller {
|
||||||
|
|
||||||
return $query_params;
|
return $query_params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_schema() {
|
||||||
|
$schema = [
|
||||||
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
||||||
|
'title' => 'term',
|
||||||
|
'type' => 'object'
|
||||||
|
];
|
||||||
|
|
||||||
|
$main_schema = parent::get_repository_schema( $this->terms_repository );
|
||||||
|
$permissions_schema = parent::get_permissions_schema();
|
||||||
|
|
||||||
|
// $taxonomy_scheme = parent::get_repository_schema( $this->taxonomy_repository );
|
||||||
|
|
||||||
|
$schema['properties'] = array_merge(
|
||||||
|
parent::get_base_properties_schema(),
|
||||||
|
$main_schema,
|
||||||
|
$permissions_schema
|
||||||
|
// $taxonomy_scheme
|
||||||
|
);
|
||||||
|
|
||||||
|
return $schema;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -18,7 +18,6 @@ $rest_exporters_controller = new \Tainacan\API\EndPoints\REST_Exporters_Contr
|
||||||
$rest_background_processes_controller = new \Tainacan\API\EndPoints\REST_Background_Processes_Controller();
|
$rest_background_processes_controller = new \Tainacan\API\EndPoints\REST_Background_Processes_Controller();
|
||||||
$rest_bulkedit_controller = new \Tainacan\API\EndPoints\REST_Bulkedit_Controller();
|
$rest_bulkedit_controller = new \Tainacan\API\EndPoints\REST_Bulkedit_Controller();
|
||||||
$rest_exposers_controller = new \Tainacan\API\EndPoints\REST_Exposers_Controller();
|
$rest_exposers_controller = new \Tainacan\API\EndPoints\REST_Exposers_Controller();
|
||||||
new \Tainacan\API\EndPoints\REST_Export_Controller();
|
|
||||||
new \Tainacan\API\EndPoints\REST_Metadatum_Mappers_Controller();
|
new \Tainacan\API\EndPoints\REST_Metadatum_Mappers_Controller();
|
||||||
$rest_facets_controller = new \Tainacan\API\EndPoints\REST_Facets_Controller();
|
$rest_facets_controller = new \Tainacan\API\EndPoints\REST_Facets_Controller();
|
||||||
$rest_oaipmh_expose_controller = new \Tainacan\API\EndPoints\REST_Oaipmh_Expose_Controller();
|
$rest_oaipmh_expose_controller = new \Tainacan\API\EndPoints\REST_Oaipmh_Expose_Controller();
|
||||||
|
|
|
@ -0,0 +1,424 @@
|
||||||
|
[data-align='full'] .block-control {
|
||||||
|
width: calc(100% + 14px); }
|
||||||
|
|
||||||
|
.block-control {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 5px;
|
||||||
|
position: relative;
|
||||||
|
top: -14px;
|
||||||
|
left: -14px;
|
||||||
|
width: calc(100% + 28px);
|
||||||
|
background: #f2f2f2; }
|
||||||
|
.block-control p {
|
||||||
|
font-size: 0.875rem !important;
|
||||||
|
margin: 12px 1.5rem 16px 0;
|
||||||
|
fill: #555758; }
|
||||||
|
.block-control p svg {
|
||||||
|
top: 4px;
|
||||||
|
margin-right: 0.75rem;
|
||||||
|
position: relative;
|
||||||
|
fill: #555758; }
|
||||||
|
|
||||||
|
.components-placeholder__fieldset p {
|
||||||
|
font-size: 0.875rem !important;
|
||||||
|
margin-top: -2px;
|
||||||
|
fill: #555758; }
|
||||||
|
.components-placeholder__fieldset p svg {
|
||||||
|
margin-right: 1rem;
|
||||||
|
top: 4px;
|
||||||
|
position: relative;
|
||||||
|
fill: #555758; }
|
||||||
|
|
||||||
|
.wp-block-tainacan-modal {
|
||||||
|
width: 50%; }
|
||||||
|
@media only screen and (max-width: 1024px) {
|
||||||
|
.wp-block-tainacan-modal {
|
||||||
|
width: 75%; } }
|
||||||
|
@media only screen and (max-width: 768px) {
|
||||||
|
.wp-block-tainacan-modal {
|
||||||
|
width: 100%; } }
|
||||||
|
.wp-block-tainacan-modal.dynamic-modal {
|
||||||
|
width: 90%;
|
||||||
|
height: 90%;
|
||||||
|
width: 80vw;
|
||||||
|
height: 80vh; }
|
||||||
|
.wp-block-tainacan-modal.dynamic-modal iframe {
|
||||||
|
width: calc(100% + 32px);
|
||||||
|
height: calc(100% - 128px);
|
||||||
|
margin-left: -16px; }
|
||||||
|
.wp-block-tainacan-modal.dynamic-modal .modal-footer-area {
|
||||||
|
height: 68px;
|
||||||
|
width: calc(100% + 32px);
|
||||||
|
margin-left: -16px !important;
|
||||||
|
padding: 1.2rem 1.2rem !important;
|
||||||
|
border-top: 1px solid #cbcbcb; }
|
||||||
|
.wp-block-tainacan-modal .spinner-container {
|
||||||
|
min-height: 56px;
|
||||||
|
padding: 1rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #555758; }
|
||||||
|
.wp-block-tainacan-modal .spinner-container .components-spineer {
|
||||||
|
margin: 8px; }
|
||||||
|
.wp-block-tainacan-modal .components-modal__header .components-icon-button {
|
||||||
|
padding-right: 0; }
|
||||||
|
.wp-block-tainacan-modal hr {
|
||||||
|
margin: 5px 0.75rem; }
|
||||||
|
.wp-block-tainacan-modal .modal-search-area {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 14px; }
|
||||||
|
.wp-block-tainacan-modal .modal-search-area .components-base-control {
|
||||||
|
width: 60%; }
|
||||||
|
@media only screen and (max-width: 1024px) {
|
||||||
|
.wp-block-tainacan-modal .modal-search-area .components-base-control {
|
||||||
|
width: 95%; } }
|
||||||
|
.wp-block-tainacan-modal .modal-search-area .components-base-control:nth-child(2) {
|
||||||
|
flex-shrink: 2; }
|
||||||
|
.wp-block-tainacan-modal .modal-search-area .components-base-control .components-base-control__field {
|
||||||
|
flex-wrap: wrap; }
|
||||||
|
.wp-block-tainacan-modal .modal-search-area .components-base-control label.components-base-control__label {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #454647;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
text-align: center; }
|
||||||
|
.wp-block-tainacan-modal .modal-search-area .components-base-control input.components-text-control__input {
|
||||||
|
padding: 5px 8px;
|
||||||
|
height: 28px; }
|
||||||
|
.wp-block-tainacan-modal .modal-radio-area-label {
|
||||||
|
font-weight: 500;
|
||||||
|
margin-left: 1.75rem; }
|
||||||
|
.wp-block-tainacan-modal .modal-checkbox-list,
|
||||||
|
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field {
|
||||||
|
padding: 0;
|
||||||
|
display: -ms-grid;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, 250px);
|
||||||
|
grid-gap: 0px;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 12px;
|
||||||
|
max-height: 50vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden; }
|
||||||
|
.wp-block-tainacan-modal .modal-checkbox-list .components-base-control,
|
||||||
|
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-base-control {
|
||||||
|
overflow: hidden; }
|
||||||
|
.wp-block-tainacan-modal .modal-checkbox-list .modal-checkbox-list-item,
|
||||||
|
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option,
|
||||||
|
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .modal-checkbox-list-item,
|
||||||
|
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-radio-control__option {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start; }
|
||||||
|
.wp-block-tainacan-modal .modal-checkbox-list .modal-checkbox-list-item img,
|
||||||
|
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option img,
|
||||||
|
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .modal-checkbox-list-item img,
|
||||||
|
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-radio-control__option img {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
margin-right: 10px; }
|
||||||
|
.wp-block-tainacan-modal .modal-checkbox-list .modal-checkbox-list-item label,
|
||||||
|
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option label,
|
||||||
|
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .modal-checkbox-list-item label,
|
||||||
|
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-radio-control__option label {
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 85%; }
|
||||||
|
@media only screen and (max-width: 768px) {
|
||||||
|
.wp-block-tainacan-modal .modal-checkbox-list .modal-checkbox-list-item label,
|
||||||
|
.wp-block-tainacan-modal .modal-checkbox-list .components-radio-control__option label,
|
||||||
|
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .modal-checkbox-list-item label,
|
||||||
|
.wp-block-tainacan-modal .modal-radio-list .components-base-control__field .components-radio-control__option label {
|
||||||
|
max-width: 80%; } }
|
||||||
|
.wp-block-tainacan-modal .modal-loadmore-section {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: center; }
|
||||||
|
.wp-block-tainacan-modal .modal-loadmore-section p {
|
||||||
|
color: #555758;
|
||||||
|
margin-right: 12px;
|
||||||
|
margin-top: 2px; }
|
||||||
|
.wp-block-tainacan-modal .modal-footer-area {
|
||||||
|
border-top: 1px solid #e2e4e7;
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 16px 16px 0 16px;
|
||||||
|
margin: 0 -16px; }
|
||||||
|
.wp-block-tainacan-modal .modal-footer-area p {
|
||||||
|
padding: 0 12px;
|
||||||
|
color: #454647; }
|
||||||
|
|
||||||
|
.components-panel__body .term-carousel-view-modes {
|
||||||
|
display: flex;
|
||||||
|
margin: 12px 0 24px 0; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button {
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid #cbcbcb;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 2px;
|
||||||
|
margin: 0;
|
||||||
|
width: calc(50% - 6px);
|
||||||
|
flex-shrink: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: border ease 0.5s, opacity ease 0.5; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button.term-carousel-view-mode-grid {
|
||||||
|
margin-right: 6px; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button.term-carousel-view-mode-grid div {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 33% 33% 33%;
|
||||||
|
grid-template-rows: 50% 50%;
|
||||||
|
grid-column-gap: 2px;
|
||||||
|
grid-row-gap: 2px;
|
||||||
|
width: 60px;
|
||||||
|
height: 40px;
|
||||||
|
margin: 4px auto 8px auto; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button.term-carousel-view-mode-grid div > div:first-of-type {
|
||||||
|
grid-column-start: 1;
|
||||||
|
grid-column-end: span 2;
|
||||||
|
grid-row-start: 1;
|
||||||
|
grid-row-end: span 2;
|
||||||
|
width: 41px;
|
||||||
|
height: 42px; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button.term-carousel-view-mode-grid div > div {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
background: #555758;
|
||||||
|
transition: background-color ease 0.5s; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button.term-carousel-view-mode-thumbnail {
|
||||||
|
margin-left: 6px; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button.term-carousel-view-mode-thumbnail div {
|
||||||
|
display: block;
|
||||||
|
height: 40px;
|
||||||
|
width: 40px;
|
||||||
|
background: #555758;
|
||||||
|
margin: 4px auto 8px auto;
|
||||||
|
transition: background-color ease 0.5s; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button label {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: #555758; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button.is-active {
|
||||||
|
border: 2px solid #298596; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button.is-active.term-carousel-view-mode-thumbnail div, .components-panel__body .term-carousel-view-modes button.is-active.term-carousel-view-mode-grid div > div {
|
||||||
|
background-color: #298596; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
border-width: 2px; }
|
||||||
|
.components-panel__body .term-carousel-view-modes button:hover button {
|
||||||
|
background: #f2f2f2; }
|
||||||
|
|
||||||
|
.wp-block-tainacan-carousel-terms-list {
|
||||||
|
margin: 2rem 0px; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .spinner-container {
|
||||||
|
min-height: 56px;
|
||||||
|
padding: 1rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #555758; }
|
||||||
|
@-webkit-keyframes skeleton-animation {
|
||||||
|
0% {
|
||||||
|
opacity: 1.0; }
|
||||||
|
50% {
|
||||||
|
opacity: 0.2; }
|
||||||
|
100% {
|
||||||
|
opacity: 1.0; } }
|
||||||
|
@-moz-keyframes skeleton-animation {
|
||||||
|
0% {
|
||||||
|
opacity: 1.0; }
|
||||||
|
50% {
|
||||||
|
opacity: 0.2; }
|
||||||
|
100% {
|
||||||
|
opacity: 1.0; } }
|
||||||
|
@-o-keyframes skeleton-animation {
|
||||||
|
0% {
|
||||||
|
opacity: 1.0; }
|
||||||
|
50% {
|
||||||
|
opacity: 0.2; }
|
||||||
|
100% {
|
||||||
|
opacity: 1.0; } }
|
||||||
|
@keyframes skeleton-animation {
|
||||||
|
0% {
|
||||||
|
opacity: 1.0; }
|
||||||
|
50% {
|
||||||
|
opacity: 0.2; }
|
||||||
|
100% {
|
||||||
|
opacity: 1.0; } }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .skeleton {
|
||||||
|
border-radius: 2px;
|
||||||
|
background: #f2f2f2;
|
||||||
|
-webkit-animation: skeleton-animation 1.8s ease infinite;
|
||||||
|
-moz-animation: skeleton-animation 1.8s ease infinite;
|
||||||
|
-o-animation: skeleton-animation 1.8s ease infinite;
|
||||||
|
animation: skeleton-animation 1.8s ease infinite; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel {
|
||||||
|
position: relative;
|
||||||
|
width: calc(100% + 40px);
|
||||||
|
left: -20px; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel .swiper-container {
|
||||||
|
margin: 0 50px; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel .swiper-container a > span,
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel .swiper-container a:hover > span {
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 8px 16px;
|
||||||
|
display: block;
|
||||||
|
line-height: 1.2rem; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel .swiper-container a > img {
|
||||||
|
width: 100%;
|
||||||
|
height: auto; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel .swiper-container a:hover {
|
||||||
|
text-decoration: none; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel .swiper-container .swiper-slide.term-list-item-grid a {
|
||||||
|
width: 100%;
|
||||||
|
display: block; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel .swiper-container .swiper-slide.term-list-item-grid .term-items-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 33% 33% 33%;
|
||||||
|
grid-template-rows: 50% 50%;
|
||||||
|
width: 100%; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel .swiper-container .swiper-slide.term-list-item-grid .term-items-grid img:first-of-type {
|
||||||
|
grid-column-start: 1;
|
||||||
|
grid-column-end: span 2;
|
||||||
|
grid-row-start: 1;
|
||||||
|
grid-row-end: span 2; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel .swiper-container .swiper-slide.term-list-item-grid .term-items-grid img {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
padding: 2px;
|
||||||
|
margin-bottom: 0px; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .preview-warning {
|
||||||
|
width: 100%;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-style: italic;
|
||||||
|
color: #898d8f;
|
||||||
|
text-align: center;
|
||||||
|
margin: 4px auto; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .swiper-button-prev, .wp-block-tainacan-carousel-terms-list .swiper-button-next {
|
||||||
|
top: calc(50% - 42px);
|
||||||
|
bottom: initial;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
width: 42px;
|
||||||
|
height: 42px;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0 -4px; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .swiper-button-prev svg, .wp-block-tainacan-carousel-terms-list .swiper-button-next svg {
|
||||||
|
fill: #298596; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .terms-list-edit-container,
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel {
|
||||||
|
position: relative; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .terms-list-edit-container .skeleton,
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel .skeleton {
|
||||||
|
min-height: 150px;
|
||||||
|
max-height: 150px; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .terms-list-edit-container.has-arrows-none .swiper-button-prev, .wp-block-tainacan-carousel-terms-list .terms-list-edit-container.has-arrows-none .swiper-button-next,
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel.has-arrows-none .swiper-button-prev,
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel.has-arrows-none .swiper-button-next {
|
||||||
|
display: none; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .terms-list-edit-container.has-arrows-left .swiper-button-next,
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel.has-arrows-left .swiper-button-next {
|
||||||
|
left: 10px;
|
||||||
|
right: auto;
|
||||||
|
top: calc(50% + 12px) !important; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .terms-list-edit-container.has-arrows-right .swiper-button-prev,
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel.has-arrows-right .swiper-button-prev {
|
||||||
|
right: 10px;
|
||||||
|
left: auto; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list .terms-list-edit-container.has-arrows-right .swiper-button-next,
|
||||||
|
.wp-block-tainacan-carousel-terms-list .tainacan-carousel.has-arrows-right .swiper-button-next {
|
||||||
|
top: calc(50% + 12px) !important; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
overflow-x: scroll;
|
||||||
|
list-style: none;
|
||||||
|
margin: 0 36px; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item {
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
margin: 16px 32px 16px 0px;
|
||||||
|
width: calc(16.666% - 32px);
|
||||||
|
min-width: calc(16.666% - 32px); }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item.term-list-item-grid {
|
||||||
|
margin: 16px;
|
||||||
|
width: calc(25% - 16px);
|
||||||
|
min-width: calc(25% - 16px); }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item a {
|
||||||
|
color: #454647;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: normal; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item img {
|
||||||
|
height: auto;
|
||||||
|
padding: 0px;
|
||||||
|
margin-bottom: 0.5rem; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item:hover a {
|
||||||
|
color: #454647;
|
||||||
|
text-decoration: none; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item button {
|
||||||
|
position: absolute !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.75);
|
||||||
|
color: #454647;
|
||||||
|
padding: 2px;
|
||||||
|
margin-left: 5px;
|
||||||
|
min-width: 14px;
|
||||||
|
visibility: hidden;
|
||||||
|
position: relative;
|
||||||
|
opacity: 0;
|
||||||
|
right: -14px;
|
||||||
|
top: 0px;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 999; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item:hover button {
|
||||||
|
visibility: visible;
|
||||||
|
background-color: white !important;
|
||||||
|
opacity: 1;
|
||||||
|
right: -8px;
|
||||||
|
top: -8px;
|
||||||
|
border: 1px solid #cbcbcb;
|
||||||
|
border-radius: 12px;
|
||||||
|
transition: opacity linear 0.15s, right linear 0.15s; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item:hover button:hover {
|
||||||
|
background-color: white !important;
|
||||||
|
border: 1px solid #cbcbcb !important; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item .term-items-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 33% 33% 33%;
|
||||||
|
grid-template-rows: 50% 50%; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item .term-items-grid img:first-of-type {
|
||||||
|
grid-column-start: 1;
|
||||||
|
grid-column-end: span 2;
|
||||||
|
grid-row-start: 1;
|
||||||
|
grid-row-end: span 2; }
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item .term-items-grid img {
|
||||||
|
padding: 2px;
|
||||||
|
margin-bottom: 0px; }
|
||||||
|
@media only screen and (max-width: 1686px) {
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item {
|
||||||
|
width: calc(20% - 32px);
|
||||||
|
min-width: calc(20% - 32px); } }
|
||||||
|
@media only screen and (max-width: 1452px) {
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item {
|
||||||
|
width: calc(25% - 32px);
|
||||||
|
min-width: calc(25% - 32px); } }
|
||||||
|
@media only screen and (max-width: 1118px) {
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-edit li.term-list-item {
|
||||||
|
width: calc(33.333% - 32px);
|
||||||
|
min-width: calc(33.333% - 32px); } }
|
||||||
|
@media only screen and (max-width: 854px) {
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item {
|
||||||
|
width: calc(50% - 32px);
|
||||||
|
min-width: calc(50% - 32px); } }
|
||||||
|
@media only screen and (max-width: 584px) {
|
||||||
|
.wp-block-tainacan-carousel-terms-list ul.terms-list-edit li.term-list-item {
|
||||||
|
width: calc(100% - 32px);
|
||||||
|
min-width: calc(100% - 32px); } }
|
||||||
|
|
||||||
|
/*# sourceMappingURL=tainacan-gutenberg-block-carousel-terms-list.css.map */
|
File diff suppressed because one or more lines are too long
|
@ -12,18 +12,10 @@ namespace Tainacan;
|
||||||
|
|
||||||
defined( 'ABSPATH' ) || exit;
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
if ( ! class_exists( 'WP_Async_Request', false ) ) {
|
|
||||||
include_once TAINACAN_CLASSES_DIR . '/lib/wp-async-request.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! class_exists( 'WP_Background_Process', false ) ) {
|
|
||||||
include_once TAINACAN_CLASSES_DIR . '/lib/wp-background-process.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tainacan_Background_Process class.
|
* Tainacan_Background_Process class.
|
||||||
*/
|
*/
|
||||||
abstract class Background_Process extends \WP_Background_Process {
|
abstract class Background_Process extends \Tainacan_WP_Background_Process {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table name where the queue is stored
|
* Table name where the queue is stored
|
||||||
|
|
|
@ -584,7 +584,7 @@ class Elastic_Press {
|
||||||
}
|
}
|
||||||
|
|
||||||
if($search != '') {
|
if($search != '') {
|
||||||
$formatted_args['query']['bool']['must'][] = ["wildcard"=>["$field.name.raw" => "*$search*"]];
|
$formatted_args['query']['bool']['must'][] = ["wildcard"=>["$field.name.sortable" => "*$search*"]];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$aggs[$id] = [
|
$aggs[$id] = [
|
||||||
|
@ -613,7 +613,7 @@ class Elastic_Press {
|
||||||
$field_relationship_label = "$field_relationship_label[0].$field_relationship_label[1].relationship_label";
|
$field_relationship_label = "$field_relationship_label[0].$field_relationship_label[1].relationship_label";
|
||||||
//$formatted_args['query']['bool']['must'][] = ["wildcard"=>["$field" => "*$search*"]];
|
//$formatted_args['query']['bool']['must'][] = ["wildcard"=>["$field" => "*$search*"]];
|
||||||
$formatted_args['query']['bool']['must'][] = ["bool"=>["should"=>[
|
$formatted_args['query']['bool']['must'][] = ["bool"=>["should"=>[
|
||||||
["wildcard"=>["$field"=>"*$search*"]],
|
["wildcard"=>["$id.value.sortable"=>"*$search*"]],
|
||||||
["wildcard"=>["$field_relationship_label"=>"*$search*"]] //pega nome do metadado é melhor!
|
["wildcard"=>["$field_relationship_label"=>"*$search*"]] //pega nome do metadado é melhor!
|
||||||
]]];
|
]]];
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ class Private_Files {
|
||||||
|
|
||||||
private static $instance = null;
|
private static $instance = null;
|
||||||
|
|
||||||
|
public $dir_separator;
|
||||||
|
|
||||||
public static function get_instance() {
|
public static function get_instance() {
|
||||||
if(!isset(self::$instance)) {
|
if(!isset(self::$instance)) {
|
||||||
self::$instance = new self();
|
self::$instance = new self();
|
||||||
|
@ -20,6 +22,11 @@ class Private_Files {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function __construct() {
|
protected function __construct() {
|
||||||
|
|
||||||
|
// Once upon a time I thought I had to worry about Windows and use DIRECTORY_SEPARATOR
|
||||||
|
// but this only gave me frustration and bugs.
|
||||||
|
$this->dir_separator = '/';
|
||||||
|
|
||||||
add_filter('wp_handle_upload_prefilter', [$this, 'pre_upload']);
|
add_filter('wp_handle_upload_prefilter', [$this, 'pre_upload']);
|
||||||
add_filter('wp_handle_sideload_prefilter', [$this, 'pre_upload']);
|
add_filter('wp_handle_sideload_prefilter', [$this, 'pre_upload']);
|
||||||
add_filter('wp_handle_upload', [$this, 'post_upload']);
|
add_filter('wp_handle_upload', [$this, 'post_upload']);
|
||||||
|
@ -31,7 +38,7 @@ class Private_Files {
|
||||||
add_filter('image_get_intermediate_size', [$this, 'image_get_intermediate_size'], 10, 3);
|
add_filter('image_get_intermediate_size', [$this, 'image_get_intermediate_size'], 10, 3);
|
||||||
add_filter('wp_get_attachment_url', [$this, 'wp_get_attachment_url'], 10, 2);
|
add_filter('wp_get_attachment_url', [$this, 'wp_get_attachment_url'], 10, 2);
|
||||||
|
|
||||||
add_action('tainacan-insert', [$this, 'update_item_and_collection'], 10, 3);
|
add_action('tainacan-insert', [$this, 'update_item_and_collection']);
|
||||||
|
|
||||||
add_action('tainacan-bulk-edit-set-status', [$this, 'bulk_edit'], 10, 4);
|
add_action('tainacan-bulk-edit-set-status', [$this, 'bulk_edit'], 10, 4);
|
||||||
|
|
||||||
|
@ -160,8 +167,8 @@ class Private_Files {
|
||||||
|
|
||||||
$path['path'] = str_replace($path['subdir'], '', $path['path']); //remove default subdir (year/month)
|
$path['path'] = str_replace($path['subdir'], '', $path['path']); //remove default subdir (year/month)
|
||||||
$path['url'] = str_replace($path['subdir'], '/' . $tainacan_basepath . '/' . $col_id_url . '/' . $item_id_url, $path['url']);
|
$path['url'] = str_replace($path['subdir'], '/' . $tainacan_basepath . '/' . $col_id_url . '/' . $item_id_url, $path['url']);
|
||||||
$path['path'] .= DIRECTORY_SEPARATOR . $tainacan_basepath . DIRECTORY_SEPARATOR . $col_id . '/' . $item_id;
|
$path['path'] .= $this->dir_separator . $tainacan_basepath . $this->dir_separator . $col_id . $this->dir_separator . $item_id;
|
||||||
$path['subdir'] = DIRECTORY_SEPARATOR . $tainacan_basepath . DIRECTORY_SEPARATOR . $col_id . '/' . $item_id;
|
$path['subdir'] = $this->dir_separator . $tainacan_basepath . $this->dir_separator . $col_id . $this->dir_separator . $item_id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,31 +200,31 @@ class Private_Files {
|
||||||
|
|
||||||
$requested_uri = str_replace('/' . $this->get_private_folder_prefix(), '/', $requested_uri);
|
$requested_uri = str_replace('/' . $this->get_private_folder_prefix(), '/', $requested_uri);
|
||||||
|
|
||||||
$file_path = \str_replace( '/', DIRECTORY_SEPARATOR, str_replace($base_upload_url, '', $requested_uri) );
|
$file_path = \str_replace( '/', $this->dir_separator, str_replace($base_upload_url, '', $requested_uri) );
|
||||||
|
|
||||||
$file = $upload_dir['basedir'] . $file_path;
|
$file = $upload_dir['basedir'] . $file_path;
|
||||||
|
|
||||||
$existing_file = false;
|
$existing_file = false;
|
||||||
|
|
||||||
$file_dirs = explode(DIRECTORY_SEPARATOR, $file);
|
$file_dirs = explode($this->dir_separator, $file);
|
||||||
$file_dirs_size = sizeof($file_dirs);
|
$file_dirs_size = sizeof($file_dirs);
|
||||||
|
|
||||||
$item_id = $file_dirs[$file_dirs_size-2];
|
$item_id = $file_dirs[$file_dirs_size-2];
|
||||||
$collection_id = $file_dirs[$file_dirs_size-3];
|
$collection_id = $file_dirs[$file_dirs_size-3];
|
||||||
|
|
||||||
// private item
|
// private item
|
||||||
$prefixed_file = str_replace( DIRECTORY_SEPARATOR . $item_id . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR . $this->get_private_folder_prefix() . $item_id . DIRECTORY_SEPARATOR, $file);
|
$prefixed_file = str_replace( $this->dir_separator . $item_id . $this->dir_separator, $this->dir_separator . $this->get_private_folder_prefix() . $item_id . $this->dir_separator, $file);
|
||||||
|
|
||||||
if ( \file_exists( $prefixed_file ) ) {
|
if ( \file_exists( $prefixed_file ) ) {
|
||||||
$existing_file = $prefixed_file;
|
$existing_file = $prefixed_file;
|
||||||
}
|
}
|
||||||
// private collection
|
// private collection
|
||||||
$prefixed_collection = str_replace( DIRECTORY_SEPARATOR . $collection_id . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR . $this->get_private_folder_prefix() . $collection_id . DIRECTORY_SEPARATOR, $file);
|
$prefixed_collection = str_replace( $this->dir_separator . $collection_id . $this->dir_separator, $this->dir_separator . $this->get_private_folder_prefix() . $collection_id . $this->dir_separator, $file);
|
||||||
if ( !$existing_file && \file_exists( $prefixed_collection ) ) {
|
if ( !$existing_file && \file_exists( $prefixed_collection ) ) {
|
||||||
$existing_file = $prefixed_collection;
|
$existing_file = $prefixed_collection;
|
||||||
}
|
}
|
||||||
// private both
|
// private both
|
||||||
$prefixed_both = str_replace( DIRECTORY_SEPARATOR . $collection_id . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR . $this->get_private_folder_prefix() . $collection_id . DIRECTORY_SEPARATOR, $prefixed_file);
|
$prefixed_both = str_replace( $this->dir_separator . $collection_id . $this->dir_separator, $this->dir_separator . $this->get_private_folder_prefix() . $collection_id . $this->dir_separator, $prefixed_file);
|
||||||
if ( !$existing_file && \file_exists( $prefixed_both ) ) {
|
if ( !$existing_file && \file_exists( $prefixed_both ) ) {
|
||||||
$existing_file = $prefixed_both;
|
$existing_file = $prefixed_both;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +262,7 @@ class Private_Files {
|
||||||
*/
|
*/
|
||||||
function image_get_intermediate_size($data, $post_id, $size) {
|
function image_get_intermediate_size($data, $post_id, $size) {
|
||||||
|
|
||||||
$data['path'] = str_replace(DIRECTORY_SEPARATOR . $this->get_private_folder_prefix(), DIRECTORY_SEPARATOR, $data['path']);
|
$data['path'] = str_replace($this->dir_separator . $this->get_private_folder_prefix(), $this->dir_separator, $data['path']);
|
||||||
$data['url'] = str_replace('/' . $this->get_private_folder_prefix(), '/', $data['url']);
|
$data['url'] = str_replace('/' . $this->get_private_folder_prefix(), '/', $data['url']);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -276,13 +283,10 @@ class Private_Files {
|
||||||
* if the items upload directory mus be renamed to add or remove the
|
* if the items upload directory mus be renamed to add or remove the
|
||||||
* private folder prefix
|
* private folder prefix
|
||||||
*/
|
*/
|
||||||
function update_item_and_collection($obj, $diffs, $is_update) {
|
function update_item_and_collection($obj) {
|
||||||
|
|
||||||
// updating collection or item
|
$folder = $this->dir_separator;
|
||||||
if ( $is_update ) {
|
$check_folder = $this->dir_separator;
|
||||||
|
|
||||||
$folder = DIRECTORY_SEPARATOR;
|
|
||||||
$check_folder = DIRECTORY_SEPARATOR;
|
|
||||||
$check = false;
|
$check = false;
|
||||||
|
|
||||||
if ( $obj instanceof \Tainacan\Entities\Collection ) {
|
if ( $obj instanceof \Tainacan\Entities\Collection ) {
|
||||||
|
@ -301,11 +305,11 @@ class Private_Files {
|
||||||
$collection = $obj->get_collection();
|
$collection = $obj->get_collection();
|
||||||
$col_status_object = get_post_status_object($collection->get_status());
|
$col_status_object = get_post_status_object($collection->get_status());
|
||||||
|
|
||||||
$folder .= $col_status_object->public ? $collection->get_id() : $this->get_private_folder_prefix() . $collection->get_id() . DIRECTORY_SEPARATOR;
|
$folder .= $col_status_object->public ? $collection->get_id() : $this->get_private_folder_prefix() . $collection->get_id() . $this->dir_separator;
|
||||||
$check_folder .= $col_status_object->public ? $collection->get_id() : $this->get_private_folder_prefix() . $collection->get_id() . DIRECTORY_SEPARATOR;
|
$check_folder .= $col_status_object->public ? $collection->get_id() : $this->get_private_folder_prefix() . $collection->get_id() . $this->dir_separator;
|
||||||
|
|
||||||
$folder .= DIRECTORY_SEPARATOR;
|
$folder .= $this->dir_separator;
|
||||||
$check_folder .= DIRECTORY_SEPARATOR;
|
$check_folder .= $this->dir_separator;
|
||||||
|
|
||||||
$status_obj = get_post_status_object($obj->get_status());
|
$status_obj = get_post_status_object($obj->get_status());
|
||||||
|
|
||||||
|
@ -320,8 +324,8 @@ class Private_Files {
|
||||||
|
|
||||||
$upload_dir = wp_get_upload_dir();
|
$upload_dir = wp_get_upload_dir();
|
||||||
$base_dir = $upload_dir['basedir'];
|
$base_dir = $upload_dir['basedir'];
|
||||||
$full_path = $base_dir . DIRECTORY_SEPARATOR . $this->get_items_uploads_folder() . $folder;
|
$full_path = $base_dir . $this->dir_separator . $this->get_items_uploads_folder() . $folder;
|
||||||
$full_path_check = $base_dir . DIRECTORY_SEPARATOR . $this->get_items_uploads_folder() . $check_folder;
|
$full_path_check = $base_dir . $this->dir_separator . $this->get_items_uploads_folder() . $check_folder;
|
||||||
|
|
||||||
if (\file_exists($full_path_check)) {
|
if (\file_exists($full_path_check)) {
|
||||||
rename($full_path_check, $full_path);
|
rename($full_path_check, $full_path);
|
||||||
|
@ -330,7 +334,6 @@ class Private_Files {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +353,7 @@ class Private_Files {
|
||||||
|
|
||||||
$upload_dir = wp_get_upload_dir();
|
$upload_dir = wp_get_upload_dir();
|
||||||
$base_dir = $upload_dir['basedir'];
|
$base_dir = $upload_dir['basedir'];
|
||||||
$full_path = $base_dir . DIRECTORY_SEPARATOR . $this->get_items_uploads_folder() . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . $prefix;
|
$full_path = $base_dir . $this->dir_separator . $this->get_items_uploads_folder() . $this->dir_separator . '*' . $this->dir_separator . $prefix;
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
$folder = $full_path . $id;
|
$folder = $full_path . $id;
|
||||||
|
@ -359,9 +362,9 @@ class Private_Files {
|
||||||
if (sizeof($found) == 1 && isset($found[0])) {
|
if (sizeof($found) == 1 && isset($found[0])) {
|
||||||
|
|
||||||
if ($status_obj->public) {
|
if ($status_obj->public) {
|
||||||
$target = str_replace(DIRECTORY_SEPARATOR . $this->get_private_folder_prefix() . $id, DIRECTORY_SEPARATOR . $id, $found[0]);
|
$target = str_replace($this->dir_separator . $this->get_private_folder_prefix() . $id, $this->dir_separator . $id, $found[0]);
|
||||||
} else {
|
} else {
|
||||||
$target = str_replace(DIRECTORY_SEPARATOR . $id, DIRECTORY_SEPARATOR . $this->get_private_folder_prefix() . $id, $found[0]);
|
$target = str_replace($this->dir_separator . $id, $this->dir_separator . $this->get_private_folder_prefix() . $id, $found[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
rename($found[0], $target);
|
rename($found[0], $target);
|
||||||
|
|
|
@ -366,7 +366,7 @@ class Entity {
|
||||||
|
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach($map as $prop => $content) {
|
foreach($map as $prop => $content) {
|
||||||
$attributes[$prop] = $this->get_mapped_property($prop);
|
$attributes[$prop] = $this->get($prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
$hook_prefix = self::get_post_type();
|
$hook_prefix = self::get_post_type();
|
||||||
|
|
|
@ -152,7 +152,7 @@ class Filter extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
$object_type = new $class_name();
|
$object_type = new $class_name();
|
||||||
$object_type->set_options( $this->get_filter_type_options() );
|
$object_type->set_options( $this->get_mapped_property('filter_type_options') );
|
||||||
return $object_type;
|
return $object_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +171,10 @@ class Filter extends Entity {
|
||||||
* @return array Configurations for the filter type object
|
* @return array Configurations for the filter type object
|
||||||
*/
|
*/
|
||||||
function get_filter_type_options(){
|
function get_filter_type_options(){
|
||||||
|
$object = $this->get_filter_type_object();
|
||||||
|
if ($object) {
|
||||||
|
return $object->get_options(); // merge with dedault filter type options
|
||||||
|
}
|
||||||
return $this->get_mapped_property('filter_type_options');
|
return $this->get_mapped_property('filter_type_options');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +279,21 @@ class Filter extends Entity {
|
||||||
if (false === $is_valid)
|
if (false === $is_valid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
$status = $this->get_status();
|
||||||
|
$status_obj = get_post_status_object($status);
|
||||||
|
|
||||||
|
if ($status_obj->public) {
|
||||||
|
$metadatum = $this->get_metadatum();
|
||||||
|
if ($metadatum) {
|
||||||
|
$metadatum_status_obj = get_post_status_object($metadatum->get_status());
|
||||||
|
if ( ! $metadatum_status_obj->public ) {
|
||||||
|
$this->add_error('status', __('Filter can not be public because the related metadatum is private', 'tainacan'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$fto = $this->get_filter_type_object();
|
$fto = $this->get_filter_type_object();
|
||||||
if (is_object($fto)) {
|
if (is_object($fto)) {
|
||||||
$is_valid = $fto->validate_options( $this );
|
$is_valid = $fto->validate_options( $this );
|
||||||
|
|
|
@ -444,25 +444,29 @@ class Item_Metadata_Entity extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->is_required() && !$one_filled) {
|
if ($this->is_required() && !$one_filled) {
|
||||||
$this->add_error('required', $metadatum->get_name() . ' is required');
|
// translators: %s = metadatum name. ex: Title is required
|
||||||
|
$this->add_error( 'required', sprintf( __('%s is required', 'tainacan'), $metadatum->get_name() ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$valid) {
|
if (!$valid) {
|
||||||
$this->add_error('invalid', $metadatum->get_name() . ' is invalid');
|
// translators: %s = metadatum name. ex: Title is invalid
|
||||||
|
$this->add_error( 'invalid', sprintf( __('%s is invalid', 'tainacan'), $metadatum->get_name() ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set_as_valid();
|
$this->set_as_valid();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$this->add_error('invalid', $metadatum->get_name() . ' is invalid');
|
// translators: %s = metadatum name. ex: Title is invalid
|
||||||
|
$this->add_error( 'invalid', sprintf( __('%s is invalid', 'tainacan'), $metadatum->get_name() ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if( is_array($value) ){
|
if( is_array($value) ){
|
||||||
$this->add_error('not_multiple', $metadatum->get_name() . ' do not accept array as value');
|
// translators: %s = metadatum name. ex: Title accepts only one single value and not a list of values
|
||||||
|
$this->add_error( 'not_multiple', sprintf( __('%s accepts only one single value and not a list of values', 'tainacan'), $metadatum->get_name() ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +484,8 @@ class Item_Metadata_Entity extends Entity {
|
||||||
], $item->get_collection());
|
], $item->get_collection());
|
||||||
|
|
||||||
if ($test->have_posts()) {
|
if ($test->have_posts()) {
|
||||||
$this->add_error('key_exists', $metadatum->get_name() . ' is a collection key and there is another item with the same value');
|
// translators: %s = metadatum name. ex: Register ID is a collection key and there is another item with the same value
|
||||||
|
$this->add_error( 'key_exists', sprintf( __('%s is a collection key and there is another item with the same value', 'tainacan'), $metadatum->get_name() ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ class Item extends Entity {
|
||||||
|
|
||||||
$attachments_query = [
|
$attachments_query = [
|
||||||
'post_type' => 'attachment',
|
'post_type' => 'attachment',
|
||||||
'post_per_page' => -1,
|
'posts_per_page' => -1,
|
||||||
'post_parent' => $item_id,
|
'post_parent' => $item_id,
|
||||||
'exclude' => $to_exclude,
|
'exclude' => $to_exclude,
|
||||||
];
|
];
|
||||||
|
|
|
@ -12,14 +12,17 @@ class Log extends Entity {
|
||||||
protected
|
protected
|
||||||
$title,
|
$title,
|
||||||
$order,
|
$order,
|
||||||
$parent,
|
|
||||||
$description,
|
$description,
|
||||||
$blog_id,
|
$blog_id,
|
||||||
$user_id,
|
$user_id,
|
||||||
$log_date,
|
$date,
|
||||||
$user_name,
|
$user_name,
|
||||||
$collection_id,
|
$collection_id,
|
||||||
$item_id;
|
$item_id,
|
||||||
|
$object_type,
|
||||||
|
$object_id,
|
||||||
|
$old_value,
|
||||||
|
$new_value;
|
||||||
|
|
||||||
static $post_type = 'tainacan-log';
|
static $post_type = 'tainacan-log';
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +37,6 @@ class Log extends Entity {
|
||||||
|
|
||||||
if ( is_int( $which ) && $which == 0 ) {
|
if ( is_int( $which ) && $which == 0 ) {
|
||||||
$this->set_user_id();
|
$this->set_user_id();
|
||||||
$this->set_blog_id();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,27 +91,19 @@ class Log extends Entity {
|
||||||
*
|
*
|
||||||
* @return mixed|null
|
* @return mixed|null
|
||||||
*/
|
*/
|
||||||
function get_log_date() {
|
function get_date() {
|
||||||
return $this->get_mapped_property( 'log_date' );
|
return $this->get_mapped_property( 'date' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the log order type
|
* Return the log slug
|
||||||
*
|
*
|
||||||
* @return string
|
* @return mixed|null
|
||||||
*/
|
*/
|
||||||
function get_order() {
|
function get_slug() {
|
||||||
return $this->get_mapped_property( 'order' );
|
return $this->get_mapped_property( 'slug' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retun the parent ID
|
|
||||||
*
|
|
||||||
* @return integer
|
|
||||||
*/
|
|
||||||
function get_parent() {
|
|
||||||
return $this->get_mapped_property( 'parent' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Log description
|
* Return the Log description
|
||||||
|
@ -120,15 +114,6 @@ class Log extends Entity {
|
||||||
return $this->get_mapped_property( 'description' );
|
return $this->get_mapped_property( 'description' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the ID of blog
|
|
||||||
*
|
|
||||||
* @return integer
|
|
||||||
*/
|
|
||||||
function get_blog_id() {
|
|
||||||
return $this->get_mapped_property( 'blog_id' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return User Id of who make the action
|
* Return User Id of who make the action
|
||||||
*
|
*
|
||||||
|
@ -138,27 +123,28 @@ class Log extends Entity {
|
||||||
return $this->get_mapped_property( 'user_id' );
|
return $this->get_mapped_property( 'user_id' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get value of log entry
|
* Get old value of log entry object
|
||||||
*
|
*
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function get_value() {
|
public function get_old_value() {
|
||||||
return maybe_unserialize( base64_decode( $this->get_mapped_property( 'value' ) ) );
|
return $this->get_mapped_property( 'old_value' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Get old value of log entry object
|
* Get new value of log entry object
|
||||||
// *
|
*
|
||||||
// * @param mixed $value
|
* @param mixed $value
|
||||||
// *
|
*
|
||||||
// * @return void
|
* @return void
|
||||||
// */
|
*/
|
||||||
// public function get_old_value() {
|
public function get_new_value() {
|
||||||
// return maybe_unserialize( base64_decode( $this->get_mapped_property( 'old_value' ) ) );
|
return $this->get_mapped_property( 'new_value' );
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set log tittle
|
* Set log tittle
|
||||||
|
@ -167,30 +153,8 @@ class Log extends Entity {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function set_title( $value ) {
|
public function set_title( $value ) {
|
||||||
$this->set_mapped_property( 'title', $value );
|
$this->set_mapped_property( 'title', apply_filters('tainacan-log-set-title', $value) );
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the order type
|
|
||||||
*
|
|
||||||
* @param [string] $value
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function set_order( $value ) {
|
|
||||||
$this->set_mapped_property( 'order', $value );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the parent ID
|
|
||||||
*
|
|
||||||
* @param [integer] $value
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function set_parent( $value ) {
|
|
||||||
$this->set_mapped_property( 'parent', $value );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,7 +164,7 @@ class Log extends Entity {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function set_description( $value ) {
|
public function set_description( $value ) {
|
||||||
$this->set_mapped_property( 'description', $value );
|
$this->set_mapped_property( 'description', $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +175,7 @@ class Log extends Entity {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function set_user_id( $value = 0 ) {
|
public function set_user_id( $value = 0 ) {
|
||||||
if ( 0 == $value ) {
|
if ( 0 == $value ) {
|
||||||
$value = get_current_user_id();
|
$value = get_current_user_id();
|
||||||
}
|
}
|
||||||
|
@ -219,46 +183,25 @@ class Log extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the blog ID of log entry
|
* Set old value of log entry
|
||||||
*
|
|
||||||
* @param [integer] $value
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function set_blog_id( $value = 0 ) {
|
|
||||||
if ( 0 == $value ) {
|
|
||||||
$value = get_current_blog_id();
|
|
||||||
}
|
|
||||||
$this->set_mapped_property( 'blog_id', $value );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the value of log entry
|
|
||||||
*
|
*
|
||||||
* @param [mixed] $value
|
* @param [mixed] $value
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function set_value( $value = null ) {
|
public function set_old_value( $value ) {
|
||||||
$this->set_mapped_property( 'value', base64_encode( maybe_serialize( $value ) ) );
|
$this->set_mapped_property( 'old_value', $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Set old value of log entry
|
|
||||||
// *
|
|
||||||
// * @param [mixed] $value
|
|
||||||
// *
|
|
||||||
// * @return void
|
|
||||||
// */
|
|
||||||
// protected function set_old_value( $value = null ) {
|
|
||||||
// $this->set_mapped_property( 'old_value', base64_encode( maybe_serialize( $value ) ) );
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $diffs
|
* Set new value of log entry
|
||||||
|
*
|
||||||
|
* @param [mixed] $value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function set_log_diffs($diffs){
|
public function set_new_value( $value ) {
|
||||||
$this->set_mapped_property( 'log_diffs', $diffs );
|
$this->set_mapped_property( 'new_value', $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,55 +211,20 @@ class Log extends Entity {
|
||||||
return $this->get_mapped_property('log_diffs');
|
return $this->get_mapped_property('log_diffs');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function get_object_type() {
|
||||||
*
|
return $this->get_mapped_property('object_type');
|
||||||
* @param bool $message
|
|
||||||
* @param string $desc
|
|
||||||
* @param null $value
|
|
||||||
* @param array $diffs
|
|
||||||
* @param string $status 'publish', 'private', 'pending', 'processing' or 'error'
|
|
||||||
* @param int $parent
|
|
||||||
*
|
|
||||||
* @return \Tainacan\Entities\Log | bool
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public static function create( $message = false, $desc = '', $value = null, $diffs = [], $status = 'publish', $parent = 0 ) {
|
|
||||||
|
|
||||||
$log = new Log();
|
|
||||||
|
|
||||||
$log->set_title( $message );
|
|
||||||
$log->set_description( $desc );
|
|
||||||
$log->set_status( $status );
|
|
||||||
$log->set_log_diffs( $diffs );
|
|
||||||
|
|
||||||
if($parent > 0) {
|
|
||||||
$log->set_parent($parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_object($value) || is_string($value)) {
|
public function set_object_type($value) {
|
||||||
if(array_search( 'Tainacan\Traits\Entity_Collection_Relation', class_uses($value))) {
|
$this->set_mapped_property('object_type', $value);
|
||||||
$log->set_collection_id( $value->get_collection_id() );
|
|
||||||
} elseif($value instanceof Collection){
|
|
||||||
$log->set_collection_id( $value->get_id());
|
|
||||||
} elseif($value instanceof Item_Metadata_Entity){
|
|
||||||
$log->set_item_id($value->get_item()->get_id());
|
|
||||||
$log->set_collection_id($value->get_item()->get_collection_id());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! is_null( $value ) ) {
|
public function get_object_id() {
|
||||||
$log->set_value( $value );
|
return $this->get_mapped_property('object_id');
|
||||||
} elseif ( $message === false ) {
|
|
||||||
throw new \Exception( 'Message or value is needed to log' );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
|
public function set_object_id($value) {
|
||||||
|
$this->set_mapped_property('object_id', $value);
|
||||||
if ( $log->validate() ) {
|
|
||||||
return $Tainacan_Logs->insert( $log );
|
|
||||||
} else {
|
|
||||||
throw new \Exception( 'Invalid log' );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -333,6 +241,14 @@ class Log extends Entity {
|
||||||
return $this->get_mapped_property('item_id');
|
return $this->get_mapped_property('item_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_action() {
|
||||||
|
return $this->get_mapped_property('action');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_action($value) {
|
||||||
|
$this->set_mapped_property('action', $value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* @see \Tainacan\Repositories\Logs::approve
|
* @see \Tainacan\Repositories\Logs::approve
|
||||||
|
|
|
@ -178,7 +178,7 @@ class Metadatum extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
$object_type = new $class_name();
|
$object_type = new $class_name();
|
||||||
$object_type->set_options( $this->get_metadata_type_options() );
|
$object_type->set_options( $this->get_mapped_property('metadata_type_options') );
|
||||||
return $object_type;
|
return $object_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +197,10 @@ class Metadatum extends Entity {
|
||||||
* @return array Configurations for the metadatum type object
|
* @return array Configurations for the metadatum type object
|
||||||
*/
|
*/
|
||||||
function get_metadata_type_options(){
|
function get_metadata_type_options(){
|
||||||
|
$object = $this->get_metadata_type_object();
|
||||||
|
if ($object) {
|
||||||
|
return $object->get_options(); // merge with dedault metadata type options
|
||||||
|
}
|
||||||
return $this->get_mapped_property('metadata_type_options');
|
return $this->get_mapped_property('metadata_type_options');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ class Taxonomy extends Entity {
|
||||||
'rewrite' => [
|
'rewrite' => [
|
||||||
'slug' => $this->get_slug()
|
'slug' => $this->get_slug()
|
||||||
],
|
],
|
||||||
|
'update_count_callback' => '_update_generic_term_count'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (taxonomy_exists($this->get_db_identifier())){
|
if (taxonomy_exists($this->get_db_identifier())){
|
||||||
|
|
|
@ -145,6 +145,16 @@ class Term extends Entity {
|
||||||
return wp_get_attachment_url( $this->get_header_image_id() );
|
return wp_get_attachment_url( $this->get_header_image_id() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
|
function get_url(){
|
||||||
|
$url = get_term_link( $this->get_id() );
|
||||||
|
if (is_wp_error($url))
|
||||||
|
return "";
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
<b-autocomplete
|
<b-autocomplete
|
||||||
icon="magnify"
|
icon="magnify"
|
||||||
size="is-small"
|
size="is-small"
|
||||||
:aria-labelledby="labelId"
|
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||||
v-model="selected"
|
v-model="selected"
|
||||||
:data="options"
|
:data="options"
|
||||||
expanded
|
expanded
|
||||||
:loading="isLoadingOptions"
|
:loading="isLoadingOptions"
|
||||||
@input="search"
|
@input="search"
|
||||||
field="label"
|
field="label"
|
||||||
@select="option => setResults(option) "
|
@select="onSelect"
|
||||||
:placeholder="(type == 'Tainacan\\Metadata_Types\\Relationship') ? $i18n.get('info_type_to_search_items') : $i18n.get('info_type_to_search_metadata')">
|
:placeholder="(metadatumType === 'Tainacan\\Metadata_Types\\Relationship') ? $i18n.get('info_type_to_search_items') : $i18n.get('info_type_to_search_metadata')">
|
||||||
<template slot-scope="props">
|
<template slot-scope="props">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<div
|
<div
|
||||||
|
@ -41,83 +41,54 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { tainacan as axios, isCancel } from '../../../js/axios/axios'
|
import { tainacan as axios, isCancel } from '../../../js/axios/axios'
|
||||||
import { filter_type_mixin } from '../filter-types-mixin'
|
import { filterTypeMixin, dynamicFilterTypeMixin } from '../filter-types-mixin';
|
||||||
// import qs from 'qs';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
created(){
|
mixins: [filterTypeMixin, dynamicFilterTypeMixin],
|
||||||
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
|
|
||||||
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id;
|
|
||||||
const vm = this;
|
|
||||||
|
|
||||||
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum;
|
|
||||||
|
|
||||||
if(this.isRepositoryLevel || this.collection == 'filter_in_repository'){
|
|
||||||
in_route = '/metadata/'+ this.metadatum;
|
|
||||||
}
|
|
||||||
|
|
||||||
axios.get(in_route)
|
|
||||||
.then( res => {
|
|
||||||
let result = res.data;
|
|
||||||
if( result && result.metadata_type ){
|
|
||||||
vm.metadatum_object = result;
|
|
||||||
vm.type = result.metadata_type;
|
|
||||||
vm.selectedValues();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.$console.log(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
|
|
||||||
},
|
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
results:'',
|
|
||||||
selected:'',
|
selected:'',
|
||||||
options: [],
|
options: [],
|
||||||
type: '',
|
|
||||||
collection: '',
|
|
||||||
metadatum: '',
|
|
||||||
metadatum_object: {},
|
|
||||||
label: ''
|
label: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
watch: {
|
||||||
isRepositoryLevel: Boolean,
|
'query.metaquery'() {
|
||||||
labelId: String
|
this.updateSelectedValues();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.updateSelectedValues();
|
||||||
},
|
},
|
||||||
mixins: [filter_type_mixin],
|
|
||||||
methods: {
|
methods: {
|
||||||
setResults(option){
|
onSelect(option){
|
||||||
|
|
||||||
if(!option)
|
if(!option)
|
||||||
return;
|
return;
|
||||||
this.results = option.value;
|
this.selected = option.value;
|
||||||
this.label = option.label;
|
this.label = option.label;
|
||||||
this.onSelect()
|
|
||||||
},
|
|
||||||
onSelect(){
|
|
||||||
this.$emit('input', {
|
this.$emit('input', {
|
||||||
filter: 'autocomplete',
|
filter: 'autocomplete',
|
||||||
metadatum_id: this.metadatum,
|
metadatum_id: this.metadatumId,
|
||||||
collection_id: this.collection,
|
collection_id: this.collectionId,
|
||||||
value: this.results
|
value: this.selected
|
||||||
});
|
});
|
||||||
this.selectedValues();
|
this.updateSelectedValues();
|
||||||
},
|
},
|
||||||
search: _.debounce( function(query) {
|
search: _.debounce( function(query) {
|
||||||
|
|
||||||
if (query != '') {
|
if (query != '') {
|
||||||
let promise = null;
|
let promise = null;
|
||||||
this.options = [];
|
this.options = [];
|
||||||
|
|
||||||
// Cancels previous Request
|
// Cancels previous Request
|
||||||
if (this.getOptionsValuesCancel != undefined)
|
if (this.getOptionsValuesCancel != undefined)
|
||||||
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
||||||
|
|
||||||
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' )
|
if ( this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' )
|
||||||
promise = this.getValuesRelationship( query, this.isRepositoryLevel );
|
promise = this.getValuesRelationship( query, this.isRepositoryLevel );
|
||||||
else
|
else
|
||||||
promise = this.getValuesPlainText( this.metadatum, query, this.isRepositoryLevel );
|
promise = this.getValuesPlainText( this.metadatumId, query, this.isRepositoryLevel );
|
||||||
|
|
||||||
promise.request.catch( error => {
|
promise.request.catch( error => {
|
||||||
if (isCancel(error))
|
if (isCancel(error))
|
||||||
|
@ -130,71 +101,51 @@
|
||||||
this.getOptionsValuesCancel = promise.source;
|
this.getOptionsValuesCancel = promise.source;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.cleanSearch();
|
this.label = '';
|
||||||
|
this.selected = '';
|
||||||
|
this.$emit('input', {
|
||||||
|
filter: 'autocomplete',
|
||||||
|
metadatum_id: this.metadatumId,
|
||||||
|
collection_id: this.collectionId,
|
||||||
|
value: this.selected
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, 500),
|
}, 500),
|
||||||
selectedValues(){
|
updateSelectedValues(){
|
||||||
const instance = this;
|
|
||||||
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
if (!this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key === this.metadatum );
|
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key == this.metadatumId);
|
||||||
if ( index >= 0){
|
if (index >= 0) {
|
||||||
let metadata = this.query.metaquery[ index ];
|
let metadata = this.query.metaquery[ index ];
|
||||||
// let collectionTarget = ( this.metadatum_object && this.metadatum_object.metadata_type_options.collection_id ) ?
|
|
||||||
// this.metadatum_object.metadata_type_options.collection_id : this.collection_id;
|
|
||||||
|
|
||||||
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' ) {
|
if (this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship') {
|
||||||
// let query = qs.stringify({ postin: metadata.value });
|
|
||||||
|
|
||||||
axios.get('/items/' + metadata.value)
|
let endpoint = '/items/' + metadata.value + '?fetch_only=title,thumbnail';
|
||||||
|
|
||||||
|
axios.get(endpoint)
|
||||||
.then( res => {
|
.then( res => {
|
||||||
|
|
||||||
let item = res.data;
|
let item = res.data;
|
||||||
instance.results = item.title;
|
this.label = item.title;
|
||||||
instance.label = item.title;
|
this.selected = item.title;
|
||||||
instance.selected = item.title;
|
|
||||||
|
|
||||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
this.$emit( 'sendValuesToTags', { label: this.label, value: this.selected });
|
||||||
filterId: instance.filter.id,
|
|
||||||
value: instance.label
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.$console.log(error);
|
this.$console.log(error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
instance.results = metadata.value;
|
this.label = metadata.value;
|
||||||
instance.label = metadata.value;
|
this.selected = metadata.value;
|
||||||
instance.selected = metadata.value;
|
this.$emit( 'sendValuesToTags', { label: this.label, value: this.selected });
|
||||||
|
|
||||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
|
||||||
filterId: instance.filter.id,
|
|
||||||
value: metadata.value
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cleanSearchFromTags(filterTag) {
|
|
||||||
if (filterTag.filterId == this.filter.id)
|
|
||||||
this.cleanSearch();
|
|
||||||
},
|
|
||||||
cleanSearch(){
|
|
||||||
this.results = '';
|
|
||||||
this.label = '';
|
this.label = '';
|
||||||
this.selected = '';
|
this.selected = '';
|
||||||
this.$emit('input', {
|
}
|
||||||
filter: 'autocomplete',
|
}
|
||||||
metadatum_id: this.metadatum,
|
|
||||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
|
||||||
value: ''
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -9,6 +9,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||||
class Autocomplete extends Filter_Type {
|
class Autocomplete extends Filter_Type {
|
||||||
|
|
||||||
function __construct(){
|
function __construct(){
|
||||||
|
$this->set_name( __('Autocomplete', 'tainacan') );
|
||||||
$this->set_supported_types(['string','long_string','item']);
|
$this->set_supported_types(['string','long_string','item']);
|
||||||
$this->set_component('tainacan-filter-autocomplete');
|
$this->set_component('tainacan-filter-autocomplete');
|
||||||
$this->set_use_max_options(false);
|
$this->set_use_max_options(false);
|
||||||
|
|
|
@ -3,12 +3,6 @@
|
||||||
:style="{ 'height': isLoadingOptions ? (Number(filter.max_options)*28) + 'px' : 'auto' }"
|
:style="{ 'height': isLoadingOptions ? (Number(filter.max_options)*28) + 'px' : 'auto' }"
|
||||||
:class="{ 'skeleton': isLoadingOptions }"
|
:class="{ 'skeleton': isLoadingOptions }"
|
||||||
class="block">
|
class="block">
|
||||||
<!-- <span
|
|
||||||
v-if="isLoadingOptions"
|
|
||||||
style="width: 100%; position: absolute;"
|
|
||||||
class="icon has-text-centered loading-icon">
|
|
||||||
<div class="control has-icons-right is-loading is-clearfix" />
|
|
||||||
</span> -->
|
|
||||||
<div
|
<div
|
||||||
v-for="(option, index) in options.slice(0, filter.max_options)"
|
v-for="(option, index) in options.slice(0, filter.max_options)"
|
||||||
v-if="!isLoadingOptions"
|
v-if="!isLoadingOptions"
|
||||||
|
@ -29,15 +23,6 @@
|
||||||
class="has-text-gray"> {{ "(" + option.total_items + ")" }}</span>
|
class="has-text-gray"> {{ "(" + option.total_items + ")" }}</span>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<!-- <b-checkbox
|
|
||||||
v-if="index <= filter.max_options - 1"
|
|
||||||
v-model="selected"
|
|
||||||
:native-value="option.value">
|
|
||||||
<span class="checkbox-label-text">{{ option.label }}</span>
|
|
||||||
<span
|
|
||||||
v-if="option.total_items != undefined"
|
|
||||||
class="has-text-gray">{{ "(" + option.total_items + ")" }}</span>
|
|
||||||
</b-checkbox> -->
|
|
||||||
<button
|
<button
|
||||||
class="view-all-button link-style"
|
class="view-all-button link-style"
|
||||||
v-if="option.showViewAllButton && index == options.slice(0, filter.max_options).length - 1"
|
v-if="option.showViewAllButton && index == options.slice(0, filter.max_options).length - 1"
|
||||||
|
@ -54,96 +39,61 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { tainacan as axios, isCancel } from '../../../js/axios/axios';
|
import { isCancel } from '../../../js/axios/axios';
|
||||||
import { filter_type_mixin } from '../filter-types-mixin';
|
import { filterTypeMixin, dynamicFilterTypeMixin } from '../filter-types-mixin';
|
||||||
import CheckboxRadioModal from '../../../admin/components/other/checkbox-radio-modal.vue';
|
import CheckboxRadioModal from '../../../admin/components/other/checkbox-radio-modal.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
created(){
|
mixins: [filterTypeMixin, dynamicFilterTypeMixin],
|
||||||
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
|
|
||||||
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id;
|
|
||||||
|
|
||||||
let route = '/collection/' + this.collection + '/metadata/' + this.metadatum +'?nopaging=1';
|
|
||||||
|
|
||||||
if (this.isRepositoryLevel || this.collection == 'filter_in_repository')
|
|
||||||
route = '/metadata?nopaging=1';
|
|
||||||
|
|
||||||
axios.get(route)
|
|
||||||
.then( res => {
|
|
||||||
let result = res.data;
|
|
||||||
if ( result && result.metadata_type ){
|
|
||||||
this.metadatum_object = result;
|
|
||||||
this.type = result.metadata_type;
|
|
||||||
|
|
||||||
if (!this.isUsingElasticSearch)
|
|
||||||
this.loadOptions();
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.$console.log(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
|
|
||||||
|
|
||||||
if (this.isUsingElasticSearch) {
|
|
||||||
this.isLoadingOptions = false;
|
|
||||||
this.$eventBusSearch.$on('isLoadingItems', this.updatesIsLoading);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
isRepositoryLevel: Boolean,
|
|
||||||
},
|
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
options: [],
|
options: [],
|
||||||
type: '',
|
selected: []
|
||||||
collection: '',
|
|
||||||
metadatum: '',
|
|
||||||
selected: [],
|
|
||||||
metadatum_object: {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mixins: [filter_type_mixin],
|
|
||||||
watch: {
|
watch: {
|
||||||
selected: function(){
|
selected(newVal, oldVal) {
|
||||||
//this.selected = val;
|
const isEqual = (newVal.length == oldVal.length) && newVal.every((element, index) => {
|
||||||
|
return element === oldVal[index];
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isEqual)
|
||||||
this.onSelect();
|
this.onSelect();
|
||||||
|
},
|
||||||
|
'query.metaquery'() {
|
||||||
|
if (!this.isUsingElasticSearch)
|
||||||
|
this.loadOptions();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
if (!this.isUsingElasticSearch)
|
||||||
|
this.loadOptions();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadOptions(skipSelected) {
|
loadOptions() {
|
||||||
let promise = null;
|
let promise = null;
|
||||||
|
|
||||||
// Cancels previous Request
|
// Cancels previous Request
|
||||||
if (this.getOptionsValuesCancel != undefined)
|
if (this.getOptionsValuesCancel != undefined)
|
||||||
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
||||||
|
|
||||||
if ( this.type === 'Tainacan\\Metadata_Types\\Relationship' )
|
if ( this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship' )
|
||||||
promise = this.getValuesRelationship( null, this.isRepositoryLevel, [], 0, this.filter.max_options, false, '1');
|
promise = this.getValuesRelationship( null, this.isRepositoryLevel, [], 0, this.filter.max_options, false, '1');
|
||||||
else
|
else
|
||||||
promise = this.getValuesPlainText( this.metadatum, null, this.isRepositoryLevel, [], 0, this.filter.max_options, false, '1' );
|
promise = this.getValuesPlainText( this.metadatumId, null, this.isRepositoryLevel, [], 0, this.filter.max_options, false, '1' );
|
||||||
|
|
||||||
if (skipSelected != undefined && skipSelected == true) {
|
|
||||||
promise.request
|
promise.request
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (this.options.length > this.filter.max_options)
|
this.updateSelectedValues();
|
||||||
this.options.splice(this.filter.max_options);
|
|
||||||
}).catch((error) => {
|
|
||||||
this.$console.error(error);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
promise.request
|
|
||||||
.then(() => {
|
|
||||||
this.selectedValues();
|
|
||||||
})
|
})
|
||||||
.catch( (error) => {
|
.catch( (error) => {
|
||||||
if (isCancel(error)) {
|
if (isCancel(error)) {
|
||||||
this.$console.log('Request canceled: ' + error.message);
|
this.$console.log('Request canceled: ' + error.message);
|
||||||
}else
|
this.updateSelectedValues();
|
||||||
|
} else
|
||||||
this.$console.error( error );
|
this.$console.error( error );
|
||||||
});
|
});
|
||||||
}
|
|
||||||
// Search Request Token for cancelling
|
// Search Request Token for cancelling
|
||||||
this.getOptionsValuesCancel = promise.source;
|
this.getOptionsValuesCancel = promise.source;
|
||||||
},
|
},
|
||||||
|
@ -151,14 +101,26 @@
|
||||||
this.$emit('input', {
|
this.$emit('input', {
|
||||||
filter: 'checkbox',
|
filter: 'checkbox',
|
||||||
compare: 'IN',
|
compare: 'IN',
|
||||||
metadatum_id: this.metadatum,
|
metadatum_id: this.metadatumId,
|
||||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
collection_id: this.collectionId,
|
||||||
value: this.selected
|
value: this.selected
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
updateSelectedValues() {
|
||||||
|
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key == this.metadatumId );
|
||||||
|
|
||||||
|
if ( index >= 0){
|
||||||
|
let query = this.query.metaquery.slice();
|
||||||
|
this.selected = query[ index ].value;
|
||||||
|
} else {
|
||||||
|
this.selected = [];
|
||||||
|
}
|
||||||
|
|
||||||
let onlyLabels = [];
|
let onlyLabels = [];
|
||||||
|
if (!isNaN(this.selected[0])){
|
||||||
if(!isNaN(this.selected[0])){
|
|
||||||
for (let aSelected of this.selected) {
|
for (let aSelected of this.selected) {
|
||||||
let valueIndex = this.options.findIndex(option => option.value == aSelected);
|
let valueIndex = this.options.findIndex(option => option.value == aSelected);
|
||||||
|
|
||||||
|
@ -168,24 +130,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
this.$emit( 'sendValuesToTags', { label: onlyLabels.length ? onlyLabels : this.selected, value: this.selected });
|
||||||
filterId: this.filter.id,
|
|
||||||
value: onlyLabels.length ? onlyLabels : this.selected,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
selectedValues() {
|
|
||||||
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key === this.metadatum );
|
|
||||||
if ( index >= 0){
|
|
||||||
let query = this.query.metaquery.slice();
|
|
||||||
this.selected = query[ index ].value;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.selected = [];
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
openCheckboxModal() {
|
openCheckboxModal() {
|
||||||
this.$buefy.modal.open({
|
this.$buefy.modal.open({
|
||||||
|
@ -196,11 +141,10 @@
|
||||||
filter: this.filter,
|
filter: this.filter,
|
||||||
//taxonomy_id: this.taxonomy_id,
|
//taxonomy_id: this.taxonomy_id,
|
||||||
selected: this.selected,
|
selected: this.selected,
|
||||||
metadatum_id: this.metadatum,
|
metadatumId: this.metadatumId,
|
||||||
//taxonomy: this.taxonomy,
|
//taxonomy: this.taxonomy,
|
||||||
collection_id: this.collection,
|
collectionId: this.collectionId,
|
||||||
metadatum_type: this.type,
|
metadatum_type: this.metadatumType,
|
||||||
metadatum_object: this.metadatum_object,
|
|
||||||
isRepositoryLevel: this.isRepositoryLevel,
|
isRepositoryLevel: this.isRepositoryLevel,
|
||||||
query: this.query
|
query: this.query
|
||||||
},
|
},
|
||||||
|
@ -208,50 +152,13 @@
|
||||||
appliedCheckBoxModal: () => {
|
appliedCheckBoxModal: () => {
|
||||||
this.loadOptions();
|
this.loadOptions();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
trapFocus: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cleanSearchFromTags(filterTag) {
|
updatesIsLoading(isLoadingOptions) {
|
||||||
if (filterTag.filterId == this.filter.id) {
|
this.isLoadingOptions = isLoadingOptions;
|
||||||
|
|
||||||
let selectedIndex = this.selected.findIndex(option => option == filterTag.singleValue);
|
|
||||||
let optionIndex = this.options.findIndex(option => option.label == filterTag.singleValue);
|
|
||||||
let alternativeIndex;
|
|
||||||
|
|
||||||
if (optionIndex >= 0) {
|
|
||||||
alternativeIndex = this.selected.findIndex(option => this.options[optionIndex].value == option);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedIndex >= 0 || alternativeIndex >= 0) {
|
|
||||||
|
|
||||||
selectedIndex >= 0 ? this.selected.splice(selectedIndex, 1) : this.selected.splice(alternativeIndex, 1);
|
|
||||||
|
|
||||||
this.$emit('input', {
|
|
||||||
filter: 'checkbox',
|
|
||||||
compare: 'IN',
|
|
||||||
metadatum_id: this.metadatum,
|
|
||||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
|
||||||
value: this.selected
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
|
||||||
filterId: this.filter.id,
|
|
||||||
value: this.selected
|
|
||||||
});
|
|
||||||
|
|
||||||
this.selectedValues();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updatesIsLoading(isLoading) {
|
|
||||||
this.isLoadingOptions = isLoading;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
|
||||||
|
|
||||||
if (this.isUsingElasticSearch)
|
|
||||||
this.$eventBusSearch.$off('isLoadingItems', this.updatesIsLoading);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -9,6 +9,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||||
class Checkbox extends Filter_Type {
|
class Checkbox extends Filter_Type {
|
||||||
|
|
||||||
function __construct(){
|
function __construct(){
|
||||||
|
$this->set_name( __('Checkbox List', 'tainacan') );
|
||||||
$this->set_supported_types(['string','long_string','item']);
|
$this->set_supported_types(['string','long_string','item']);
|
||||||
$this->set_component('tainacan-filter-checkbox');
|
$this->set_component('tainacan-filter-checkbox');
|
||||||
$this->set_preview_template('
|
$this->set_preview_template('
|
||||||
|
|
|
@ -1,330 +0,0 @@
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<!-- Date -->
|
|
||||||
<div v-if="type === 'date'">
|
|
||||||
<b-datepicker
|
|
||||||
:aria-labelledby="labelId"
|
|
||||||
:placeholder="$i18n.get('label_selectbox_init')"
|
|
||||||
v-model="date_init"
|
|
||||||
size="is-small"
|
|
||||||
@focus="isTouched = true"
|
|
||||||
@input="validate_values()"
|
|
||||||
editable
|
|
||||||
:date-formatter="(date) => dateFormatter(date)"
|
|
||||||
:date-parser="(date) => dateParser(date)"
|
|
||||||
icon="calendar-today"
|
|
||||||
:day-names="[
|
|
||||||
$i18n.get('datepicker_short_sunday'),
|
|
||||||
$i18n.get('datepicker_short_monday'),
|
|
||||||
$i18n.get('datepicker_short_tuesday'),
|
|
||||||
$i18n.get('datepicker_short_wednesday'),
|
|
||||||
$i18n.get('datepicker_short_thursday'),
|
|
||||||
$i18n.get('datepicker_short_friday'),
|
|
||||||
$i18n.get('datepicker_short_saturday'),
|
|
||||||
]"/>
|
|
||||||
<p class="is-size-7 has-text-centered is-marginless">{{ $i18n.get('label_until') }}</p>
|
|
||||||
<b-datepicker
|
|
||||||
:aria-labelledby="labelId"
|
|
||||||
:placeholder="$i18n.get('label_selectbox_init')"
|
|
||||||
v-model="date_end"
|
|
||||||
size="is-small"
|
|
||||||
@input="validate_values()"
|
|
||||||
@focus="isTouched = true"
|
|
||||||
editable
|
|
||||||
:date-formatter="(date) => dateFormatter(date)"
|
|
||||||
:date-parser="(date) => dateParser(date)"
|
|
||||||
icon="calendar-today"
|
|
||||||
:day-names="[
|
|
||||||
$i18n.get('datepicker_short_sunday'),
|
|
||||||
$i18n.get('datepicker_short_monday'),
|
|
||||||
$i18n.get('datepicker_short_tuesday'),
|
|
||||||
$i18n.get('datepicker_short_wednesday'),
|
|
||||||
$i18n.get('datepicker_short_thursday'),
|
|
||||||
$i18n.get('datepicker_short_friday'),
|
|
||||||
$i18n.get('datepicker_short_saturday'),
|
|
||||||
]"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Numeric -->
|
|
||||||
<div v-else>
|
|
||||||
<b-numberinput
|
|
||||||
:aria-labelledby="labelId"
|
|
||||||
size="is-small"
|
|
||||||
step="any"
|
|
||||||
@input="validate_values()"
|
|
||||||
v-model="value_init"/>
|
|
||||||
<p class="is-size-7 has-text-centered is-marginless">{{ $i18n.get('label_until') }}</p>
|
|
||||||
<b-numberinput
|
|
||||||
:aria-labelledby="labelId"
|
|
||||||
size="is-small"
|
|
||||||
step="any"
|
|
||||||
@input="validate_values()"
|
|
||||||
@focus="isTouched = true"
|
|
||||||
v-model="value_end"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { tainacan as axios } from '../../../js/axios/axios';
|
|
||||||
import { wpAjax, dateInter } from "../../../admin/js/mixins";
|
|
||||||
import moment from 'moment';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
mixins: [ wpAjax, dateInter ],
|
|
||||||
created() {
|
|
||||||
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
|
|
||||||
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id;
|
|
||||||
|
|
||||||
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum;
|
|
||||||
|
|
||||||
if(this.isRepositoryLevel || this.collection == 'filter_in_repository'){
|
|
||||||
in_route = '/metadata/'+ this.metadatum;
|
|
||||||
}
|
|
||||||
|
|
||||||
axios.get(in_route)
|
|
||||||
.then( res => {
|
|
||||||
let result = res.data;
|
|
||||||
if( result && result.metadata_type ){
|
|
||||||
this.metadatum_object = result;
|
|
||||||
this.type = ( result.metadata_type === 'Tainacan\\Metadata_Types\\Date') ? 'date' : 'numeric';
|
|
||||||
this.selectedValues();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.$console.log(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
|
|
||||||
},
|
|
||||||
data(){
|
|
||||||
return {
|
|
||||||
value_init: null,
|
|
||||||
value_end: null,
|
|
||||||
date_init: undefined,
|
|
||||||
date_end: undefined,
|
|
||||||
isTouched: false,
|
|
||||||
isValid: false,
|
|
||||||
clear: false,
|
|
||||||
type: 'numeric',
|
|
||||||
collection: '',
|
|
||||||
metadatum: '',
|
|
||||||
metadatum_object: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
filter: {
|
|
||||||
type: Object // concentrate all attributes metadatum id and type
|
|
||||||
},
|
|
||||||
metadatum_id: [Number], // not required, but overrides the filter metadatum id if is set
|
|
||||||
collection_id: [Number], // not required, but overrides the filter metadatum id if is set
|
|
||||||
labelId: '',
|
|
||||||
query: Object,
|
|
||||||
isRepositoryLevel: Boolean,
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
isTouched( val ){
|
|
||||||
if ( val && this.date_init === null)
|
|
||||||
this.date_init = new Date();
|
|
||||||
|
|
||||||
if ( val && this.date_end === null)
|
|
||||||
this.date_end = new Date();
|
|
||||||
|
|
||||||
this.isTouched = val;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// only validate if the first value is higher than first
|
|
||||||
validate_values: _.debounce( function (){
|
|
||||||
if( this.type === 'date' ){
|
|
||||||
if (this.date_init === undefined)
|
|
||||||
this.date_init = new Date();
|
|
||||||
|
|
||||||
if (this.date_end === undefined)
|
|
||||||
this.date_end = new Date();
|
|
||||||
|
|
||||||
if ( this.date_init > this.date_end ) {
|
|
||||||
let result = this.date_init;
|
|
||||||
result.setDate(result.getDate() + 1);
|
|
||||||
this.date_end = result;
|
|
||||||
|
|
||||||
result.setDate(result.getDate() - 1);
|
|
||||||
this.date_init = result;
|
|
||||||
//this.error_message();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if ( parseFloat( this.value_init ) > parseFloat( this.value_end )) {
|
|
||||||
//this.value_end = parseFloat( this.value_init ) + 1;
|
|
||||||
//this.error_message();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.emit();
|
|
||||||
}, 1000),
|
|
||||||
// message for error
|
|
||||||
error_message(){
|
|
||||||
if ( !this.isTouched ) return false;
|
|
||||||
|
|
||||||
this.$buefy.toast.open({
|
|
||||||
duration: 3000,
|
|
||||||
message: this.$i18n.get('info_error_first_value_greater'),
|
|
||||||
position: 'is-bottom',
|
|
||||||
type: 'is-danger'
|
|
||||||
})
|
|
||||||
},
|
|
||||||
dateFormatter(dateObject) {
|
|
||||||
return moment(dateObject, moment.ISO_8601).format(this.dateFormat);
|
|
||||||
},
|
|
||||||
dateParser(dateString) {
|
|
||||||
return moment(dateString, this.dateFormat).toDate();
|
|
||||||
},
|
|
||||||
selectedValues(){
|
|
||||||
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key === this.metadatum );
|
|
||||||
if ( index >= 0){
|
|
||||||
let metadata = this.query.metaquery[ index ];
|
|
||||||
if( metadata.value && metadata.value.length > 0 && this.type === 'numeric'){
|
|
||||||
this.value_init = metadata.value[0];
|
|
||||||
this.value_end = metadata.value[1];
|
|
||||||
this.isValid = true;
|
|
||||||
} else if( metadata.value && metadata.value.length > 0 ){
|
|
||||||
this.date_init = new Date( metadata.value[0] );
|
|
||||||
this.date_end = new Date( metadata.value[1] );
|
|
||||||
|
|
||||||
this.isValid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (metadata.value[0] != undefined && metadata.value[1] != undefined) {
|
|
||||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
|
||||||
filterId: this.filter.id,
|
|
||||||
value: this.parseDateToNavigatorLanguage(metadata.value[0]) + ' - ' + this.parseDateToNavigatorLanguage(metadata.value[1])
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
showSearch(){
|
|
||||||
if( this.type === 'date' ){
|
|
||||||
|
|
||||||
if( this.date_init === null || this.date_end === null ){
|
|
||||||
this.clear = true;
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.date_init.toLocaleString().split(' ')[0] + ' - ' + this.date_end.toLocaleString().split(' ')[0];
|
|
||||||
}
|
|
||||||
// else {
|
|
||||||
// return this.value_init + ' - ' +this.value_end;
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
cleanSearchFromTags(filterTag) {
|
|
||||||
if (filterTag.filterId == this.filter.id)
|
|
||||||
this.clearSearch();
|
|
||||||
},
|
|
||||||
clearSearch(){
|
|
||||||
|
|
||||||
this.clear = true;
|
|
||||||
|
|
||||||
this.$emit('input', {
|
|
||||||
filter: 'range',
|
|
||||||
compare: 'BETWEEN',
|
|
||||||
metadatum_id: this.metadatum,
|
|
||||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
|
||||||
value: ''
|
|
||||||
});
|
|
||||||
|
|
||||||
if( this.type === 'date' ){
|
|
||||||
this.date_init = null;
|
|
||||||
this.date_end = null;
|
|
||||||
this.isTouched = false;
|
|
||||||
} else {
|
|
||||||
this.value_end = null;
|
|
||||||
this.value_init = null;
|
|
||||||
this.isTouched = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// emit the operation for listeners
|
|
||||||
emit() {
|
|
||||||
let values = [];
|
|
||||||
let type = '';
|
|
||||||
|
|
||||||
if( this.type === 'date' ){
|
|
||||||
|
|
||||||
if( this.date_init === null && this.date_end === null ){
|
|
||||||
values = [];
|
|
||||||
type = 'DATE';
|
|
||||||
this.isValid = false;
|
|
||||||
this.clear = true;
|
|
||||||
} else {
|
|
||||||
let date_init = this.date_init.getUTCFullYear() + '-' +
|
|
||||||
('00' + (this.date_init.getUTCMonth() + 1)).slice(-2) + '-' +
|
|
||||||
('00' + this.date_init.getUTCDate()).slice(-2);
|
|
||||||
let date_end = this.date_end.getUTCFullYear() + '-' +
|
|
||||||
('00' + (this.date_end.getUTCMonth() + 1)).slice(-2) + '-' +
|
|
||||||
('00' + this.date_end.getUTCDate()).slice(-2);
|
|
||||||
values = [ date_init, date_end ];
|
|
||||||
type = 'DATE';
|
|
||||||
this.isValid = true;
|
|
||||||
this.clear = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if( this.value_init === null || this.value_end === null
|
|
||||||
|| this.value_init === '' || this.value_end === ''){
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
values = [ this.value_init, this.value_end ];
|
|
||||||
|
|
||||||
if(this.value_init !== this.value_end && (this.value_init % 1 !== 0 && this.value_end % 1 == 0)) {
|
|
||||||
type = 'DECIMAL';
|
|
||||||
} else if(this.value_init !== this.value_end &&
|
|
||||||
this.value_init % 1 !== 0 &&
|
|
||||||
this.value_end % 1 !== 0) {
|
|
||||||
|
|
||||||
type = '';
|
|
||||||
} else if(this.value_init !== this.value_end &&
|
|
||||||
!(this.value_init % 1 == 0 && this.value_end % 1 !== 0)){
|
|
||||||
type = 'DECIMAL';
|
|
||||||
} else {
|
|
||||||
type = '';
|
|
||||||
}
|
|
||||||
//this.isValid = true;
|
|
||||||
//this.clear = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$emit('input', {
|
|
||||||
filter: 'range',
|
|
||||||
type: type,
|
|
||||||
compare: 'BETWEEN',
|
|
||||||
metadatum_id: this.metadatum,
|
|
||||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
|
||||||
value: values
|
|
||||||
});
|
|
||||||
|
|
||||||
if (values[0] != undefined && values[1] != undefined) {
|
|
||||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
|
||||||
filterId: this.filter.id,
|
|
||||||
value: this.parseDateToNavigatorLanguage(values[0]) + ' - ' + this.parseDateToNavigatorLanguage(values[1])
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.field {
|
|
||||||
margin-bottom: 0.125rem !important;
|
|
||||||
}
|
|
||||||
p.is-size-7 {
|
|
||||||
margin-bottom: 0.125rem !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -0,0 +1,181 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<b-datepicker
|
||||||
|
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||||
|
:placeholder="$i18n.get('label_selectbox_init')"
|
||||||
|
v-model="dateInit"
|
||||||
|
size="is-small"
|
||||||
|
@focus="isTouched = true"
|
||||||
|
@input="validadeValues()"
|
||||||
|
editable
|
||||||
|
:date-formatter="(date) => dateFormatter(date)"
|
||||||
|
:date-parser="(date) => dateParser(date)"
|
||||||
|
icon="calendar-today"
|
||||||
|
:years-range="[-200, 100]"
|
||||||
|
:day-names="[
|
||||||
|
$i18n.get('datepicker_short_sunday'),
|
||||||
|
$i18n.get('datepicker_short_monday'),
|
||||||
|
$i18n.get('datepicker_short_tuesday'),
|
||||||
|
$i18n.get('datepicker_short_wednesday'),
|
||||||
|
$i18n.get('datepicker_short_thursday'),
|
||||||
|
$i18n.get('datepicker_short_friday'),
|
||||||
|
$i18n.get('datepicker_short_saturday'),
|
||||||
|
]"/>
|
||||||
|
<p class="is-size-7 has-text-centered is-marginless">{{ $i18n.get('label_until') }}</p>
|
||||||
|
<b-datepicker
|
||||||
|
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||||
|
:placeholder="$i18n.get('label_selectbox_init')"
|
||||||
|
v-model="dateEnd"
|
||||||
|
size="is-small"
|
||||||
|
@input="validadeValues()"
|
||||||
|
@focus="isTouched = true"
|
||||||
|
editable
|
||||||
|
:date-formatter="(date) => dateFormatter(date)"
|
||||||
|
:date-parser="(date) => dateParser(date)"
|
||||||
|
icon="calendar-today"
|
||||||
|
:years-range="[-200, 50]"
|
||||||
|
:day-names="[
|
||||||
|
$i18n.get('datepicker_short_sunday'),
|
||||||
|
$i18n.get('datepicker_short_monday'),
|
||||||
|
$i18n.get('datepicker_short_tuesday'),
|
||||||
|
$i18n.get('datepicker_short_wednesday'),
|
||||||
|
$i18n.get('datepicker_short_thursday'),
|
||||||
|
$i18n.get('datepicker_short_friday'),
|
||||||
|
$i18n.get('datepicker_short_saturday'),
|
||||||
|
]"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { wpAjax, dateInter } from "../../../admin/js/mixins";
|
||||||
|
import { filterTypeMixin } from '../filter-types-mixin';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [
|
||||||
|
wpAjax,
|
||||||
|
dateInter,
|
||||||
|
filterTypeMixin
|
||||||
|
],
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
dateInit: undefined,
|
||||||
|
dateEnd: undefined,
|
||||||
|
isTouched: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isTouched( val ){
|
||||||
|
if ( val && this.dateInit === null)
|
||||||
|
this.dateInit = new Date();
|
||||||
|
|
||||||
|
if ( val && this.dateEnd === null)
|
||||||
|
this.dateEnd = new Date();
|
||||||
|
},
|
||||||
|
'query.metaquery'() {
|
||||||
|
this.updateSelectedValues();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.updateSelectedValues();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// only validate if the first value is higher than first
|
||||||
|
validadeValues: _.debounce( function (){
|
||||||
|
|
||||||
|
if (this.dateInit === undefined)
|
||||||
|
this.dateInit = new Date();
|
||||||
|
|
||||||
|
if (this.dateEnd === undefined)
|
||||||
|
this.dateEnd = new Date();
|
||||||
|
|
||||||
|
if (this.dateInit > this.dateEnd) {
|
||||||
|
this.showErrorMessage();
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.emit();
|
||||||
|
}, 800),
|
||||||
|
showErrorMessage(){
|
||||||
|
if ( !this.isTouched ) return false;
|
||||||
|
|
||||||
|
this.$buefy.toast.open({
|
||||||
|
duration: 3000,
|
||||||
|
message: this.$i18n.get('info_error_first_value_greater'),
|
||||||
|
position: 'is-bottom',
|
||||||
|
type: 'is-danger'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
dateFormatter(dateObject){
|
||||||
|
return moment(dateObject, moment.ISO_8601).format(this.dateFormat);
|
||||||
|
},
|
||||||
|
dateParser(dateString){
|
||||||
|
return moment(dateString, this.dateFormat).toDate();
|
||||||
|
},
|
||||||
|
updateSelectedValues(){
|
||||||
|
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key == this.metadatumId);
|
||||||
|
|
||||||
|
if (index >= 0) {
|
||||||
|
let metadata = this.query.metaquery[ index ];
|
||||||
|
|
||||||
|
if (metadata.value && metadata.value.length > 0){
|
||||||
|
this.dateInit = new Date(metadata.value[0]);
|
||||||
|
this.dateEnd = new Date(metadata.value[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metadata.value[0] != undefined && metadata.value[1] != undefined)
|
||||||
|
this.$emit('sendValuesToTags', {
|
||||||
|
label: this.parseDateToNavigatorLanguage(metadata.value[0]) + ' - ' + this.parseDateToNavigatorLanguage(metadata.value[1]),
|
||||||
|
value: [metadata.value[0], metadata.value[1]]
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.dateInit = null;
|
||||||
|
this.dateEnd = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// emit the operation for listeners
|
||||||
|
emit() {
|
||||||
|
let values = [];
|
||||||
|
|
||||||
|
if (this.dateInit === null && this.dateEnd === null) {
|
||||||
|
values = [];
|
||||||
|
} else {
|
||||||
|
let dateInit = this.dateInit.getUTCFullYear() + '-' +
|
||||||
|
('00' + (this.dateInit.getUTCMonth() + 1)).slice(-2) + '-' +
|
||||||
|
('00' + this.dateInit.getUTCDate()).slice(-2);
|
||||||
|
let dateEnd = this.dateEnd.getUTCFullYear() + '-' +
|
||||||
|
('00' + (this.dateEnd.getUTCMonth() + 1)).slice(-2) + '-' +
|
||||||
|
('00' + this.dateEnd.getUTCDate()).slice(-2);
|
||||||
|
values = [ dateInit, dateEnd ];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$emit('input', {
|
||||||
|
filter: 'range',
|
||||||
|
type: 'DATE',
|
||||||
|
compare: 'BETWEEN',
|
||||||
|
metadatum_id: this.metadatumId,
|
||||||
|
collection_id: this.collectionId,
|
||||||
|
value: values
|
||||||
|
});
|
||||||
|
|
||||||
|
if (values[0] != undefined && values[1] != undefined)
|
||||||
|
this.$emit( 'sendValuesToTags', {
|
||||||
|
label: this.parseDateToNavigatorLanguage(values[0]) + ' - ' + this.parseDateToNavigatorLanguage(values[1]),
|
||||||
|
value: [ values[0], values[1] ]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.field {
|
||||||
|
margin-bottom: 0.125rem !important;
|
||||||
|
}
|
||||||
|
p.is-size-7 {
|
||||||
|
margin-bottom: 0.125rem !important;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tainacan\Filter_Types;
|
||||||
|
|
||||||
|
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TainacanMetadatumType
|
||||||
|
*/
|
||||||
|
class Date_Interval extends Filter_Type {
|
||||||
|
|
||||||
|
function __construct(){
|
||||||
|
$this->set_name( __('Date Interval', 'tainacan') );
|
||||||
|
$this->set_supported_types(['date']);
|
||||||
|
$this->set_component('tainacan-filter-date-interval');
|
||||||
|
$this->set_use_max_options(false);
|
||||||
|
$this->set_preview_template('
|
||||||
|
<div>
|
||||||
|
<div class="datepicker control is-small">
|
||||||
|
<div class="dropdown is-bottom-left is-mobile-modal">
|
||||||
|
<div role="button" class="dropdown-trigger">
|
||||||
|
<div class="control has-icons-left is-small is-clearfix">
|
||||||
|
<input type="text" autocomplete="off" placeholder=" '. __('Select a date', 'tainacan') .'" class="input is-small">
|
||||||
|
<span class="icon is-left is-small"><i class="mdi mdi-calendar-today"></i></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="is-size-7 has-text-centered is-marginless">until</p>
|
||||||
|
<div class="datepicker control is-small">
|
||||||
|
<div class="dropdown is-bottom-left is-mobile-modal">
|
||||||
|
<div role="button" class="dropdown-trigger">
|
||||||
|
<div class="control has-icons-left is-small is-clearfix">
|
||||||
|
<input type="text" autocomplete="off" placeholder=" '. __('Select a date', 'tainacan') .'" class="input is-small">
|
||||||
|
<span class="icon is-left is-small"><i class="mdi mdi-calendar-today"></i></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $filter
|
||||||
|
* @return string
|
||||||
|
* @internal param $metadatum
|
||||||
|
*/
|
||||||
|
public function render( $filter ){
|
||||||
|
return '<tainacan-filter-date-interval
|
||||||
|
name="'.$filter->get_name().'"
|
||||||
|
collection_id="'.$filter->get_collection_id().'"
|
||||||
|
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-date-interval>';
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,8 @@
|
||||||
<b-dropdown
|
<b-dropdown
|
||||||
:mobile-modal="true"
|
:mobile-modal="true"
|
||||||
@input="onChangeComparator($event)"
|
@input="onChangeComparator($event)"
|
||||||
aria-role="list">
|
aria-role="list"
|
||||||
|
trap-focus>
|
||||||
<button
|
<button
|
||||||
:aria-label="$i18n.get('label_comparator')"
|
:aria-label="$i18n.get('label_comparator')"
|
||||||
class="button is-white"
|
class="button is-white"
|
||||||
|
@ -59,16 +60,16 @@
|
||||||
</b-dropdown-item>
|
</b-dropdown-item>
|
||||||
</b-dropdown>
|
</b-dropdown>
|
||||||
<!-- <b-numberinput
|
<!-- <b-numberinput
|
||||||
v-if="options.type == 'year'"
|
v-if="filterTypeOptions.type == 'year'"
|
||||||
:placeholder="$i18n.get('instruction_type_value_year')"
|
:placeholder="$i18n.get('instruction_type_value_year')"
|
||||||
:aria-labelledby="labelId"
|
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||||
size="is-small"
|
size="is-small"
|
||||||
step="1"
|
step="1"
|
||||||
@input="emitOnlyYear($event)"
|
@input="emitOnlyYear($event)"
|
||||||
v-model="yearsOnlyValue"/> -->
|
v-model="yearsOnlyValue"/> -->
|
||||||
<b-datepicker
|
<b-datepicker
|
||||||
position="is-bottom-left"
|
position="is-bottom-left"
|
||||||
:aria-labelledby="labelId"
|
:aria-labelledby="'filter-label-id-' + filter.id"
|
||||||
:placeholder="$i18n.get('instruction_select_a_date')"
|
:placeholder="$i18n.get('instruction_select_a_date')"
|
||||||
v-model="value"
|
v-model="value"
|
||||||
@input="emit()"
|
@input="emit()"
|
||||||
|
@ -77,6 +78,7 @@
|
||||||
:date-parser="(date) => dateParser(date)"
|
:date-parser="(date) => dateParser(date)"
|
||||||
size="is-small"
|
size="is-small"
|
||||||
icon="calendar-today"
|
icon="calendar-today"
|
||||||
|
:years-range="[-200, 50]"
|
||||||
:day-names="[
|
:day-names="[
|
||||||
$i18n.get('datepicker_short_sunday'),
|
$i18n.get('datepicker_short_sunday'),
|
||||||
$i18n.get('datepicker_short_monday'),
|
$i18n.get('datepicker_short_monday'),
|
||||||
|
@ -100,67 +102,38 @@
|
||||||
$i18n.get('datepicker_month_november'),
|
$i18n.get('datepicker_month_november'),
|
||||||
$i18n.get('datepicker_month_december')
|
$i18n.get('datepicker_month_december')
|
||||||
]"/>
|
]"/>
|
||||||
<!-- OPTIONS FOR TYPE
|
<!-- filterTypeOptions FOR TYPE
|
||||||
v-else
|
v-else
|
||||||
:type="options.type == 'month' ? 'month' : null"
|
:type="filterTypeOptions.type == 'month' ? 'month' : null"
|
||||||
:placeholder="options.type == 'month' ? $i18n.get('instruction_select_a_date') : $i18n.get('instruction_select_a_month')"
|
:placeholder="filterTypeOptions.type == 'month' ? $i18n.get('instruction_select_a_date') : $i18n.get('instruction_select_a_month')"
|
||||||
-->
|
-->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { tainacan as axios } from '../../../js/axios/axios';
|
|
||||||
import { wpAjax, dateInter } from "../../../admin/js/mixins";
|
import { wpAjax, dateInter } from "../../../admin/js/mixins";
|
||||||
|
import { filterTypeMixin } from '../filter-types-mixin';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [ wpAjax, dateInter ],
|
mixins: [
|
||||||
created() {
|
wpAjax,
|
||||||
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
|
dateInter,
|
||||||
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : (typeof this.filter.metadatum.metadatum_id == 'object' ? this.filter.metadatum.metadatum_id.metadatum_id : this.filter.metadatum.metadatum_id);
|
filterTypeMixin
|
||||||
this.options = this.filter.filter_type_options;
|
],
|
||||||
|
|
||||||
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum;
|
|
||||||
|
|
||||||
if (this.isRepositoryLevel || this.collection == 'filter_in_repository')
|
|
||||||
in_route = '/metadata/'+ this.metadatum;
|
|
||||||
|
|
||||||
axios.get(in_route)
|
|
||||||
.then( res => {
|
|
||||||
let result = res.data;
|
|
||||||
if ( result && result.metadata_type ){
|
|
||||||
this.metadatum_object = result;
|
|
||||||
this.selectedValues();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.$console.log(error);
|
|
||||||
});
|
|
||||||
this.$eventBusSearch.$on('removeFromFilterTag', this.cleanSearchFromTags);
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.selectedValues();
|
this.updateSelectedValues();
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
value: null,
|
value: null,
|
||||||
clear: false,
|
|
||||||
options: [],
|
|
||||||
collection: '',
|
|
||||||
metadatum: '',
|
|
||||||
metadatum_object: {},
|
|
||||||
comparator: '=', // =, !=, >, >=, <, <=
|
comparator: '=', // =, !=, >, >=, <, <=
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
watch: {
|
||||||
filter: {
|
'query.metaquery'() {
|
||||||
type: Object // concentrate all attributes metadatum id and type
|
this.updateSelectedValues();
|
||||||
},
|
}
|
||||||
metadatum_id: [Number], // not required, but overrides the filter metadatum id if is set
|
|
||||||
collection_id: [Number], // not required, but overrides the filter metadatum id if is set
|
|
||||||
labelId: '',
|
|
||||||
query: Object,
|
|
||||||
isRepositoryLevel: Boolean,
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
yearsOnlyValue() {
|
yearsOnlyValue() {
|
||||||
|
@ -179,11 +152,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
selectedValues(){
|
updateSelectedValues(){
|
||||||
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key === this.metadatum );
|
let index = this.query.metaquery.findIndex(newMetadatum => newMetadatum.key == this.metadatumId );
|
||||||
|
|
||||||
if ( index >= 0){
|
if ( index >= 0){
|
||||||
let metadata = this.query.metaquery[ index ];
|
let metadata = this.query.metaquery[ index ];
|
||||||
|
@ -199,35 +172,15 @@
|
||||||
|
|
||||||
this.value = new Date(textValue);
|
this.value = new Date(textValue);
|
||||||
|
|
||||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
this.$emit('sendValuesToTags', {
|
||||||
filterId: this.filter.id,
|
label: this.comparator + ' ' + moment(this.value, moment.ISO_8601).format(this.dateFormat),
|
||||||
value: this.comparator + ' ' + moment(this.value, moment.ISO_8601).format(this.dateFormat)
|
value: textValue
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
cleanSearchFromTags(filterTag) {
|
|
||||||
if (filterTag.filterId == this.filter.id)
|
|
||||||
this.clearSearch();
|
|
||||||
},
|
|
||||||
clearSearch(){
|
|
||||||
|
|
||||||
this.clear = true;
|
|
||||||
|
|
||||||
this.$emit('input', {
|
|
||||||
filter: 'date',
|
|
||||||
type: 'DATE',
|
|
||||||
compare: this.comparator,
|
|
||||||
metadatum_id: this.metadatum,
|
|
||||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
|
||||||
value: ''
|
|
||||||
});
|
|
||||||
|
|
||||||
this.value = null;
|
this.value = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
dateFormatter(dateObject) {
|
dateFormatter(dateObject) {
|
||||||
return moment(dateObject, moment.ISO_8601).format(this.dateFormat);
|
return moment(dateObject, moment.ISO_8601).format(this.dateFormat);
|
||||||
|
@ -260,13 +213,13 @@
|
||||||
filter: 'date',
|
filter: 'date',
|
||||||
type: 'DATE',
|
type: 'DATE',
|
||||||
compare: this.comparator,
|
compare: this.comparator,
|
||||||
metadatum_id: this.metadatum,
|
metadatum_id: this.metadatumId,
|
||||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
collection_id: this.collectionId,
|
||||||
value: valueQuery
|
value: valueQuery
|
||||||
});
|
});
|
||||||
this.$eventBusSearch.$emit( 'sendValuesToTags', {
|
this.$emit('sendValuesToTags', {
|
||||||
filterId: this.filter.id,
|
label: this.comparator + ' ' + moment(this.value, moment.ISO_8601).format(this.dateFormat),
|
||||||
value: this.comparator + ' ' + moment(this.value, moment.ISO_8601).format(this.dateFormat)
|
value: valueQuery
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -274,9 +227,6 @@
|
||||||
this.comparator = newComparator;
|
this.comparator = newComparator;
|
||||||
this.emit();
|
this.emit();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
this.$eventBusSearch.$off('removeFromFilterTag', this.cleanSearchFromTags);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
type: Object
|
type: Object
|
||||||
},
|
},
|
||||||
value: [String, Number, Array],
|
value: [String, Number, Array],
|
||||||
id: '',
|
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -39,9 +38,6 @@
|
||||||
onUpdateType(type) {
|
onUpdateType(type) {
|
||||||
this.$emit('input', { type: type });
|
this.$emit('input', { type: type });
|
||||||
},
|
},
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.type = this.type && this.value.type ? this.value.type : 'day';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -10,6 +10,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||||
class Date extends Filter_Type {
|
class Date extends Filter_Type {
|
||||||
|
|
||||||
function __construct(){
|
function __construct(){
|
||||||
|
$this->set_name( __('Date', 'tainacan') );
|
||||||
$this->set_supported_types(['date']);
|
$this->set_supported_types(['date']);
|
||||||
$this->set_component('tainacan-filter-date');
|
$this->set_component('tainacan-filter-date');
|
||||||
// $this->set_form_component('tainacan-filter-form-date');
|
// $this->set_form_component('tainacan-filter-form-date');
|
||||||
|
|
|
@ -24,6 +24,12 @@ abstract class Filter_Type {
|
||||||
*/
|
*/
|
||||||
private $default_options = [];
|
private $default_options = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the filter type that will be rendered on labels
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the web component used by this filter type
|
* The name of the web component used by this filter type
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -56,6 +62,20 @@ abstract class Filter_Type {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name for the filter type
|
||||||
|
*/
|
||||||
|
public function set_name($name){
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_name() {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array Supported types by the filter
|
* @return array Supported types by the filter
|
||||||
*/
|
*/
|
||||||
|
@ -103,6 +123,7 @@ abstract class Filter_Type {
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
|
|
||||||
$attributes['className'] = get_class($this);
|
$attributes['className'] = get_class($this);
|
||||||
|
$attributes['name'] = $this->get_name();
|
||||||
$attributes['component'] = $this->get_component();
|
$attributes['component'] = $this->get_component();
|
||||||
$attributes['options'] = $this->get_options();
|
$attributes['options'] = $this->get_options();
|
||||||
$attributes['supported_types'] = $this->get_supported_types();
|
$attributes['supported_types'] = $this->get_supported_types();
|
||||||
|
@ -207,4 +228,8 @@ abstract class Filter_Type {
|
||||||
public function set_form_component($form_component){
|
public function set_form_component($form_component){
|
||||||
$this->form_component = $form_component;
|
$this->form_component = $form_component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_filter_type() {
|
||||||
|
return str_replace( 'Tainacan\Filter_Types\\', '', get_class($this) );
|
||||||
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue