Merge branch 'develop' of github.com:tainacan/tainacan into develop

This commit is contained in:
Jacson Passold 2018-07-16 11:55:27 -03:00
commit cb07acfcf0
39 changed files with 778 additions and 2275 deletions

View File

@ -1,4 +1,4 @@
sudo: false sudo: true
language: php language: php
php: php:
- 7.1 - 7.1
@ -23,6 +23,7 @@ apt:
services: services:
- mysql - mysql
before_install: before_install:
- sudo apt-get update
- sudo apt-get install sshpass - sudo apt-get install sshpass
- sudo service mysql restart - sudo service mysql restart
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;' - mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
@ -33,6 +34,7 @@ install:
true true
- composer install - composer install
- sudo mkdir /tmp/wordpress/wordpress-test/wp-content/uploads - sudo mkdir /tmp/wordpress/wordpress-test/wp-content/uploads
- sudo chmod -R 777 /tmp/wordpress/wordpress-test/wp-content/uploads
- sudo wget https://phar.phpunit.de/phpunit-6.5.7.phar -P /tmp - sudo wget https://phar.phpunit.de/phpunit-6.5.7.phar -P /tmp
- sudo chmod +x /tmp/phpunit-6.5.7.phar - sudo chmod +x /tmp/phpunit-6.5.7.phar
- sudo mv /tmp/phpunit-6.5.7.phar /usr/local/bin/phpunit-6 - sudo mv /tmp/phpunit-6.5.7.phar /usr/local/bin/phpunit-6
@ -52,6 +54,7 @@ before_deploy:
- ssh-add /tmp/deploy_rsa - ssh-add /tmp/deploy_rsa
- echo -e "Host $ssh_host\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config - echo -e "Host $ssh_host\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- ssh-add -l - ssh-add -l
#teste Crontab
deploy: deploy:
- provider: script - provider: script
script: sshpass -p '$ssh_password' ssh $ssh_user@$ssh_host sh /home/l3p/atualiza_git/atualiza_todos.sh #ssh $ssh_user@$ssh_host $script_deploy_tainacan script: sshpass -p '$ssh_password' ssh $ssh_user@$ssh_host sh /home/l3p/atualiza_git/atualiza_todos.sh #ssh $ssh_user@$ssh_host $script_deploy_tainacan

2153
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,6 @@
"axios": "^0.18.0", "axios": "^0.18.0",
"buefy": "^0.6.6", "buefy": "^0.6.6",
"bulma": "^0.7.1", "bulma": "^0.7.1",
"html-to-json": "^0.6.0",
"mdi": "^2.2.43", "mdi": "^2.2.43",
"moment": "^2.22.2", "moment": "^2.22.2",
"npm": "^6.1.0", "npm": "^6.1.0",
@ -18,33 +17,33 @@
"v-mask": "^1.3.2", "v-mask": "^1.3.2",
"v-tooltip": "^2.0.0-rc.33", "v-tooltip": "^2.0.0-rc.33",
"vue": "^2.5.16", "vue": "^2.5.16",
"node-sass": "^4.9.2",
"vue-router": "^3.0.1", "vue-router": "^3.0.1",
"vuedraggable": "^2.16.0", "vuedraggable": "^2.16.0",
"vuex": "^3.0.1" "vuex": "^3.0.1"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^8.6.4", "autoprefixer": "^8.6.5",
"babel-core": "^6.26.3", "babel-core": "^6.26.3",
"babel-loader": "^7.1.4", "babel-loader": "^7.1.5",
"babel-preset-env": "^1.7.0", "babel-preset-env": "^1.7.0",
"babel-preset-stage-3": "^6.24.1", "babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"css-loader": "^0.28.11", "css-loader": "^1.0.0",
"cypress": "^3.0.2", "cypress": "^3.0.2",
"element-theme-chalk": "^2.4.3", "element-theme-chalk": "^2.4.3",
"eslint": "^5.0.1", "eslint": "^5.1.0",
"eslint-loader": "^2.0.0", "eslint-loader": "^2.0.0",
"eslint-plugin-vue": "^4.5.0", "eslint-plugin-vue": "^4.5.0",
"file-loader": "^1.1.11", "file-loader": "^1.1.11",
"node-sass": "^4.9.1", "postcss-loader": "^2.1.6",
"postcss-loader": "^2.1.5",
"sass-loader": "^7.0.3", "sass-loader": "^7.0.3",
"style-loader": "^0.21.0", "style-loader": "^0.21.0",
"uglifyjs-webpack-plugin": "^1.2.7", "uglifyjs-webpack-plugin": "^1.2.7",
"vue-custom-element": "^3.2.1", "vue-custom-element": "^3.2.2",
"vue-loader": "^15.2.4", "vue-loader": "^15.2.4",
"vue-template-compiler": "^2.5.16", "vue-template-compiler": "^2.5.16",
"webpack": "^4.15.1", "webpack": "^4.16.0",
"webpack-cli": "^3.0.8", "webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4" "webpack-dev-server": "^3.1.4"
} }

View File

@ -18,7 +18,9 @@ class Admin {
private function __construct() { private function __construct() {
add_action( 'wp_ajax_tainacan_date_i18n', array( &$this, 'ajax_date_i18n') ); add_action( 'wp_ajax_tainacan-date-i18n', array( &$this, 'ajax_date_i18n') );
add_action( 'wp_ajax_tainacan-sample-permalink', array( &$this, 'ajax_sample_permalink') );
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) ); add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) ); add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
@ -119,7 +121,7 @@ class Admin {
wp_localize_script( 'tainacan-user-admin', 'tainacan_plugin', $settings ); wp_localize_script( 'tainacan-user-admin', 'tainacan_plugin', $settings );
wp_enqueue_media(); wp_enqueue_media();
wp_enqueue_script('undescore', includes_url('js') . '/underscore.min.js' ); wp_enqueue_script('underscore', includes_url('js') . '/underscore.min.js' );
wp_enqueue_script('jcrop'); wp_enqueue_script('jcrop');
wp_enqueue_script( 'customize-controls' ); wp_enqueue_script( 'customize-controls' );
@ -170,7 +172,6 @@ class Admin {
'root_wp_api' => esc_url_raw( rest_url() ) . 'wp/v2/', 'root_wp_api' => esc_url_raw( rest_url() ) . 'wp/v2/',
'wp_ajax_url' => admin_url( 'admin-ajax.php' ), 'wp_ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wp_rest' ), 'nonce' => wp_create_nonce( 'wp_rest' ),
'sample_permalink_nonce' => wp_create_nonce( 'samplepermalink' ),
'components' => $components, 'components' => $components,
'i18n' => $tainacan_admin_i18n, 'i18n' => $tainacan_admin_i18n,
'user_caps' => $user_caps, 'user_caps' => $user_caps,
@ -242,5 +243,61 @@ class Admin {
wp_die(); wp_die();
} }
function ajax_sample_permalink(){
$id = $_POST['post_id'];
$title = $_POST['new_title'];
$name = $_POST['new_slug'];
$post = get_post( $id );
if ( ! $post )
return array( '', '' );
$ptype = get_post_type_object($post->post_type);
// Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published.
if ( in_array( $post->post_status, array( 'auto-draft', 'draft', 'pending', 'future' ) ) ) {
$post->post_status = 'publish';
$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
}
// If the user wants to set a new name -- override the current one
// Note: if empty name is supplied -- use the title instead, see #6072
if ( !is_null($name) )
$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
$post->filter = 'sample';
$permalink = get_permalink($post, true);
// Replace custom post_type Token with generic pagename token for ease of use.
$permalink = str_replace("%$post->post_type%", '%pagename%', $permalink);
// Handle page hierarchy
if ( $ptype->hierarchical ) {
$uri = get_page_uri($post);
if ( $uri ) {
$uri = untrailingslashit($uri);
$uri = strrev( stristr( strrev( $uri ), '/' ) );
$uri = untrailingslashit($uri);
}
/** This filter is documented in wp-admin/edit-tag-form.php */
$uri = apply_filters( 'editable_slug', $uri, $post );
if ( !empty($uri) )
$uri .= '/';
$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
}
/** This filter is documented in wp-admin/edit-tag-form.php */
$permalink = array( 'permalink' => $permalink, 'slug' => apply_filters( 'editable_slug', $post->post_name, $post ) );
echo json_encode($permalink);
wp_die();
}
} }

View File

@ -260,6 +260,7 @@
<b-input <b-input
id="tainacan-text-name" id="tainacan-text-name"
v-model="form.name" v-model="form.name"
@blur="updateSlug"
@focus="clearErrors('name')"/> @focus="clearErrors('name')"/>
</b-field> </b-field>
@ -359,6 +360,7 @@
:message="$i18n.getHelperMessage('collections', 'slug')"/> :message="$i18n.getHelperMessage('collections', 'slug')"/>
<b-input <b-input
id="tainacan-text-slug" id="tainacan-text-slug"
@input="updateSlug"
v-model="form.slug" v-model="form.slug"
@focus="clearErrors('slug')"/> @focus="clearErrors('slug')"/>
</b-field> </b-field>
@ -393,9 +395,11 @@
<script> <script>
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import wpMediaFrames from '../../js/wp-media-frames'; import wpMediaFrames from '../../js/wp-media-frames';
import { wpAjax } from '../../js/mixins';
export default { export default {
name: 'CollectionEditionForm', name: 'CollectionEditionForm',
mixins: [ wpAjax ],
data(){ data(){
return { return {
collectionId: Number, collectionId: Number,
@ -452,7 +456,8 @@ export default {
registeredViewModes: tainacan_plugin.registered_view_modes, registeredViewModes: tainacan_plugin.registered_view_modes,
viewModesList: [], viewModesList: [],
fromImporter: '', fromImporter: '',
newPagePath: tainacan_plugin.admin_url + 'post-new.php?post_type=page' newPagePath: tainacan_plugin.admin_url + 'post-new.php?post_type=page',
isUpdatingSlug: false,
} }
}, },
methods: { methods: {
@ -471,6 +476,27 @@ export default {
...mapActions('metadata', [ ...mapActions('metadata', [
'fetchMetadata' 'fetchMetadata'
]), ]),
updateSlug: _.debounce(function() {
if(!this.form.name || this.form.name.length <= 0){
return;
}
this.isUpdatingSlug = true;
this.getSamplePermalink(this.collectionId, this.form.name, this.form.slug)
.then((res) => {
this.form.slug = res.data.slug;
this.isUpdatingSlug = false;
this.formErrorMessage = '';
this.editFormErrors = {};
})
.catch(errors => {
this.$console.error(errors);
this.isUpdatingSlug = false;
});
}, 500),
onSubmit() { onSubmit() {
this.isLoading = true; this.isLoading = true;
@ -770,8 +796,7 @@ export default {
} }
}, },
mounted() { mounted() {
if (!this.$route.path.includes("new")) {
if (this.$route.path.split("/").pop() != "new") {
document.getElementById('collection-page-container').addEventListener('scroll', ($event) => { document.getElementById('collection-page-container').addEventListener('scroll', ($event) => {
this.$emit('onShrinkHeader', ($event.target.scrollTop > 53)); this.$emit('onShrinkHeader', ($event.target.scrollTop > 53));
}); });

View File

@ -415,6 +415,7 @@ export default {
this.updateImporterOptions({ sessionId: this.sessionId, optionsForm: formObj }) this.updateImporterOptions({ sessionId: this.sessionId, optionsForm: formObj })
.then(updatedImporter => { .then(updatedImporter => {
this.importer = updatedImporter; this.importer = updatedImporter;
this.finishRunImporter(); this.finishRunImporter();
}) })
.catch((errors) => { .catch((errors) => {

View File

@ -343,6 +343,19 @@
</div> </div>
</div>--> </div>-->
<!-- Collection -------------------------------- -->
<div class="section-label">
<label>{{ $i18n.get('collection') }}</label>
</div>
<div class="section-collection">
<div class="field has-addons">
<p>
{{ collectionName }}
</p>
</div>
</div>
<!-- Metadata from Collection-------------------------------- -->
<label class="section-label">{{ $i18n.get('metadata') }}</label> <label class="section-label">{{ $i18n.get('metadata') }}</label>
<br> <br>
<a <a
@ -353,8 +366,6 @@
type="is-gray" type="is-gray"
:icon=" collapseAll ? 'menu-down' : 'menu-right'" /> :icon=" collapseAll ? 'menu-down' : 'menu-right'" />
</a> </a>
<!-- Metadata from Collection-------------------------------- -->
<tainacan-form-item <tainacan-form-item
v-for="(metadatum, index) of metadatumList" v-for="(metadatum, index) of metadatumList"
:key="index" :key="index"
@ -367,14 +378,17 @@
<div class="footer"> <div class="footer">
<!-- Last Updated Info --> <!-- Last Updated Info -->
<div class="update-info-section"> <div class="update-info-section">
<p>{{ ($i18n.get('info_updated_at') + ' ' + lastUpdated) }} <p v-if="!isUpdatingValues">
<em> {{ ($i18n.get('info_updated_at') + ' ' + lastUpdated) }}
<span v-if="isUpdatingValues && !isEditingValues">&nbsp;&nbsp;{{ $i18n.get('info_updating_metadata_values') }}</span> <span class="help is-danger">{{ formErrorMessage }}</span>
<span v-if="isEditingValues">&nbsp;&nbsp;{{ $i18n.get('info_editing_metadata_values') }}</span>
</em>
</p> </p>
<p class="help is-danger">{{ errorList }}</p> <p
<p class="help is-danger">{{ formErrorMessage }}</p> class="update-warning"
v-if="isUpdatingValues">
<b-icon icon="autorenew" />{{ $i18n.get('info_updating_metadata_values') }}
<span class="help is-danger">{{ formErrorMessage }}</span>
</p>
</div> </div>
<div <div
class="form-submission-footer" class="form-submission-footer"
@ -408,7 +422,7 @@
<button <button
@click="onSubmit('draft')" @click="onSubmit('draft')"
type="button" type="button"
class="button is-secondary">{{ form.status == 'draft' ? $i18n.get('label_update_draft') : $i18n.get('label_save_as_draft') }}</button> class="button is-secondary">{{ form.status == 'draft' ? $i18n.get('label_update') : $i18n.get('label_save_as_draft') }}</button>
<button <button
@click="onSubmit(visibility)" @click="onSubmit(visibility)"
type="button" type="button"
@ -426,9 +440,10 @@
type="button" type="button"
class="button is-secondary">{{ $i18n.get('label_return_to_draft') }}</button> class="button is-secondary">{{ $i18n.get('label_return_to_draft') }}</button>
<button <button
:disabled="formErrorMessage != undefined && formErrorMessage != ''"
@click="onSubmit(visibility)" @click="onSubmit(visibility)"
type="button" type="button"
class="button is-success">{{ $i18n.get('label_update') }}</button> class="button is-secondary">{{ $i18n.get('label_update') }}</button>
</div> </div>
</div> </div>
</form> </form>
@ -485,8 +500,8 @@ export default {
urlLink: '', urlLink: '',
isTextModalActive: false, isTextModalActive: false,
textLink: '', textLink: '',
isEditingValues: false, isUpdatingValues: false,
isUpdatingValues: false collectionName: ''
} }
}, },
computed: { computed: {
@ -498,9 +513,6 @@ export default {
}, },
lastUpdated() { lastUpdated() {
return this.getLastUpdated(); return this.getLastUpdated();
},
errrorList() {
return eventBus.errors;
} }
}, },
components: { components: {
@ -527,6 +539,7 @@ export default {
'getLastUpdated' 'getLastUpdated'
]), ]),
...mapActions('collection', [ ...mapActions('collection', [
'fetchCollectionName',
'deleteItem', 'deleteItem',
]), ]),
onSubmit(status) { onSubmit(status) {
@ -820,6 +833,11 @@ export default {
this.fetchAttachments(this.itemId); this.fetchAttachments(this.itemId);
} }
// Obtains collection name
this.fetchCollectionName(this.collectionId).then((collectionName) => {
this.collectionName = collectionName;
});
// Sets feedback variables // Sets feedback variables
eventBus.$on('isUpdatingValue', (status) => { eventBus.$on('isUpdatingValue', (status) => {
this.isUpdatingValues = status; this.isUpdatingValues = status;
@ -831,6 +849,12 @@ export default {
// }) // })
// } // }
}); });
eventBus.$on('hasErrorsOnForm', (hasErrors) => {
if (hasErrors)
this.formErrorMessage = this.$i18n.get('info_errors_in_form');
else
this.formErrorMessage = '';
});
this.cleanLastUpdated(); this.cleanLastUpdated();
}, },
mounted() { mounted() {
@ -886,7 +910,7 @@ export default {
} }
.page-container-shrinked { .page-container-shrinked {
height: calc(100% - 132px) !important; // Bigger than the others due footer's height height: calc(100% - 118px) !important; // Bigger than the others due footer's height
} }
.page-container { .page-container {
@ -1058,36 +1082,48 @@ export default {
} }
.footer { .footer {
padding: 18px $page-side-padding;
padding: 24px $page-side-padding;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
z-index: 999999; z-index: 999999;
background-color: white; background-color: $primary-lighter;
border-top: 2px solid $secondary;
width: 100%; width: 100%;
height: 65px;
display: flex;
justify-content: flex-end;
align-items: center;
.form-submission-footer { .form-submission-footer {
width: 100%;
display: flex;
justify-content: end;
.button { .button {
margin-left: 6px; margin-left: 16px;
margin-right: 6px; margin-right: 6px;
} }
.button.is-outlined {
margin-left: 0px;
margin-right: auto;
} }
@keyframes blink {
from { color: $tertiary; }
to { color: $gray-light; }
}
.update-warning {
color: $tertiary;
animation-name: blink;
animation-duration: 0.5s;
animation-delay: 0.5s;
align-items: center;
display: flex;
} }
.update-info-section { .update-info-section {
text-align: center;
position: relative;
margin-top: -20px;
top: 28px;
color: $gray-light; color: $gray-light;
margin-right: auto;
}
.help {
display: inline-block;
font-size: 1.0em;
margin-top: 0;
margin-left: 24px;
} }
} }

View File

@ -135,8 +135,7 @@
<script> <script>
import { wpAjax } from "../../js/mixins"; import { wpAjax } from "../../js/mixins";
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import TermsList from '../lists/terms-list.vue' import TermsList from '../lists/terms-list.vue';
import htmlToJSON from 'html-to-json';
import CustomDialog from '../other/custom-dialog.vue'; import CustomDialog from '../other/custom-dialog.vue';
export default { export default {
@ -260,7 +259,7 @@
this.isLoadingTaxonomy = false; this.isLoadingTaxonomy = false;
}); });
}, },
updateSlug(){ updateSlug: _.debounce(function(){
if(!this.form.name || this.form.name.length <= 0){ if(!this.form.name || this.form.name.length <= 0){
return; return;
} }
@ -268,18 +267,8 @@
this.isUpdatingSlug = true; this.isUpdatingSlug = true;
this.getSamplePermalink(this.taxonomyId, this.form.name, this.form.slug) this.getSamplePermalink(this.taxonomyId, this.form.name, this.form.slug)
.then(samplePermalink => { .then((res) => {
this.form.slug = res.data.slug;
let promise = htmlToJSON.parse(samplePermalink, {
permalink($doc) {
return $doc.find('#editable-post-name-full').text();
}
});
promise.done((result) => {
this.form.slug = result.permalink;
//this.$console.info(this.form.slug);
});
this.isUpdatingSlug = false; this.isUpdatingSlug = false;
this.formErrorMessage = ''; this.formErrorMessage = '';
@ -291,7 +280,7 @@
this.isUpdatingSlug = false; this.isUpdatingSlug = false;
}); });
}, }, 500),
createNewTaxonomy() { createNewTaxonomy() {
// Puts loading on Draft Taxonomy creation // Puts loading on Draft Taxonomy creation
this.isLoadingTaxonomy = true; this.isLoadingTaxonomy = true;

View File

@ -92,13 +92,13 @@
</button> </button>
</div> </div>
<div class="control"> <div class="control">
<button <a
type="button" type="button"
v-if="editForm.url != undefined && editForm.url!= ''" v-if="editForm.url != undefined && editForm.url!= ''"
class="button is-secondary" class="button is-secondary"
:href="editForm.url"> :href="editForm.url">
{{ $i18n.get('see') + ' ' + $i18n.get('term') }} {{ $i18n.get('see') + ' ' + $i18n.get('term') }}
</button> </a>
</div> </div>
<div class="control"> <div class="control">
<button <button

View File

@ -1,6 +1,6 @@
<template> <template>
<div <div
v-if="totalCollections > 0 && !isLoading" v-if="collections.length > 0 && !isLoading"
class="table-container"> class="table-container">
<div class="selection-control"> <div class="selection-control">
<div class="field select-all is-pulled-left"> <div class="field select-all is-pulled-left">
@ -13,7 +13,7 @@
<div class="field is-pulled-right"> <div class="field is-pulled-right">
<b-dropdown <b-dropdown
position="is-bottom-left" position="is-bottom-left"
v-if="collections[0].current_user_can_edit" v-if="$userCaps.hasCapability('delete_tainacan-collections')"
:disabled="!isSelectingCollections" :disabled="!isSelectingCollections"
id="bulk-actions-dropdown"> id="bulk-actions-dropdown">
<button <button

View File

@ -1,6 +1,6 @@
<template> <template>
<div <div
v-if="total > 0 && !isLoading" v-if="taxonomies.length > 0 && !isLoading"
class="table-container"> class="table-container">
<div class="selection-control"> <div class="selection-control">
@ -14,7 +14,7 @@
<div class="field is-pulled-right"> <div class="field is-pulled-right">
<b-dropdown <b-dropdown
position="is-bottom-left" position="is-bottom-left"
v-if="taxonomies[0].current_user_can_edit" v-if="$userCaps.hasCapability('delete_tainacan-taxonomies')"
:disabled="!isSelecting" :disabled="!isSelecting"
id="bulk-actions-dropdown"> id="bulk-actions-dropdown">
<button <button
@ -120,7 +120,7 @@
@click.prevent.stop="deleteOneTaxonomy(taxonomy.id)"> @click.prevent.stop="deleteOneTaxonomy(taxonomy.id)">
<b-icon <b-icon
type="is-secondary" type="is-secondary"
icon="delete"/> :icon="!isOnTrash ? 'delete' : 'delete-forever'"/>
</a> </a>
</div> </div>
</td> </td>
@ -149,7 +149,8 @@
total: 0, total: 0,
page: 1, page: 1,
taxonomiesPerPage: 12, taxonomiesPerPage: 12,
taxonomies: Array taxonomies: Array,
isOnTrash: false
}, },
watch: { watch: {
taxonomies() { taxonomies() {
@ -188,7 +189,7 @@
title: this.$i18n.get('label_warning'), title: this.$i18n.get('label_warning'),
message: this.$i18n.get('info_warning_taxonomy_delete'), message: this.$i18n.get('info_warning_taxonomy_delete'),
onConfirm: () => { onConfirm: () => {
this.deleteTaxonomy(taxonomyId) this.deleteTaxonomy({ taxonomyId: taxonomyId, isPermanently: this.isOnTrash })
.then(() => { .then(() => {
// this.$toast.open({ // this.$toast.open({
// duration: 3000, // duration: 3000,
@ -227,7 +228,7 @@
for (let i = 0; i < this.taxonomies.length; i++) { for (let i = 0; i < this.taxonomies.length; i++) {
if (this.selected[i]) { if (this.selected[i]) {
this.deleteTaxonomy(this.taxonomies[i].id) this.deleteTaxonomy({ taxonomyId: this.taxonomies[i].id, isPermanently: this.isOnTrash })
.then(() => { .then(() => {
// this.load(); // this.load();
// this.$toast.open({ // this.$toast.open({

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <div class="extra-margin">
<collections-filter <collections-filter
:open="collapsed" :open="collapsed"
:query="getQuery" :query="getQuery"
@ -40,3 +40,9 @@
} }
} }
</script> </script>
<style>
.extra-margin {
margin-bottom: 40px;
}
</style>

View File

@ -1,6 +1,6 @@
// Overrides lodash by original WordPress Underscore Library // Overrides lodash by original WordPress Underscore Library
window.lodash = _.noConflict(); //window.lodash = _.noConflict();
window.underscore = _.noConflict(); //window.underscore = _.noConflict();
// Main imports // Main imports
import Vue from 'vue'; import Vue from 'vue';

View File

@ -15,30 +15,20 @@ export const wpAjax = {
}, },
methods: { methods: {
getSamplePermalink(id, newTitle, newSlug){ getSamplePermalink(id, newTitle, newSlug){
return new Promise((resolve, reject) => { return this.axiosWPAjax.post('', qs.stringify({
this.axiosWPAjax.post('', qs.stringify({ action: 'tainacan-sample-permalink',
action: 'sample-permalink',
post_id: id, post_id: id,
new_title: newTitle, new_title: newTitle,
new_slug: newSlug, new_slug: newSlug,
samplepermalinknonce: tainacan_plugin.sample_permalink_nonce, nonce: tainacan_plugin.nonce,
})) }));
.then(res => {
resolve(res.data);
})
.catch(error => {
reject(error)
})
});
}, },
getDatei18n(dateString){ getDatei18n(dateString){
this.axiosWPAjax.post('', qs.stringify({ return this.axiosWPAjax.post('', qs.stringify({
action: 'tainacan_date_i18n', action: 'tainacan-date-i18n',
date_string: dateString, date_string: dateString,
nonce: tainacan_plugin.nonce, nonce: tainacan_plugin.nonce,
})).then(res => { }));
return res.data
});
}, },
} }
}; };

View File

@ -62,7 +62,7 @@
:is-on-trash="status == 'trash'"/> :is-on-trash="status == 'trash'"/>
<!-- Empty state image --> <!-- Empty state image -->
<div v-if="totalCollections <= 0 && !isLoading"> <div v-if="collections.length <= 0 && !isLoading">
<section class="section"> <section class="section">
<div class="content has-text-grey has-text-centered"> <div class="content has-text-grey has-text-centered">
<p> <p>
@ -88,7 +88,7 @@
<!-- Footer --> <!-- Footer -->
<div <div
class="pagination-area" class="pagination-area"
v-if="totalCollections > 0"> v-if="collections.length > 0">
<div class="shown-items"> <div class="shown-items">
{{ {{
$i18n.get('info_showing_collections') + $i18n.get('info_showing_collections') +

View File

@ -216,12 +216,20 @@
</option> --> </option> -->
</b-select> </b-select>
<button <button
:disabled="totalItems <= 0" class="button is-white is-small"
:disabled="totalItems <= 0 || order == 'DESC'"
@click="onChangeOrder()">
<span class="icon is-small gray-icon">
<i class="mdi mdi-sort-ascending"/>
</span>
</button>
<button
:disabled="totalItems <= 0 || order == 'ASC'"
class="button is-white is-small" class="button is-white is-small"
@click="onChangeOrder()"> @click="onChangeOrder()">
<b-icon <span class="icon is-small gray-icon">
class="gray-icon" <i class="mdi mdi-sort-descending"/>
:icon="order === 'ASC' ? 'sort-ascending' : 'sort-descending'"/> </span>
</button> </button>
</b-field> </b-field>
</div> </div>
@ -247,6 +255,7 @@
<b-icon icon="menu-down" /> <b-icon icon="menu-down" />
</button> </button>
<b-dropdown-item <b-dropdown-item
:class="{ 'is-active': viewModeOption == viewMode }"
v-for="(viewModeOption, index) of enabledViewModes" v-for="(viewModeOption, index) of enabledViewModes"
:key="index" :key="index"
:value="viewModeOption" :value="viewModeOption"
@ -272,39 +281,50 @@
class="button is-white" class="button is-white"
slot="trigger"> slot="trigger">
<span> <span>
<b-icon <span class="icon is-small gray-icon">
class="gray-icon view-mode-icon" <i
:icon="(adminViewMode == 'table' || adminViewMode == undefined) ? :class="{'mdi-table' : ( adminViewMode == 'table' || adminViewMode == undefined),
'table' : (adminViewMode == 'cards' ? 'mdi-view-list' : adminViewMode == 'cards',
'view-list' : 'view-grid')"/> 'mdi-view-grid' : adminViewMode == 'grid',
'mdi-view-module' : adminViewMode == 'records'}"
class="mdi"/>
</span>
</span> </span>
&nbsp;&nbsp;&nbsp;{{ $i18n.get('label_visualization') }} &nbsp;&nbsp;&nbsp;{{ $i18n.get('label_visualization') }}
<b-icon icon="menu-down" /> <b-icon icon="menu-down" />
</button> </button>
<b-dropdown-item :value="'table'"> <b-dropdown-item
:class="{ 'is-active': adminViewMode == 'table' }"
:value="'table'">
<b-icon <b-icon
class="gray-icon" class="gray-icon"
icon="table"/> icon="table"/>
{{ $i18n.get('label_table') }} {{ $i18n.get('label_table') }}
</b-dropdown-item> </b-dropdown-item>
<b-dropdown-item :value="'cards'"> <b-dropdown-item
:class="{ 'is-active': adminViewMode == 'cards' }"
:value="'cards'">
<b-icon <b-icon
class="gray-icon" class="gray-icon"
icon="view-list"/> icon="view-list"/>
{{ $i18n.get('label_cards') }} {{ $i18n.get('label_cards') }}
</b-dropdown-item> </b-dropdown-item>
<b-dropdown-item :value="'records'"> <b-dropdown-item
<b-icon :class="{ 'is-active': adminViewMode == 'grid' }"
class="gray-icon" :value="'grid'">
icon="view-module"/>
{{ $i18n.get('label_records') }}
</b-dropdown-item>
<b-dropdown-item :value="'grid'">
<b-icon <b-icon
class="gray-icon" class="gray-icon"
icon="view-grid"/> icon="view-grid"/>
{{ $i18n.get('label_grid') }} {{ $i18n.get('label_grid') }}
</b-dropdown-item> </b-dropdown-item>
<b-dropdown-item
:class="{ 'is-active': adminViewMode == 'records' }"
:value="'records'">
<b-icon
class="gray-icon"
icon="view-module"/>
{{ $i18n.get('label_records') }}
</b-dropdown-item>
</b-dropdown> </b-dropdown>
</b-field> </b-field>
</div> </div>
@ -327,7 +347,7 @@
class="control"> class="control">
<button <button
@click="advancedSearchResults = !advancedSearchResults" @click="advancedSearchResults = !advancedSearchResults"
class="button is-small is-light">{{ $i18n.get('edit_search') }}</button> class="button is-small is-outlined">{{ $i18n.get('edit_search') }}</button>
</p> </p>
<p <p
v-if="advancedSearchResults" v-if="advancedSearchResults"
@ -1002,6 +1022,7 @@
.gray-icon, .gray-icon .icon { .gray-icon, .gray-icon .icon {
color: $tainacan-placeholder-color !important; color: $tainacan-placeholder-color !important;
padding-right: 10px;
} }
.gray-icon .icon i::before, .gray-icon i::before { .gray-icon .icon i::before, .gray-icon i::before {
font-size: 21px !important; font-size: 21px !important;
@ -1018,11 +1039,13 @@
div.dropdown-content { div.dropdown-content {
padding: 0; padding: 0;
.metadata-options-container { .metadata-options-container {
max-height: 240px; max-height: 240px;
overflow: auto; overflow: auto;
} }
.dropdown-item {
padding: 0.25rem 1.0rem 0.25rem 0.75rem;
}
.dropdown-item span{ .dropdown-item span{
vertical-align: sub; vertical-align: sub;
} }

View File

@ -37,12 +37,13 @@
<taxonomies-list <taxonomies-list
:is-loading="isLoading" :is-loading="isLoading"
:total="total" :total="total"
:is-on-trash="status == 'trash'"
:page="page" :page="page"
:taxonomies-per-page="taxonomiesPerPage" :taxonomies-per-page="taxonomiesPerPage"
:taxonomies="taxonomies"/> :taxonomies="taxonomies"/>
<!-- Empty state image --> <!-- Empty state image -->
<div v-if="total <= 0 && !isLoading"> <div v-if="taxonomies.length <= 0 && !isLoading">
<section class="section"> <section class="section">
<div class="content has-text-grey has-text-centered"> <div class="content has-text-grey has-text-centered">
<p> <p>
@ -67,7 +68,7 @@
<!-- Footer --> <!-- Footer -->
<div <div
class="pagination-area" class="pagination-area"
v-if="total > 0"> v-if="taxonomies.length > 0">
<div class="shown-items"> <div class="shown-items">
{{ {{
$i18n.get('info_showing_taxonomies') + $i18n.get('info_showing_taxonomies') +

View File

@ -9,7 +9,8 @@
<b-icon :icon="isMetadataColumnCompressed ? 'menu-left' : 'menu-right'" /> <b-icon :icon="isMetadataColumnCompressed ? 'menu-left' : 'menu-right'" />
</button> </button>
<tainacan-title/> <tainacan-title/>
<div class="tainacan-form columns"> <div class="tainacan-form">
<div class="columns">
<div class="column is-5-5"> <div class="column is-5-5">
<!-- Document -------------------------------- --> <!-- Document -------------------------------- -->
@ -35,6 +36,9 @@
<div v-html="item.document_as_html"/> <div v-html="item.document_as_html"/>
</div> </div>
</div> </div>
<div v-else>
<p>{{ $i18n.get('info_no_document_to_item') }}</p>
</div>
</div> </div>
<!-- Thumbnail -------------------------------- --> <!-- Thumbnail -------------------------------- -->
@ -88,7 +92,6 @@
<!-- Visibility (status public or private) -------------------------------- --> <!-- Visibility (status public or private) -------------------------------- -->
<div class="section-label"> <div class="section-label">
<label>{{ $i18n.get('label_visibility') }}</label> <label>{{ $i18n.get('label_visibility') }}</label>
<span class="required-metadatum-asterisk">*</span>
</div> </div>
<div class="section-status"> <div class="section-status">
<div class="field has-addons"> <div class="field has-addons">
@ -105,8 +108,23 @@
</div> </div>
</div> </div>
<!-- Collection -------------------------------- -->
<div class="section-label">
<label>{{ $i18n.get('collection') }}</label>
</div>
<div class="section-status">
<div class="field has-addons">
<span>
{{ collectionName }}
</span>
</div>
</div>
<!-- Metadata -------------------------------- --> <!-- Metadata -------------------------------- -->
<label class="section-label">{{ $i18n.get('metadata') }}</label> <div class="section-label">
<label>{{ $i18n.get('metadata') }}</label>
</div>
<br> <br>
<a <a
class="collapse-all" class="collapse-all"
@ -162,6 +180,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
@ -177,6 +196,8 @@
isLoading: false, isLoading: false,
isMetadataColumnCompressed: false, isMetadataColumnCompressed: false,
open: false, open: false,
collectionName: '',
thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png'
} }
}, },
components: { components: {
@ -188,6 +209,9 @@
'fetchAttachments', 'fetchAttachments',
'fetchMetadata', 'fetchMetadata',
]), ]),
...mapActions('collection', [
'fetchCollectionName'
]),
...mapGetters('item', [ ...mapGetters('item', [
'getItem', 'getItem',
'getMetadata', 'getMetadata',
@ -224,6 +248,11 @@
this.loadMetadata(); this.loadMetadata();
}); });
// Obtains collection name
this.fetchCollectionName(this.collectionId).then((collectionName) => {
this.collectionName = collectionName;
});
// Get attachments // Get attachments
this.fetchAttachments(this.itemId); this.fetchAttachments(this.itemId);
} }
@ -258,7 +287,7 @@
} }
.page-container-shrinked { .page-container-shrinked {
height: calc(100% - 132px) !important; // Bigger than the others due footer's height height: calc(100% - 118px) !important; // Bigger than the others due footer's height
} }
.page-container { .page-container {
@ -269,6 +298,10 @@
padding-right: $page-side-padding; padding-right: $page-side-padding;
} }
.tainacan-form>.columns {
margin-bottom: 70px;
}
.column.is-5-5 { .column.is-5-5 {
width: 45.833333333%; width: 45.833333333%;
padding-left: $page-side-padding; padding-left: $page-side-padding;
@ -288,16 +321,15 @@
.field { .field {
padding: 10px 0px 10px 30px; padding: 10px 0px 10px 30px;
.collapse .collapse-content {
margin-left: 30px;
}
} }
@media screen and (max-width: 769px) { @media screen and (max-width: 769px) {
width: 100%; width: 100%;
} }
} }
.collapse .collapse-content {
margin-left: 30px;
}
} }
.field { .field {
@ -418,22 +450,21 @@
} }
.footer { .footer {
padding: 18px $page-side-padding;
padding: 24px $page-side-padding;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
z-index: 999999; z-index: 999999;
background-color: white; background-color: $primary-lighter;
border-top: 2px solid $secondary;
width: 100%; width: 100%;
height: 65px;
.form-submission-footer { .form-submission-footer {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: end; justify-content: flex-end;
.button { .button {
margin-left: 6px; margin-left: 16px;
margin-right: 6px; margin-right: 6px;
} }
.button.is-outlined { .button.is-outlined {

View File

@ -34,8 +34,11 @@
&:focus { &:focus {
outline: 0px; outline: 0px;
} }
&[disabled] { &[disabled], &:hover[disabled] {
border: none; border: none !important;
cursor: not-allowed !important;
color: $gray-light !important;
background-color: $tainacan-input-background !important;
} }
&.is-white[disabled] { &.is-white[disabled] {
background-color: white !important; background-color: white !important;

View File

@ -30,7 +30,7 @@
.b-checkbox { width: 100% }; .b-checkbox { width: 100% };
&:hover { background-color: $primary-lighter; } &:hover { background-color: $primary-lighter; }
.is-small { color: gray; } .is-small { color: gray; }
&.is-active { background-color: white; } &.is-active { background-color: $primary-light; }
} }
} }
} }

View File

@ -14,6 +14,8 @@
table.tainacan-table { table.tainacan-table {
width: 100%; width: 100%;
border-collapse: separate;
border-spacing: 0;
.checkbox-cell { .checkbox-cell {
min-width: 38px; min-width: 38px;

View File

@ -24,13 +24,12 @@ return apply_filters( 'tainacan-admin-i18n', [
'item' => __( 'Item', 'tainacan' ), 'item' => __( 'Item', 'tainacan' ),
'metadatum' => __( 'Metadata', 'tainacan' ), 'metadatum' => __( 'Metadata', 'tainacan' ),
'filter' => __( 'Filter', 'tainacan' ), 'filter' => __( 'Filter', 'tainacan' ),
'taxonomy' => __( 'Taxonomia', 'tainacan' ), 'taxonomy' => __( 'Taxonomy', 'tainacan' ),
'event' => __( 'Event', 'tainacan' ), 'event' => __( 'Event', 'tainacan' ),
'term' => __( 'Term', 'tainacan' ), 'term' => __( 'Term', 'tainacan' ),
'terms' => __( 'Terms', 'tainacan' ), 'terms' => __( 'Terms', 'tainacan' ),
'mapping' => __( 'Mapping', 'tainacan' ), 'mapping' => __( 'Mapping', 'tainacan' ),
'importers' => __( 'Importers', 'tainacan' ), 'importers' => __( 'Importers', 'tainacan' ),
'metadata' => __( 'metadata', 'tainacan' ),
// Actions // Actions
'edit' => __( 'Edit', 'tainacan' ), 'edit' => __( 'Edit', 'tainacan' ),
@ -255,7 +254,6 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_update_draft' => __( 'Update draft', 'tainacan' ), 'label_update_draft' => __( 'Update draft', 'tainacan' ),
'label_return_to_draft' => __( 'Return to draft', 'tainacan' ), 'label_return_to_draft' => __( 'Return to draft', 'tainacan' ),
'label_publish' => __( 'Publish', 'tainacan' ), 'label_publish' => __( 'Publish', 'tainacan' ),
'label_send_to_trash' => __( 'Send to trash', 'tainacan' ),
'label_update' => __( 'Update', 'tainacan' ), 'label_update' => __( 'Update', 'tainacan' ),
'label_mapper_metadata' => __( 'Mapper Metadata', 'tainacan' ), 'label_mapper_metadata' => __( 'Mapper Metadata', 'tainacan' ),
'label_add_more_mapper_metadata' => __( 'Add more mapper\'s metadata', 'tainacan' ), 'label_add_more_mapper_metadata' => __( 'Add more mapper\'s metadata', 'tainacan' ),
@ -283,7 +281,6 @@ return apply_filters( 'tainacan-admin-i18n', [
'instruction_search' => __( 'Search', 'tainacan' ), 'instruction_search' => __( 'Search', 'tainacan' ),
'instruction_search_in_repository' => __( 'Search in repository', 'tainacan' ), 'instruction_search_in_repository' => __( 'Search in repository', 'tainacan' ),
'instruction_select_a_target_collection' => __( 'Select a target collection', 'tainacan' ), 'instruction_select_a_target_collection' => __( 'Select a target collection', 'tainacan' ),
'instruction_select_a_metadatum' => __( 'Select a metadatum', 'tainacan' ),
'instruction_select_a_mapper' => __( 'Select a mapper', 'tainacan' ), 'instruction_select_a_mapper' => __( 'Select a mapper', 'tainacan' ),
'instruction_select_an_importer_type' => __( 'Select an importer type from the options above:', 'tainacan' ), 'instruction_select_an_importer_type' => __( 'Select an importer type from the options above:', 'tainacan' ),
'instruction_drop_file_or_click_to_upload' => __( 'Drop your source file or click here to upload.', 'tainacan' ), 'instruction_drop_file_or_click_to_upload' => __( 'Drop your source file or click here to upload.', 'tainacan' ),
@ -374,6 +371,9 @@ return apply_filters( 'tainacan-admin-i18n', [
'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...', '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_no_document_to_item' => __( 'No document was uploaded to this item.', 'tainacan' ),
// Tainacan Metadatum Types // Tainacan Metadatum Types
'tainacan-text' => __( 'Text', 'tainacan' ), 'tainacan-text' => __( 'Text', 'tainacan' ),

View File

@ -295,6 +295,12 @@ export default {
.columns { .columns {
display: flex; display: flex;
} }
.taginput-container {
.control.has-icons-left .icon {
top: 5px;
}
}
} }
.search-control { .search-control {
@ -305,9 +311,16 @@ export default {
font-size: 21px; font-size: 21px;
} }
} }
.dropdown-item {
padding: 0.25rem 1.35rem 0.25rem 0.25rem;
}
.view-mode-icon { .view-mode-icon {
margin-right: 8px !important; margin-right: 0px !important;
margin-top: 2px; margin-top: 1px;
&.icon i::before, .gray-icon i::before {
font-size: 19px !important;
}
} }
} }

View File

@ -221,7 +221,6 @@ class REST_Bulkedit_Controller extends REST_Controller {
} }
$group_id = $request['group_id']; $group_id = $request['group_id'];
var_dump($group_id);
$args = ['id' => $group_id]; $args = ['id' => $group_id];

View File

@ -60,7 +60,7 @@ class REST_Importers_Controller extends REST_Controller {
'description' => __( 'The array describing the destination collectino as expected by the importer', 'tainacan' ), 'description' => __( 'The array describing the destination collectino as expected by the importer', 'tainacan' ),
], ],
'options' => [ 'options' => [
'type' => 'array', 'type' => 'array/object',
'description' => __( 'The importer options', 'tainacan' ), 'description' => __( 'The importer options', 'tainacan' ),
] ]
], ],

View File

@ -53,7 +53,7 @@ class Taxonomy extends Entity {
* *
* @return bool * @return bool
*/ */
function register_taxonomy() { function tainacan_register_taxonomy() {
$labels = array( $labels = array(
'name' => $this->get_name(), 'name' => $this->get_name(),
'singular_name' => $this->get_name(), 'singular_name' => $this->get_name(),

View File

@ -215,7 +215,7 @@
} }
.taginput-container { .taginput-container {
display: table-cell; //display: table-cell;
border: none !important; border: none !important;
&.is-focusable:active, &.is-focusable:focus { &.is-focusable:active, &.is-focusable:focus {
border: none !important; border: none !important;
@ -224,7 +224,7 @@
border: 1px solid $tainacan-input-background !important; border: 1px solid $tainacan-input-background !important;
} }
.control.has-icons-left .icon { .control.has-icons-left .icon {
top: 5px; top: 0px !important;
} }
.tags { .tags {
display: none !important; display: none !important;

View File

@ -158,7 +158,7 @@ class Items extends Repository {
// register taxonomies // register taxonomies
if ( is_array( $taxonomies ) && sizeof( $taxonomies ) > 0 ) { if ( is_array( $taxonomies ) && sizeof( $taxonomies ) > 0 ) {
foreach ( $taxonomies as $taxonomy ) { foreach ( $taxonomies as $taxonomy ) {
$taxonomy->register_taxonomy(); $taxonomy->tainacan_register_taxonomy();
} }
} }
} }

View File

@ -531,7 +531,19 @@ class Metadata extends Repository {
] ]
]; ];
if( $collection->get_parent() !== 0 ){ if( $collection->get_parent() != 0 ){
if(!empty($metadata)){
foreach ( $data_core_metadata as $index => $data_core_metadatum ) {
foreach ( $metadata as $metadatum ){
if ( $metadatum->get_metadata_type() === $data_core_metadatum['metadata_type'] ) {
update_post_meta($metadatum->get_id(), 'metadata_type', 'to_delete', $data_core_metadatum['metadata_type']);
wp_delete_post($metadatum->get_id(), true);
}
}
}
}
return false; return false;
} }

View File

@ -133,7 +133,7 @@ class Taxonomies extends Repository {
public function insert($taxonomy) { public function insert($taxonomy) {
$new_taxonomy = parent::insert($taxonomy); $new_taxonomy = parent::insert($taxonomy);
$new_taxonomy->register_taxonomy(); $new_taxonomy->tainacan_register_taxonomy();
// return a brand new object // return a brand new object
return $new_taxonomy; return $new_taxonomy;
@ -187,11 +187,19 @@ class Taxonomies extends Repository {
$permanently = $args[2]; $permanently = $args[2];
if($permanently == true){ if($permanently == true){
/* TODO: Investigate the cause of taxonomies aren't been registered
*
* This cause a 'invalid taxonomy' exception when try to delete permanently a taxonomy
*
* This condition is a temporary solution
*/
if(taxonomy_exists($taxonomy_name)) {
$unregistered = unregister_taxonomy( $taxonomy_name ); $unregistered = unregister_taxonomy( $taxonomy_name );
if ( $unregistered instanceof \WP_Error ) { if ( $unregistered instanceof \WP_Error ) {
return $unregistered; return $unregistered;
} }
}
$deleted = new Entities\Taxonomy(wp_delete_post($taxonomy_id, true)); $deleted = new Entities\Taxonomy(wp_delete_post($taxonomy_id, true));

View File

@ -102,7 +102,7 @@ $Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Numeric');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Selectbox'); $Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Selectbox');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Relationship'); $Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Relationship');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Taxonomy'); $Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Taxonomy');
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Compound'); //$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Compound');
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance(); $Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();

View File

@ -67,7 +67,7 @@ class CSV extends Importer {
$column = $this->handle_encoding( $values[ $cont ] ); $column = $this->handle_encoding( $values[ $cont ] );
$processedItem[ $header ] = ( $metadatum->get_multiple() ) ? $processedItem[ $header ] = ( $metadatum->is_multiple() ) ?
explode( $this->get_option('multivalued_delimiter'), $column) : $column; explode( $this->get_option('multivalued_delimiter'), $column) : $column;
$cont++; $cont++;

View File

@ -8,19 +8,6 @@
* used to learn how to write an importer and to * used to learn how to write an importer and to
* create test collections and items * create test collections and items
* *
* Example how to invoke it
*
* add_action('init', function() {
* if ( isset($_GET['run_test_importer']) && $_GET['run_test_importer'] == 'go' ) {
* global $Tainacan_Importer_Handler;
* $test = new \Tainacan\Importer\Test_Importer();
* $Tainacan_Importer_Handler->add_to_queue($test);
* }
* });
*
* Put this code somewhere and access any URL of your site with ?run_test_importer=go
*
* TODO: check validate() methods and write log & abort importer in case of error.
*/ */
namespace Tainacan\Importer; namespace Tainacan\Importer;
@ -70,6 +57,26 @@ class Test_Importer extends Importer {
$this->items_repo = \Tainacan\Repositories\Items::get_instance(); $this->items_repo = \Tainacan\Repositories\Items::get_instance();
$this->metadata_repo = \Tainacan\Repositories\Metadata::get_instance(); $this->metadata_repo = \Tainacan\Repositories\Metadata::get_instance();
$this->remove_import_method('file');
$this->remove_import_method('url');
$this->set_default_options([
'items_col_1' => 20,
'items_col_2' => 20
]);
}
public function options_form() {
$form = '<label class="label">' . __('Number of items in collection 1', 'tainacan') . '</label>';
$form .= '<input type="text" class="input" name="items_col_1" value="' . $this->get_option('items_col_1') . '" />';
$form .= '<label class="label">' . __('Number of items in collection 2', 'tainacan') . '</label>';
$form .= '<input type="text" class="input" name="items_col_2" value="' . $this->get_option('items_col_2') . '" />';
return $form;
} }
public function create_taxonomies() { public function create_taxonomies() {
@ -324,10 +331,10 @@ class Test_Importer extends Importer {
* Here we are just returning random values * Here we are just returning random values
*/ */
public function get_col1_number_of_items() { public function get_col1_number_of_items() {
return 10; return $this->get_option('items_col_1');
} }
public function get_col2_number_of_items() { public function get_col2_number_of_items() {
return 20; return $this->get_option('items_col_2');
} }
public function get_col1_item($index) { public function get_col1_item($index) {

View File

@ -13,6 +13,11 @@ export const eventBus = new Vue({
} }
this.$on('input', data => this.updateValue(data) ); this.$on('input', data => this.updateValue(data) );
}, },
watch: {
errors() {
this.$emit('hasErrorsOnForm', this.errors.length > 0);
}
},
methods : { methods : {
registerComponent( name ){ registerComponent( name ){
if (this.componentsTag.indexOf(name) < 0) { if (this.componentsTag.indexOf(name) < 0) {

View File

@ -95,10 +95,11 @@ export const updateImporterURL = ( { commit }, { sessionId, url }) => {
}); });
}; };
export const updateImporterOptions = ( { commit }, { sessionId, options }) => { export const updateImporterOptions = ( { commit }, { sessionId, optionsForm }) => {
return new Promise(( resolve, reject ) => { return new Promise(( resolve, reject ) => {
axios.tainacan.put('importers/session/' + sessionId, { axios.tainacan.put('importers/session/' + sessionId, {
options: options options: optionsForm
}) })
.then( res => { .then( res => {
let importer = res.data; let importer = res.data;

View File

@ -23,9 +23,9 @@ export const createTaxonomy = ({commit}, taxonomy) => {
}); });
}; };
export const deleteTaxonomy = ({ commit }, taxonomyId) => { export const deleteTaxonomy = ({ commit }, { taxonomyId, isPermanently }) => {
return new Promise(( resolve, reject ) => { return new Promise(( resolve, reject ) => {
axios.tainacan.delete(`/taxonomies/${taxonomyId}?permanently=1`) axios.tainacan.delete(`/taxonomies/${taxonomyId}?permanently=` + (isPermanently ? '1' : '0'))
.then(res => { .then(res => {
commit('deleteTaxonomy', res.data); commit('deleteTaxonomy', res.data);

View File

@ -2,9 +2,9 @@
Contributors: fabianobn, jacsonp, leogermani, weryques, wetah Contributors: fabianobn, jacsonp, leogermani, weryques, wetah
Tags: museums, libraries, archives, GLAM, collections, repository Tags: museums, libraries, archives, GLAM, collections, repository
Requires at least: 4.8 Requires at least: 4.8
Tested up to: 4.9 Tested up to: 4.9.7
Requires PHP: 5.6 Requires PHP: 5.6
Stable tag: 0.1 Stable tag: 0.2
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html

View File

@ -4,7 +4,7 @@ Plugin Name: Tainacan
Plugin URI: https://tainacan.org/new Plugin URI: https://tainacan.org/new
Description: powerfull and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional respository platform. Description: powerfull and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional respository platform.
Author: Media Lab / UFG Author: Media Lab / UFG
Version: 0.1 Version: 0.2
Text Domain: tainacan Text Domain: tainacan
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html

View File

@ -194,7 +194,7 @@ class Metadata extends TAINACAN_UnitTestCase {
*/ */
function test_metadata_metadata_type(){ function test_metadata_metadata_type(){
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$this->assertEquals( 8, sizeof( $Tainacan_Metadata->fetch_metadata_types() ) ); $this->assertEquals( 7, sizeof( $Tainacan_Metadata->fetch_metadata_types() ) );
} }