add helper message in field type options

This commit is contained in:
Eduardo humberto 2018-03-22 14:21:14 -03:00
parent 8012aae0fc
commit ca9f83e23c
8 changed files with 92 additions and 8 deletions

View File

@ -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 );

View File

@ -8,7 +8,10 @@
>
<label class="label">
{{ $i18n.get('label_select_category') }}<span :class="taxonomyType" >&nbsp;*&nbsp;</span>
<a class="help-button"><b-icon size="is-small" icon="help-circle-outline"></b-icon></a>
<help-button
:title="$i18n.getHelperTitle('tainacan-category', 'taxonomy_id')"
:message="$i18n.getHelperMessage('tainacan-category', 'taxonomy_id')">
</help-button>
</label>
<b-select
name="field_type_options[taxonomy_id]"
@ -30,7 +33,10 @@
<b-field :addons="false">
<label class="label">
{{ $i18n.get('label_select_category_input_type') }}
<a class="help-button"><b-icon size="is-small" icon="help-circle-outline"></b-icon></a>
<help-button
:title="$i18n.getHelperTitle('tainacan-category', 'input_type')"
:message="$i18n.getHelperMessage('tainacan-category', 'input_type')">
</help-button>
</label>
<b-select
v-if="listInputType"
@ -66,7 +72,10 @@
<b-field :addons="false">
<label class="label">
{{ $i18n.get('label_category_allow_new_terms') }}
<a class="help-button"><b-icon size="is-small" icon="help-circle-outline"></b-icon></a>
<help-button
:title="$i18n.getHelperTitle('tainacan-category', 'allow_new_terms')"
:message="$i18n.getHelperMessage('tainacan-category', 'allow_new_terms')">
</help-button>
</label>
<div class="block">
<b-checkbox v-model="allow_new_terms"

View File

@ -23,6 +23,26 @@ class Category extends Field_Type {
$this->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

View File

@ -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
*/

View File

@ -7,7 +7,10 @@
:message="collectionMessage">
<label class="label">
{{ $i18n.get('label_collection_related') }}<span :class="collectionType" >&nbsp;*&nbsp;</span>
<a class="help-button"><b-icon size="is-small" icon="help-circle-outline"></b-icon></a>
<help-button
:title="$i18n.getHelperTitle('tainacan-relationship', 'collection_id')"
:message="$i18n.getHelperMessage('tainacan-relationship', 'collection_id')">
</help-button>
</label>
<b-select
name="field_type_relationship[collection_id]"
@ -35,7 +38,10 @@
:addons="false">
<label class="label">
{{ $i18n.get('label_fields_for_search') }}
<a class="help-button"><b-icon size="is-small" icon="help-circle-outline"></b-icon></a>
<help-button
:title="$i18n.getHelperTitle('tainacan-relationship', 'search')"
:message="$i18n.getHelperMessage('tainacan-relationship', 'search')">
</help-button>
</label>
<div class="block">
<div
@ -57,7 +63,10 @@
<b-field :addons="false">
<label class="label">
{{ $i18n.get('label_allow_repeated_items') }}
<a class="help-button"><b-icon size="is-small" icon="help-circle-outline"></b-icon></a>
<help-button
:title="$i18n.getHelperTitle('tainacan-relationship', 'repeated')"
:message="$i18n.getHelperMessage('tainacan-relationship', 'repeated')">
</help-button>
</label>
<div class="block">
<b-checkbox v-model="modelRepeated"

View File

@ -19,6 +19,26 @@ class Relationship extends Field_Type {
$this->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

View File

@ -6,8 +6,11 @@
:message="optionMessage"
>
<label class="label">
{{ $i18n.get('lavel_insert_options') }}<span :class="optionType" >&nbsp;*&nbsp;</span>
<a class="help-button"><b-icon size="is-small" icon="help-circle-outline"></b-icon></a>
{{ $i18n.getHelperTitle('tainacan-selectbox', 'options') }}<span :class="optionType" >&nbsp;*&nbsp;</span>
<help-button
:title="$i18n.getHelperTitle('tainacan-selectbox', 'options')"
:message="$i18n.getHelperMessage('tainacan-selectbox', 'options')">
</help-button>
</label>
<b-taginput
v-model="options"

View File

@ -17,6 +17,17 @@ class Selectbox extends Field_Type {
$this->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