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

This commit is contained in:
vnmedeiros 2020-09-15 11:26:54 -03:00
commit 0b40a163a8
19 changed files with 95 additions and 48 deletions

12
package-lock.json generated
View File

@ -2362,9 +2362,9 @@
}
},
"buefy": {
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/buefy/-/buefy-0.9.2.tgz",
"integrity": "sha512-f3UXfI6DDIHXE+pk8TC0mjT5BkKyGgoiZpdA5QGf9hVz0yfphJxWeu8+2WrOQLxahrr7HleD0B7ZkslsTQZZIA==",
"version": "0.9.3",
"resolved": "https://registry.npmjs.org/buefy/-/buefy-0.9.3.tgz",
"integrity": "sha512-Xqfo3ppeBo8Fwhb2fLwWnpkIC/1thPErU7DX3HksxTHxrSMixJ2BYkf3f6aWv4Ffx/FWX5UHnUrgtT7o7slnDA==",
"requires": {
"bulma": "0.9.0"
}
@ -11745,9 +11745,9 @@
}
},
"websocket-extensions": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz",
"integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==",
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz",
"integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==",
"dev": true
},
"which": {

View File

@ -8,7 +8,7 @@
},
"dependencies": {
"axios": "^0.19.2",
"buefy": "^0.9.2",
"buefy": "^0.9.3",
"bulma": "^0.9.0",
"css-vars-ponyfill": "^2.3.1",
"mdi": "^2.2.43",

View File

@ -69,6 +69,7 @@ class REST_Controller extends \WP_REST_Controller {
'authorid' => 'author',
'authorname' => 'author_name',
'search' => 's',
's' => 's',
'searchterm' => 'search',
'status' => 'post_status',
'offset' => 'offset',
@ -146,7 +147,7 @@ class REST_Controller extends \WP_REST_Controller {
}
$args['perm'] = 'readable';
return apply_filters('tainacan-api-prepare-items-args', $args, $request);
}

View File

@ -364,7 +364,6 @@ class REST_Items_Controller extends REST_Controller {
// Free php session early so simultaneous requests dont get queued
session_write_close();
$args = $this->prepare_filters($request);
/**

View File

@ -306,7 +306,6 @@ class REST_Metadata_Controller extends REST_Controller {
public function prepare_item_for_response( $item, $request ) {
if(!empty($item)){
$item_arr = $item->_toArray();
$item_arr['metadata_type_object'] = $item->get_metadata_type_object()->_toArray();
if(isset($item_arr['metadata_type_options']) && isset($item_arr['metadata_type_options']['taxonomy_id'])){
@ -392,7 +391,7 @@ class REST_Metadata_Controller extends REST_Controller {
}
return new \WP_REST_Response($prepared_item, 200);
}
}
/**
* @param \WP_REST_Request $request

View File

@ -259,7 +259,7 @@ export default {
this.uploadedItems.push( item );
// Uploads Media Document
this.sendFile(file)
this.sendFile({ itemId: item.id, file:file })
.then((uploadedFile) => {
// Updates Item with Document

View File

@ -16,14 +16,14 @@
<span
style="margin-left: 10px"
v-if="allItemsOnPageSelected && items.length > 1">
v-if="totalPages > 1 && allItemsOnPageSelected && items.length > 1">
<b-checkbox
v-model="isAllItemsSelected">
{{ $i18n.getWithVariables('label_select_all_%s_items', [totalItems]) }}
</b-checkbox>
</span>
</div>
<pre>{{ firstSelectedIndex }}</pre>
<div class="field">
<b-dropdown
:mobile-modal="true"
@ -36,7 +36,7 @@
<button
class="button is-white"
slot="trigger">
<span>{{ $i18n.get('label_bulk_actions') }}</span>
<span>{{ $i18n.get('label_actions_for_the_selection') }}</span>
<span class="icon">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-arrowdown"/>
</span>
@ -67,6 +67,12 @@
aria-role="listitem">
{{ $i18n.get('label_untrash_selected_items') }}
</b-dropdown-item>
<b-dropdown-item
:disabled="isAllItemsSelected"
@click="$parent.openExposersModal(selectedItems)"
aria-role="listitem">
{{ $i18n.get('label_view_selected_items_as') }}
</b-dropdown-item>
</b-dropdown>
</div>
</div>
@ -1072,7 +1078,7 @@ export default {
thumbPlaceholderPath: tainacan_plugin.base_url + '/assets/images/placeholder_square.png',
cursorPosX: -1,
cursorPosY: -1,
contextMenuItem: null
contextMenuItem: null,
}
},
computed: {
@ -1082,15 +1088,15 @@ export default {
highlightedItem () {
return this.getHighlightedItem();
},
selectedItemsFromStore() {
return this.getSelectedItems();
},
selectedItems () {
if (this.$route.query.iframemode)
this.$eventBusSearch.setSelectedItemsForIframe(this.getSelectedItems());
return this.getSelectedItems();
},
firstSelectedIndex() {
return (this.selectedItems && this.selectedItems.length) ? this.items.findIndex((anItem) => this.selectedItems[0] == anItem.id) : null;
},
isSelectingItems () {
return this.selectedItems.length > 0;
},
@ -1100,7 +1106,13 @@ export default {
return false;
}
return true;
}
},
itemsPerPage(){
return this.getItemsPerPage();
},
totalPages(){
return Math.ceil(Number(this.totalItems)/Number(this.itemsPerPage));
},
},
watch: {
isAllItemsSelected(value) {
@ -1152,13 +1164,15 @@ export default {
'getOrder',
'getOrderBy',
'getSelectedItems',
'getHighlightedItem'
'getHighlightedItem',
'getItemsPerPage'
]),
setSelectedItemChecked(itemId) {
if (this.selectedItems.find((item) => item == itemId) != undefined)
this.removeSelectedItem(itemId);
else
else {
this.addSelectedItem(itemId);
}
},
getSelectedItemChecked(itemId) {
return this.selectedItems.find(item => item == itemId) != undefined;
@ -1361,8 +1375,26 @@ export default {
this.clearContextMenu();
},
onClickItem($event, item) {
if ($event.ctrlKey || $event.shiftKey) {
if ($event.ctrlKey) {
this.setSelectedItemChecked(item.id);
} else if ($event.shiftKey) {
if (this.firstSelectedIndex != null) {
const lastFirstSelectedIndex = this.firstSelectedIndex;
const lastSelectedIndex = this.items.findIndex((anItem) => anItem.id == item.id);
this.cleanSelectedItems();
if (lastFirstSelectedIndex > lastSelectedIndex) {
for (let i = lastFirstSelectedIndex; i >= lastSelectedIndex; i--)
this.setSelectedItemChecked(this.items[i].id);
} else {
for (let i = lastFirstSelectedIndex; i <= lastSelectedIndex; i++)
this.setSelectedItemChecked(this.items[i].id);
}
} else {
this.setSelectedItemChecked(item.id);
}
} else {
if (this.$route.query.iframemode && !this.$route.query.readmode) {
this.setSelectedItemChecked(item.id)

View File

@ -249,7 +249,7 @@
fetchCollections() {
this.loadingCollections = true;
return axios.get('/collections?nopaging=1')
return axios.get('/collections?nopaging=1&context=edit&nopaging=1&fetch_only=name,id,thumbnail')
.then(res => {
this.collections = res.data ? res.data : [];
this.loadingCollections = false;
@ -262,7 +262,7 @@
fetchTaxonomies(){
this.loading = true;
return axios.get('/taxonomies?nopaging=1&order=asc&orderby=title&context=edit&nopaging=1&fetch_only=name,id,thumbnail')
return axios.get('/taxonomies?nopaging=1&order=asc&orderby=title')
.then(res => {
this.taxonomies = res.data ? res.data : [];
this.loading = false;

View File

@ -12,7 +12,7 @@
<h2
id="exposers-modal-title"
v-if="selectedExposer == undefined">
{{ itemId ? $i18n.get('label_urls_for_item_page') : $i18n.get('label_urls_for_items_list') }}
{{ itemId ? $i18n.get('label_urls_for_item_page') : ($i18n.get('label_urls_for_items_list') + (selectedItems && selectedItems.length ? (' (' + selectedItems.length + ' ' + $i18n.get('items') + ')') : '')) }}
</h2>
<h2
id="exposers-modal-title"
@ -257,7 +257,8 @@ export default {
collectionId: Number,
totalItems: Number,
itemId: Number,
itemURL: String
itemURL: String,
selectedItems: Array
},
data(){
return {
@ -272,7 +273,7 @@ export default {
},
computed: {
totalPages() {
return Math.ceil(Number(this.totalItems)/Number(this.maxItemsPerPage));
return this.selectedItems && this.selectedItems.length ? 1 : Math.ceil(Number(this.totalItems)/Number(this.maxItemsPerPage));
},
exposerBaseURL() {
let baseURL = this.collectionId != undefined ? '/collection/' + this.collectionId + '/items/' : '/items/';
@ -293,6 +294,7 @@ export default {
// Removes Admin View Mode
if (currentParams.admin_view_mode != undefined)
delete currentParams.admin_view_mode;
// Handles pagination of this link
delete currentParams.paged;
@ -301,6 +303,13 @@ export default {
else
currentParams.perpage = this.maxItemsPerPage;
// If selectedItems were provided, filters by them
if (this.selectedItems && this.selectedItems.length) {
currentParams.postin = this.selectedItems;
delete currentParams.paged;
currentParams.perpage = this.maxItemsPerPage;
}
return tainacan_plugin.tainacan_api_url + baseURL + '?' + qs.stringify(currentParams);
},
availableExposers() {
@ -456,7 +465,7 @@ export default {
});
},
getLastItemNumber(page) {
let last = (Number(this.maxItemsPerPage*(page - 1)) + Number(this.maxItemsPerPage));
let last = (this.selectedItems && this.selectedItems.length) ? this.selectedItems.length : (Number(this.maxItemsPerPage*(page - 1)) + Number(this.maxItemsPerPage));
return last > this.totalItems ? this.totalItems : last;
},

View File

@ -38,6 +38,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
if (postQueries.advancedSearch)
advancedSearchResults = postQueries.advancedSearch;
}
let query = qs.stringify(postQueries);
// Guarantees at least empty fetch_only are passed in case none is found
@ -412,9 +413,9 @@ export const fetchAllCollectionNames = ({ commit }, collectionsIds) => {
};
// Send Files to Item Bulk Addition
export const sendFile = ( { commit }, file ) => {
export const sendFile = ( { commit }, {itemId, file } ) => {
return new Promise(( resolve, reject ) => {
axios.wp.post('/media/', file, {
axios.wp.post('/media/?post=' + itemId, file, {
headers: { 'Content-Disposition': 'attachment; filename=' + file.name },
})
.then( res => {

View File

@ -9,6 +9,7 @@ export const set_postquery = ({ commit }, postquery ) => {
export const set_advanced_query = ({commit}, advancedSearchQuery) => {
commit('removePostQueryAttribute', 'search');
commit('removePostQueryAttribute', 's');
commit('setAdvancedSearchQuery', advancedSearchQuery);
};

View File

@ -46,7 +46,7 @@ export const getOrderBy = state => {
};
export const getSearchQuery = state => {
return state.postquery.search;
return state.postquery.search || state.postquery.s;
};
export const getStatus = state => {

View File

@ -134,11 +134,13 @@ export const setItemsPerPage = ( state, itemsPerPage ) => {
export const setSearchQuery = ( state, searchQuery ) => {
if (searchQuery != '') {
if (searchQuery != '')
state.postquery.search = searchQuery;
} else {
else
delete state.postquery.search;
}
// In case a s parameter was passed
delete state.postquery.s;
};
export const setStatus = ( state, status ) => {

View File

@ -890,14 +890,15 @@
trapFocus: true
});
},
openExposersModal() {
openExposersModal(selectedItems) {
this.$buefy.modal.open({
parent: this,
component: ExposersModal,
hasModalCard: true,
props: {
collectionId: this.collectionId,
totalItems: this.totalItems
totalItems: this.totalItems,
selectedItems: selectedItems
},
trapFocus: true
})

View File

@ -24,7 +24,7 @@
}
}
li.is-active a {
border-bottom-color: var(--tainacan-turquoise5);
border-bottom-color: var(--tainacan-secondary);
color: var(--tainacan-black) !important;
}
.icon:first-child {

View File

@ -184,7 +184,7 @@ registerBlockType('tainacan/search-bar', {
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
id="tainacan-search-bar-block_input"
label={ __('Search', 'tainacan')}
name='search'
name='s'
placeholder={ placeholderText }
/>
<button
@ -229,7 +229,7 @@ registerBlockType('tainacan/search-bar', {
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
id="tainacan-search-bar-block_input"
label={ __('Search', 'tainacan')}
name='search'
name='s'
placeholder={ placeholderText }
/>
<button
@ -621,7 +621,7 @@ registerBlockType('tainacan/search-bar', {
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
id="tainacan-search-bar-block_input"
label={ __('Search', 'tainacan')}
name='search'
name='s'
placeholder={ placeholderText }
/>
<button
@ -667,7 +667,7 @@ registerBlockType('tainacan/search-bar', {
style={{ borderColor: showCollectionHeader && collectionBackgroundColor ? collectionBackgroundColor : '' }}
id="tainacan-search-bar-block_input"
label={ __('Search', 'tainacan')}
name='search'
name='s'
placeholder={ placeholderText }
/>
<button

View File

@ -6,7 +6,7 @@ document.addEventListener("DOMContentLoaded",() => {
let input = document.getElementById('tainacan-search-bar-block_input');
if (input) {
if (input.value)
window.location.href = e.target.action + '?search=' + input.value;
window.location.href = e.target.action + '?s=' + input.value;
return;
}
}));

View File

@ -477,7 +477,9 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_gallery_help' => __( 'Help with the gallery view mode', 'tainacan' ),
'label_space_key' => __( 'SPACE', 'tainacan' ),
'label_esc_key' => __( 'ESC', 'tainacan' ),
'label_view_selected_items_as' => __( 'View selected items as...', 'tainacan' ),
'label_actions_for_the_selection' => __( 'Actions for the selection', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ),

View File

@ -85,7 +85,7 @@
hr {
margin-top: 0;
width: 100%;
background-color: var(--tainacan-turquoise5);
background-color: var(--tainacan-secondary);
}
}
@ -319,7 +319,7 @@
.icon {
border-radius: 100px;
background: var(--tainacan-white);
border: 3px solid var(--tainacan-turquoise5);
border: 3px solid var(--tainacan-secondary);
i, i:before {
font-size: 1.5em;
}
@ -358,7 +358,7 @@
.tainacan-icon::before {
line-height: 5em;
font-size: 5em;
color: var(--tainacan-turquoise5);
color: var(--tainacan-secondary);
text-shadow: 0px 0px 2px var(--tainacan-gray5);
}
}
@ -428,7 +428,7 @@
&.active-item img,
&.swiper-slide-active img {
border-bottom: 4px solid var(--tainacan-turquoise5);
border-bottom: 4px solid var(--tainacan-secondary);
}
&:hover img{
border-bottom: 4px solid var(--tainacan-gray2);