Makes all reference to 96 max per page setting reference the constant #771.

This commit is contained in:
mateuswetah 2023-05-09 14:25:37 -03:00
parent cd5ba1c50c
commit 7adbfa82c9
10 changed files with 21 additions and 30 deletions

View File

@ -70,21 +70,6 @@
$i18n.get('info_of') + totalAttachments + '.' $i18n.get('info_of') + totalAttachments + '.'
}} }}
</div> </div>
<!-- <div class="items-per-page">
<b-field
horizontal
:label="$i18n.get('label_attachments_per_page')">
<b-select
:value="attachmentsPerPage"
@input="onChangeAttachmentsPerPage"
:disabled="attachments.length <= 0">
<option value="12">12</option>
<option value="24">24</option>
<option value="48">48</option>
<option value="96">96</option>
</b-select>
</b-field>
</div> -->
<div class="pagination"> <div class="pagination">
<b-pagination <b-pagination
@change="onPageChange" @change="onPageChange"

View File

@ -59,17 +59,18 @@ import { mapActions } from 'vuex';
export default { export default {
name: 'CollectionsModal', name: 'CollectionsModal',
data(){ data() {
return { return {
collections: [], collections: [],
isLoading: false isLoading: false,
maxCollectionsPerPage: tainacan_plugin.api_max_items_per_page ? Number(tainacan_plugin.api_max_items_per_page) : 96
} }
}, },
mounted() { mounted() {
this.isLoading = true; this.isLoading = true;
this.fetchCollections({ this.fetchCollections({
page: 1, page: 1,
collectionsPerPage: 96, collectionsPerPage: this.maxCollectionsPerPage,
contextEdit: true contextEdit: true
}) })
.then((res) => { .then((res) => {

View File

@ -116,7 +116,7 @@ export default {
}, },
data() { data() {
return { return {
maxItemsPerPage: tainacan_plugin.api_max_items_per_page maxItemsPerPage: tainacan_plugin.api_max_items_per_page ? Number(tainacan_plugin.api_max_items_per_page) : 96
} }
}, },
computed: { computed: {
@ -133,7 +133,7 @@ export default {
return Math.ceil(Number(this.totalItems)/Number(this.itemsPerPage)); return Math.ceil(Number(this.totalItems)/Number(this.itemsPerPage));
}, },
itemsPerPageOptions() { itemsPerPageOptions() {
const defaultItemsPerPageOptions = [12, 24, 48, 96]; const defaultItemsPerPageOptions = [12, 24, 48, this.maxItemsPerPage];
if (!isNaN(this.itemsPerPage) && !defaultItemsPerPageOptions.includes(this.itemsPerPage)) if (!isNaN(this.itemsPerPage) && !defaultItemsPerPageOptions.includes(this.itemsPerPage))
defaultItemsPerPageOptions.push(this.itemsPerPage); defaultItemsPerPageOptions.push(this.itemsPerPage);

View File

@ -271,7 +271,7 @@
<option value="12">12</option> <option value="12">12</option>
<option value="24">24</option> <option value="24">24</option>
<option value="48">48</option> <option value="48">48</option>
<option value="96">96</option> <option :value="maxActivitiesPerPage">{{ maxActivitiesPerPage }}</option>
</b-select> </b-select>
</b-field> </b-field>
</div> </div>
@ -312,7 +312,7 @@
<option value="12">12</option> <option value="12">12</option>
<option value="24">24</option> <option value="24">24</option>
<option value="48">48</option> <option value="48">48</option>
<option value="96">96</option> <option :value="maxActivitiesPerPage">{{ maxActivitiesPerPage }}</option>
</b-select> </b-select>
</b-field> </b-field>
</div> </div>
@ -367,7 +367,8 @@
userIdForFiltering: null, userIdForFiltering: null,
usersForFilteringSearchQuery: '', usersForFilteringSearchQuery: '',
usersForFilteringSearchPage: 1, usersForFilteringSearchPage: 1,
totalUsers: 0 totalUsers: 0,
maxActivitiesPerPage: tainacan_plugin.api_max_items_per_page ? Number(tainacan_plugin.api_max_items_per_page) : 96
} }
}, },
computed: { computed: {

View File

@ -333,7 +333,7 @@
<option value="12">12</option> <option value="12">12</option>
<option value="24">24</option> <option value="24">24</option>
<option value="48">48</option> <option value="48">48</option>
<option value="96">96</option> <option :value="maxCollectionsPerPage">{{ maxCollectionsPerPage }}</option>
</b-select> </b-select>
</b-field> </b-field>
</div> </div>
@ -383,7 +383,8 @@ export default {
{ label: this.$i18n.get('label_title'), value: 'title' }, { label: this.$i18n.get('label_title'), value: 'title' },
{ label: this.$i18n.get('label_creation_date'), value: 'date' }, { label: this.$i18n.get('label_creation_date'), value: 'date' },
{ label: this.$i18n.get('label_modification_date'), value: 'modified' } { label: this.$i18n.get('label_modification_date'), value: 'modified' }
] ],
maxCollectionsPerPage: tainacan_plugin.api_max_items_per_page ? Number(tainacan_plugin.api_max_items_per_page) : 96
} }
}, },
computed: { computed: {

View File

@ -212,7 +212,7 @@
<option value="12">12</option> <option value="12">12</option>
<option value="24">24</option> <option value="24">24</option>
<option value="48">48</option> <option value="48">48</option>
<option value="96">96</option> <option :value="maxTaxonomiesPerPage">{{ maxTaxonomiesPerPage }}</option>
</b-select> </b-select>
</b-field> </b-field>
</div> </div>
@ -259,7 +259,8 @@
sortingOptions: [ sortingOptions: [
{ label: this.$i18n.get('label_title'), value: 'title' }, { label: this.$i18n.get('label_title'), value: 'title' },
{ label: this.$i18n.get('label_creation_date'), value: 'date' }, { label: this.$i18n.get('label_creation_date'), value: 'date' },
] ],
maxTaxonomiesPerPage: tainacan_plugin.api_max_items_per_page ? Number(tainacan_plugin.api_max_items_per_page) : 96
} }
}, },
computed: { computed: {

View File

@ -526,7 +526,7 @@ export default function({ attributes, setAttributes, className, isSelected, clie
setContent(); setContent();
}} }}
min={ 1 } min={ 1 }
max={ 96 } max={ tainacan_blocks.api_max_items_per_page ? Number(tainacan_blocks.api_max_items_per_page) : 96 }
/> />
</div> </div>
</PanelBody> </PanelBody>

View File

@ -678,7 +678,7 @@ export default function({ attributes, setAttributes, className, isSelected, clie
setContent(); setContent();
}} }}
min={ 1 } min={ 1 }
max={ 96 } max={ tainacan_blocks.api_max_items_per_page ? Number(tainacan_blocks.api_max_items_per_page) : 96 }
/> />
<hr></hr> <hr></hr>
</div> </div>

View File

@ -521,7 +521,7 @@ export default function({ attributes, setAttributes, className, isSelected, clie
setContent(); setContent();
}} }}
min={ 1 } min={ 1 }
max={ 96 } max={ tainacan_blocks.api_max_items_per_page ? Number(tainacan_blocks.api_max_items_per_page) : 96 }
/> />
<ToggleControl <ToggleControl
label={__('Items count', 'tainacan')} label={__('Items count', 'tainacan')}

View File

@ -215,6 +215,7 @@ function tainacan_blocks_get_common_editor_styles() {
*/ */
function tainacan_blocks_get_plugin_js_settings(){ function tainacan_blocks_get_plugin_js_settings(){
global $TAINACAN_BASE_URL; global $TAINACAN_BASE_URL;
global $TAINACAN_API_MAX_ITEMS_PER_PAGE;
global $wp_version; global $wp_version;
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance(); $Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
@ -229,6 +230,7 @@ function tainacan_blocks_get_plugin_js_settings(){
'root' => esc_url_raw( rest_url() ) . 'tainacan/v2', 'root' => esc_url_raw( rest_url() ) . 'tainacan/v2',
'nonce' => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : false, 'nonce' => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : false,
'base_url' => $TAINACAN_BASE_URL, 'base_url' => $TAINACAN_BASE_URL,
'api_max_items_per_page' => $TAINACAN_API_MAX_ITEMS_PER_PAGE,
'admin_url' => admin_url(), 'admin_url' => admin_url(),
'site_url' => site_url(), 'site_url' => site_url(),
'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug(), 'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug(),