[pricelist][chore] minor cleanup

This commit is contained in:
Tim Gröger 2021-04-01 11:15:21 +02:00
parent 8ecbddc6ca
commit 909275727a
6 changed files with 36 additions and 33 deletions

View File

@ -335,14 +335,9 @@ import MinPriceSetting from 'src/plugins/pricelist/components/MinPriceSetting.vu
import NewDrink from 'src/plugins/pricelist/components/CalculationTable/NewDrink.vue';
import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue';
import SearchInput from './SearchInput.vue';
import { filter } from '../utils/filter';
import { filter, Search } from '../utils/filter';
import { Notify } from 'quasar';
function sort(a: string | number, b: string | number) {
if (a > b) return 1;
if (b > a) return -1;
return 0;
}
import { sort } from '../utils/sort';
export default defineComponent({
name: 'CalculationTable',
@ -528,7 +523,7 @@ export default defineComponent({
updateDrink(drink);
}
const search = ref({
const search = ref<Search>({
value: '',
key: '',
label: '',

View File

@ -91,12 +91,8 @@ import { defineComponent, onBeforeMount, computed, ref } from 'vue';
import { usePricelistStore } from '../store';
import { useMainStore } from 'src/stores';
import SearchInput from './SearchInput.vue';
import { filter } from '../utils/filter';
function sort(a: string | number, b: string | number) {
if (a > b) return 1;
if (b > a) return -1;
return 0;
}
import { filter, Search } from '../utils/filter';
import { sort } from '../utils/sort';
export default defineComponent({
name: 'Pricelist',
components: { SearchInput },
@ -223,7 +219,7 @@ export default defineComponent({
});
return retVal;
}
const search = ref({ label: '', value: '', key: '' });
const search = ref<Search>({ label: '', value: '', key: '' });
return {
columns_drinks,

View File

@ -7,19 +7,16 @@
</template>
<script lang="ts">
import { defineComponent, computed, PropType } from 'vue';
import { Search, Col } from '../utils/filter';
export default defineComponent({
name: 'SearchInput',
props: {
modelValue: {
type: Object as PropType<{
value: string;
key: string | undefined;
label: string | undefined;
}>,
type: Object as PropType<Search>,
default: { value: '', key: undefined, label: '' },
},
keys: {
type: Object as PropType<Array<{ name: string; label: string }>>,
type: Object as PropType<Array<Col>>,
required: true,
},
},
@ -51,7 +48,6 @@ export default defineComponent({
}
return false;
});
//emit('update:modelValue', {value: split[0], label: split[1], key: undefined})
}
},
});
@ -59,3 +55,4 @@ export default defineComponent({
},
});
</script>
a

View File

@ -44,12 +44,8 @@ import { usePricelistStore } from 'src/plugins/pricelist/store';
import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue';
import BuildManualVolume from '../components/BuildManual/BuildManualVolume.vue';
import SearchInput from '../components/SearchInput.vue';
import { filter } from '../utils/filter';
function sort(a: string | number, b: string | number) {
if (a > b) return 1;
if (b > a) return -1;
return 0;
}
import { filter, Search } from '../utils/filter';
import { sort } from '../utils/sort';
export default defineComponent({
name: 'Reciepts',
components: { BuildManual, BuildManualVolume, SearchInput },
@ -123,7 +119,7 @@ export default defineComponent({
},
];
const search = ref({ value: '', key: '', label: '' });
const search = ref<Search>({ value: '', key: '', label: '' });
return {
drinks,

View File

@ -2,9 +2,9 @@ import { Drink } from '../store';
function filter(
rows: Array<Drink>,
terms: { value: string; key: string },
cols: Array<{ name: string; label: string; field: string }>,
cellValue: { (col: { name: string; label: string; field: string }, row: Drink): string }
terms: Search,
cols: Array<Col>,
cellValue: { (col: Col, row: Drink): string }
) {
if (terms.value) {
return rows.filter((row) => {
@ -24,4 +24,16 @@ function filter(
return rows;
}
export { filter };
interface Search {
value: string;
label: string | undefined;
key: string | undefined;
}
interface Col {
name: string;
label: string;
field: string;
}
export { filter, Search, Col };

View File

@ -0,0 +1,7 @@
function sort(a: string | number, b: string | number) {
if (a > b) return 1;
if (b > a) return -1;
return 0;
}
export { sort };