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

View File

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

View File

@ -69,6 +69,7 @@ class REST_Controller extends \WP_REST_Controller {
'authorid' => 'author', 'authorid' => 'author',
'authorname' => 'author_name', 'authorname' => 'author_name',
'search' => 's', 'search' => 's',
's' => 's',
'searchterm' => 'search', 'searchterm' => 'search',
'status' => 'post_status', 'status' => 'post_status',
'offset' => 'offset', 'offset' => 'offset',
@ -146,7 +147,7 @@ class REST_Controller extends \WP_REST_Controller {
} }
$args['perm'] = 'readable'; $args['perm'] = 'readable';
return apply_filters('tainacan-api-prepare-items-args', $args, $request); 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 // Free php session early so simultaneous requests dont get queued
session_write_close(); session_write_close();
$args = $this->prepare_filters($request); $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 ) { public function prepare_item_for_response( $item, $request ) {
if(!empty($item)){ if(!empty($item)){
$item_arr = $item->_toArray(); $item_arr = $item->_toArray();
$item_arr['metadata_type_object'] = $item->get_metadata_type_object()->_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'])){ 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); return new \WP_REST_Response($prepared_item, 200);
} }
/** /**
* @param \WP_REST_Request $request * @param \WP_REST_Request $request

View File

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

View File

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

View File

@ -249,7 +249,7 @@
fetchCollections() { fetchCollections() {
this.loadingCollections = true; 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 => { .then(res => {
this.collections = res.data ? res.data : []; this.collections = res.data ? res.data : [];
this.loadingCollections = false; this.loadingCollections = false;
@ -262,7 +262,7 @@
fetchTaxonomies(){ fetchTaxonomies(){
this.loading = true; 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 => { .then(res => {
this.taxonomies = res.data ? res.data : []; this.taxonomies = res.data ? res.data : [];
this.loading = false; this.loading = false;

View File

@ -12,7 +12,7 @@
<h2 <h2
id="exposers-modal-title" id="exposers-modal-title"
v-if="selectedExposer == undefined"> 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>
<h2 <h2
id="exposers-modal-title" id="exposers-modal-title"
@ -257,7 +257,8 @@ export default {
collectionId: Number, collectionId: Number,
totalItems: Number, totalItems: Number,
itemId: Number, itemId: Number,
itemURL: String itemURL: String,
selectedItems: Array
}, },
data(){ data(){
return { return {
@ -272,7 +273,7 @@ export default {
}, },
computed: { computed: {
totalPages() { 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() { exposerBaseURL() {
let baseURL = this.collectionId != undefined ? '/collection/' + this.collectionId + '/items/' : '/items/'; let baseURL = this.collectionId != undefined ? '/collection/' + this.collectionId + '/items/' : '/items/';
@ -293,6 +294,7 @@ export default {
// Removes Admin View Mode // Removes Admin View Mode
if (currentParams.admin_view_mode != undefined) if (currentParams.admin_view_mode != undefined)
delete currentParams.admin_view_mode; delete currentParams.admin_view_mode;
// Handles pagination of this link // Handles pagination of this link
delete currentParams.paged; delete currentParams.paged;
@ -301,6 +303,13 @@ export default {
else else
currentParams.perpage = this.maxItemsPerPage; 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); return tainacan_plugin.tainacan_api_url + baseURL + '?' + qs.stringify(currentParams);
}, },
availableExposers() { availableExposers() {
@ -456,7 +465,7 @@ export default {
}); });
}, },
getLastItemNumber(page) { 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; return last > this.totalItems ? this.totalItems : last;
}, },

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -477,7 +477,9 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_gallery_help' => __( 'Help with the gallery view mode', 'tainacan' ), 'label_gallery_help' => __( 'Help with the gallery view mode', 'tainacan' ),
'label_space_key' => __( 'SPACE', 'tainacan' ), 'label_space_key' => __( 'SPACE', 'tainacan' ),
'label_esc_key' => __( 'ESC', '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 // Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ), 'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ), 'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ),

View File

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