remove form method from field types
This commit is contained in:
parent
897625e1c3
commit
960596aa82
|
@ -37,46 +37,6 @@ class Category extends Field_Type {
|
|||
value=\''.json_encode( $itemMetadata->get_value() ).'\'
|
||||
name="'.$itemMetadata->get_field()->get_name().'"></tainacan-selectbox>';
|
||||
}
|
||||
|
||||
/**
|
||||
* generate the fields for this field type
|
||||
*/
|
||||
public function form(){
|
||||
global $Tainacan_Taxonomies;
|
||||
$taxonomies = $Tainacan_Taxonomies->fetch([], 'OBJECT')
|
||||
|
||||
// TODO: form incomplete and not tested
|
||||
|
||||
?>
|
||||
<div class="field">
|
||||
<label class="label">
|
||||
<?php _e('Category','tainacan'); ?>
|
||||
</label>
|
||||
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
<select name="field_type_options[taxonomy_id]">
|
||||
<?php foreach ($taxonomies as $tax): ?>
|
||||
|
||||
<option value="<?php echo $tax->get_db_identifier(); ?>" <?php selected($this->get_option('taxonomy_id'), $tax->get_db_identifier()); ?> ><?php echo $tax->get_name(); ?></option>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="field_type_options[allow_new_terms]" <?php checked(true, $this->get_option('allow_new_terms')); ?> >
|
||||
Allow
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public function validate_options(\Tainacan\Entities\Field $field) {
|
||||
|
||||
|
|
|
@ -29,21 +29,4 @@ class Checkbox extends Field_Type {
|
|||
value=\''.json_encode( $itemMetadata->get_value() ).'\'
|
||||
name="'.$itemMetadata->get_field()->get_name().'"></tainacan-checkbox>';
|
||||
}
|
||||
|
||||
/**
|
||||
* generate the fields for this field type
|
||||
*/
|
||||
public function form(){
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<label><?php echo __('Options','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('Insert the options, separate by lines for the field value','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="field_type_options[options]"><?php echo $this->get_option('options'); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
|
@ -8,13 +8,22 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
created(){
|
||||
if( this.field && this.field.value ){
|
||||
this.inputValue = this.field.value
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dateValue: new Date()
|
||||
}
|
||||
},
|
||||
props: {
|
||||
id: ''
|
||||
id: '',
|
||||
field: {
|
||||
type: Object
|
||||
},
|
||||
value: [String, Number, Array],
|
||||
},
|
||||
methods: {
|
||||
onBlur() {
|
||||
|
|
|
@ -28,22 +28,4 @@ class Date extends Field_Type {
|
|||
value=\''.json_encode( $itemMetadata->get_value() ).'\'
|
||||
name="'.$itemMetadata->get_field()->get_name().'"></tainacan-date>';
|
||||
}
|
||||
|
||||
/**
|
||||
* generate the fields for this field type
|
||||
*/
|
||||
public function form(){
|
||||
$approx_date = $this->get_option('approximate_date');
|
||||
?>
|
||||
<!--tr>
|
||||
<td>
|
||||
<label><?php echo __('Approximate Date','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('Allow format approximate date','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<?php Helpers\HtmlHelpers::radio_field( $approx_date, 'field_type_options[approximate_date]' ) ?>
|
||||
</td>
|
||||
</tr-->
|
||||
<?php
|
||||
}
|
||||
}
|
|
@ -10,13 +10,22 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
created(){
|
||||
if( this.field && this.field.value ){
|
||||
this.inputValue = this.field.value
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
inputValue: ''
|
||||
}
|
||||
},
|
||||
props: {
|
||||
id: ''
|
||||
id: '',
|
||||
field: {
|
||||
type: Object
|
||||
},
|
||||
value: [String, Number, Array],
|
||||
},
|
||||
methods: {
|
||||
onBlur() {
|
||||
|
|
|
@ -28,11 +28,4 @@ class Numeric extends Field_Type {
|
|||
value=\''.json_encode( $itemMetadata->get_value() ).'\'
|
||||
name="'.$itemMetadata->get_field()->get_name().'"></tainacan-numeric>';
|
||||
}
|
||||
|
||||
/**
|
||||
* generate the fields for this field type
|
||||
*/
|
||||
public function form(){
|
||||
|
||||
}
|
||||
}
|
|
@ -16,17 +16,32 @@
|
|||
autocomplete
|
||||
:loading="loading"
|
||||
field="label"
|
||||
@input="onChecked()"
|
||||
@typing="search">
|
||||
</b-taginput>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import debounce from 'lodash/debounce'
|
||||
import { tainacan as axios} from '../../../js/axios/axios'
|
||||
import { tainacan as axios } from '../../../js/axios/axios'
|
||||
import qs from 'qs';
|
||||
|
||||
export default {
|
||||
created(){
|
||||
if( this.field.value ){
|
||||
let collectionId = ( this.field && this.field.field.field_type_options.collection_id ) ? this.field.field.field_type_options.collection_id : this.collection_id;
|
||||
let query = qs.stringify({ postin: ( Array.isArray( this.field.value ) ) ? this.field.value : [ this.field.value ] });
|
||||
|
||||
axios.get('/collection/'+collectionId+'/items?' + query)
|
||||
.then( res => {
|
||||
for (let item of res.data) {
|
||||
this.selected.push({ label: item.title, value: item.id, img: '' });
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
results:'',
|
||||
|
@ -46,21 +61,27 @@
|
|||
},
|
||||
id: ''
|
||||
},
|
||||
watch: {
|
||||
selected( value ){
|
||||
this.selected = value;
|
||||
let values = [];
|
||||
if( this.selected.length > 0 ){
|
||||
for(let val of this.selected){
|
||||
values.push( val.value );
|
||||
}
|
||||
}
|
||||
this.onInput( values );
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setResults(option){
|
||||
if(!option)
|
||||
return;
|
||||
this.results = option.value;
|
||||
this.onChecked()
|
||||
},
|
||||
onChecked() {
|
||||
onInput( $event ) {
|
||||
this.$emit('input', $event);
|
||||
this.$emit('blur');
|
||||
this.onInput(this.selected)
|
||||
},
|
||||
onInput($event) {
|
||||
this.inputValue = $event;
|
||||
console.log( this.inputValue, 'log' );
|
||||
this.$emit('input', this.inputValue);
|
||||
},
|
||||
search(query){
|
||||
if (query !== '') {
|
||||
|
|
|
@ -32,81 +32,6 @@ class Relationship extends Field_Type {
|
|||
value=\''.json_encode( $itemMetadata->get_value() ).'\'
|
||||
name="'.$itemMetadata->get_field()->get_name().'"></tainacan-relationship>';
|
||||
}
|
||||
|
||||
public function form(){
|
||||
?>
|
||||
<tainacan-form-relationship
|
||||
collection_id="<?php echo ( $this->options['collection_id'] ) ? $this->options['collection_id'] : '' ?>"
|
||||
repeated="<?php echo ( $this->options['repeated'] ) ? $this->options['repeated'] : 'yes' ?>"
|
||||
search='<?php echo ( $this->options['search'] ) ? json_encode($this->options['search']) : '' ?>'
|
||||
></tainacan-form-relationship>
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* generate the fields for this field type
|
||||
*/
|
||||
public function form_raw(){
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<label><?php echo __('Collection related','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('Select the collection to fetch items','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<?php Helpers\HtmlHelpers::collections_dropdown( $this->options['collection_id'], 'field_type_relationship[collection_id]' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if( $this->options['collection_id'] ): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<label><?php echo __('Field for search','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('Selected field to help in the search','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<?php Helpers\HtmlHelpers::metadata_checkbox_list(
|
||||
$this->options['collection_id'],
|
||||
( isset( $this->options['search'] ) ) ? $this->options['search'] : '',
|
||||
'field_type_relationship[search][]'
|
||||
) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<td>
|
||||
<label><?php echo __('Allow repeated items','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('Allow/Block selected items in this relationship','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<?php Helpers\HtmlHelpers::radio_field( ( isset( $this->options['repeated'] ) ) ? $this->options['repeated'] : 'yes', 'field_type_relationship[repeated]' ) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if( isset( $this->options['collection_id'] ) ): ?>
|
||||
<?php
|
||||
|
||||
//filter only related field
|
||||
$args = array( 'meta_query' => array ( array(
|
||||
'key' => 'field_type',
|
||||
'value' => 'Tainacan\Field_Types\Relationship',
|
||||
) ) );
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<label><?php echo __('Inverse','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('Select the relationship inverse for this field','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<?php Helpers\HtmlHelpers::metadata_dropdown(
|
||||
$this->options['collection_id'],
|
||||
( isset( $this->options['inverse'] ) ) ? $this->options['inverse'] : '',
|
||||
'field_type_relationship[inverse]',
|
||||
$args
|
||||
) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function validate_options(\Tainacan\Entities\Field $field) {
|
||||
if ( !in_array($field->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
<script>
|
||||
|
||||
export default {
|
||||
created(){
|
||||
if( this.field && this.field.value ){
|
||||
this.selected = this.field.value
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
selected:''
|
||||
|
|
|
@ -32,23 +32,6 @@ class Selectbox extends Field_Type {
|
|||
name="'.$itemMetadata->get_field()->get_name().'"></tainacan-selectbox>';
|
||||
}
|
||||
|
||||
/**
|
||||
* generate the fields for this field type
|
||||
*/
|
||||
public function form(){
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<label><?php echo __('Options','tainacan'); ?></label><br/>
|
||||
<small><?php echo __('Insert the options, separate by lines for the field value','tainacan'); ?></small>
|
||||
</td>
|
||||
<td>
|
||||
<textarea name="field_type_options[options]"><?php echo $this->get_option('options'); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Tainacan\Entities\Field $field
|
||||
* @return array|bool true if is validate or array if has error
|
||||
|
|
|
@ -8,13 +8,21 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
created(){
|
||||
if( this.field && this.field.value ){
|
||||
this.inputValue = this.field.value
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
inputValue: '',
|
||||
}
|
||||
},
|
||||
props: {
|
||||
value: [String, Number, Object],
|
||||
field: {
|
||||
type: Object
|
||||
},
|
||||
value: [String, Number, Array],
|
||||
id: ''
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -27,11 +27,4 @@ class Text extends Field_Type {
|
|||
value=\''.json_encode( $itemMetadata->get_value() ).'\'
|
||||
name="'.$itemMetadata->get_field()->get_name().'"></tainacan-text>';
|
||||
}
|
||||
|
||||
/**
|
||||
* generate the fields for this field type
|
||||
*/
|
||||
public function form(){
|
||||
|
||||
}
|
||||
}
|
|
@ -9,6 +9,11 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
created(){
|
||||
if( this.field && this.field.value ){
|
||||
this.inputValue = this.field.value
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
inputValue: ''
|
||||
|
@ -16,7 +21,10 @@
|
|||
},
|
||||
props: {
|
||||
id: '',
|
||||
value: [String, Number, Object]
|
||||
field: {
|
||||
type: Object
|
||||
},
|
||||
value: [String, Number, Array],
|
||||
},
|
||||
methods: {
|
||||
onBlur() {
|
||||
|
|
|
@ -28,11 +28,4 @@ class Textarea extends Field_Type {
|
|||
value=\''.json_encode( $itemMetadata->get_value() ).'\'
|
||||
name="'.$itemMetadata->get_field()->get_name().'"></tainacan-textarea>';
|
||||
}
|
||||
|
||||
/**
|
||||
* generate the fields for this field type
|
||||
*/
|
||||
public function form(){
|
||||
|
||||
}
|
||||
}
|
|
@ -363,9 +363,9 @@ class Fields extends Repository {
|
|||
if( $index !== false ) {
|
||||
|
||||
// skipping fields disabled if the arg is set
|
||||
if( !$include_disabled && !$order[$index]['enable'] ) {
|
||||
if( !$include_disabled && isset( $order[$index]['enable'] ) && !$order[$index]['enable'] ) {
|
||||
continue;
|
||||
} elseif ($include_disabled && !$order[$index]['enable']) {
|
||||
} elseif ($include_disabled && isset( $order[$index]['enable'] ) && !$order[$index]['enable']) {
|
||||
$item->set_disabled_for_collection(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,9 @@ export const eventBus = new Vue({
|
|||
},
|
||||
updateValue(data){
|
||||
if ( data.item_id ){
|
||||
let values = ( Array.isArray( data.values[0] ) ) ? data.values[0] : data.values ;
|
||||
const promisse = this.$store.dispatch('item/updateMetadata',
|
||||
{ item_id: data.item_id, field_id: data.field_id, values: data.values });
|
||||
{ item_id: data.item_id, field_id: data.field_id, values: values });
|
||||
promisse.then( response => {
|
||||
let index = this.errors.findIndex( errorItem => errorItem.field_id === data.field_id );
|
||||
if ( index >= 0){
|
||||
|
|
Loading…
Reference in New Issue