46 lines
1.6 KiB
JavaScript
46 lines
1.6 KiB
JavaScript
(function(){
|
|
|
|
Vue.component('sdo-select',{
|
|
props: {
|
|
descriptors: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
},
|
|
data: function(){
|
|
return {
|
|
filters: {
|
|
slave: null,
|
|
name: "",
|
|
index: null,
|
|
datatype: null,
|
|
},
|
|
selectedIndex: null,
|
|
};
|
|
},
|
|
methods: {
|
|
getFilteredDescriptors: function(){
|
|
return this.descriptors.filter((sdo)=>
|
|
(!this.filters.name || sdo.name.toLowerCase().includes(this.filters.name.toLowerCase())) ); // &&
|
|
// (!this.filters.index || sdo.index.toString(16).toLowerCase().includes(this.filters.index.toLowerCase())) &&
|
|
// (!this.filters.datatype || sdo.datatype.toLowerCase().includes(this.filters.datatype.toLowerCase())) &&
|
|
// (!this.filters.slave || sdo.address.slave.toLowerCase().includes(this.filters.slave.toLowerCase()))
|
|
// );
|
|
},
|
|
},
|
|
template: `
|
|
<sdoselect class="flex" style="flex-direction: column;">
|
|
<input type="text" v-model="filters.name">
|
|
<select size="15" v-model="selectedIndex" @dblclick="if (selectedIndex>=0) $emit('selected', selectedIndex);">
|
|
<option
|
|
v-for="descriptor,key in this.getFilteredDescriptors()"
|
|
:value="descriptor.index"
|
|
>{{ descriptor.index.toString(16) }} : {{ descriptor.name }}
|
|
</option>
|
|
</select>
|
|
</sdoselect>
|
|
`,
|
|
});
|
|
|
|
|
|
})(); |