Fetches status from WordPress api.
This commit is contained in:
parent
2058413064
commit
22f9ba900b
|
@ -64,6 +64,7 @@
|
|||
TainacanRepositorySubheader
|
||||
},
|
||||
created() {
|
||||
this.$statusHelper.loadStatuses();
|
||||
this.$userPrefs.init();
|
||||
this.isMenuCompressed = (this.$route.params.collectionId != undefined);
|
||||
this.activeRoute = this.$route.name;
|
||||
|
|
|
@ -78,6 +78,7 @@ class Admin {
|
|||
|
||||
// wp_enqueue_style( 'style', $TAINACAN_BASE_URL . '/assets/css/fonts/materialdesignicons.css' );
|
||||
wp_enqueue_style( 'tainacan-fonts', $TAINACAN_BASE_URL . '/assets/css/fonts/tainacanicons.css', [], TAINACAN_VERSION );
|
||||
wp_enqueue_style( 'roboto-fonts', 'https://fonts.googleapis.com/css?family=Roboto:400,400i,500,500i,700,700i', [], TAINACAN_VERSION );
|
||||
wp_enqueue_script('underscore');
|
||||
}
|
||||
|
||||
|
|
|
@ -126,8 +126,8 @@
|
|||
<option
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses().filter(option => { return option.value != 'trash' })"
|
||||
:key="index"
|
||||
:value="statusOption.value">
|
||||
{{ statusOption.label }}
|
||||
:value="statusOption.slug">
|
||||
{{ statusOption.name }}
|
||||
</option>
|
||||
</b-select>
|
||||
</template>
|
||||
|
|
|
@ -299,13 +299,13 @@
|
|||
v-model="form.status"
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
||||
:key="index"
|
||||
:native-value="statusOption.value">
|
||||
:native-value="statusOption.slug">
|
||||
<span class="icon has-text-gray">
|
||||
<i
|
||||
class="tainacan-icon tainacan-icon-18px"
|
||||
:class="$statusHelper.getIcon(statusOption.value)"/>
|
||||
:class="$statusHelper.getIcon(statusOption.slug)"/>
|
||||
</span>
|
||||
{{ statusOption.label }}
|
||||
{{ statusOption.name }}
|
||||
</b-radio>
|
||||
</div>
|
||||
</b-field>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
:active.sync="isLoadingMetadata"
|
||||
:can-cancel="false"/>
|
||||
<div class="tainacan-page-title">
|
||||
<h1><span class="status-tag">{{ $i18n.get(status) }}</span>{{ $i18n.get('label_bulk_edit_items') }}</h1>
|
||||
<h1><span class="status-tag">{{ $i18n.get('status_' + status) }}</span>{{ $i18n.get('label_bulk_edit_items') }}</h1>
|
||||
<a
|
||||
@click="$router.go(-1)"
|
||||
class="back-link has-text-secondary">
|
||||
|
@ -31,7 +31,7 @@
|
|||
{{ $i18n.get('info_there_is_one_item_being_edited') }}
|
||||
</p>
|
||||
<p v-if="items.length <= 0 && !isLoadingGroupInfo && bulkEditGroup.items_count > 1">
|
||||
{{ $i18n.getWithVariables('info_there_are_%s_items_being_edited', bulkEditGroup.items_count) }}
|
||||
{{ $i18n.getWithVariables('info_there_are_%s_items_being_edited', [bulkEditGroup.items_count]) }}
|
||||
</p>
|
||||
<p v-if="items.length <= 0 && !isLoadingGroupInfo">
|
||||
{{ $i18n.get('info_no_preview_found') }}
|
||||
|
@ -70,31 +70,17 @@
|
|||
<div class="section-status">
|
||||
<div class="field has-addons">
|
||||
<b-radio
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses().filter(option => { return option.value != 'trash' })"
|
||||
:key="index"
|
||||
v-model="status"
|
||||
@input="changeStatus($event)"
|
||||
value="publish"
|
||||
native-value="publish">
|
||||
:value="statusOption.slug"
|
||||
:native-value="statusOption.slug">
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-public"/>
|
||||
</span> {{ $i18n.get('publish_visibility') }}
|
||||
</b-radio>
|
||||
<b-radio
|
||||
v-model="status"
|
||||
@input="changeStatus($event)"
|
||||
value="private"
|
||||
native-value="private">
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-private"/>
|
||||
</span> {{ $i18n.get('private_visibility') }}
|
||||
</b-radio>
|
||||
<b-radio
|
||||
v-model="status"
|
||||
@input="changeStatus($event)"
|
||||
value="draft"
|
||||
native-value="draft">
|
||||
<span class="icon">
|
||||
<i class="tainacan-icon tainacan-icon-draft"/>
|
||||
</span> {{ $i18n.get('status_draft') }}
|
||||
<i
|
||||
class="tainacan-icon"
|
||||
:class="$statusHelper.getIcon(statusOption.slug)"/>
|
||||
</span> {{ statusOption.name }}
|
||||
</b-radio>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -92,13 +92,13 @@
|
|||
v-model="form.status"
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
||||
:key="index"
|
||||
:native-value="statusOption.value">
|
||||
:native-value="statusOption.slug">
|
||||
<span class="icon has-text-gray">
|
||||
<i
|
||||
class="tainacan-icon tainacan-icon-18px"
|
||||
:class="$statusHelper.getIcon(statusOption.value)"/>
|
||||
:class="$statusHelper.getIcon(statusOption.slug)"/>
|
||||
</span>
|
||||
{{ statusOption.label }}
|
||||
{{ statusOption.name }}
|
||||
</b-radio>
|
||||
</div>
|
||||
</b-field>
|
||||
|
|
|
@ -346,6 +346,12 @@ export const StatusHelperPlugin = {};
|
|||
StatusHelperPlugin.install = function (Vue, options = {}) {
|
||||
|
||||
Vue.prototype.$statusHelper = {
|
||||
statuses: [
|
||||
{ name: tainacan_plugin.i18n['status_publish'], slug: 'publish' },
|
||||
{ name: tainacan_plugin.i18n['status_private'], slug: 'private' },
|
||||
{ name: tainacan_plugin.i18n['status_draft'], slug: 'draft' },
|
||||
{ name: tainacan_plugin.i18n['status_trash'], slug: 'trash' }
|
||||
],
|
||||
getIcon(status) {
|
||||
switch (status) {
|
||||
case 'publish': return 'tainacan-icon-public';
|
||||
|
@ -359,12 +365,27 @@ StatusHelperPlugin.install = function (Vue, options = {}) {
|
|||
return ['publish', 'private', 'draft', 'trash'].includes(status);
|
||||
},
|
||||
getStatuses() {
|
||||
return [
|
||||
{ label: tainacan_plugin.i18n['status_publish'], value: 'publish' },
|
||||
{ label: tainacan_plugin.i18n['status_private'], value: 'private' },
|
||||
{ label: tainacan_plugin.i18n['status_draft'], value: 'draft' },
|
||||
{ label: tainacan_plugin.i18n['status_trash'], value: 'trash' }
|
||||
]
|
||||
return this.statuses;
|
||||
},
|
||||
loadStatuses() {
|
||||
wpApi.get('/statuses/')
|
||||
.then( res => {
|
||||
let loadedStatus = res.data;
|
||||
this.statuses = [];
|
||||
|
||||
this.statuses.push(loadedStatus['publish']);
|
||||
this.statuses.push(loadedStatus['private']);
|
||||
|
||||
this.statuses.concat(Object.values(loadedStatus).filter((status) => {
|
||||
return !['publish','private','draft','trash'].includes(status);
|
||||
}));
|
||||
|
||||
this.statuses.push(loadedStatus['draft']);
|
||||
this.statuses.push(loadedStatus['trash']);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error( error );
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,25 +141,25 @@
|
|||
<li
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
||||
:key="index"
|
||||
@click="onChangeTab(statusOption.value)"
|
||||
:class="{ 'is-active': status == statusOption.value}"
|
||||
:style="{ marginLeft: statusOption.value == 'draft' ? 'auto' : '' }"
|
||||
@click="onChangeTab(statusOption.slug)"
|
||||
:class="{ 'is-active': status == statusOption.slug}"
|
||||
:style="{ marginRight: statusOption.slug == 'private' ? 'auto' : '' }"
|
||||
v-tooltip="{
|
||||
content: $i18n.getWithVariables('info_%s_tab_' + statusOption.value,[$i18n.get('collections')]),
|
||||
content: $i18n.getWithVariables('info_%s_tab_' + statusOption.slug,[$i18n.get('collections')]),
|
||||
autoHide: true,
|
||||
placement: 'auto',
|
||||
}">
|
||||
<a>
|
||||
<span
|
||||
v-if="$statusHelper.hasIcon(statusOption.value)"
|
||||
v-if="$statusHelper.hasIcon(statusOption.slug)"
|
||||
class="icon has-text-gray">
|
||||
<i
|
||||
class="tainacan-icon tainacan-icon-18px"
|
||||
:class="$statusHelper.getIcon(statusOption.value)"
|
||||
:class="$statusHelper.getIcon(statusOption.slug)"
|
||||
/>
|
||||
</span>
|
||||
{{ statusOption.label }}
|
||||
<span class="has-text-gray"> {{ `${` ${repositoryTotalCollections ? `(${repositoryTotalCollections[statusOption.value]})` : '' }`}` }}</span>
|
||||
{{ statusOption.name }}
|
||||
<span class="has-text-gray"> {{ `${` ${repositoryTotalCollections ? `(${repositoryTotalCollections[statusOption.slug]})` : '' }`}` }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -187,8 +187,8 @@
|
|||
<p
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
||||
:key="index"
|
||||
v-if="status == statusOption.value">
|
||||
{{ $i18n.getWithVariables('info_no_%s_' + statusOption.value,['collection']) }}
|
||||
v-if="status == statusOption.slug">
|
||||
{{ $i18n.getWithVariables('info_no_%s_' + statusOption.slug,['collection']) }}
|
||||
</p>
|
||||
|
||||
<div v-if="$userCaps.hasCapability('edit_tainacan-collections') && status == undefined || status == ''">
|
||||
|
|
|
@ -626,25 +626,25 @@
|
|||
<li
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
||||
:key="index"
|
||||
@click="onChangeTab(statusOption.value)"
|
||||
:class="{ 'is-active': status == statusOption.value}"
|
||||
:style="{ marginLeft: statusOption.value == 'draft' ? 'auto' : '' }"
|
||||
@click="onChangeTab(statusOption.slug)"
|
||||
:class="{ 'is-active': status == statusOption.slug}"
|
||||
:style="{ marginRight: statusOption.slug == 'private' ? 'auto' : '' }"
|
||||
v-tooltip="{
|
||||
content: $i18n.getWithVariables('info_%s_tab_' + statusOption.value,[$i18n.get('items')]),
|
||||
content: $i18n.getWithVariables('info_%s_tab_' + statusOption.slug,[$i18n.get('items')]),
|
||||
autoHide: true,
|
||||
placement: 'auto',
|
||||
}">
|
||||
<a>
|
||||
<span
|
||||
v-if="$statusHelper.hasIcon(statusOption.value)"
|
||||
v-if="$statusHelper.hasIcon(statusOption.slug)"
|
||||
class="icon has-text-gray">
|
||||
<i
|
||||
class="tainacan-icon tainacan-icon-18px"
|
||||
:class="$statusHelper.getIcon(statusOption.value)"
|
||||
:class="$statusHelper.getIcon(statusOption.slug)"
|
||||
/>
|
||||
</span>
|
||||
{{ statusOption.label }}
|
||||
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items[statusOption.value]})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems[statusOption.value] })` : '' }}</span>
|
||||
{{ statusOption.name }}
|
||||
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items[statusOption.slug]})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems[statusOption.slug] })` : '' }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -744,8 +744,8 @@
|
|||
<p
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
||||
:key="index"
|
||||
v-if="status == statusOption.value">
|
||||
{{ $i18n.getWithVariables('info_no_%s_' + statusOption.value,['item']) }}
|
||||
v-if="status == statusOption.slug">
|
||||
{{ $i18n.getWithVariables('info_no_%s_' + statusOption.slug,['item']) }}
|
||||
</p>
|
||||
|
||||
<router-link
|
||||
|
|
|
@ -108,25 +108,25 @@
|
|||
<li
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
||||
:key="index"
|
||||
@click="onChangeTab(statusOption.value)"
|
||||
:class="{ 'is-active': status == statusOption.value}"
|
||||
:style="{ marginLeft: statusOption.value == 'draft' ? 'auto' : '' }"
|
||||
@click="onChangeTab(statusOption.slug)"
|
||||
:class="{ 'is-active': status == statusOption.slug}"
|
||||
:style="{ marginRight: statusOption.slug == 'private' ? 'auto' : '' }"
|
||||
v-tooltip="{
|
||||
content: $i18n.getWithVariables('info_%s_tab_' + statusOption.value,[$i18n.get('taxonomies')]),
|
||||
content: $i18n.getWithVariables('info_%s_tab_' + statusOption.slug,[$i18n.get('taxonomies')]),
|
||||
autoHide: true,
|
||||
placement: 'auto',
|
||||
}">
|
||||
<a>
|
||||
<span
|
||||
v-if="$statusHelper.hasIcon(statusOption.value)"
|
||||
v-if="$statusHelper.hasIcon(statusOption.slug)"
|
||||
class="icon has-text-gray">
|
||||
<i
|
||||
class="tainacan-icon tainacan-icon-18px"
|
||||
:class="$statusHelper.getIcon(statusOption.value)"
|
||||
:class="$statusHelper.getIcon(statusOption.slug)"
|
||||
/>
|
||||
</span>
|
||||
{{ statusOption.label }}
|
||||
<span class="has-text-gray"> {{ repositoryTotalTaxonomies ? `(${repositoryTotalTaxonomies[statusOption.value]})` : '' }}</span>
|
||||
{{ statusOption.name }}
|
||||
<span class="has-text-gray"> {{ repositoryTotalTaxonomies ? `(${repositoryTotalTaxonomies[statusOption.slug]})` : '' }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -151,8 +151,8 @@
|
|||
<p
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
||||
:key="index"
|
||||
v-if="status == statusOption.value">
|
||||
{{ $i18n.getWithVariables('info_no_%s_' + statusOption.value,['taxonomy']) }}
|
||||
v-if="status == statusOption.slug">
|
||||
{{ $i18n.getWithVariables('info_no_%s_' + statusOption.slug,['taxonomy']) }}
|
||||
</p>
|
||||
<router-link
|
||||
v-if="status == undefined || status == ''"
|
||||
|
|
|
@ -611,25 +611,25 @@
|
|||
<li
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
||||
:key="index"
|
||||
@click="onChangeTab(statusOption.value)"
|
||||
:class="{ 'is-active': status == statusOption.value}"
|
||||
:style="{ marginLeft: statusOption.value == 'draft' ? 'auto' : '' }"
|
||||
@click="onChangeTab(statusOption.slug)"
|
||||
:class="{ 'is-active': status == statusOption.slug}"
|
||||
:style="{ marginRight: statusOption.slug == 'private' ? 'auto' : '' }"
|
||||
v-tooltip="{
|
||||
content: $i18n.getWithVariables('info_%s_tab_' + statusOption.value,[$i18n.get('items')]),
|
||||
content: $i18n.getWithVariables('info_%s_tab_' + statusOption.slug,[$i18n.get('items')]),
|
||||
autoHide: true,
|
||||
placement: 'auto',
|
||||
}">
|
||||
<a>
|
||||
<span
|
||||
v-if="$statusHelper.hasIcon(statusOption.value)"
|
||||
v-if="$statusHelper.hasIcon(statusOption.slug)"
|
||||
class="icon has-text-gray">
|
||||
<i
|
||||
class="tainacan-icon tainacan-icon-18px"
|
||||
:class="$statusHelper.getIcon(statusOption.value)"
|
||||
:class="$statusHelper.getIcon(statusOption.slug)"
|
||||
/>
|
||||
</span>
|
||||
{{ statusOption.label }}
|
||||
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items[statusOption.value]})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems[statusOption.value] })` : '' }}</span>
|
||||
{{ statusOption.name }}
|
||||
<span class="has-text-gray"> {{ collection && collection.total_items ? ` (${collection.total_items[statusOption.slug]})` : (isRepositoryLevel && repositoryTotalItems) ? ` (${ repositoryTotalItems[statusOption.slug] })` : '' }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -728,8 +728,8 @@
|
|||
<p
|
||||
v-for="(statusOption, index) of $statusHelper.getStatuses()"
|
||||
:key="index"
|
||||
v-if="status == statusOption.value">
|
||||
{{ $i18n.getWithVariables('info_no_%s_' + statusOption.value,['items']) }}
|
||||
v-if="status == statusOption.slug">
|
||||
{{ $i18n.getWithVariables('info_no_%s_' + statusOption.slug,['items']) }}
|
||||
</p>
|
||||
|
||||
<router-link
|
||||
|
|
|
@ -88,8 +88,8 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'status_private' => __( 'Private', 'tainacan' ),
|
||||
'status_trash' => __( 'Trash', 'tainacan' ),
|
||||
'status_auto-draft' => __( 'Automatic Draft', 'tainacan' ),
|
||||
'publish_visibility' => __( 'Visible to everyone', 'tainacan' ),
|
||||
'private_visibility' => __( 'Visible only for editors', 'tainacan' ),
|
||||
'publish_visibility' => __( 'Public (Visible to everyone)', 'tainacan' ),
|
||||
'private_visibility' => __( 'Private (Visible only for editors)', 'tainacan' ),
|
||||
|
||||
// Page Titles (used mainly on Router)
|
||||
'title_repository_collections_page' => __( 'Repository Collections', 'tainacan' ),
|
||||
|
@ -572,9 +572,8 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'info_no_options_avialable_filtering' => __( 'No options for this filtering.', 'tainacan' ),
|
||||
'info_no_options_found' => __( 'No options found.', 'tainacan' ),
|
||||
'info_all_files_uploaded' => __( 'All files uploaded.', 'tainacan' ),
|
||||
'info_there_are_%s_items_being_edited' => __( 'There are %s items being edited', 'tainacan' ),
|
||||
'info_there_is_one_item_being_edited' => __( 'There is one item being edited', 'tainacan' ),
|
||||
'info_item_being_edited' => __( 'item being edited', 'tainacan' ),
|
||||
'info_there_are_%s_items_being_edited' => __( 'There are %s items being edited;', 'tainacan' ),
|
||||
'info_there_is_one_item_being_edited' => __( 'There is one item being edited.', 'tainacan' ),
|
||||
'info_no_preview_found' => __( 'No preview was found.', 'tainacan' ),
|
||||
'info_leaving_bulk_edition' => __( 'You are leaving the bulk edition now.', 'tainacan' ),
|
||||
'info_current_view_mode_metadata_not_allowed' => __( 'Current view mode does not allow displayed metadata selection.', 'tainacan' ),
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
export default {
|
||||
name: "ThemeItemsList",
|
||||
created() {
|
||||
this.$statusHelper.loadStatuses();
|
||||
this.$userPrefs.init();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue