From 0c540b987f0302edd105dba4be29a5300bfad8f2 Mon Sep 17 00:00:00 2001 From: weryques Date: Wed, 28 Feb 2018 10:31:44 -0300 Subject: [PATCH 01/19] Fix meta query error when have only one meta query --- src/api/class-tainacan-rest-controller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/class-tainacan-rest-controller.php b/src/api/class-tainacan-rest-controller.php index c04d65c7b..3eb406a30 100644 --- a/src/api/class-tainacan-rest-controller.php +++ b/src/api/class-tainacan-rest-controller.php @@ -195,8 +195,8 @@ class TAINACAN_REST_Controller extends WP_REST_Controller { * @return bool */ protected function contains_array($array){ - foreach ($array as $value){ - if(is_array($value)){ + foreach ($array as $index => $value){ + if(is_array($value) && in_array($index, ['metaquery', 'datequery', 'taxquery'])){ return true; } } From 83e0393917590db13dfe23028ac559af4fe53d57 Mon Sep 17 00:00:00 2001 From: weryques Date: Wed, 28 Feb 2018 11:11:26 -0300 Subject: [PATCH 02/19] Add support to named meta queries --- src/api/class-tainacan-rest-controller.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/api/class-tainacan-rest-controller.php b/src/api/class-tainacan-rest-controller.php index 3eb406a30..f380b64e0 100644 --- a/src/api/class-tainacan-rest-controller.php +++ b/src/api/class-tainacan-rest-controller.php @@ -170,7 +170,7 @@ class TAINACAN_REST_Controller extends WP_REST_Controller { $request_meta_query = $request[$mapped]; // If is a multidimensional array (array of array) - if($this->contains_array($request_meta_query)) { + if($this->contains_array($request_meta_query, $query)) { foreach ( $request_meta_query as $index1 => $a ) { foreach ( $query as $mapped_meta => $meta_v ) { if ( isset( $a[ $meta_v ] ) ) { @@ -192,11 +192,14 @@ class TAINACAN_REST_Controller extends WP_REST_Controller { /** * @param $array * + * @param $query + * * @return bool */ - protected function contains_array($array){ + protected function contains_array($array, $query){ foreach ($array as $index => $value){ - if(is_array($value) && in_array($index, ['metaquery', 'datequery', 'taxquery'])){ + // Not will pass named meta query, which use reserved names + if(is_array($value) && !key_exists($index, $query)){ return true; } } From 829b19fb0ba330103a85d3ebd647f66b59dc00c4 Mon Sep 17 00:00:00 2001 From: Eduardo humberto Date: Wed, 28 Feb 2018 12:48:30 -0300 Subject: [PATCH 03/19] create examples for filter store structure --- src/classes/filter-types/range/Range.vue | 27 ++++++------- .../range/class-tainacan-range.php | 1 + src/js/event-bus-filters.js | 18 +++++++-- src/js/store/modules/filter/actions.js | 38 ++++++++++++++----- src/js/store/modules/filter/getters.js | 12 ++++-- src/js/store/modules/filter/index.js | 10 ++++- src/js/store/modules/filter/mutations.js | 35 ++++++++++++++--- src/js/store/store.js | 4 +- 8 files changed, 105 insertions(+), 40 deletions(-) diff --git a/src/classes/filter-types/range/Range.vue b/src/classes/filter-types/range/Range.vue index 699b7372e..282e6f722 100644 --- a/src/classes/filter-types/range/Range.vue +++ b/src/classes/filter-types/range/Range.vue @@ -62,6 +62,7 @@ type: Object // concentrate all attributes field id and type }, field_id: [Number], // not required, but overrides the filter field id if is set + collection_id: [Number], // not required, but overrides the filter field id if is set typeRange: [String], // not required, but overrides the filter field type if is set id: '' }, @@ -82,23 +83,23 @@ } } }, - // emit the operation for component listener + // emit the operation for listeners emit(){ + let values = null; if( this.type === 'date' ){ - this.$emit('input', { - filter: 'range', - type: 'date', - field_id: ( this.field_id ) ? this.field_id : this.filter.field, - values: [ this.date_init, this.date_end ] - }); + values = [ this.date_init, this.date_end ] } else { - this.$emit('input', { - filter: 'range', - type: 'numeric', - field_id: ( this.field_id ) ? this.field_id : this.filter.field, - values: [ this.value_init, this.value_end ] - }); + values = [ this.value_init, this.value_end ] } + + this.$emit('input', { + filter: 'range', + type: 'numeric', + compare: 'BETWEEN', + field_id: ( this.field_id ) ? this.field_id : this.filter.field, + collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id, + value: values + }); }, // message for error error_message(){ diff --git a/src/classes/filter-types/range/class-tainacan-range.php b/src/classes/filter-types/range/class-tainacan-range.php index 28a9fe792..0b6342a4f 100644 --- a/src/classes/filter-types/range/class-tainacan-range.php +++ b/src/classes/filter-types/range/class-tainacan-range.php @@ -21,6 +21,7 @@ class Range extends Filter_Type { public function render( $filter ){ return ''; } } \ No newline at end of file diff --git a/src/js/event-bus-filters.js b/src/js/event-bus-filters.js index 4b32dd939..2c6c7d371 100644 --- a/src/js/event-bus-filters.js +++ b/src/js/event-bus-filters.js @@ -1,17 +1,27 @@ import Vue from 'vue'; +import store from './store/store' export const eventFilterBus = new Vue({ + store, data: { componentsTag: [], errors : [], query: {} }, created(){ - this.$on('input', data => this.search(data) ); + this.$on('input', data => this.add_metaquery(data) ); }, methods: { - search( ){ - console.log( data ); + add_metaquery( data ){ + if ( data.collection_id ){ + this.$store.dispatch('filter/add_metaquery', data ); + const promisse = this.$store.dispatch('filter/search_by_collection', data.collection_id ); + promisse.then( response => { + + }, error => { + + }); + } }, /* Dev interfaces methods */ @@ -37,7 +47,7 @@ export const eventFilterBus = new Vue({ const components = this.getAllComponents(); for (let eventElement of components){ eventElement.addEventListener('input', (event) => { - console.log( event.detail, 'dev' ); + this.add_metaquery( event.detail[0] ); }); } }, diff --git a/src/js/store/modules/filter/actions.js b/src/js/store/modules/filter/actions.js index 5a2ce23f2..5282fced1 100644 --- a/src/js/store/modules/filter/actions.js +++ b/src/js/store/modules/filter/actions.js @@ -1,14 +1,32 @@ import axios from '../../../axios/axios'; import qs from 'qs'; -export const do_query = ({ commit, state }) => { - return new Promise((resolve, reject) =>{ - axios.get('/collections/' + state.collection + '/items?' + qs.stringify( state.query )) - .then(res => { - - }) - .catch(error => { - - }) +export const search_by_collection = ({ commit, state, dispatch }, collectionId) => { + commit('setPostQuery', 'meta_query', state.meta_query ); + commit('setPostQuery', 'tax_query', state.tax_query ); + return new Promise((resolve, reject) =>{ + axios.get('/collection/' + collectionId + '/items?' + qs.stringify( state.query )) + .then(res => { + resolve( res.data ); + }) + .catch(error => { + reject( error ) + }) }); -} +}; + + +export const set_postquery_attribute = ({ commit }, field, value ) => { + commit('setPostQuery', field, value ); +}; + +export const add_metaquery = ( { commit }, filter ) => { + commit('addMetaQuery', filter ); +}; + +export const remove_metaquery = ( { commit }, filter ) => { + commit('removeMetaQuery', filter ); +}; + + + diff --git a/src/js/store/modules/filter/getters.js b/src/js/store/modules/filter/getters.js index 3d508ffd2..6624b08cb 100644 --- a/src/js/store/modules/filter/getters.js +++ b/src/js/store/modules/filter/getters.js @@ -1,7 +1,11 @@ -export const getQuery = state => { - return state.query; +export const getPostQuery = state => { + return state.post_query; } -export const getCollection = state => { - return state.collection; +export const getMetaQuery = state => { + return state.meta_query; } + +export const getTaxQuery = state => { + return state.tax_query; +} \ No newline at end of file diff --git a/src/js/store/modules/filter/index.js b/src/js/store/modules/filter/index.js index 5f5320534..591174e22 100644 --- a/src/js/store/modules/filter/index.js +++ b/src/js/store/modules/filter/index.js @@ -3,8 +3,14 @@ import * as getters from './getters'; import * as mutations from './mutations'; const state = { - query: {}, - collection: null + post_query: { + post_status: 'publish', + post_type: [], + meta_query: null, + tax_query: null + }, + meta_query: [], + tax_query: [] }; export default { diff --git a/src/js/store/modules/filter/mutations.js b/src/js/store/modules/filter/mutations.js index f935a50ce..cb0a0665b 100644 --- a/src/js/store/modules/filter/mutations.js +++ b/src/js/store/modules/filter/mutations.js @@ -1,8 +1,31 @@ -export const setQuery = ( state, query ) => { - state.query = query; -} +import Vue from 'vue'; -export const setCollection = ( state, collection ) => { - state.query = collection; -} +export const setPostQuery = ( state, field, value ) => { + Vue.set( state.post_query, field, value ); +}; +export const addMetaQuery = ( state, filter ) => { + let index = state.meta_query.findIndex( item => item.key === filter.field_id); + if ( index >= 0){ + Vue.set( state.meta_query, index, { + key: filter.field_id, + value: filter.value, + compare: filter.compare, + type: filter.type + } ); + }else{ + state.meta_query.push({ + key: filter.field_id, + value: filter.value, + compare: filter.compare, + type: filter.type + }); + } +}; + +export const removeMetaQuery = ( state, filter ) => { + let index = state.meta_query.findIndex( item => item.key === filter.field_id); + if (index >= 0) { + state.meta_query.splice(index, 1); + } +} diff --git a/src/js/store/store.js b/src/js/store/store.js index 14c7336f1..82196bdcb 100644 --- a/src/js/store/store.js +++ b/src/js/store/store.js @@ -3,12 +3,14 @@ import Vuex from 'vuex'; import item from './modules/item/'; import collection from './modules/collection/'; +import filter from './modules/filter/'; Vue.use(Vuex); export default new Vuex.Store({ modules: { item, - collection + collection, + filter } }) \ No newline at end of file From 1dbf96a33cfb1078047a7d8b8e84eca954033378 Mon Sep 17 00:00:00 2001 From: weryques Date: Wed, 28 Feb 2018 12:52:33 -0300 Subject: [PATCH 04/19] Update build.js --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 2323df656..615e8557b 100755 --- a/build.sh +++ b/build.sh @@ -15,7 +15,7 @@ if [ $current_OS == "Darwin" ]; then find src -type f \( -name "*.js" -or -name "*.vue" \) -exec md5 {} \; | sort -k 2 | md5 > last-js-build.md5 find src -type f \( -name "*.scss" \) -exec md5 {} \; | sort -k 2 | md5 > last-sass-build.md5 find src -type f \( -name "composer.json" \) -exec md5 {} \; | sort -k 2 | md5 > last-composer-build.md5 - find src -type f \( -name "package.json" \) -exec md5 {} \; | sort -k 2 | md5 > last-package-build.md5 + find src -type f \( -name "package.json" -or -name "package-lock.json" \) -exec md5 {} \; | sort -k 2 | md5 > last-package-build.md5 else find src -type f \( -name "*.js" -or -name "*.vue" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-js-build.md5 find src -type f \( -name "*.scss" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-sass-build.md5 From ecd8a222075c1b33a3297038e783880ea2cfbafc Mon Sep 17 00:00:00 2001 From: weryques Date: Wed, 28 Feb 2018 12:54:46 -0300 Subject: [PATCH 05/19] Update build.js --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 615e8557b..5dfa2c4b4 100755 --- a/build.sh +++ b/build.sh @@ -20,7 +20,7 @@ else find src -type f \( -name "*.js" -or -name "*.vue" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-js-build.md5 find src -type f \( -name "*.scss" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-sass-build.md5 find src -type f \( -name "composer.json" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-composer-build.md5 - find src -type f \( -name "package.json" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-package-build.md5 + find src -type f \( -name "package.json" -or -name "package-lock.json" \) -exec md5sum {} \; | sort -k 2 | md5sum > last-package-build.md5 fi new_md5_package=$( Date: Fri, 23 Feb 2018 09:00:45 -0300 Subject: [PATCH 06/19] remove uselesss registration and duplicated test --- .../field-type/class-tainacan-field-type.php | 7 +------ tests/test-fields.php | 10 +--------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/classes/field-types/field-type/class-tainacan-field-type.php b/src/classes/field-types/field-type/class-tainacan-field-type.php index db822bebd..4dd79e23b 100644 --- a/src/classes/field-types/field-type/class-tainacan-field-type.php +++ b/src/classes/field-types/field-type/class-tainacan-field-type.php @@ -37,12 +37,7 @@ abstract class Field_Type { abstract function render( $itemMetadata ); public function __construct(){ - add_action('register_field_types', array(&$this, 'register_field_type')); - } - - public function register_field_type(){ - global $Tainacan_Fields; - $Tainacan_Fields->register_field_type( $this ); + } public function validate(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) { diff --git a/tests/test-fields.php b/tests/test-fields.php index 3a6f1a0eb..7e3147155 100644 --- a/tests/test-fields.php +++ b/tests/test-fields.php @@ -194,18 +194,10 @@ class Fields extends TAINACAN_UnitTestCase { */ function test_metadata_field_type(){ global $Tainacan_Fields; - $this->assertEquals( 8, sizeof( $Tainacan_Fields->fetch_field_types() ) ); - } - - /** - * test if the defaults types are registered - */ - function test_metadata_field_type_insert(){ - global $Tainacan_Fields; - $class = new RandomType; $this->assertEquals( 9, sizeof( $Tainacan_Fields->fetch_field_types() ) ); } + /** * */ From 0fddaa083396790b2a4451505841dce4950384d1 Mon Sep 17 00:00:00 2001 From: Leo Germani Date: Wed, 28 Feb 2018 12:55:52 -0300 Subject: [PATCH 07/19] Fix tainacan_plugin global js variable and image path --- src/admin/class-tainacan-admin.php | 5 +++-- src/admin/components/primary-menu.vue | 2 +- src/admin/components/secondary-menu.vue | 2 +- src/admin/js/router.js | 2 +- src/admin/js/utilities.js | 2 +- src/dev-interface/class-tainacan-dev-interface.php | 2 +- src/js/axios/axios.js | 4 ++-- src/js/event-bus-web-components.js | 4 ++-- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/admin/class-tainacan-admin.php b/src/admin/class-tainacan-admin.php index 63d2d71da..7293e6abf 100644 --- a/src/admin/class-tainacan-admin.php +++ b/src/admin/class-tainacan-admin.php @@ -89,12 +89,13 @@ class Admin { 'nonce' => wp_create_nonce( 'wp_rest' ), 'components' => $components, 'i18n' => $tainacan_admin_i18n, - 'user_caps' => $user_caps + 'user_caps' => $user_caps, + 'base_url' => $TAINACAN_BASE_URL ]; - wp_localize_script( 'tainacan-user-admin', 'wp_settings', $settings ); + wp_localize_script( 'tainacan-user-admin', 'tainacan_plugin', $settings ); } diff --git a/src/admin/components/primary-menu.vue b/src/admin/components/primary-menu.vue index a32fd1741..71af1cab3 100644 --- a/src/admin/components/primary-menu.vue +++ b/src/admin/components/primary-menu.vue @@ -41,7 +41,7 @@ export default { name: 'PrimaryMenu', data(){ return { - logoHeader: '../wp-content/plugins/tainacan/admin/images/tainacan_logo_header.png', + logoHeader: tainacan_plugin.base_url + '/admin/images/tainacan_logo_header.png', wordpressAdmin: window.location.origin + window.location.pathname.replace('admin.php', ''), isCompressed: false, activeRoute: '/collections' diff --git a/src/admin/components/secondary-menu.vue b/src/admin/components/secondary-menu.vue index 157c3544f..da086e5f9 100644 --- a/src/admin/components/secondary-menu.vue +++ b/src/admin/components/secondary-menu.vue @@ -31,7 +31,7 @@ export default { name: 'SecondaryMenu', data(){ return { - logoHeader: '../wp-content/plugins/tainacan/admin/images/tainacan_logo_header.png', + logoHeader: tainacan_plugin.base_url + '/admin/images/tainacan_logo_header.png', activeRoute: 'ItemsList' } }, diff --git a/src/admin/js/router.js b/src/admin/js/router.js index 80bf7d646..070be1e52 100644 --- a/src/admin/js/router.js +++ b/src/admin/js/router.js @@ -25,7 +25,7 @@ import FieldsList from '../components/fields-list.vue' Vue.use(VueRouter); const i18nGet = function (key) { - let string = wp_settings.i18n[key]; + let string = tainacan_plugin.i18n[key]; return (string != undefined && string != null && string != '' ) ? string : "ERROR: Invalid i18n key!"; } diff --git a/src/admin/js/utilities.js b/src/admin/js/utilities.js index 4de262f7d..9515b8392 100644 --- a/src/admin/js/utilities.js +++ b/src/admin/js/utilities.js @@ -6,7 +6,7 @@ I18NPlugin.install = function (Vue, options = {}) { Vue.prototype.$i18n = { get(key) { - let string = wp_settings.i18n[key]; + let string = tainacan_plugin.i18n[key]; return (string != undefined && string != null && string != '' ) ? string : "ERROR: Invalid i18n key!"; } } diff --git a/src/dev-interface/class-tainacan-dev-interface.php b/src/dev-interface/class-tainacan-dev-interface.php index 7938292ad..66f640bac 100644 --- a/src/dev-interface/class-tainacan-dev-interface.php +++ b/src/dev-interface/class-tainacan-dev-interface.php @@ -40,7 +40,7 @@ class DevInterface { ]; wp_enqueue_script( 'tainacan-dev-admin', $TAINACAN_BASE_URL . '/assets/dev_admin-components.js', [] , null, true); - wp_localize_script( 'tainacan-dev-admin', 'wp_settings', $settings ); + wp_localize_script( 'tainacan-dev-admin', 'tainacan_plugin', $settings ); } function add_admin_css() { diff --git a/src/js/axios/axios.js b/src/js/axios/axios.js index cf81cd146..79517537a 100644 --- a/src/js/axios/axios.js +++ b/src/js/axios/axios.js @@ -1,9 +1,9 @@ import axios from 'axios'; const instance = axios.create({ - baseURL: wp_settings.root + baseURL: tainacan_plugin.root }); -instance.defaults.headers.common['X-WP-Nonce'] = wp_settings.nonce; +instance.defaults.headers.common['X-WP-Nonce'] = tainacan_plugin.nonce; export default instance; \ No newline at end of file diff --git a/src/js/event-bus-web-components.js b/src/js/event-bus-web-components.js index 644fe00b6..50b30d3c5 100644 --- a/src/js/event-bus-web-components.js +++ b/src/js/event-bus-web-components.js @@ -8,8 +8,8 @@ export const eventBus = new Vue({ errors : [] }, created(){ - if( wp_settings.components ){ - this.componentsTag = wp_settings.components; + if( tainacan_plugin.components ){ + this.componentsTag = tainacan_plugin.components; } this.$on('input', data => this.updateValue(data) ); }, From 6c016e44379d00878acbcf387de6968d8fd76837 Mon Sep 17 00:00:00 2001 From: Eduardo humberto Date: Wed, 28 Feb 2018 15:19:12 -0300 Subject: [PATCH 08/19] create query attribute in store filter --- src/classes/filter-types/range/Range.vue | 21 ++++++++++++------- .../range/class-tainacan-range.php | 4 +++- src/js/event-bus-filters.js | 8 ++++--- src/js/store/modules/filter/actions.js | 8 +++---- src/js/store/modules/filter/getters.js | 6 +++--- src/js/store/modules/filter/index.js | 10 ++++----- src/js/store/modules/filter/mutations.js | 14 ++++++------- 7 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/classes/filter-types/range/Range.vue b/src/classes/filter-types/range/Range.vue index 282e6f722..0f6239b14 100644 --- a/src/classes/filter-types/range/Range.vue +++ b/src/classes/filter-types/range/Range.vue @@ -44,8 +44,8 @@ diff --git a/src/admin/scss/_variables.scss b/src/admin/scss/_variables.scss index 01c7de5f8..ddfed2f99 100644 --- a/src/admin/scss/_variables.scss +++ b/src/admin/scss/_variables.scss @@ -8,9 +8,9 @@ $secondary: #1F2F56; $secondary-invert: findColorInvert($primary); $primary-light:#A5CDD7; -$primary-lighter: lighten($primary-light, 4); +$primary-lighter: lighten($primary-light, 10%); $primary-dark: #55A0AF; -$primary-darker: darken($primary-dark, 4); +$primary-darker: darken($primary-dark, 5%); // Setup $colors to use as bulma classes $colors: ( diff --git a/src/js/store/modules/collection/actions.js b/src/js/store/modules/collection/actions.js index 92ae5f7a2..da9c7fde5 100644 --- a/src/js/store/modules/collection/actions.js +++ b/src/js/store/modules/collection/actions.js @@ -55,6 +55,37 @@ export const fetchFields = ({ commit }, id) => { }); } +export const sendField = ( { commit }, { collectionId, name, fieldType, status }) => { + return new Promise(( resolve, reject ) => { + axios.post('/collection/'+ collectionId + '/fields/', { + name: name, + field_type: fieldType, + status: status + }) + .then( res => { + commit('setField', { collection_id: collectionId, name: name, field_type: fieldType, status: status }); + resolve( res.data ); + }) + .catch(error => { + reject( error.response ); + }); + }); +}; + +export const deleteField = ({ commit }, { collectionId, fieldId }) => { + return new Promise((resolve, reject) => { + axios.delete('/collection/' + collectionId + '/fields/' + fieldId) + .then( res => { + commit('deleteField', { fieldId } ); + resolve( res.data ); + }).catch((error) => { + console.log(error); + reject( error ); + }); + + }); +}; + export const fetchCollection = ({ commit }, id) => { return new Promise((resolve, reject) =>{ axios.get('/collections/' + id) diff --git a/src/js/store/modules/collection/mutations.js b/src/js/store/modules/collection/mutations.js index 7bcf3dbfe..f9273028b 100644 --- a/src/js/store/modules/collection/mutations.js +++ b/src/js/store/modules/collection/mutations.js @@ -9,6 +9,13 @@ export const deleteItem = ( state, item ) => { } } +export const deleteField = ( state, field ) => { + let index = state.fields.findIndex(deletedField => deletedField.id === field.id); + if (index >= 0) { + state.fields.splice(index, 1); + } +} + export const deleteCollection = ( state, collection ) => { let index = state.collections.findIndex(deletedCollection => deletedCollection.id === collection.id); if (index >= 0) { @@ -20,6 +27,16 @@ export const setCollections = (state, collections) => { state.collections = collections; } +export const setSingleField = (state, field) => { + let index = state.fields.findIndex(newField => newField.id === field.id); + if ( index >= 0){ + //state.field[index] = field; + Vue.set( state.fields, index, field ); + } else { + state.fields.push( field ); + } +} + export const setFields = (state, fields) => { state.fields = fields; } diff --git a/src/js/store/modules/item/mutations.js b/src/js/store/modules/item/mutations.js index 448a44e9c..b9a8e3fbd 100644 --- a/src/js/store/modules/item/mutations.js +++ b/src/js/store/modules/item/mutations.js @@ -13,7 +13,7 @@ export const setSingleField = ( state, field) => { if ( index >= 0){ //state.field[index] = field; Vue.set( state.fields, index, field ); - }else{ + } else { state.fields.push( field ); } } From c04a0a4a8eff9cadfbc420b76e508b757335cdb0 Mon Sep 17 00:00:00 2001 From: weryques Date: Wed, 28 Feb 2018 15:53:59 -0300 Subject: [PATCH 12/19] Now values of not multiple item metadata are saved as string --- .../class-tainacan-rest-item-metadata-controller.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/endpoints/class-tainacan-rest-item-metadata-controller.php b/src/api/endpoints/class-tainacan-rest-item-metadata-controller.php index 206a8503b..869ddf47e 100644 --- a/src/api/endpoints/class-tainacan-rest-item-metadata-controller.php +++ b/src/api/endpoints/class-tainacan-rest-item-metadata-controller.php @@ -161,7 +161,13 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_REST_Controller { $field = $this->field_repository->fetch( $field_id ); $item_metadata = new Entities\Item_Metadata_Entity( $item, $field ); - $item_metadata->set_value( $value ); + if($item_metadata->is_multiple()) { + $item_metadata->set_value( $value ); + } elseif(is_array($value)) { + $item_metadata->set_value(implode(' ', $value)); + } else{ + $item_metadata->set_value($value); + } if ( $item_metadata->validate() ) { $field_updated = $this->item_metadata_repository->update( $item_metadata ); From a9a907e6627f2441eb5ff7760fdd6258b403de4e Mon Sep 17 00:00:00 2001 From: Eduardo humberto Date: Wed, 28 Feb 2018 15:48:44 -0300 Subject: [PATCH 13/19] add validation for not multiple fields in validate itemMetadata --- .../entities/class-tainacan-item-metadata-entity.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/classes/entities/class-tainacan-item-metadata-entity.php b/src/classes/entities/class-tainacan-item-metadata-entity.php index 760936768..ad2f0fb70 100644 --- a/src/classes/entities/class-tainacan-item-metadata-entity.php +++ b/src/classes/entities/class-tainacan-item-metadata-entity.php @@ -180,6 +180,11 @@ class Item_Metadata_Entity extends Entity { return false; } } else { + + if( is_array($value) ){ + $this->add_error('not_multiple', $field->get_name() . ' do not accept array as value'); + return false; + } if ($this->is_collection_key()) { $Tainacan_Items = new \Tainacan\Repositories\Items(); @@ -198,9 +203,7 @@ class Item_Metadata_Entity extends Entity { return false; } } - - // TODO: call fieldType validation - // + $this->set_as_valid(); return true; } From 59a931b7a9afb4ccf5c0fdc7d18c6fa491c5dd61 Mon Sep 17 00:00:00 2001 From: Eduardo humberto Date: Wed, 28 Feb 2018 15:58:18 -0300 Subject: [PATCH 14/19] unregister Check box field type --- src/classes/tainacan-creator.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/classes/tainacan-creator.php b/src/classes/tainacan-creator.php index fa4ef6c44..24407120e 100644 --- a/src/classes/tainacan-creator.php +++ b/src/classes/tainacan-creator.php @@ -88,7 +88,6 @@ $Tainacan_Fields->register_field_type('Tainacan\Field_Types\Numeric'); $Tainacan_Fields->register_field_type('Tainacan\Field_Types\Selectbox'); $Tainacan_Fields->register_field_type('Tainacan\Field_Types\Relationship'); $Tainacan_Fields->register_field_type('Tainacan\Field_Types\Radio'); -$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Checkbox'); global $Tainacan_Filters; $Tainacan_Filters = new \Tainacan\Repositories\Filters(); From fe2ba5bffdc5f54e36a532609276ac27192ae044 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Wed, 28 Feb 2018 16:29:55 -0300 Subject: [PATCH 15/19] Habemuns Field Type Ordenation via dragndrop. --- .../edition/collection-fields-edition-page.vue | 15 +++++++++++---- src/js/store/modules/collection/actions.js | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/admin/pages/edition/collection-fields-edition-page.vue b/src/admin/pages/edition/collection-fields-edition-page.vue index a4e6db334..8fba1ecda 100644 --- a/src/admin/pages/edition/collection-fields-edition-page.vue +++ b/src/admin/pages/edition/collection-fields-edition-page.vue @@ -44,7 +44,8 @@ export default { 'fetchFieldTypes', 'fetchFields', 'sendField', - 'deleteField' + 'deleteField', + 'updateCollectionFieldsOrder' ]), ...mapGetters('collection',[ 'getFieldTypes', @@ -55,9 +56,15 @@ export default { this.addNewField($event.added.element); } else if ($event.removed) { this.removeField($event.removed.element); - } else if ($event.moved) { - console.log($event.moved.element); - } + } + this.updateFieldsOrder(); + }, + updateFieldsOrder() { + let fieldsOrder = []; + for (let field of this.activeFieldList) { + fieldsOrder.push({'id': field.id, 'enabled': true}); + } + this.updateCollectionFieldsOrder({ collectionId: this.collectionId, fieldsOrder: fieldsOrder }); }, addNewField(newField) { this.sendField({collectionId: this.collectionId, name: newField.name, fieldType: newField.className, status: 'publish'}) diff --git a/src/js/store/modules/collection/actions.js b/src/js/store/modules/collection/actions.js index da9c7fde5..424db6a4b 100644 --- a/src/js/store/modules/collection/actions.js +++ b/src/js/store/modules/collection/actions.js @@ -130,6 +130,20 @@ export const updateCollection = ({ commit }, { collection_id, name, description, }); } +export const updateCollectionFieldsOrder = ({ commit }, { collectionId, fieldsOrder }) => { + return new Promise((resolve, reject) => { + axios.patch('/collections/' + collectionId, { + fields_order: fieldsOrder + }).then( res => { + commit('setCollection', res.data); + resolve( res.data ); + }).catch( error => { + reject( error.response ); + }); + + }); +} + export const sendCollection = ( { commit }, { name, description, status }) => { return new Promise(( resolve, reject ) => { axios.post('/collections/', { From 640f1ffb0129e4c777b4aa91b8ca8f90813e96fc Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Wed, 28 Feb 2018 18:58:22 -0300 Subject: [PATCH 16/19] Prevent index updating before field adition via API on DragNDrop. Adds disabled and loaging states for fields that are being configured. --- src/admin/components/collections-list.vue | 6 +-- .../collection-fields-edition-page.vue | 43 ++++++++++++++----- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/admin/components/collections-list.vue b/src/admin/components/collections-list.vue index 1d4676770..ac330d2ab 100644 --- a/src/admin/components/collections-list.vue +++ b/src/admin/components/collections-list.vue @@ -66,7 +66,7 @@

Nenhuma coleção ainda neste repositório.

+ :to="{ path: $routerHelper.getNewCollectionPath() }"> Criar Coleção @@ -162,10 +162,10 @@ export default { handleSelectionChange(value) { }, goToCollectionPage(collectionId) { - this.$router.push(`/collections/${collectionId}`); + this.$router.push(this.$routerHelper.getCollectionPath(collectionId)); }, goToCollectionEditPage(collectionId) { - this.$router.push(`/collections/${collectionId}/edit`); + this.$router.push(this.$routerHelper.getCollectionEditPath(collectionId)); }, onChangeCollectionsPerPage(value) { this.collectionsPerPage = value; diff --git a/src/admin/pages/edition/collection-fields-edition-page.vue b/src/admin/pages/edition/collection-fields-edition-page.vue index 8fba1ecda..488fcb6b7 100644 --- a/src/admin/pages/edition/collection-fields-edition-page.vue +++ b/src/admin/pages/edition/collection-fields-edition-page.vue @@ -5,9 +5,20 @@
- -
- {{ field.name }} (not configured) + +
+ {{ field.name }} + (not configured) + +
Drag and drop Fields here to add them to Collection.
@@ -52,12 +63,15 @@ export default { 'getFields' ]), handleChange($event) { + if ($event.added) { - this.addNewField($event.added.element); + this.addNewField($event.added.element, $event.added.newIndex); } else if ($event.removed) { this.removeField($event.removed.element); + } else if ($event.moved) { + this.updateFieldsOrder(); } - this.updateFieldsOrder(); + }, updateFieldsOrder() { let fieldsOrder = []; @@ -66,21 +80,24 @@ export default { } this.updateCollectionFieldsOrder({ collectionId: this.collectionId, fieldsOrder: fieldsOrder }); }, - addNewField(newField) { + addNewField(newField, newIndex) { this.sendField({collectionId: this.collectionId, name: newField.name, fieldType: newField.className, status: 'publish'}) - .then((res) => { - + .then((field) => { + this.activeFieldList.splice(newIndex, 1, field); + this.updateFieldsOrder(); }) .catch((error) => { + console.log(error); }); }, removeField(removedField) { this.deleteField({ collectionId: this.collectionId, fieldId: removedField.id }) .then((field) => { - let index = this.activeFieldList.findIndex(deletedItem => deletedItem.id === field.id); + let index = this.activeFieldList.findIndex(deletedField => deletedField.id === field.id); if (index >= 0) { this.activeFieldList.splice(index, 1); } + this.updateFieldsOrder(); }) .catch((error) => { }); @@ -146,17 +163,21 @@ export default { color: gray; } - &.is-loading:after { + .loading-spinner { animation: spinAround 500ms infinite linear; border: 2px solid #dbdbdb; border-radius: 290486px; border-right-color: transparent; border-top-color: transparent; content: ""; - display: block; + display: inline-block; height: 1em; width: 1em; } + + &.not-sortable-item { + color: gray; + } } .active-field-item:hover { box-shadow: 0px 0px 2px #777; From 65ca45c605568fbf1a4addbe4c1519db581e21c8 Mon Sep 17 00:00:00 2001 From: Eduardo humberto Date: Thu, 1 Mar 2018 10:13:22 -0300 Subject: [PATCH 17/19] set items on search --- src/classes/filter-types/range/Range.vue | 8 +++++++- src/js/event-bus-filters.js | 2 +- src/js/store/modules/collection/actions.js | 6 +++++- src/js/store/modules/filter/actions.js | 3 ++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/classes/filter-types/range/Range.vue b/src/classes/filter-types/range/Range.vue index 0f6239b14..a59314c1f 100644 --- a/src/classes/filter-types/range/Range.vue +++ b/src/classes/filter-types/range/Range.vue @@ -89,7 +89,13 @@ let type = '' if( this.type === 'date' ){ - values = [ this.date_init, this.date_end ]; + let date_init = this.date_init.getUTCFullYear() + '-' + + ('00' + (this.date_init.getUTCMonth() + 1)).slice(-2) + '-' + + ('00' + this.date_init.getUTCDate()).slice(-2); + let date_end = this.date_end.getUTCFullYear() + '-' + + ('00' + (this.date_end.getUTCMonth() + 1)).slice(-2) + '-' + + ('00' + this.date_end.getUTCDate()).slice(-2); + values = [ date_init, date_end ]; type = 'DATE'; } else { values = [ this.value_init, this.value_end ]; diff --git a/src/js/event-bus-filters.js b/src/js/event-bus-filters.js index 440b68e07..d3744c94d 100644 --- a/src/js/event-bus-filters.js +++ b/src/js/event-bus-filters.js @@ -17,7 +17,7 @@ export const eventFilterBus = new Vue({ this.$store.dispatch('filter/add_metaquery', data ); const promisse = this.$store.dispatch('filter/search_by_collection', data.collection_id ); promisse.then( response => { - console.log( response ); + }, error => { }); diff --git a/src/js/store/modules/collection/actions.js b/src/js/store/modules/collection/actions.js index 424db6a4b..70fa903c2 100644 --- a/src/js/store/modules/collection/actions.js +++ b/src/js/store/modules/collection/actions.js @@ -175,4 +175,8 @@ export const sendCollection = ( { commit }, { name, description, status }) => { reject(error); }); }); -} \ No newline at end of file +} + +export const setItems = ({ commit }, items ) => { + commit('setItems', items); +}; \ No newline at end of file diff --git a/src/js/store/modules/filter/actions.js b/src/js/store/modules/filter/actions.js index 039be9584..462067b47 100644 --- a/src/js/store/modules/filter/actions.js +++ b/src/js/store/modules/filter/actions.js @@ -1,11 +1,12 @@ import axios from '../../../axios/axios'; import qs from 'qs'; -export const search_by_collection = ({ commit, state, getters }, collectionId) => { +export const search_by_collection = ({ state, dispatch, rootGetters }, collectionId) => { return new Promise((resolve, reject) =>{ axios.get('/collection/' + collectionId + '/items?' + qs.stringify( state.postquery )) .then(res => { resolve( res.data ); + dispatch('collection/setItems', res.data, { root: true } ); }) .catch(error => { reject( error ) From 25983c584ea7f32e7ebb5e24c08c12d071c1f361 Mon Sep 17 00:00:00 2001 From: Leo Germani Date: Thu, 1 Mar 2018 11:46:48 -0300 Subject: [PATCH 18/19] fixes capabilities and post types names inconsistencies --- ...ass-tainacan-rest-collections-controller.php | 6 +++--- src/classes/class-tainacan-capabilities.php | 10 +++++----- .../entities/class-tainacan-collection.php | 2 +- src/classes/entities/class-tainacan-entity.php | 14 ++++++++++++-- src/classes/entities/class-tainacan-filter.php | 2 +- src/classes/entities/class-tainacan-log.php | 2 +- .../entities/class-tainacan-taxonomy.php | 17 +++++++++++++++-- .../repositories/class-tainacan-collections.php | 2 +- .../repositories/class-tainacan-fields.php | 2 +- .../repositories/class-tainacan-filters.php | 2 +- .../repositories/class-tainacan-logs.php | 4 ++-- .../repositories/class-tainacan-repository.php | 2 +- .../repositories/class-tainacan-taxonomies.php | 2 +- src/classes/tainacan-creator.php | 2 ++ 14 files changed, 47 insertions(+), 22 deletions(-) diff --git a/src/api/endpoints/class-tainacan-rest-collections-controller.php b/src/api/endpoints/class-tainacan-rest-collections-controller.php index afd4f1142..3052e38da 100644 --- a/src/api/endpoints/class-tainacan-rest-collections-controller.php +++ b/src/api/endpoints/class-tainacan-rest-collections-controller.php @@ -153,8 +153,8 @@ class TAINACAN_REST_Collections_Controller extends TAINACAN_REST_Controller { * @throws Exception */ public function get_items_permissions_check($request){ - - if ( 'edit' === $request['context'] && ! current_user_can('edit_tainacan-collections') ) { + $dummy = new Entities\Collection(); + if ( 'edit' === $request['context'] && ! current_user_can($dummy->get_capabilities()->edit_posts) ) { return false; } @@ -230,7 +230,7 @@ class TAINACAN_REST_Collections_Controller extends TAINACAN_REST_Controller { * @throws Exception */ public function create_item_permissions_check( $request ) { - return $this->collections_repository->can_edit($this->collection); + return $this->collection->can_edit(); } /** diff --git a/src/classes/class-tainacan-capabilities.php b/src/classes/class-tainacan-capabilities.php index 271e4000e..3b82af85f 100644 --- a/src/classes/class-tainacan-capabilities.php +++ b/src/classes/class-tainacan-capabilities.php @@ -5,7 +5,7 @@ use Tainacan\Repositories\Repository; class Capabilities { protected $defaults = [ - "tainacan-collections"=> [ + "tainacan-collection"=> [ "administrator"=> [ "delete_posts", "delete_private_posts", @@ -93,7 +93,7 @@ class Capabilities { "read" ] ], - "tainacan-filters"=> [ + "tainacan-filter"=> [ "administrator"=> [ "delete_posts", "delete_private_posts", @@ -137,7 +137,7 @@ class Capabilities { "read" ] ], - "tainacan-taxonomies"=> [ + "tainacan-taxonomy"=> [ "administrator"=> [ "delete_posts", "delete_private_posts", @@ -181,7 +181,7 @@ class Capabilities { "read" ] ], - "tainacan-logs"=> [ + "tainacan-log"=> [ "administrator"=> [ "delete_posts", "delete_private_posts", @@ -276,7 +276,7 @@ class Capabilities { */ function __construct() { add_action('init', array(&$this, 'init'), 11); - add_action('tainacan-insert-tainacan-collections', array(&$this, 'new_collection')); + add_action('tainacan-insert-tainacan-collection', array(&$this, 'new_collection')); add_action('tainacan-add-collection-moderators', array(&$this, 'add_moderators'), 10, 2); add_action('tainacan-remove-collection-moderators', array(&$this, 'remove_moderators'), 10, 2); diff --git a/src/classes/entities/class-tainacan-collection.php b/src/classes/entities/class-tainacan-collection.php index f7d1d4503..338b2937e 100644 --- a/src/classes/entities/class-tainacan-collection.php +++ b/src/classes/entities/class-tainacan-collection.php @@ -14,7 +14,7 @@ class Collection extends Entity { * @see \Tainacan\Entities\Entity::post_type * @var string */ - protected static $post_type = 'tainacan-collections'; + protected static $post_type = 'tainacan-collection'; /** * {@inheritDoc} * @see \Tainacan\Entities\Entity::repository diff --git a/src/classes/entities/class-tainacan-entity.php b/src/classes/entities/class-tainacan-entity.php index b7a6b75e2..774468376 100644 --- a/src/classes/entities/class-tainacan-entity.php +++ b/src/classes/entities/class-tainacan-entity.php @@ -27,6 +27,12 @@ class Entity { */ protected static $post_type = false; + /** + * The WordPress capability for the entity post type. Default is to be equal to $post_type + * @var string + */ + protected static $capability_type = false; + /** * Store the WordPress post object * @var \WP_Post @@ -227,6 +233,10 @@ class Entity { return static::$post_type; } + public static function get_capability_type() { + return false !== static::$capability_type ? static::$capability_type : static::$post_type; + } + public function get_status(){ $value = $this->get_mapped_property('status'); if(empty($value)) $value = 'draft'; @@ -345,9 +355,9 @@ class Entity { * @return object Object with all the capabilities as member variables. */ public function get_capabilities() { - $args = [ + $args = [ 'map_meta_cap' => true, - 'capability_type' => self::get_post_type(), + 'capability_type' => self::get_capability_type(), 'capabilities' => array() ]; diff --git a/src/classes/entities/class-tainacan-filter.php b/src/classes/entities/class-tainacan-filter.php index 6f9a3a028..2f91e9831 100644 --- a/src/classes/entities/class-tainacan-filter.php +++ b/src/classes/entities/class-tainacan-filter.php @@ -10,7 +10,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); class Filter extends Entity { use \Tainacan\Traits\Entity_Collection_Relation; - protected static $post_type = 'tainacan-filters'; + protected static $post_type = 'tainacan-filter'; /** * {@inheritDoc} diff --git a/src/classes/entities/class-tainacan-log.php b/src/classes/entities/class-tainacan-log.php index 9390a528b..979a4ceb0 100644 --- a/src/classes/entities/class-tainacan-log.php +++ b/src/classes/entities/class-tainacan-log.php @@ -8,7 +8,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); * Represents entity Log */ class Log extends Entity { - protected static $post_type = 'tainacan-logs'; + protected static $post_type = 'tainacan-log'; /** * {@inheritDoc} * @see \Tainacan\Entities\Entity::repository diff --git a/src/classes/entities/class-tainacan-taxonomy.php b/src/classes/entities/class-tainacan-taxonomy.php index 48be4a9d0..32fab377e 100644 --- a/src/classes/entities/class-tainacan-taxonomy.php +++ b/src/classes/entities/class-tainacan-taxonomy.php @@ -9,8 +9,21 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); */ class Taxonomy extends Entity { use \Tainacan\Traits\Entity_Collections_Relation; - - protected static $post_type = 'tainacan-taxonomies'; + + /** + * {@inheritDoc} + * @see \Tainacan\Entities\Entity::post_type + * @var string + */ + protected static $post_type = 'tainacan-taxonomy'; + + /** + * {@inheritDoc} + * @see \Tainacan\Entities\Entity::capability_type + * @var string + */ + protected static $capability_type = ['tainacan-taxonomy', 'tainacan-taxonomies']; + /** * {@inheritDoc} * @see \Tainacan\Entities\Entity::repository diff --git a/src/classes/repositories/class-tainacan-collections.php b/src/classes/repositories/class-tainacan-collections.php index 5fa709c98..4d35f0793 100644 --- a/src/classes/repositories/class-tainacan-collections.php +++ b/src/classes/repositories/class-tainacan-collections.php @@ -208,7 +208,7 @@ class Collections extends Repository { 'query_var' => true, 'can_export' => true, 'rewrite' => true, - 'capability_type' => 'tainacan-collection', // hardcode because post_type is in plural + 'capability_type' => Entities\Collection::get_capability_type(), 'map_meta_cap' => true, 'supports' => [ 'title', diff --git a/src/classes/repositories/class-tainacan-fields.php b/src/classes/repositories/class-tainacan-fields.php index 680fcb8c0..d4b31bd70 100644 --- a/src/classes/repositories/class-tainacan-fields.php +++ b/src/classes/repositories/class-tainacan-fields.php @@ -206,7 +206,7 @@ class Fields extends Repository { 'can_export' => true, 'rewrite' => true, 'map_meta_cap' => true, - 'capability_type' => Entities\Field::get_post_type(), + 'capability_type' => Entities\Field::get_capability_type(), 'supports' => [ 'title', 'editor', diff --git a/src/classes/repositories/class-tainacan-filters.php b/src/classes/repositories/class-tainacan-filters.php index 5428a004f..60594c3c9 100644 --- a/src/classes/repositories/class-tainacan-filters.php +++ b/src/classes/repositories/class-tainacan-filters.php @@ -106,7 +106,7 @@ class Filters extends Repository { 'can_export' => true, 'rewrite' => true, 'map_meta_cap' => true, - 'capability_type' => Entities\Field::get_post_type(), + 'capability_type' => Entities\Field::get_capability_type(), 'supports' => [ 'title', 'editor', diff --git a/src/classes/repositories/class-tainacan-logs.php b/src/classes/repositories/class-tainacan-logs.php index 3ea603c04..31aae2e04 100644 --- a/src/classes/repositories/class-tainacan-logs.php +++ b/src/classes/repositories/class-tainacan-logs.php @@ -132,7 +132,7 @@ class Logs extends Repository { 'can_export' => true, 'rewrite' => true, 'map_meta_cap' => true, - 'capability_type' => Entities\Log::get_post_type(), + 'capability_type' => Entities\Log::get_capability_type(), 'supports' => [ 'title', 'editor', @@ -202,7 +202,7 @@ class Logs extends Repository { $msn = ""; if(is_object($new_value)) { // do not log a log - if(method_exists($new_value, 'get_post_type') && $new_value->get_post_type() == 'tainacan-logs'){ + if(method_exists($new_value, 'get_post_type') && $new_value->get_post_type() == 'tainacan-log'){ return; } diff --git a/src/classes/repositories/class-tainacan-repository.php b/src/classes/repositories/class-tainacan-repository.php index eea697ad7..939b519f7 100644 --- a/src/classes/repositories/class-tainacan-repository.php +++ b/src/classes/repositories/class-tainacan-repository.php @@ -370,7 +370,7 @@ abstract class Repository { public static function get_entity_by_post_type($post_type, $post = 0) { $prefix = substr($post_type, 0, strlen(Entities\Collection::$db_identifier_prefix)); - // its is a collection Item? + // Is it a collection Item? if($prefix == Entities\Collection::$db_identifier_prefix) { $cpts = self::get_collections_db_identifier(); if(array_key_exists($post_type, $cpts)) { diff --git a/src/classes/repositories/class-tainacan-taxonomies.php b/src/classes/repositories/class-tainacan-taxonomies.php index f888e48e1..8a77db2d0 100644 --- a/src/classes/repositories/class-tainacan-taxonomies.php +++ b/src/classes/repositories/class-tainacan-taxonomies.php @@ -90,7 +90,7 @@ class Taxonomies extends Repository { 'can_export' => true, 'rewrite' => true, 'map_meta_cap' => true, - 'capability_type' => Entities\Taxonomy::get_post_type(), + 'capability_type' => Entities\Taxonomy::get_capability_type(), 'supports' => [ 'title', 'editor', diff --git a/src/classes/tainacan-creator.php b/src/classes/tainacan-creator.php index 24407120e..d09b88ee3 100644 --- a/src/classes/tainacan-creator.php +++ b/src/classes/tainacan-creator.php @@ -81,6 +81,8 @@ global $Tainacan_Fields; $Tainacan_Fields = new \Tainacan\Repositories\Fields(); //register field types +$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Core_Title'); +$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Core_Description'); $Tainacan_Fields->register_field_type('Tainacan\Field_Types\Text'); $Tainacan_Fields->register_field_type('Tainacan\Field_Types\Textarea'); $Tainacan_Fields->register_field_type('Tainacan\Field_Types\Date'); From 5ff49133fe30f9c775a97e4b34597f6130dd2ad3 Mon Sep 17 00:00:00 2001 From: Eduardo humberto Date: Thu, 1 Mar 2018 12:30:17 -0300 Subject: [PATCH 19/19] creating selectbox filter --- .../filter-types/selectbox/Selectbox.vue | 112 ++++++++++++++++++ .../selectbox/class-tainacan-selectbox.php | 4 +- src/js/main.js | 4 + 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 src/classes/filter-types/selectbox/Selectbox.vue diff --git a/src/classes/filter-types/selectbox/Selectbox.vue b/src/classes/filter-types/selectbox/Selectbox.vue new file mode 100644 index 000000000..98945c1d6 --- /dev/null +++ b/src/classes/filter-types/selectbox/Selectbox.vue @@ -0,0 +1,112 @@ + + + \ No newline at end of file diff --git a/src/classes/filter-types/selectbox/class-tainacan-selectbox.php b/src/classes/filter-types/selectbox/class-tainacan-selectbox.php index 0cb00a785..4fd43908f 100644 --- a/src/classes/filter-types/selectbox/class-tainacan-selectbox.php +++ b/src/classes/filter-types/selectbox/class-tainacan-selectbox.php @@ -19,6 +19,8 @@ class Selectbox extends Filter_Type { */ public function render( $filter ){ - return ''; + return ''; } } \ No newline at end of file diff --git a/src/js/main.js b/src/js/main.js index 7d3ad365d..a1ec44217 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -21,6 +21,7 @@ import Date from '../classes/field-types/date/Date.vue'; import Relationship from '../classes/field-types/relationship/Relationship.vue'; import FilterRange from '../classes/filter-types/range/Range.vue'; +import FilterSelectbox from '../classes/filter-types/selectbox/Selectbox.vue'; Vue.customElement('tainacan-text', Text); eventBus.registerComponent( 'tainacan-text' ); @@ -53,4 +54,7 @@ eventBus.listener(); Vue.customElement('tainacan-filter-range', FilterRange); eventFilterBus.registerComponent( 'tainacan-filter-range' ); +Vue.customElement('tainacan-filter-selectbox', FilterSelectbox); +eventFilterBus.registerComponent( 'tainacan-filter-selectbox' ); + eventFilterBus.listener();