From ca9f83e23cfa44ba23c40c8f843d089ab5e5824a Mon Sep 17 00:00:00 2001 From: Eduardo humberto Date: Thu, 22 Mar 2018 14:21:14 -0300 Subject: [PATCH] add helper message in field type options --- src/admin/class-tainacan-admin.php | 6 ++++++ .../field-types/category/FormCategory.vue | 15 +++++++++++--- .../category/class-tainacan-category.php | 20 +++++++++++++++++++ .../field-type/class-tainacan-field-type.php | 6 ++++++ .../relationship/FormRelationship.vue | 15 +++++++++++--- .../class-tainacan-relationship.php | 20 +++++++++++++++++++ .../field-types/selectbox/FormSelectbox.vue | 7 +++++-- .../selectbox/class-tainacan-selectbox.php | 11 ++++++++++ 8 files changed, 92 insertions(+), 8 deletions(-) diff --git a/src/admin/class-tainacan-admin.php b/src/admin/class-tainacan-admin.php index 5d96e94aa..be0c8340c 100644 --- a/src/admin/class-tainacan-admin.php +++ b/src/admin/class-tainacan-admin.php @@ -161,11 +161,17 @@ class Admin { 'taxonomies' => $Tainacan_Taxonomies->get_map(), ]; + $field_types = $Tainacan_Fields->fetch_field_types(); + foreach( $maps as $type => $map ){ foreach ( $map as $field => $details){ $settings['i18n']['helpers_label'][$type][$field] = [ 'title' => $details['title'], 'description' => $details['description'] ]; } } + foreach ( $field_types as $index => $field_type){ + $class = new $field_type; + $settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels(); + } wp_localize_script( 'tainacan-user-admin', 'tainacan_plugin', $settings ); diff --git a/src/classes/field-types/category/FormCategory.vue b/src/classes/field-types/category/FormCategory.vue index 757d962fa..76cd8e8af 100644 --- a/src/classes/field-types/category/FormCategory.vue +++ b/src/classes/field-types/category/FormCategory.vue @@ -8,7 +8,10 @@ >
set_component('tainacan-category'); } + /** + * @inheritdoc + */ + public function get_form_labels(){ + return [ + 'taxonomy_id' => [ + 'title' => __( 'Collection Related', 'tainacan' ), + 'description' => __( 'Select the collection to fetch items', 'tainacan' ), + ], + 'input_type' => [ + 'title' => __( 'Input type', 'tainacan' ), + 'description' => __( 'The html type of the terms list ', 'tainacan' ), + ], + 'allow_new_terms' => [ + 'title' => __( 'Allow new terms', 'tainacan' ), + 'description' => __( 'Allow create new terms', 'tainacan' ), + ] + ]; + } + /** * @param $itemMetadata \Tainacan\Entities\Item_Metadata_Entity The instace of the entity itemMetadata * @return string 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 c6c14ddaf..73e2abecf 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 @@ -147,6 +147,12 @@ abstract class Field_Type { return isset($options[$key]) ? $options[$key] : ''; } + /** + * allow i18n from messages + */ + public function get_form_labels(){ + return []; + } /** * generate the fields for this field type */ diff --git a/src/classes/field-types/relationship/FormRelationship.vue b/src/classes/field-types/relationship/FormRelationship.vue index 4f515ce9b..cab58fbb9 100644 --- a/src/classes/field-types/relationship/FormRelationship.vue +++ b/src/classes/field-types/relationship/FormRelationship.vue @@ -7,7 +7,10 @@ :message="collectionMessage">
set_form_component('tainacan-form-relationship'); } + /** + * @inheritdoc + */ + public function get_form_labels(){ + return [ + 'collection_id' => [ + 'title' => __( 'Collection Related', 'tainacan' ), + 'description' => __( 'Select the collection to fetch items', 'tainacan' ), + ], + 'search' => [ + 'title' => __( 'Fields for search', 'tainacan' ), + 'description' => __( 'Select the fields to help the search', 'tainacan' ), + ], + 'repeated' => [ + 'title' =>__( 'Allow repeated items', 'tainacan' ), + 'description' => __( 'Allow different items with the same item selected', 'tainacan' ), + ] + ]; + } + /** * @param $itemMetadata \Tainacan\Entities\Item_Metadata_Entity The instace of the entity itemMetadata * @return string diff --git a/src/classes/field-types/selectbox/FormSelectbox.vue b/src/classes/field-types/selectbox/FormSelectbox.vue index 20d3bf4b2..25355c4da 100644 --- a/src/classes/field-types/selectbox/FormSelectbox.vue +++ b/src/classes/field-types/selectbox/FormSelectbox.vue @@ -6,8 +6,11 @@ :message="optionMessage" > set_form_component('tainacan-form-selectbox'); } + /** + * @inheritdoc + */ + public function get_form_labels(){ + return [ + 'options' => [ + 'title' => __( 'Options', 'tainacan' ), + 'description' => __( 'Create the options for the select, hit enter to add new one', 'tainacan' ), + ] + ]; + } /** * @param $itemMetadata \Tainacan\Entities\Item_Metadata_Entity The instace of the entity itemMetadata * @return string