Ver a proveniência

Feafactor: Move AutoComplete filter function as utils

pull/168/head
winkidney há 5 anos
ascendente
cometimento
b7f24b83be
2 ficheiros alterados com 17 adições e 13 eliminações
  1. +2
    -13
      pinry-spa/src/components/pin_edit/FilterSelect.vue
  2. +15
    -0
      pinry-spa/src/components/utils/AutoComplete.js

+ 2
- 13
pinry-spa/src/components/pin_edit/FilterSelect.vue Ver ficheiro

@@ -38,21 +38,10 @@
<script>
import API from '../api';
import ModelForm from '../utils/ModelForm';
import AutoComplete from '../utils/AutoComplete';

const fields = ['name'];

function getFilteredOptions(options, filterText) {
return options.filter(
(option) => {
const index = option.name
.toString()
.toLowerCase()
.indexOf(filterText.toLowerCase());
return index >= 0;
},
);
}

function getBoardFromResp(boardObject) {
return { name: boardObject.name, value: boardObject.id };
}
@@ -62,7 +51,7 @@ function getAvailableOptions(vm, filter) {
if (filter === '' || filter === null) {
availableOptions = vm.allOptions;
} else {
availableOptions = getFilteredOptions(
availableOptions = AutoComplete.getFilteredOptions(
vm.allOptions, vm.form.name.value,
);
}


+ 15
- 0
pinry-spa/src/components/utils/AutoComplete.js Ver ficheiro

@@ -0,0 +1,15 @@
function getFilteredOptions(options, filterText) {
return options.filter(
(option) => {
const index = option.name
.toString()
.toLowerCase()
.indexOf(filterText.toLowerCase());
return index >= 0;
},
);
}

export default {
getFilteredOptions,
};

Carregando…
Cancelar
Guardar