Skip to content

Commit

Permalink
fix select component label
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Dec 6, 2023
1 parent 20035ef commit 79472ac
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 18 deletions.
73 changes: 55 additions & 18 deletions resources/js/components/TomatoSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
:hide-selected="true"
:show-no-results="false"
:internal-search="false"
selectLabel=""
:disabled="disabled"
>
<template #afterList>
Expand All @@ -65,6 +64,8 @@
v-else-if="getType==='select'"
v-model="value"
:options="options"
:track-by="optionValue??'id'"
:label="optionLabel??'name'"
:multiple="multiple"
:disabled="disabled"
>
Expand Down Expand Up @@ -200,19 +201,28 @@ export default {
this.loading = true;
axios.get(this.remoteUrl).then(response => {
if(this.paginated){
console.log('hERE!!')
this.currentPage = parseInt(response.data.data.current_page) === parseInt(response.data.data.last_page) ? 0 : parseInt(response.data.data.current_page);
this.relation = response.data.data[this.remoteRoot];
}
else {
this.relation = response.data.data;
}
this.relation = this.relation.map(option => {
let optionsArray = this.optionLabel.split('.');
return {
name: option[optionsArray[0]][optionsArray[1]],
id: option[this.optionValue]
if(this.optionLabel.includes('.')){
let optionsArray = this.optionLabel.split('.');
return {
name: option[optionsArray[0]][optionsArray[1]],
id: option[this.optionValue]
}
}
else {
let optionsArray = this.optionLabel.split('.');
return {
name: option[this.optionLabel],
id: option[this.optionValue]
}
}
})
if (this.modelValue !== null && this.modelValue !== undefined) {
let currentValue = this.modelValue;
Expand All @@ -228,10 +238,19 @@ export default {
responseData = response.data.data;
}
let newData = responseData.map(option => {
let optionsArray = this.optionLabel.split('.');
return {
name: option[optionsArray[0]][optionsArray[1]],
id: option[this.optionValue]
if(this.optionLabel.includes('.')){
let optionsArray = this.optionLabel.split('.');
return {
name: option[optionsArray[0]][optionsArray[1]],
id: option[this.optionValue]
}
}
else {
let optionsArray = this.optionLabel.split('.');
return {
name: option[this.optionLabel],
id: option[this.optionValue]
}
}
})
newData.forEach((item) => {
Expand Down Expand Up @@ -296,10 +315,19 @@ export default {
responseData = response.data.data[this.remoteRoot];
}
let newData = responseData.map(option => {
let optionsArray = this.optionLabel.split('.');
return {
name: option[optionsArray[0]][optionsArray[1]],
id: option[this.optionValue]
if(this.optionLabel.includes('.')){
let optionsArray = this.optionLabel.split('.');
return {
name: option[optionsArray[0]][optionsArray[1]],
id: option[this.optionValue]
}
}
else {
let optionsArray = this.optionLabel.split('.');
return {
name: option[this.optionLabel],
id: option[this.optionValue]
}
}
})
newData.forEach((item) => {
Expand All @@ -322,10 +350,19 @@ export default {
this.relation = response.data.data;
}
this.relation = this.relation.map(option => {
let optionsArray = this.optionLabel.split('.');
return {
name: option[optionsArray[0]][optionsArray[1]],
id: option[this.optionValue]
if(this.optionLabel.includes('.')){
let optionsArray = this.optionLabel.split('.');
return {
name: option[optionsArray[0]][optionsArray[1]],
id: option[this.optionValue]
}
}
else {
let optionsArray = this.optionLabel.split('.');
return {
name: option[this.optionLabel],
id: option[this.optionValue]
}
}
})
this.loading = false;
Expand Down
1 change: 1 addition & 0 deletions src/Services/TomatoRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace TomatoPHP\TomatoAdmin\Services;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Http\FormRequest;
Expand Down

0 comments on commit 79472ac

Please sign in to comment.