Merge pull request #1707 from SevanNerse/master
dynamic options feature is added to akaunting-select components
This commit is contained in:
commit
39d9796626
@ -185,6 +185,8 @@ export default {
|
|||||||
|
|
||||||
options: null,
|
options: null,
|
||||||
|
|
||||||
|
dynamicOptions: null,
|
||||||
|
|
||||||
disabledOptions: {
|
disabledOptions: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: function () {
|
default: function () {
|
||||||
@ -686,6 +688,55 @@ export default {
|
|||||||
|
|
||||||
this.change();
|
this.change();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
dynamicOptions: function(options) {
|
||||||
|
if (this.group) {
|
||||||
|
// Option set sort_option data
|
||||||
|
if (!Array.isArray(options)) {
|
||||||
|
for (const [index, _options] of Object.entries(options)) {
|
||||||
|
let values = [];
|
||||||
|
|
||||||
|
for (const [key, value] of Object.entries(_options)) {
|
||||||
|
values.push({
|
||||||
|
key: key,
|
||||||
|
value: value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sort_options.push({
|
||||||
|
key: index,
|
||||||
|
value: values
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
options.forEach(function (option, index) {
|
||||||
|
this.sort_options.push({
|
||||||
|
index: index,
|
||||||
|
key: option.id,
|
||||||
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Option set sort_option data
|
||||||
|
if (!Array.isArray(options)) {
|
||||||
|
for (const [key, value] of Object.entries(options)) {
|
||||||
|
this.sort_options.push({
|
||||||
|
key: key,
|
||||||
|
value: value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
options.forEach(function (option, index) {
|
||||||
|
this.sort_options.push({
|
||||||
|
index: index,
|
||||||
|
key: option.id,
|
||||||
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -286,6 +286,8 @@ export default {
|
|||||||
|
|
||||||
options: null,
|
options: null,
|
||||||
|
|
||||||
|
dynamicOptions: null,
|
||||||
|
|
||||||
disabledOptions: {
|
disabledOptions: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: function () {
|
default: function () {
|
||||||
@ -895,6 +897,55 @@ export default {
|
|||||||
|
|
||||||
this.change();
|
this.change();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
dynamicOptions: function(options) {
|
||||||
|
if (this.group) {
|
||||||
|
// Option set sort_option data
|
||||||
|
if (!Array.isArray(options)) {
|
||||||
|
for (const [index, _options] of Object.entries(options)) {
|
||||||
|
let values = [];
|
||||||
|
|
||||||
|
for (const [key, value] of Object.entries(_options)) {
|
||||||
|
values.push({
|
||||||
|
key: key,
|
||||||
|
value: value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sort_options.push({
|
||||||
|
key: index,
|
||||||
|
value: values
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
options.forEach(function (option, index) {
|
||||||
|
this.sort_options.push({
|
||||||
|
index: index,
|
||||||
|
key: option.id,
|
||||||
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Option set sort_option data
|
||||||
|
if (!Array.isArray(options)) {
|
||||||
|
for (const [key, value] of Object.entries(options)) {
|
||||||
|
this.sort_options.push({
|
||||||
|
key: key,
|
||||||
|
value: value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
options.forEach(function (option, index) {
|
||||||
|
this.sort_options.push({
|
||||||
|
index: index,
|
||||||
|
key: option.id,
|
||||||
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (isset($attributes['dynamicOptions']))
|
||||||
|
:dynamic-options="{{ $attributes['dynamicOptions'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (isset($selected) || old($name))
|
@if (isset($selected) || old($name))
|
||||||
:value="{{ json_encode(old($name, $selected)) }}"
|
:value="{{ json_encode(old($name, $selected)) }}"
|
||||||
@endif
|
@endif
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (isset($attributes['dynamicOptions']))
|
||||||
|
:dynamic-options="{{ $attributes['dynamicOptions'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (isset($selected) || old($name))
|
@if (isset($selected) || old($name))
|
||||||
:value="{{ json_encode(old($name, $selected)) }}"
|
:value="{{ json_encode(old($name, $selected)) }}"
|
||||||
@endif
|
@endif
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (isset($attributes['dynamicOptions']))
|
||||||
|
:dynamic-options="{{ $attributes['dynamicOptions'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (!empty($selected) || old($name))
|
@if (!empty($selected) || old($name))
|
||||||
:value="{{ json_encode(old($name, $selected)) }}"
|
:value="{{ json_encode(old($name, $selected)) }}"
|
||||||
@endif
|
@endif
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (isset($attributes['dynamicOptions']))
|
||||||
|
:dynamic-options="{{ $attributes['dynamicOptions'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (!empty($selected) || old($name))
|
@if (!empty($selected) || old($name))
|
||||||
:value="{{ json_encode(old($name, $selected)) }}"
|
:value="{{ json_encode(old($name, $selected)) }}"
|
||||||
@endif
|
@endif
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (isset($attributes['dynamicOptions']))
|
||||||
|
:dynamic-options="{{ $attributes['dynamicOptions'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (isset($selected) || old($name))
|
@if (isset($selected) || old($name))
|
||||||
value="{{ old($name, $selected) }}"
|
value="{{ old($name, $selected) }}"
|
||||||
@endif
|
@endif
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (isset($attributes['dynamicOptions']))
|
||||||
|
:dynamic-options="{{ $attributes['dynamicOptions'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (isset($selected) || old($name))
|
@if (isset($selected) || old($name))
|
||||||
value="{{ old($name, $selected) }}"
|
value="{{ old($name, $selected) }}"
|
||||||
@endif
|
@endif
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (isset($attributes['dynamicOptions']))
|
||||||
|
:dynamic-options="{{ $attributes['dynamicOptions'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (isset($selected) || old($name))
|
@if (isset($selected) || old($name))
|
||||||
value="{{ old($name, $selected) }}"
|
value="{{ old($name, $selected) }}"
|
||||||
@endif
|
@endif
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (isset($attributes['dynamicOptions']))
|
||||||
|
:dynamic-options="{{ $attributes['dynamicOptions'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (isset($selected) || old($name))
|
@if (isset($selected) || old($name))
|
||||||
value="{{ old($name, $selected) }}"
|
value="{{ old($name, $selected) }}"
|
||||||
@endif
|
@endif
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (isset($attributes['dynamicOptions']))
|
||||||
|
:dynamic-options="{{ $attributes['dynamicOptions'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (isset($selected) || old($name))
|
@if (isset($selected) || old($name))
|
||||||
value="{{ old($name, $selected) }}"
|
value="{{ old($name, $selected) }}"
|
||||||
@endif
|
@endif
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
:disabled-options="{{ json_encode($attributes['disabledOptions']) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (isset($attributes['dynamicOptions']))
|
||||||
|
:dynamic-options="{{ $attributes['dynamicOptions'] }}"
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (isset($selected) || old($name))
|
@if (isset($selected) || old($name))
|
||||||
value="{{ old($name, $selected) }}"
|
value="{{ old($name, $selected) }}"
|
||||||
@endif
|
@endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user