Changes term_id to id

This commit is contained in:
weryques 2018-03-27 09:33:47 -03:00
parent 7e07f4f611
commit 8df43d504b
8 changed files with 30 additions and 17 deletions

View File

@ -45,6 +45,19 @@ class Term extends Entity {
return 'Hello, my name is '. $this->get_name();
}
public function __toArray(){
$term_array = parent::__toArray();
$term_id = $term_array['term_id'];
unset($term_array['term_id']);
unset($term_array['status']);
$term_array['id'] = $term_id;
return $term_array;
}
// Getters
/**

View File

@ -28,7 +28,7 @@
<option
v-for="(option,index) in options"
:key="index"
:value="option.term_id"
:value="option.id"
v-html="setSpaces( option.level ) + option.name"/>
</b-select>
</b-field>
@ -94,19 +94,19 @@
instance.name = '';
instance.parent = 0;
if( res.data && res.data.term_id || res.term_id ){
let term_id = ( res.term_id ) ? res.term_id : res.data.term_id;
if( res.data && res.data.id || res.id ){
let id = ( res.id ) ? res.id : res.data.id;
let val = this.value;
if( !Array.isArray( val ) && this.field.field.multiple === 'no' ){
axios.patch(`/item/${this.item_id}/metadata/${this.field_id}`, {
values: term_id,
values: id,
}).then(() => {
instance.$emit('newTerm', term_id);
instance.$emit('newTerm', id);
})
} else {
val = ( val ) ? val : [];
val.push( term_id );
val.push( id );
axios.patch(`/item/${this.item_id}/metadata/${this.field_id}`, {
values: val,
}).then( () => {

View File

@ -99,7 +99,7 @@
term['level'] = level;
result.push( term );
const levelTerm = level + 1;
const children = this.getOptions( term.term_id, levelTerm);
const children = this.getOptions( term.id, levelTerm);
result = result.concat( children );
}
}
@ -110,8 +110,8 @@
let values = [];
if( this.value && this.value.length > 0){
for( let term of this.value ){
if( term && term.term_id)
values.push(term.term_id);
if( term && term.id)
values.push(term.id);
}
}

View File

@ -9,7 +9,7 @@
:key="index"
v-model="checked"
@input="onChecked(option)"
:native-value="option.term_id"
:native-value="option.id"
border>
{{ option.name }}
</b-checkbox>

View File

@ -9,7 +9,7 @@
:key="index"
v-model="checked"
@input="onChecked(option)"
:native-value="option.term_id"
:native-value="option.id"
border>
{{ option.name }}
</b-radio>

View File

@ -10,7 +10,7 @@
<option
v-for="(option, index) in options"
:key="index"
:value="option.term_id"
:value="option.id"
v-html="setSpaces( option.level ) + option.name"/>
</b-select>
</div>

View File

@ -44,20 +44,20 @@
});
this.labels = [];
for( let term of result){
this.labels.push({label: term.name, value: term.term_id})
this.labels.push({label: term.name, value: term.id})
}
}
},
selectedValues(){
if( this.value && this.value.length > 0 && this.selected.length === 0){
let result = this.terms.filter( ( item ) => {
let id = item.term_id;
let id = item.id;
return ( this.value.indexOf( id ) >= 0 )
});
let selected = [];
for( let term of result){
selected.push({label: term.name, value: term.term_id})
selected.push({label: term.name, value: term.id})
}
this.selected = selected;
}

View File

@ -792,8 +792,8 @@ msgstr ""
#: api/class-tainacan-rest-controller.php:501
msgid ""
"Select taxonomy term by. Possible values are term_id, name, slug or "
"term_taxonomy_id. Default value is term_id."
"Select taxonomy term by. Possible values are id, name, slug or "
"term_taxonomy_id. Default value is id."
msgstr ""
#: api/class-tainacan-rest-controller.php:505