Merge branch 'develop' of https://github.com/tainacan/tainacan into develop
This commit is contained in:
commit
3c35bf1350
|
@ -103,6 +103,7 @@ class Admin {
|
|||
wp_enqueue_media();
|
||||
wp_enqueue_script('undescore', includes_url('js') . '/underscore.min.js' );
|
||||
wp_enqueue_script('jcrop');
|
||||
wp_enqueue_script( 'customize-controls' );
|
||||
|
||||
}
|
||||
|
||||
|
@ -157,7 +158,8 @@ class Admin {
|
|||
'user_caps' => $user_caps,
|
||||
'user_prefs' => $prefs,
|
||||
'base_url' => $TAINACAN_BASE_URL,
|
||||
'admin_url' => admin_url()
|
||||
'admin_url' => admin_url(),
|
||||
'custom_header_support' => get_theme_support('custom-header'),
|
||||
];
|
||||
|
||||
$maps = [
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class="button is-rounred is-secondary"
|
||||
id="button-edit-thumbnail"
|
||||
:aria-label="$i18n.get('label_button_edit_thumb')"
|
||||
@click="editImage($event, true)">
|
||||
@click.prevent="thumbnailMediaFrame.openFrame($event)">
|
||||
<b-icon icon="pencil" />
|
||||
</a>
|
||||
<figure class="image is-128x128">
|
||||
|
@ -31,6 +31,7 @@
|
|||
v-if="collection.featured_image == undefined || collection.featured_image == false"
|
||||
class="image-placeholder">{{ $i18n.get('label_empty_thumbnail') }}</span>
|
||||
<img
|
||||
id="thumbail-image"
|
||||
:alt="$i18n.get('label_thumbnail')"
|
||||
:src="(collection.featured_image == undefined || collection.featured_image == false) ? thumbPlaceholderPath : collection.featured_image">
|
||||
</figure>
|
||||
|
@ -54,7 +55,7 @@
|
|||
class="button is-rounred is-secondary"
|
||||
id="button-edit-header-image"
|
||||
:aria-label="$i18n.get('label_button_edit_header_image')"
|
||||
@click="editImage($event, false)">
|
||||
@click="headerImageMediaFrame.openFrame($event)">
|
||||
<b-icon icon="pencil" />
|
||||
</a>
|
||||
<figure class="image is-128x128">
|
||||
|
@ -305,6 +306,7 @@
|
|||
|
||||
<script>
|
||||
import { mapActions } from 'vuex';
|
||||
import wpMediaFrames from '../../js/wp-media-frames';
|
||||
|
||||
export default {
|
||||
name: 'CollectionEditionForm',
|
||||
|
@ -348,15 +350,15 @@ export default {
|
|||
editFormErrors: {},
|
||||
formErrorMessage: '',
|
||||
isNewCollection: false,
|
||||
// Fream Uploader variables
|
||||
frameUploader: undefined,
|
||||
thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png',
|
||||
headerPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_rectangle.png',
|
||||
isFetchingModerators: false,
|
||||
users: [],
|
||||
moderators: [],
|
||||
collections: [],
|
||||
isFetchingCollections: true
|
||||
isFetchingCollections: true,
|
||||
thumbnailMediaFrame: undefined,
|
||||
headerImageMediaFrame: undefined
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -446,6 +448,9 @@ export default {
|
|||
this.collectionId = res.id;
|
||||
this.collection = res;
|
||||
|
||||
// Initializes Media Frames now that collectonId exists
|
||||
this.initializeMediaFrames();
|
||||
|
||||
// Fill this.form data with current data.
|
||||
this.form.name = this.collection.name;
|
||||
this.form.description = this.collection.description;
|
||||
|
@ -528,118 +533,6 @@ export default {
|
|||
this.coverPageTitle = '';
|
||||
this.form.cover_page_id = '';
|
||||
},
|
||||
editImage(event, isThumbnail) {
|
||||
'use strict';
|
||||
event.preventDefault();
|
||||
|
||||
// If the media frame already exists, reopen it.
|
||||
if ( this.frameUploader ) {
|
||||
this.frameUploader.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new media frame
|
||||
this.frameUploader = wp.media.frames.frame_uploader = wp.media({
|
||||
frame: 'select',
|
||||
title: 'Select or Upload and Image.',
|
||||
button: {
|
||||
text: 'Select and Crop',
|
||||
close: false
|
||||
},
|
||||
multiple: false,
|
||||
library: {
|
||||
type: 'image',
|
||||
uploadedTo: this.collectionId
|
||||
},
|
||||
uploader: true,
|
||||
states: [
|
||||
new wp.media.controller.Library({
|
||||
title: 'Corta aí',
|
||||
library: wp.media.query({ type: 'image' }),
|
||||
multiple: false,
|
||||
date: false,
|
||||
priority: 20,
|
||||
suggestedWidth: 1000,
|
||||
suggestedHeight: 200
|
||||
}),
|
||||
new wp.media.controller.Cropper({
|
||||
imgSelectOptions: {
|
||||
enable: true,
|
||||
handles: true,
|
||||
imageHeight: 200,
|
||||
imageWidth: 1000,
|
||||
instance: true,
|
||||
keys: true,
|
||||
maxWidth: 1000,
|
||||
persistent: true,
|
||||
x1: 0,
|
||||
x2: 250,
|
||||
y1: 0,
|
||||
y2: 50
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
wp.media.view.settings.post = {
|
||||
id: this.collectionId
|
||||
}
|
||||
|
||||
this.frameUploader.on('select', () => {
|
||||
this.frameUploader.state('cropper').set( 'canSkipCrop', true );
|
||||
this.frameUploader.setState('cropper');
|
||||
});
|
||||
|
||||
this.frameUploader.on('skippedcrop', () => {
|
||||
let media = this.frameUploader.state().get( 'selection' ).first().toJSON();
|
||||
|
||||
if (isThumbnail) {
|
||||
this.updateThumbnail({collectionId: this.collectionId, thumbnailId: media.id})
|
||||
.then((res) => {
|
||||
this.collection.featured_image = res.featured_image;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
});
|
||||
} else {
|
||||
this.updateHeaderImage({collectionId: this.collectionId, headerImageId: media.id})
|
||||
.then((res) => {
|
||||
this.collection.header_image = res.header_image;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.frameUploader.on('cropped', (croppedImage) => {
|
||||
|
||||
// it is not cropping where we choose, but almost there
|
||||
|
||||
if (isThumbnail) {
|
||||
this.updateThumbnail({collectionId: this.collectionId, thumbnailId: croppedImage.attachment_id})
|
||||
.then((res) => {
|
||||
this.collection.featured_image = res.featured_image;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
});
|
||||
} else {
|
||||
this.updateHeaderImage({collectionId: this.collectionId, headerImageId: croppedImage.attachment_id})
|
||||
.then((res) => {
|
||||
this.collection.header_image = res.header_image;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.frameUploader.open();
|
||||
},
|
||||
deleteThumbnail() {
|
||||
|
||||
this.updateThumbnail({collectionId: this.collectionId, thumbnailId: 0})
|
||||
|
@ -660,6 +553,40 @@ export default {
|
|||
this.$console.error(error);
|
||||
});
|
||||
},
|
||||
initializeMediaFrames() {
|
||||
|
||||
this.thumbnailMediaFrame = new wpMediaFrames.thumbnailControl(
|
||||
'my-thumbnail-media-frame', {
|
||||
button_labels: {
|
||||
frame_title: this.$i18n.get('instruction_select_collection_thumbnail'),
|
||||
},
|
||||
relatedPostId: this.collectionId,
|
||||
onSave: (mediaId) => {
|
||||
this.updateThumbnail({collectionId: this.collectionId, thumbnailId: mediaId})
|
||||
.then((res) => {
|
||||
this.collection.featured_image = res.featured_image;
|
||||
})
|
||||
.catch(error => this.$console.error(error));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
this.headerImageMediaFrame = new wpMediaFrames.headerImageControl(
|
||||
'my-header-image-media-frame', {
|
||||
button_labels: {
|
||||
frame_title: this.$i18n.get('instruction_select_collection_header_image'),
|
||||
},
|
||||
relatedPostId: this.collectionId,
|
||||
onSave: (mediaId) => {
|
||||
this.updateHeaderImage({collectionId: this.collectionId, headerImageId: mediaId})
|
||||
.then((res) => {
|
||||
this.collection.header_image = res.header_image;
|
||||
})
|
||||
.catch(error => this.$console.error(error));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
created(){
|
||||
|
||||
|
@ -677,6 +604,9 @@ export default {
|
|||
this.fetchCollection(this.collectionId).then(res => {
|
||||
this.collection = res;
|
||||
|
||||
// Initializes Media Frames now that collectonId exists
|
||||
this.initializeMediaFrames();
|
||||
|
||||
// Fill this.form data with current data.
|
||||
this.form.name = this.collection.name;
|
||||
this.form.description = this.collection.description;
|
||||
|
|
|
@ -11,29 +11,29 @@
|
|||
|
||||
<div class="columns">
|
||||
<div class="column is-narrow">
|
||||
|
||||
<!-- Thumbnail -------------------------------- -->
|
||||
<b-field :label="$i18n.get('label_image')">
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_thumbnail')">
|
||||
<div class="thumbnail-field">
|
||||
<button
|
||||
v-if="item.featured_image == undefined || item.featured_image == false"
|
||||
@click="editThumbnail($event)"
|
||||
class="button is-primary">
|
||||
<b-icon icon="upload" />
|
||||
<span>{{ $i18n.get('label_choose_thumb') }}</span>
|
||||
</button>
|
||||
<div v-else>
|
||||
<figure class="image is-128x128">
|
||||
<img
|
||||
:alt="$i18n.get('label_thumbnail')"
|
||||
:src="item.featured_image">
|
||||
</figure>
|
||||
<div class="thumbnail-buttons-row">
|
||||
<a
|
||||
@click="editThumbnail($event)"
|
||||
id="button-edit"
|
||||
:aria-label="$i18n.get('label_button_edit_thumb')">
|
||||
class="button is-rounred is-secondary"
|
||||
id="button-edit-thumbnail"
|
||||
:aria-label="$i18n.get('label_button_edit_thumb')"
|
||||
@click.prevent="thumbnailMediaFrame.openFrame($event)">
|
||||
<b-icon icon="pencil" />
|
||||
</a>
|
||||
<figure class="image is-128x128">
|
||||
<span
|
||||
v-if="item.featured_image == undefined || item.featured_image == false"
|
||||
class="image-placeholder">{{ $i18n.get('label_empty_thumbnail') }}</span>
|
||||
<img
|
||||
id="thumbail-image"
|
||||
:alt="$i18n.get('label_thumbnail')"
|
||||
:src="(item.featured_image == undefined || item.featured_image == false) ? thumbPlaceholderPath : item.featured_image">
|
||||
</figure>
|
||||
<div class="thumbnail-buttons-row">
|
||||
<a
|
||||
id="button-delete"
|
||||
:aria-label="$i18n.get('label_button_delete_thumb')"
|
||||
|
@ -42,57 +42,28 @@
|
|||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</b-field>
|
||||
|
||||
<!-- Attachments ------------------------------------------ -->
|
||||
<b-field :label="$i18n.get('label_attachments')">
|
||||
<div class="columns is-multiline">
|
||||
<div class="column is-8">
|
||||
<b-upload
|
||||
v-model="form.files"
|
||||
multiple
|
||||
drag-drop
|
||||
@input="uploadAttachment($event)">
|
||||
<section class="section">
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
<b-icon
|
||||
icon="upload"
|
||||
size="is-large"/>
|
||||
</p>
|
||||
<p>{{ $i18n.get('instruction_image_upload_box') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
</b-upload>
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_attachments')">
|
||||
<button
|
||||
class="button is-secondary"
|
||||
@click.prevent="attachmentMediaFrame.openFrame($event)">
|
||||
Attatchments (tests)
|
||||
</button>
|
||||
|
||||
<div class="uploaded-files">
|
||||
<div
|
||||
v-for="(file, index) in form.files"
|
||||
v-for="(attachment, index) in attachmentsList"
|
||||
:key="index">
|
||||
<span class="tag is-primary">
|
||||
{{ file.name }}
|
||||
<button
|
||||
class="delete is-small"
|
||||
type="button"
|
||||
@click="deleteFile(index)"/>
|
||||
{{ attachment.title.rendered }}
|
||||
</span>
|
||||
<!-- <progress class="progress is-secondary" value="15" max="100">30%</progress> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="column is-narrow"
|
||||
v-for="(attachment, index) of item.attachments"
|
||||
:key="index">
|
||||
<figure class="image is-128x128">
|
||||
<img
|
||||
:alt="attachment.title"
|
||||
:src="attachment.url">
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
|
@ -152,6 +123,7 @@
|
|||
<script>
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import { eventBus } from '../../../js/event-bus-web-components.js'
|
||||
import wpMediaFrames from '../../js/wp-media-frames';
|
||||
|
||||
export default {
|
||||
name: 'ItemEditionForm',
|
||||
|
@ -164,8 +136,7 @@ export default {
|
|||
isLoading: false,
|
||||
form: {
|
||||
collectionId: Number,
|
||||
status: '',
|
||||
files:[],
|
||||
status: ''
|
||||
},
|
||||
thumbnail: {},
|
||||
// Can be obtained from api later
|
||||
|
@ -183,8 +154,9 @@ export default {
|
|||
label: this.$i18n.get('trash')
|
||||
}],
|
||||
formErrorMessage: '',
|
||||
// Frame Uploader variables
|
||||
frameUploader: undefined
|
||||
thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png',
|
||||
thumbnailMediaFrame: undefined,
|
||||
attachmentMediaFrame: undefined
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -195,12 +167,14 @@ export default {
|
|||
'sendField',
|
||||
'fetchItem',
|
||||
'cleanFields',
|
||||
'sendAttachment',
|
||||
'updateThumbnail'
|
||||
'sendAttachments',
|
||||
'updateThumbnail',
|
||||
'fetchAttachments'
|
||||
]),
|
||||
...mapGetters('item',[
|
||||
'getFields',
|
||||
'getItem',
|
||||
'getAttachments'
|
||||
]),
|
||||
onSubmit() {
|
||||
// Puts loading on Item edition
|
||||
|
@ -255,6 +229,9 @@ export default {
|
|||
this.itemId = res.id;
|
||||
this.item = res;
|
||||
|
||||
// Initializes Media Frames now that itemId exists
|
||||
this.initializeMediaFrames();
|
||||
|
||||
// Pre-fill status with publish to incentivate it
|
||||
this.form.status = 'publish';
|
||||
|
||||
|
@ -272,82 +249,6 @@ export default {
|
|||
cancelBack(){
|
||||
this.$router.push(this.$routerHelper.getCollectionPath(this.collectionId));
|
||||
},
|
||||
uploadAttachment($event) {
|
||||
|
||||
for (let file of $event) {
|
||||
this.sendAttachment({ item_id: this.itemId, file: file })
|
||||
.then(() => {
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
});
|
||||
}
|
||||
},
|
||||
editThumbnail(event) {
|
||||
'use strict';
|
||||
event.preventDefault();
|
||||
|
||||
// If the media frame already exists, reopen it.
|
||||
if ( this.frameUploader != undefined ) {
|
||||
this.frameUploader.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new media frame
|
||||
this.frameUploader = wp.media({
|
||||
frame: 'select',
|
||||
title: 'Select or Upload Media Of Your Chosen Persuasion',
|
||||
button: {
|
||||
text: 'Use this media'
|
||||
},
|
||||
multiple: false,
|
||||
library: {
|
||||
type: 'image',
|
||||
uploadedTo: this.itemId
|
||||
},
|
||||
uploader: true
|
||||
});
|
||||
|
||||
wp.media.view.settings.post = {
|
||||
id: this.itemId,
|
||||
featuredImageId: this.item.featured_img_id
|
||||
}
|
||||
|
||||
this.frameUploader.on('select', () => {
|
||||
|
||||
let media = this.frameUploader.state().get( 'selection' ).first().toJSON();
|
||||
|
||||
this.updateThumbnail({itemId: this.itemId, thumbnailId: media.id})
|
||||
.then((res) => {
|
||||
this.item.featured_image = res.featured_image;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
this.frameUploader.open();
|
||||
},
|
||||
uploadThumbnail($event) {
|
||||
|
||||
this.sendAttachment({ item_id: this.itemId, file: $event[0] })
|
||||
.then((res) => {
|
||||
|
||||
this.updateThumbnail({itemId: this.itemId, thumbnailId: res.id})
|
||||
.then((res) => {
|
||||
this.item.featured_image = res.featured_image;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
});
|
||||
|
||||
},
|
||||
deleteThumbnail() {
|
||||
this.updateThumbnail({itemId: this.itemId, thumbnailId: 0})
|
||||
.then(() => {
|
||||
|
@ -357,24 +258,46 @@ export default {
|
|||
this.$console.error(error);
|
||||
});
|
||||
},
|
||||
deleteFile(index) {
|
||||
this.$console.log("Delete:" + index);
|
||||
initializeMediaFrames() {
|
||||
|
||||
this.thumbnailMediaFrame = new wpMediaFrames.thumbnailControl(
|
||||
'my-thumbnail-media-frame', {
|
||||
button_labels: {
|
||||
frame_title: this.$i18n.get('instruction_select_item_thumbnail'),
|
||||
},
|
||||
relatedPostId: this.itemId,
|
||||
onSave: (mediaId) => {
|
||||
this.updateThumbnail({itemId: this.itemId, thumbnailId: mediaId})
|
||||
.then((res) => {
|
||||
this.item.featured_image = res.featured_image;
|
||||
})
|
||||
.catch(error => this.$console.error(error));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
this.attachmentMediaFrame = new wpMediaFrames.attachmentControl(
|
||||
'my-attachment-media-frame', {
|
||||
button_labels: {
|
||||
frame_title: this.$i18n.get('instruction_select_files_to_attach_to_item'),
|
||||
frame_button: this.$i18n.get('label_attach_to_item'),
|
||||
},
|
||||
relatedPostId: this.itemId,
|
||||
onSave: (files) => {
|
||||
// Fetch current existing attachments
|
||||
this.fetchAttachments(this.itemId);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
fieldList() {
|
||||
return this.getFields();
|
||||
},
|
||||
formHasErrors(){
|
||||
// for (let field of this.fieldList) {
|
||||
// if (field.field.required == 'yes' &&
|
||||
// (field.value == '' || field.value == undefined) &&
|
||||
// this.form.status == 'publish') {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
return false;
|
||||
attachmentsList(){
|
||||
return this.getAttachments();
|
||||
}
|
||||
},
|
||||
created(){
|
||||
|
@ -391,6 +314,9 @@ export default {
|
|||
// Obtains current Item ID from URL
|
||||
this.itemId = this.$route.params.itemId;
|
||||
|
||||
// Initializes Media Frames now that itemId exists
|
||||
this.initializeMediaFrames();
|
||||
|
||||
this.fetchItem(this.itemId).then(res => {
|
||||
this.item = res;
|
||||
|
||||
|
@ -399,6 +325,9 @@ export default {
|
|||
|
||||
this.loadMetadata();
|
||||
});
|
||||
|
||||
// Fetch current existing attachments
|
||||
this.fetchAttachments(this.itemId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -410,20 +339,45 @@ export default {
|
|||
<style lang="scss" scoped>
|
||||
|
||||
.thumbnail-field {
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
max-width: 128px;
|
||||
max-height: 128px;
|
||||
margin-bottom: 96px;
|
||||
margin-top: -20px;
|
||||
|
||||
.content {
|
||||
padding: 10px;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
img {
|
||||
bottom: 0;
|
||||
position: absolute;
|
||||
}
|
||||
.image-placeholder {
|
||||
position: absolute;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
bottom: 50%;
|
||||
font-size: 0.8rem;
|
||||
font-weight: bold;
|
||||
z-index: 99;
|
||||
text-align: center;
|
||||
color: gray;
|
||||
}
|
||||
#button-edit-thumbnail {
|
||||
|
||||
border-radius: 100px !important;
|
||||
height: 40px !important;
|
||||
width: 40px !important;
|
||||
bottom: -20px;
|
||||
left: -20px;
|
||||
z-index: 99;
|
||||
|
||||
.icon {
|
||||
display: inherit;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
margin-left: -8px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
}
|
||||
.thumbnail-buttons-row {
|
||||
display: none;
|
||||
}
|
||||
|
@ -431,12 +385,14 @@ export default {
|
|||
.thumbnail-buttons-row {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
bottom: 31px;
|
||||
background-color: rgba(255,255,255,0.8);
|
||||
top: -128px;
|
||||
background-color: rgba(255, 255, 255, 0.9);
|
||||
padding: 2px 8px;
|
||||
border-radius: 0px 4px 0px 0px;
|
||||
border-radius: 0px 0px 0px 4px;
|
||||
left: 88px;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,170 @@
|
|||
export default {
|
||||
attachmentControl: wp.customize.MediaControl.extend({
|
||||
/**
|
||||
* Create a media modal select frame, and store it so the instance can be reused when needed.
|
||||
*/
|
||||
initFrame: function() {
|
||||
|
||||
wp.media.view.settings.post = {
|
||||
id: this.params.relatedPostId
|
||||
}
|
||||
|
||||
this.frame = wp.media({
|
||||
button: {
|
||||
text: this.params.button_labels.frame_button
|
||||
},
|
||||
library: {
|
||||
uploadedTo: this.params.relatedPostId
|
||||
},
|
||||
states: [
|
||||
new wp.media.controller.Library({
|
||||
title: this.params.button_labels.frame_title,
|
||||
library: wp.media.query({ type: this.params.mime_type }),
|
||||
multiple: true,
|
||||
date: false,
|
||||
uploadedTo: this.params.relatedPostId
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
// When a file is selected, run a callback.
|
||||
this.frame.on( 'select', () => {
|
||||
|
||||
// Get the attachment from the modal frame.
|
||||
var node,
|
||||
attachments,
|
||||
mejsSettings = window._wpmejsSettings || {};
|
||||
attachments = this.frame.state().get( 'selection' ).toJSON();
|
||||
|
||||
this.params.attachments = attachments;
|
||||
this.params.onSave(attachments);
|
||||
// Set the Customizer setting; the callback takes care of rendering.
|
||||
//this.setting( attachment.id );
|
||||
node = this.container.find( 'audio, video' ).get(0);
|
||||
|
||||
// Initialize audio/video previews.
|
||||
if ( node ) {
|
||||
this.player = new MediaElementPlayer( node, mejsSettings );
|
||||
} else {
|
||||
this.cleanupPlayer();
|
||||
}
|
||||
});
|
||||
}
|
||||
}),
|
||||
// CroppedImageControl, with presets for thumbnail dimensions
|
||||
thumbnailControl: wp.customize.CroppedImageControl.extend({
|
||||
|
||||
initFrame: function() {
|
||||
var l10n = _wpMediaViewsL10n;
|
||||
|
||||
wp.media.view.settings.post = {
|
||||
id: this.params.relatedPostId
|
||||
}
|
||||
console.log(wp.media.view.settings.post);
|
||||
|
||||
this.params.flex_width = 0;
|
||||
this.params.flex_height = 0;
|
||||
this.params.width = 220;
|
||||
this.params.height = 220;
|
||||
|
||||
this.frame = wp.media({
|
||||
frame: 'select',
|
||||
button: {
|
||||
text: l10n.select,
|
||||
close: false
|
||||
},
|
||||
library: {
|
||||
type: 'image',
|
||||
uploadedTo: this.params.relatedPostId
|
||||
},
|
||||
uploader: true,
|
||||
states: [
|
||||
new wp.media.controller.Library({
|
||||
title: this.params.button_labels.frame_title,
|
||||
library: wp.media.query({ type: 'image' }),
|
||||
multiple: false,
|
||||
date: false,
|
||||
priority: 20,
|
||||
suggestedWidth: this.params.width,
|
||||
suggestedHeight: this.params.height,
|
||||
uploadedTo: this.params.relatedPostId
|
||||
}),
|
||||
new wp.media.controller.CustomizeImageCropper({
|
||||
imgSelectOptions: this.calculateImageSelectOptions,
|
||||
control: this
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
this.frame.on( 'select', this.onSelect, this );
|
||||
this.frame.on( 'cropped', this.onCropped, this );
|
||||
this.frame.on( 'skippedcrop', this.onSkippedCrop, this );
|
||||
},
|
||||
// Called on both skippedcrop and cropped states
|
||||
setImageFromAttachment: function( attachment ) {
|
||||
wp.media.view.settings.post = {
|
||||
id: this.params.relatedPostId
|
||||
}
|
||||
this.params.attachment = attachment;
|
||||
this.params.onSave(attachment.id);
|
||||
}
|
||||
|
||||
}),
|
||||
// CroppedImageControl, with presets for thumbnail dimensions
|
||||
headerImageControl: wp.customize.CroppedImageControl.extend({
|
||||
|
||||
initFrame: function() {
|
||||
var l10n = _wpMediaViewsL10n;
|
||||
|
||||
wp.media.view.settings.post = {
|
||||
id: this.params.relatedPostId
|
||||
}
|
||||
this.params.flex_width = tainacan_plugin.custom_header_support[0].flex_width ? 1 : 0;
|
||||
this.params.flex_height = tainacan_plugin.custom_header_support[0].flex_height ? 1 : 0;
|
||||
this.params.width = tainacan_plugin.custom_header_support[0].width;
|
||||
this.params.height = tainacan_plugin.custom_header_support[0].height;
|
||||
|
||||
this.frame = wp.media({
|
||||
frame: 'select',
|
||||
button: {
|
||||
text: l10n.select,
|
||||
close: false
|
||||
},
|
||||
library: {
|
||||
type: 'image',
|
||||
uploadedTo: this.params.relatedPostId
|
||||
},
|
||||
uploader: true,
|
||||
states: [
|
||||
new wp.media.controller.Library({
|
||||
title: this.params.button_labels.frame_title,
|
||||
library: wp.media.query({ type: 'image' }),
|
||||
multiple: false,
|
||||
date: false,
|
||||
priority: 20,
|
||||
suggestedWidth: this.params.width,
|
||||
suggestedHeight: this.params.height,
|
||||
uploadedTo: this.params.relatedPostId
|
||||
}),
|
||||
new wp.media.controller.CustomizeImageCropper({
|
||||
imgSelectOptions: this.calculateImageSelectOptions,
|
||||
control: this
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
//this.frame.state('cropper').set( 'canSkipCrop', true );
|
||||
|
||||
this.frame.on( 'select', this.onSelect, this );
|
||||
this.frame.on( 'cropped', this.onCropped, this );
|
||||
this.frame.on( 'skippedcrop', this.onSkippedCrop, this );
|
||||
},
|
||||
// Called on both skippedcrop and cropped states
|
||||
setImageFromAttachment: function( attachment ) {
|
||||
this.params.attachment = attachment;
|
||||
this.params.onSave(attachment.id);
|
||||
}
|
||||
|
||||
})
|
||||
}
|
|
@ -13,13 +13,8 @@
|
|||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns above-subheader">
|
||||
<aside
|
||||
class="column filters-menu"
|
||||
v-if="totalCollections > 0">
|
||||
<h3>{{ $i18n.getFrom('filters', 'name') }}</h3>
|
||||
</aside>
|
||||
<div class="column table-container">
|
||||
<div class="above-subheader">
|
||||
<div class="table-container">
|
||||
<collections-list
|
||||
:is-loading="isLoading"
|
||||
:total-collections="totalCollections"
|
||||
|
@ -182,14 +177,6 @@ export default {
|
|||
min-height: 100%;
|
||||
height: auto;
|
||||
|
||||
.filters-menu {
|
||||
min-width: $side-menu-width;
|
||||
max-width: $side-menu-width;
|
||||
background-color: $primary-lighter;
|
||||
margin-left: -$page-small-side-padding;
|
||||
padding-left: $page-small-side-padding
|
||||
}
|
||||
|
||||
.table-container {
|
||||
margin-right: -$page-small-side-padding;
|
||||
padding: 3em 2.5em;
|
||||
|
|
|
@ -16,18 +16,17 @@
|
|||
<b-icon icon="menu-down"/>
|
||||
</button>
|
||||
|
||||
<b-dropdown-item class="tainacan-dropdown-item">
|
||||
<b-dropdown-item>
|
||||
<router-link
|
||||
id="a-create-item"
|
||||
tag="div"
|
||||
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">
|
||||
{{ `${$i18n.get('add_one_item')}` }}
|
||||
{{ $i18n.get('add_one_item') }}
|
||||
</router-link>
|
||||
</b-dropdown-item>
|
||||
<b-dropdown-item>Adicionar itens em massa <br>
|
||||
<small class="is-small">Eu quero café</small>
|
||||
<b-dropdown-item>{{ $i18n.get('add_items_bulk') }}
|
||||
</b-dropdown-item>
|
||||
<b-dropdown-item>Adicionar item de fonte externa</b-dropdown-item>
|
||||
<b-dropdown-item>{{ $i18n.get('add_items_external_source') }}<br><small class="is-small">{{ $i18n.get() }}</small></b-dropdown-item>
|
||||
</b-dropdown>
|
||||
|
||||
</div>
|
||||
|
@ -340,10 +339,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.tainacan-dropdown-item:hover {
|
||||
background-color: rgba(192, 218, 223, 1) !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
|
|
@ -219,6 +219,9 @@ html {
|
|||
&:hover {
|
||||
background-color: $primary-lighter;
|
||||
}
|
||||
.is-small {
|
||||
color: gray;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ return [
|
|||
'approve_item' => __( 'Approve', 'tainacan' ),
|
||||
'not_approve_item' => __( 'Not approve', 'tainacan' ),
|
||||
'add_one_item' => __( 'Add one item', 'tainacan' ),
|
||||
'add_items_bulk' => __( 'Add items in bulk', 'tainacan' ),
|
||||
'add_items_external_source' => __( 'Add items from an external source', 'tainacan' ),
|
||||
|
||||
// Wordpress Status
|
||||
'publish' => __( 'Publish', 'tainacan' ),
|
||||
|
@ -153,6 +155,7 @@ return [
|
|||
'label_display_default' => __( 'Display by default', 'tainacan' ),
|
||||
'label_display_never' => __( 'Never displayed', 'tainacan' ),
|
||||
'label_not_display' => __( 'Not display by default', 'tainacan' ),
|
||||
'label_attach_to_item' => __( 'Attach to item', 'tainacan' ),
|
||||
|
||||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_dragndrop_fields_collection' => __( 'Drag and drop Fields here to Collection.', 'tainacan' ),
|
||||
|
@ -169,6 +172,10 @@ return [
|
|||
'instruction_cover_page' => __( 'Type to search a Page to choose.', 'tainacan'),
|
||||
'instruction_moderators' => __( 'Type to search a User to add.', 'tainacan'),
|
||||
'instruction_select_a_parent_collection' => __( 'Select a parent colection.', 'tainacan' ),
|
||||
'instruction_select_collection_thumbnail' => __( 'Select a thumbnail image for collection', 'tainacan' ),
|
||||
'instruction_select_item_thumbnail' => __( 'Select a thumbnail image for item', 'tainacan' ),
|
||||
'instruction_select_collection_header_image' => __( 'Select a header image for collection', 'tainacan' ),
|
||||
'instruction_select_files_to_attach_to_item' => __( 'Select files to attach to item', 'tainacan' ),
|
||||
|
||||
// Info. Other feedback to user.
|
||||
'info_name_is_required' => __( 'Name is required.', 'tainacan' ),
|
||||
|
@ -213,6 +220,7 @@ return [
|
|||
'info_there_is_no_field' => __( 'There is no field here yet.', 'tainacan' ),
|
||||
'info_there_is_no_filter' => __( 'There is no filter here yet.', 'tainacan' ),
|
||||
'info_changes' => __( 'Changes', 'tainacan' ),
|
||||
'info_possible_external_sources' => __( 'Possible external sources: CSV, Instagram, Youtube, etc.', 'tainacan' ),
|
||||
|
||||
// Tainacan Field Types
|
||||
'tainacan-text' => __( 'Text', 'tainacan' ),
|
||||
|
|
|
@ -84,6 +84,8 @@ abstract class Importer {
|
|||
|
||||
private $current_step = 0;
|
||||
|
||||
private $url = '';
|
||||
|
||||
public function __construct() {
|
||||
if (!session_id()) {
|
||||
@session_start();
|
||||
|
@ -100,6 +102,34 @@ abstract class Importer {
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set URL
|
||||
* @param $url string
|
||||
* @return bool
|
||||
*/
|
||||
public function set_url($url)
|
||||
{
|
||||
if(!empty($url) && !is_array($url))
|
||||
{
|
||||
$this->url = rtrim(trim($url), "/");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string or bool
|
||||
*/
|
||||
public function get_url()
|
||||
{
|
||||
if(!empty($this->url))
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array Mapping
|
||||
|
|
|
@ -41,7 +41,7 @@ class Old_Tainacan extends Importer
|
|||
'Create collections metadata' => 'create_collection_metas',
|
||||
'Create collections items' => 'create_collection_items',
|
||||
'Setting relationships' => 'set_relationships'
|
||||
];
|
||||
], $tainacan_api_address, $wordpress_api_address;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -50,10 +50,38 @@ class Old_Tainacan extends Importer
|
|||
$this->set_steps($this->steps);
|
||||
$this->remove_import_method('file');
|
||||
$this->add_import_method('url');
|
||||
$this->tainacan_api_address = "/wp-json/tainacan/v1";
|
||||
$this->wordpress_api_address = "/wp-json/wp/v2";
|
||||
}
|
||||
|
||||
public function verify_process_result($result)
|
||||
{
|
||||
if(is_wp_error($result))
|
||||
{
|
||||
$this->add_log('error', $result->get_error_message());
|
||||
return false;
|
||||
}else if(isset($result['body']))
|
||||
{
|
||||
return json_decode($result['body']);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function create_taxonomies()
|
||||
{
|
||||
$taxonomies_link = $this->get_url() . $this->wordpress_api_address . "/taxonomies";
|
||||
$taxonomies_link = wp_nonce_url($taxonomies_link);
|
||||
|
||||
$taxonomies = wp_remote_get($taxonomies_link);
|
||||
|
||||
$taxonomies_array = $this->verify_process_result($taxonomies);
|
||||
if($taxonomies_array)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ export const updateCollection = ({ commit }, { collection_id, name, description,
|
|||
status: status,
|
||||
enable_cover_page: enable_cover_page,
|
||||
cover_page_id: cover_page_id,
|
||||
moderators_ids: moderators_ids.name,
|
||||
moderators_ids: moderators_ids,
|
||||
parent: parent
|
||||
});
|
||||
resolve( res.data );
|
||||
|
|
|
@ -118,9 +118,6 @@ export const sendAttachment = ( { commit }, { item_id, file }) => {
|
|||
return new Promise(( resolve, reject ) => {
|
||||
axios.wp.post('/media/?post=' + item_id, file, {
|
||||
headers: { 'Content-Disposition': 'attachment; filename=' + file.name },
|
||||
onUploadProgress: progressEvent => {
|
||||
console.log(progressEvent.loaded + '/' + progressEvent.total);
|
||||
}
|
||||
})
|
||||
.then( res => {
|
||||
let attachment = res.data;
|
||||
|
@ -136,7 +133,7 @@ export const sendAttachment = ( { commit }, { item_id, file }) => {
|
|||
export const fetchAttachments = ({ commit }, item_id) => {
|
||||
commit('cleanAttachments');
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.wp.get('/media/?post=' + item_id)
|
||||
axios.wp.get('/media/?parent=' + item_id + '&per_page=100&paged=1')
|
||||
.then(res => {
|
||||
let attachments = res.data;
|
||||
commit('setAttachments', attachments);
|
||||
|
|
|
@ -45,7 +45,8 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
// }
|
||||
|
||||
//$_SESSION['tainacan_importer'][$id]->set_file( './tests/attachment/json_old_tainacan.txt' );
|
||||
$_SESSION['tainacan_importer'][$id]->fetch_from_remote( 'http://localhost/colecao/colecao-to-import/' );
|
||||
$url = 'http://localhost/';
|
||||
$_SESSION['tainacan_importer'][$id]->set_url($url);
|
||||
|
||||
$_SESSION['tainacan_importer'][$id]->run();
|
||||
}*/
|
||||
|
|
Loading…
Reference in New Issue