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(); 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 // Getters
/** /**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -44,20 +44,20 @@
}); });
this.labels = []; this.labels = [];
for( let term of result){ 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(){ selectedValues(){
if( this.value && this.value.length > 0 && this.selected.length === 0){ if( this.value && this.value.length > 0 && this.selected.length === 0){
let result = this.terms.filter( ( item ) => { let result = this.terms.filter( ( item ) => {
let id = item.term_id; let id = item.id;
return ( this.value.indexOf( id ) >= 0 ) return ( this.value.indexOf( id ) >= 0 )
}); });
let selected = []; let selected = [];
for( let term of result){ 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; this.selected = selected;
} }

View File

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