Crates category list page and fixes some errors

This commit is contained in:
weryques 2018-03-21 14:21:16 -03:00
parent 667e53f299
commit 7b29fc7795
15 changed files with 1187 additions and 614 deletions

View File

@ -1,17 +1,19 @@
<template>
<div class="page-container">
<h1>Category Edition Form</h1>
<div>
<div class="page-container">
<h1>Category Edition Form</h1>
</div>
</div>
</template>
<script>
export default {
name: 'CategoryEditionForm',
data(){
return {
export default {
name: 'CategoryEditionForm',
data(){
return {
}
}
}
}
</script>
<style scoped>

View File

@ -40,9 +40,9 @@
<b-upload
model="thumbnail"
@input="uploadThumbnail($event)">
<a id="button-edit" :aria-label="$i18n.get('label_button_edit_thumb')"><b-icon icon="pencil"></a>
<a id="button-edit" :aria-label="$i18n.get('label_button_edit_thumb')"><b-icon icon="pencil"></b-icon></a>
</b-upload>
<a id="button-delete" :aria-label="$i18n.get('label_button_delete_thumb')" @click="deleteThumbnail()"><b-icon icon="delete"></a>
<a id="button-delete" :aria-label="$i18n.get('label_button_delete_thumb')" @click="deleteThumbnail()"><b-icon icon="delete"></b-icon></a>
</div>
</div>
</div>
@ -104,7 +104,7 @@
<p class="help is-danger">{{formErrorMessage}}</p>
</form>
<b-loading :active.sync="isLoading" :canCancel="false">
<b-loading :active.sync="isLoading" :canCancel="false"></b-loading>
</div>
</template>

View File

@ -1,20 +1,206 @@
<template>
<div>
<h1>Categories List</h1>
<b-field grouped group-multiline>
<button
v-if="selectedCategories.length > 0"
class="button field is-danger"
@click="deleteSelectedCategories()">
<span>{{ $i18n.get('instruction_delete_selected_categories') }} </span>
<b-icon icon="delete"></b-icon>
</button>
</b-field>
<b-table
v-if="totalCategories > 0"
ref="categoryTable"
:data="categories"
@selection-change="handleSelectionChange"
:checked-rows.sync="selectedCategories"
checkable
:loading="isLoading"
hoverable
striped
selectable
backend-sorting>
<template slot-scope="props">
<b-table-column
tabindex="0"
:label="$i18n.get('label_name')"
:aria-label="$i18n.get('label_name')"
field="props.row.name">
<router-link
class="clickable-row"
tag="span"
:to="{path: $routerHelper.getCategoryPath(props.row.id)}">
{{ props.row.name }}
</router-link>
</b-table-column>
<b-table-column
tabindex="0"
:aria-label="$i18n.get('label_description')"
:label="$i18n.get('label_description')"
property="description"
show-overflow-tooltip
field="props.row.description">
<router-link class="clickable-row" tag="span" :to="{path: $routerHelper.getCategoryPath(props.row.id)}">
{{ props.row.description }}
</router-link>
</b-table-column>
<b-table-column
tabindex="0"
:label="$i18n.get('label_actions')"
width="78"
:aria-label="$i18n.get('label_actions')">
<!-- <a id="button-view" :aria-label="$i18n.get('label_button_view')" @click.prevent.stop="goToCollectionPage(props.row.id)"><b-icon icon="eye"></a> -->
<a
id="button-edit"
:aria-label="$i18n.getFrom('categories','edit_item')"
@click.prevent.stop="goToCategoryEditPage(props.row.id)">
<b-icon type="is-gray" icon="pencil" ></b-icon>
</a>
<a
id="button-delete"
:aria-label="$i18n.get('label_button_delete')"
@click.prevent.stop="deleteOneCategory(props.row.id)">
<b-icon type="is-gray" icon="delete" ></b-icon>
</a>
</b-table-column>
</template>
</b-table>
<div v-if="!totalCategories || totalCategories <= 0">
<section class="section">
<div class="content has-text-grey has-text-centered">
<p>
<b-icon
icon="inbox"
size="is-large">
</b-icon>
</p>
<p>{{ $i18n.get('info_no_category_created') }}</p>
<router-link tag="button" class="button is-secondary"
:to="{ path: $routerHelper.getNewCategoryPath() }">
{{ $i18n.get('new') + ' ' + $i18n.get('category') }}
</router-link>
</div>
</section>
</div>
</div>
</template>
<script>
export default {
name: 'CategoriesList',
data(){
return {
//import { mapActions } from 'vuex'
export default {
name: 'CategoriesList',
props: {
isLoading: false,
totalCategories: 0,
page: 1,
categoriesPerPage: 12,
categories: []
},
data() {
return {
selectedCategories: []
}
},
methods: {
// ...mapActions('category', [
// 'deleteCategory'
// ]),
deleteOneCategory(categoryId) {
this.$dialog.confirm({
message: this.$i18n.get('info_warning_category_delete'),
onConfirm: () => {
this.deleteCategory(categoryId).then(() => {
this.loadCategories();
this.$toast.open({
duration: 3000,
message: this.$i18n.get('info_category_deleted'),
position: 'is-bottom',
type: 'is-secondary',
queue: true
});
for (let i = 0; i < this.selectedCategories.length; i++) {
if (this.selectedCategories[i].id === this.categoryId)
this.selectedCategories.splice(i, 1);
}
}).catch(() =>
this.$toast.open({
duration: 3000,
message: this.$i18n.get('info_error_deleting_category'),
position: 'is-bottom',
type: 'is-danger',
queue: true
})
);
}
});
},
deleteSelectedCategories() {
this.$dialog.confirm({
message: this.$i18n.get('info_selected_categories_delete'),
onConfirm: () => {
for (let category of this.selectedCategories) {
this.deleteCategory(category.id)
.then((res) => {
this.loadCategories();
this.$toast.open({
duration: 3000,
message: this.$i18n.get('info_category_deleted'),
position: 'is-bottom',
type: 'is-secondary',
queue: false
})
}).catch((err) => {
this.$toast.open({
duration: 3000,
message: this.$i18n.get('info_error_deleting_category'),
position: 'is-bottom',
type: 'is-danger',
queue: false
});
});
}
this.selectedCategories = [];
}
});
},
handleSelectionChange(value) {
},
goToCategoryPage(categoryId) {
this.$router.push(this.$routerHelper.getCategoryPath(categoryId));
},
goToCategoryEditPage(categoryId) {
this.$router.push(this.$routerHelper.getCategoryEditPath(categoryId));
}
}
}
}
</script>
<style scoped>
<style lang="scss" scoped>
@import "../../scss/_variables.scss";
.table-thumb {
max-height: 38px !important;
vertical-align: middle !important;
}
.row-creation span {
color: $gray-light;
font-size: 0.75em;
line-height: 1.5
}
.clickable-row{ cursor: pointer !important; }
</style>

View File

@ -40,7 +40,7 @@
<b-icon size="is-small" icon="shape"></b-icon> <span class="menu-text">{{ $i18n.getFrom('categories', 'name') }}</span>
</router-link></li>
<li><router-link tag="a" to="/events" :class="activeRoute == 'EventsPage' ? 'is-active':''">
<b-icon size="is-small" icon="bell"></b-icon> <span class="menu-text">{{ $i18n.getFrom('events', 'name') }}</span>
<b-icon size="is-small" icon="bell"></b-icon> <span class="menu-text">{{ $i18n.get('events') }}</span>
</router-link></li>
</ul>
</aside>

View File

@ -1,27 +1,200 @@
<template>
<div>
<div class="primary-page page-container">
<h1>Category Page</h1>
<router-link tag="button" class="button is-secondary"
:to="{ path: $routerHelper.getNewCategoryPath() }">
{{ $i18n.get('new') + ' ' + $i18n.get('category') }}
</router-link>
<div class="primary-page page-container-small">
<div class="sub-header" v-if="totalCategories > 0">
<div class="header-item">
<router-link tag="button" class="button is-secondary"
:to="{ path: $routerHelper.getNewCategoryPath() }">
{{ $i18n.get('new') + ' ' + $i18n.get('category') }}
</router-link>
</div>
</div>
<div class="columns above-subheader">
<div class="column table-container">
<categories-list
:isLoading="isLoading"
:totalCategories="totalCategories"
:page="page"
:categoriesPerPage="categoriesPerPage"
:categories="categories">
</categories-list>
<!-- Footer -->
<div class="table-footer" v-if="totalCategories > 0">
<div class="shown-items">
{{
$i18n.get('info_showing_categories') +
(categoriesPerPage * (page - 1) + 1) +
$i18n.get('info_to') +
getLastCategoryNumber() +
$i18n.get('info_of') + totalCategories + '.'
}}
</div>
<div class="items-per-page">
<b-field horizontal :label="$i18n.get('label_categories_per_page')">
<b-select
:value="categoriesPerPage"
@input="onChangeCategoriesPerPage"
:disabled="categories.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">
<b-pagination
@change="onPageChange"
:total="totalCategories"
:current.sync="page"
order="is-centered"
size="is-small"
:per-page="categoriesPerPage">
</b-pagination>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'CategoriesPage',
data(){
return {
import CategoriesList from "../../components/lists/categories-list.vue";
import { mapActions, mapGetters } from 'vuex';
//import moment from 'moment'
export default {
name: 'CategoriesPage',
data(){
return {
isLoading: false,
totalCategories: 0,
page: 1,
categoriesPerPage: 12
}
},
components: {
CategoriesList
},
methods: {
...mapActions('category', [
'fetchCategories',
]),
...mapGetters('category', [
'getCategories'
]),
onChangeCategoriesPerPage(value) {
let prevValue = this.categoriesPerPage;
this.categoriesPerPage = value;
this.$userPrefs.set('categories_per_page', value, prevValue);
this.loadCategories();
},
onPageChange(page) {
this.page = page;
this.loadCategories();
},
loadCategories() {
this.isLoading = true;
this.fetchCategories({ 'page': this.page, 'categoriesPerPage': this.categoriesPerPage })
.then((res) => {
this.isLoading = false;
this.totalCategories = res.total;
})
.catch((error) => {
this.isLoading = false;
});
},
getLastCategoryNumber() {
let last = (Number(this.categoriesPerPage * (this.page - 1)) + Number(this.categoriesPerPage));
return last > this.totalCategories ? this.totalCategories : last;
}
},
computed: {
categories(){
return this.getCategories();
// for (let category of categories)
// category['creation'] = this.$i18n.get('info_created_by') +
// category['author_name'] + '<br>' + this.$i18n.get('info_date') +
// moment(category['creation_date'], 'YYYY-MM-DD').format('DD/MM/YYYY');
}
},
created() {
this.$userPrefs.get('categories_per_page')
.then((value) => {
this.categoriesPerPage = value;
})
.catch((error) => {
this.$userPrefs.set('categories_per_page', 12, null);
});
},
mounted(){
this.loadCategories();
}
}
}
</script>
<style scoped>
<style lang="scss" scoped>
@import '../../scss/_variables.scss';
.sub-header {
max-height: $header-height;
height: $header-height;
margin-left: -$page-small-side-padding;
margin-right: -$page-small-side-padding;
margin-top: -$page-small-top-padding;
padding-top: $page-small-top-padding;
padding-left: $page-small-side-padding;
padding-right: $page-small-side-padding;
border-bottom: 0.5px solid #ddd;
.header-item {
display: inline-block;
padding-right: 8em;
}
@media screen and (max-width: 769px) {
height: 60px;
margin-top: -0.5em;
padding-top: 0.9em;
.header-item {
padding-right: 0.5em;
}
}
}
.above-subheader {
margin-bottom: 0;
margin-top: 0;
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;
}
@media screen and (max-width: 769px) {
.filters-menu {
display: none;
}
.table-container {
margin-right: 0;
padding: .85em 0em;
}
}
}
</style>

View File

@ -1,170 +1,173 @@
<?php
<?php
return [
// Tainacan common terms
'repository' => __('Repository', 'tainacan'),
'collections' => __('Collections', 'tainacan'),
'items' => __('Items', 'tainacan'),
'fields' => __('Fields', 'tainacan'),
'filters' => __('Filters', 'tainacan'),
'categories' => __('Categories', 'tainacan'),
'events' => __('Events', 'tainacan'),
'collection' => __('Collection', 'tainacan'),
'item' => __('Item', 'tainacan'),
'field' => __('Field', 'tainacan'),
'filter' => __('Filter', 'tainacan'),
'category' => __('Category', 'tainacan'),
'event' => __('Event', 'tainacan'),
// Actions
'edit' => __('Edit', 'tainacan'),
'new' => __('New', 'tainacan'),
'import' => __('Import', 'tainacan'),
'export' => __('Export', 'tainacan'),
'cancel' => __('Cancel', 'tainacan'),
'save' => __('Save', 'tainacan'),
'next' => __('Next', 'tainacan'),
'see' => __('See', 'tainacan'),
'search' => __('Search', 'tainacan'),
'advanced_search' => __('Advanced Search', 'tainacan'),
// Tainacan common terms
'repository' => __( 'Repository', 'tainacan' ),
'collections' => __( 'Collections', 'tainacan' ),
'items' => __( 'Items', 'tainacan' ),
'fields' => __( 'Fields', 'tainacan' ),
'filters' => __( 'Filters', 'tainacan' ),
'categories' => __( 'Categories', 'tainacan' ),
'events' => __( 'Events', 'tainacan' ),
'collection' => __( 'Collection', 'tainacan' ),
'item' => __( 'Item', 'tainacan' ),
'field' => __( 'Field', 'tainacan' ),
'filter' => __( 'Filter', 'tainacan' ),
'category' => __( 'Category', 'tainacan' ),
'event' => __( 'Event', 'tainacan' ),
// Wordpress Status
'publish' => __('Publish', 'tainacan'),
'draft' => __('Draft', 'tainacan'),
'private' => __('Private', 'tainacan'),
'trash' => __('Trash', 'tainacan'),
'auto-draft' => __('Automatic Draft', 'tainacan'),
'publish_visibility' => __('Visible to everyone', 'tainacan'),
'private_visibility' => __('Visible only for editors', 'tainacan'),
// Actions
'edit' => __( 'Edit', 'tainacan' ),
'new' => __( 'New', 'tainacan' ),
'import' => __( 'Import', 'tainacan' ),
'export' => __( 'Export', 'tainacan' ),
'cancel' => __( 'Cancel', 'tainacan' ),
'save' => __( 'Save', 'tainacan' ),
'next' => __( 'Next', 'tainacan' ),
'see' => __( 'See', 'tainacan' ),
'search' => __( 'Search', 'tainacan' ),
'advanced_search' => __( 'Advanced Search', 'tainacan' ),
// Page Titles (used mainly on Router)
'title_collections_page' => __('Collections Page', 'tainacan'),
'title_items_page' => __('Items Page', 'tainacan'),
'title_fields_page' => __('Fields Page', 'tainacan'),
'title_filters_page' => __('Filters Page', 'tainacan'),
'title_categories_page' => __('Categories Page', 'tainacan'),
'title_terms_page' => __('Terms Page', 'tainacan'),
'title_events_page' => __('Events Page', 'tainacan'),
'title_collection_page' => __('Collection Page', 'tainacan'),
'title_item_page' => __('Item Page', 'tainacan'),
'title_field_page' => __('Field Page', 'tainacan'),
/* translators: alkdjklasdj laksjd klsadj */
'title_filter_page' => __('Filter Page', 'tainacan'),
'title_category_page' => __('Category Page', 'tainacan'),
'title_term_page' => __('Term Page', 'tainacan'),
'title_event_page' => __('Event Page', 'tainacan'),
'title_create_collection' => __('Collection Creation Page', 'tainacan'),
'title_create_category' => __('Category Creation Page', 'tainacan'),
'title_create_item' => __('Item Creation Page', 'tainacan'),
'title_create_filter' => __('Filter Creation Page', 'tainacan'),
'title_collection_edition' => __('Collection Edition Page', 'tainacan'),
'title_item_edition' => __('Item Edition Page', 'tainacan'),
'title_category_edition' => __('Category Edition Page', 'tainacan'),
'title_filter_edition' => __('Filter Edition Page', 'tainacan'),
'title_collection_fields_edition' => __('Collection Fields Edition Page', 'tainacan'),
// Wordpress Status
'publish' => __( 'Publish', 'tainacan' ),
'draft' => __( 'Draft', 'tainacan' ),
'private' => __( 'Private', 'tainacan' ),
'trash' => __( 'Trash', 'tainacan' ),
'auto-draft' => __( 'Automatic Draft', 'tainacan' ),
'publish_visibility' => __( 'Visible to everyone', 'tainacan' ),
'private_visibility' => __( 'Visible only for editors', 'tainacan' ),
// Labels (used mainly on Aria Labels and Inputs)
'label_menu' => __('Menu', 'tainacan'),
'label_main_menu' => __('Main Menu', 'tainacan'),
'label_collection_menu' => __('Collection Menu', 'tainacan'),
'label_title' => __('Title', 'tainacan'),
'label_actions' => __('Actions', 'tainacan'),
'label_name' => __('Name', 'tainacan'),
'label_description' => __('Description', 'tainacan'),
'label_status' => __('Status', 'tainacan'),
'label_slug' => __('Slug', 'tainacan'),
'label_image' => __('Image', 'tainacan'),
'label_thumbnail' => __('Thumbnail', 'tainacan'),
'label_button_view' => __('Button View', 'tainacan'),
'label_button_edit' => __('Button Edit', 'tainacan'),
'label_button_delete' => __('Button Delete', 'tainacan'),
'label_button_edit_thumb' => __('Button Edit Thumbnail', 'tainacan'),
'label_button_delete_thumb' => __('Button Delete Thumbnail', 'tainacan'),
'label_collections_per_page' => __('Collections per Page:', 'tainacan'),
'label_items_per_page' => __('Items per Page:', 'tainacan'),
'label_active_fields' => __('Active Fields', 'tainacan'),
'label_available_fields' => __('Available Fields', 'tainacan'),
'label_available_field_types' => __('Available Field Types', 'tainacan'),
'label_active_filters' => __('Active Filters', 'tainacan'),
'label_filter_type' => __('Filter Type', 'tainacan'),
'label_available_filters' => __('Available Filters', 'tainacan'),
'label_available_filter_types' => __('Available Filter Types', 'tainacan'),
'label_per_page' => __('per Page', 'tainacan'),
'label_table_fields' => __('Fields on table', 'tainacan'),
'label_required' => __('Required', 'tainacan'),
'label_allow_multiple' => __('Allow multiple values', 'tainacan'),
'label_default_value' => __('Default value', 'tainacan'),
'label_unique_value' => __('Unique value', 'tainacan'),
'label_yes' => __('Yes', 'tainacan'),
'label_no' => __('No', 'tainacan'),
'label_collection_related' => __('Collection Related', 'tainacan'),
'label_fields_for_search' => __('Fields for search', 'tainacan'),
'label_allow_repeated_items' => __('Allow repeated items', 'tainacan'),
'label_select_category' => __('Select category', 'tainacan'),
'label_select_category_input_type' => __('Input type', 'tainacan'),
'label_category_allow_new_terms' => __('Allow new terms', 'tainacan'),
'label_selectbox_init' => __('Select', 'tainacan'),
'label_options' => __('Insert options', 'tainacan'),
'label_attachments' => __('Attachments', 'tainacan'),
'label_enabled' => __('Enabled', 'tainacan'),
'label_disabled' => __('Disabled', 'tainacan'),
'label_creation' => __('Creation', 'tainacan'),
'label_collection_items' => __('Collection Items', 'tainacan'),
'label_collection_fields' => __('Collection Fields', 'tainacan'),
'label_collection_filters' => __('Collection Filters', 'tainacan'),
'label_parent_term' => __('Parent Term', 'tainacan'),
'label_add_new_term' => __('Add New Term', 'tainacan'),
// Page Titles (used mainly on Router)
'title_collections_page' => __( 'Collections Page', 'tainacan' ),
'title_items_page' => __( 'Items Page', 'tainacan' ),
'title_fields_page' => __( 'Fields Page', 'tainacan' ),
'title_filters_page' => __( 'Filters Page', 'tainacan' ),
'title_categories_page' => __( 'Categories Page', 'tainacan' ),
'title_terms_page' => __( 'Terms Page', 'tainacan' ),
'title_events_page' => __( 'Events Page', 'tainacan' ),
'title_collection_page' => __( 'Collection Page', 'tainacan' ),
'title_item_page' => __( 'Item Page', 'tainacan' ),
'title_field_page' => __( 'Field Page', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders
'instruction_dragndrop_fields_collection' => __('Drag and drop Fields here to Collection.', 'tainacan'),
'instruction_dragndrop_filters_collection' => __('Drag and drop Fields to create Filters on Collection.', 'tainacan'),
'instruction_dragndrop_fields_repository' => __('Drag and drop Fields here to Repository.', 'tainacan'),
'instruction_dragndrop_filters_repository' => __('Drag and drop Fields to create Filters on Repository.', 'tainacan'),
'instruction_delete_selected_collections' => __('Delete selected collections', 'tainacan'),
'instruction_delete_selected_items' => __('Delete selected items', 'tainacan'),
'instruction_image_upload_box' => __('Drop an image here or click to upload.', 'tainacan'),
'instruction_select_a_status' => __('Select a status:', 'tainacan'),
'instruction_select_a_filter_type' => __('Select a filter type:', 'tainacan'),
/* translators: alkdjklasdj laksjd klsadj */
'title_filter_page' => __( 'Filter Page', 'tainacan' ),
'title_category_page' => __( 'Category Page', 'tainacan' ),
'title_term_page' => __( 'Term Page', 'tainacan' ),
'title_event_page' => __( 'Event Page', 'tainacan' ),
'title_create_collection' => __( 'Collection Creation Page', 'tainacan' ),
'title_create_category_page' => __( 'Category Creation Page', 'tainacan' ),
'title_create_item' => __( 'Item Creation Page', 'tainacan' ),
'title_create_filter' => __( 'Filter Creation Page', 'tainacan' ),
'title_collection_edition' => __( 'Collection Edition Page', 'tainacan' ),
'title_item_edition' => __( 'Item Edition Page', 'tainacan' ),
'title_category_edition_page' => __( 'Category Edition Page', 'tainacan' ),
'title_filter_edition' => __( 'Filter Edition Page', 'tainacan' ),
'title_collection_fields_edition' => __( 'Collection Fields Edition Page', 'tainacan' ),
// Info. Other feedback to user.
'info_name_is_required' => __('Name is required.', 'tainacan'),
'info_no_collection_created' => __('No collection was created in this repository.', 'tainacan'),
'info_no_item_created' => __('No item was created in this collection.', 'tainacan'),
'info_error_deleting_collection' => __('Error on deleting collection.', 'tainacan'),
'info_collection_deleted' => __('Collection deleted.', 'tainacan'),
'info_item_deleted' => __('Item deleted.', 'tainacan'),
'info_warning_collection_delete' => __('Do you really want to delete this collection?', 'tainacan'),
'info_warning_item_delete' => __('Do you really want to delete this item?', 'tainacan'),
'info_warning_selected_collections_delete' => __('Do you really want to delete the selected collections?', 'tainacan'),
'info_warning_selected_items_delete' => __('Do you really want to delete the selected items?', 'tainacan'),
'info_warning_collection_related' => __('The field Collection related is required', 'tainacan'),
'info_warning_no_fields_found' => __('No fields found in this collection', 'tainacan'),
'info_showing_items' => __('Showing items ', 'tainacan'),
'info_showing_collections' => __('Showing collections ', 'tainacan'),
'info_to' => __(' to ', 'tainacan'),
'info_of' => __(' of ', 'tainacan'),
'info_created_by' => __('Created by: ', 'tainacan'),
'info_date' => __('Date: ', 'tainacan'),
'info_not_saved' => __('Not saved ', 'tainacan'),
// Labels (used mainly on Aria Labels and Inputs)
'label_menu' => __( 'Menu', 'tainacan' ),
'label_main_menu' => __( 'Main Menu', 'tainacan' ),
'label_collection_menu' => __( 'Collection Menu', 'tainacan' ),
'label_title' => __( 'Title', 'tainacan' ),
'label_actions' => __( 'Actions', 'tainacan' ),
'label_name' => __( 'Name', 'tainacan' ),
'label_description' => __( 'Description', 'tainacan' ),
'label_status' => __( 'Status', 'tainacan' ),
'label_slug' => __( 'Slug', 'tainacan' ),
'label_image' => __( 'Image', 'tainacan' ),
'label_thumbnail' => __( 'Thumbnail', 'tainacan' ),
'label_button_view' => __( 'Button View', 'tainacan' ),
'label_button_edit' => __( 'Button Edit', 'tainacan' ),
'label_button_delete' => __( 'Button Delete', 'tainacan' ),
'label_button_edit_thumb' => __( 'Button Edit Thumbnail', 'tainacan' ),
'label_button_delete_thumb' => __( 'Button Delete Thumbnail', 'tainacan' ),
'label_collections_per_page' => __( 'Collections per Page:', 'tainacan' ),
'label_categories_per_page' => __( 'Categories per Page:', 'tainacan' ),
'label_items_per_page' => __( 'Items per Page:', 'tainacan' ),
'label_active_fields' => __( 'Active Fields', 'tainacan' ),
'label_available_fields' => __( 'Available Fields', 'tainacan' ),
'label_available_field_types' => __( 'Available Field Types', 'tainacan' ),
'label_active_filters' => __( 'Active Filters', 'tainacan' ),
'label_filter_type' => __( 'Filter Type', 'tainacan' ),
'label_available_filters' => __( 'Available Filters', 'tainacan' ),
'label_available_filter_types' => __( 'Available Filter Types', 'tainacan' ),
'label_per_page' => __( 'per Page', 'tainacan' ),
'label_table_fields' => __( 'Fields on table', 'tainacan' ),
'label_required' => __( 'Required', 'tainacan' ),
'label_allow_multiple' => __( 'Allow multiple values', 'tainacan' ),
'label_default_value' => __( 'Default value', 'tainacan' ),
'label_unique_value' => __( 'Unique value', 'tainacan' ),
'label_yes' => __( 'Yes', 'tainacan' ),
'label_no' => __( 'No', 'tainacan' ),
'label_collection_related' => __( 'Collection Related', 'tainacan' ),
'label_fields_for_search' => __( 'Fields for search', 'tainacan' ),
'label_allow_repeated_items' => __( 'Allow repeated items', 'tainacan' ),
'label_select_category' => __( 'Select category', 'tainacan' ),
'label_select_category_input_type' => __( 'Input type', 'tainacan' ),
'label_category_allow_new_terms' => __( 'Allow new terms', 'tainacan' ),
'label_selectbox_init' => __( 'Select', 'tainacan' ),
'label_options' => __( 'Insert options', 'tainacan' ),
'label_attachments' => __( 'Attachments', 'tainacan' ),
'label_enabled' => __( 'Enabled', 'tainacan' ),
'label_disabled' => __( 'Disabled', 'tainacan' ),
'label_creation' => __( 'Creation', 'tainacan' ),
'label_collection_items' => __( 'Collection Items', 'tainacan' ),
'label_collection_fields' => __( 'Collection Fields', 'tainacan' ),
'label_collection_filters' => __( 'Collection Filters', 'tainacan' ),
'label_parent_term' => __( 'Parent Term', 'tainacan' ),
'label_add_new_term' => __( 'Add New Term', 'tainacan' ),
// Tainacan Field Types
'tainacan-text' => __('Text', 'tainacan'),
'tainacan-textarea' => __('Text area', 'tainacan'),
'tainacan-date' => __('Date', 'tainacan'),
'tainacan-numeric' => __('Numeric', 'tainacan'),
'tainacan-selectbox' => __('Select box', 'tainacan'),
'tainacan-relationship' => __('Relationship', 'tainacan'),
'tainacan-category' => __('Category', 'tainacan'),
// Instructions. More complex sentences to guide user and placeholders
'instruction_dragndrop_fields_collection' => __( 'Drag and drop Fields here to Collection.', 'tainacan' ),
'instruction_dragndrop_filters_collection' => __( 'Drag and drop Fields to create Filters on Collection.', 'tainacan' ),
'instruction_dragndrop_fields_repository' => __( 'Drag and drop Fields here to Repository.', 'tainacan' ),
'instruction_dragndrop_filters_repository' => __( 'Drag and drop Fields to create Filters on Repository.', 'tainacan' ),
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ),
'instruction_image_upload_box' => __( 'Drop an image here or click to upload.', 'tainacan' ),
'instruction_select_a_status' => __( 'Select a status:', 'tainacan' ),
'instruction_select_a_filter_type' => __( 'Select a filter type:', 'tainacan' ),
// Tainacan Filter Types
'tainacan-filter-custom-interval' => __('Custom Interval', 'tainacan'),
'tainacan-filter-selectbox' => __('Select Box', 'tainacan'),
'tainacan-filter-autocomplete' => __('Autocomplete', 'tainacan'),
'tainacan-filter-taginput' => __('Tag Input', 'tainacan'),
'tainacan-filter-checkbox' => __('Check Box', 'tainacan'),
'tainacan-filter-category-taginput' => __('Category Tag Input', 'tainacan'),
'tainacan-filter-category-checkbox' => __('Category Check Box', 'tainacan'),
'tainacan-filter-category-selectbox' => __('Category Select Box', 'tainacan')
// Info. Other feedback to user.
'info_name_is_required' => __( 'Name is required.', 'tainacan' ),
'info_no_collection_created' => __( 'No collection was created in this repository.', 'tainacan' ),
'info_no_category_created' => __( 'No category was created in this repository.', 'tainacan' ),
'info_no_item_created' => __( 'No item was created in this collection.', 'tainacan' ),
'info_error_deleting_collection' => __( 'Error on deleting collection.', 'tainacan' ),
'info_collection_deleted' => __( 'Collection deleted.', 'tainacan' ),
'info_item_deleted' => __( 'Item deleted.', 'tainacan' ),
'info_warning_collection_delete' => __( 'Do you really want to delete this collection?', 'tainacan' ),
'info_warning_item_delete' => __( 'Do you really want to delete this item?', 'tainacan' ),
'info_warning_selected_collections_delete' => __( 'Do you really want to delete the selected collections?', 'tainacan' ),
'info_warning_selected_items_delete' => __( 'Do you really want to delete the selected items?', 'tainacan' ),
'info_warning_collection_related' => __( 'The field Collection related is required', 'tainacan' ),
'info_warning_no_fields_found' => __( 'No fields found in this collection', 'tainacan' ),
'info_showing_items' => __( 'Showing items ', 'tainacan' ),
'info_showing_collections' => __( 'Showing collections ', 'tainacan' ),
'info_showing_categories' => __( 'Showing categories ', 'tainacan' ),
'info_to' => __( ' to ', 'tainacan' ),
'info_of' => __( ' of ', 'tainacan' ),
'info_created_by' => __( 'Created by: ', 'tainacan' ),
'info_date' => __( 'Date: ', 'tainacan' ),
'info_not_saved' => __( 'Not saved ', 'tainacan' ),
// Tainacan Field Types
'tainacan-text' => __( 'Text', 'tainacan' ),
'tainacan-textarea' => __( 'Text area', 'tainacan' ),
'tainacan-date' => __( 'Date', 'tainacan' ),
'tainacan-numeric' => __( 'Numeric', 'tainacan' ),
'tainacan-selectbox' => __( 'Select box', 'tainacan' ),
'tainacan-relationship' => __( 'Relationship', 'tainacan' ),
'tainacan-category' => __( 'Category', 'tainacan' ),
// Tainacan Filter Types
'tainacan-filter-custom-interval' => __( 'Custom Interval', 'tainacan' ),
'tainacan-filter-selectbox' => __( 'Select Box', 'tainacan' ),
'tainacan-filter-autocomplete' => __( 'Autocomplete', 'tainacan' ),
'tainacan-filter-taginput' => __( 'Tag Input', 'tainacan' ),
'tainacan-filter-checkbox' => __( 'Check Box', 'tainacan' ),
'tainacan-filter-category-taginput' => __( 'Category Tag Input', 'tainacan' ),
'tainacan-filter-category-checkbox' => __( 'Category Check Box', 'tainacan' ),
'tainacan-filter-category-selectbox' => __( 'Category Select Box', 'tainacan' )
]
?>
?>

View File

@ -227,14 +227,30 @@ class TAINACAN_REST_Taxonomies_Controller extends TAINACAN_REST_Controller {
public function get_items( $request ) {
$args = $this->prepare_filters($request);
$taxonomies = $this->taxonomy_repository->fetch($args, 'OBJECT');
$taxonomies = $this->taxonomy_repository->fetch($args);
$response = [];
foreach ($taxonomies as $taxonomy) {
array_push($response, $this->prepare_item_for_response( $taxonomy, $request ));
if($taxonomies->have_posts()){
while ($taxonomies->have_posts()){
$taxonomies->the_post();
$taxonomy = new Entities\Taxonomy($taxonomies->post);
array_push($response, $this->prepare_item_for_response($taxonomy, $request));
}
wp_reset_postdata();
}
return new WP_REST_Response($response, 200);
$total_taxonomies = (int) $taxonomies->found_posts;
$max_pages = ceil($total_taxonomies / (int) $taxonomies->query_vars['posts_per_page']);
$rest_response = new WP_REST_Response($response, 200);
$rest_response->header('X-WP-Total', $total_taxonomies);
$rest_response->header('X-WP-TotalPages', (int) $max_pages);
return $rest_response;
}
/**

View File

@ -191,7 +191,6 @@ class Taxonomies extends Repository {
$args = array_merge([
'posts_per_page' => -1,
'post_status' => 'publish'
], $args);
$args = $this->parse_fetch_args($args);

View File

@ -0,0 +1,35 @@
import axios from '../../../axios/axios'
export const createCategory = ({commit}, category) => {
return new Promise(( resolve, reject ) => {
axios.tainacan.post('/taxonomies/', {
name: category.name,
description: category.description,
status: category.status,
slug: category.slug,
allow_insert: category.allow_insert
})
.then( res => {
commit('setCategory', category);
resolve( res.data );
})
.catch(error => {
reject( error.response );
});
});
};
export const fetchCategories = ({ commit }, { page, categoriesPerPage } ) => {
return new Promise((resolve, reject) => {
axios.tainacan.get('/taxonomies?paged='+ page +'&perpage='+ categoriesPerPage)
.then(res => {
let categories = res.data;
commit('setCategories', categories);
resolve({'categories': categories, 'total': res.headers['x-wp-total'] });
})
.catch(error => {
console.log(error);
reject(error);
});
});
};

View File

@ -0,0 +1,7 @@
export const getCategory = state => {
return state.category;
};
export const getCategories = state => {
return state.categories;
};

View File

@ -0,0 +1,16 @@
import * as actions from './actions';
import * as getters from './getters';
import * as mutations from './mutations';
const state = {
categories: [],
category: null,
};
export default {
namespaced: true,
state,
mutations,
actions,
getters
}

View File

@ -0,0 +1,7 @@
export const setCategory = (state, category) => {
state.category = category;
};
export const setCategories = (state, categories) => {
state.categories = categories;
};

View File

@ -6,6 +6,7 @@ import collection from './modules/collection/';
import fields from './modules/fields/';
import filter from './modules/filter/';
import search from './modules/search/';
import category from './modules/category/'
Vue.use(Vuex);
@ -15,6 +16,7 @@ export default new Vuex.Store({
collection,
fields,
filter,
search
search,
category,
}
})

Binary file not shown.

File diff suppressed because it is too large Load Diff