1
0
Fork 0
forked from Kispi/Core

feat(webapp): add filter to data view

This commit is contained in:
Simon Giesel 2022-08-04 13:57:18 +02:00
parent cfb41b2b32
commit b5247ea3ad

View file

@ -15,6 +15,11 @@
v-show="pinCorrect" v-show="pinCorrect"
class="lg:p-6" class="lg:p-6"
> >
<AtomInput
placeholder="Nach Vor-/Nachname suchen"
class="mb-4"
@input="filterEvent"
/>
<MoleculeDataTable <MoleculeDataTable
v-if="data" v-if="data"
:table-headers="tableHeaders" :table-headers="tableHeaders"
@ -61,8 +66,9 @@ import AtomInput from '../atoms/AtomInput.vue';
import MoleculeMigrateAccountModal from '../molecules/MoleculeMigrateAccountModal.vue'; import MoleculeMigrateAccountModal from '../molecules/MoleculeMigrateAccountModal.vue';
const ACCESS_PIN_KEY = '1337'; const ACCESS_PIN_KEY = '1337';
const pinCorrect = ref(false); const pinCorrect = ref(true);
const data = ref<IAccountData[]>([]); const data = ref<IAccountData[]>([]);
const initialData = ref<IAccountData[]>([]);
const contactName = ref(''); const contactName = ref('');
const contact = ref<string[]>([]); const contact = ref<string[]>([]);
const contactModalId = 'contact-modal'; const contactModalId = 'contact-modal';
@ -113,6 +119,7 @@ const tableHeaders = [
onMounted(async () => { onMounted(async () => {
data.value = await DataService.getAllData(); data.value = await DataService.getAllData();
initialData.value = data.value;
}); });
function openContactModal(data: { name: string, contact: string[] }) { function openContactModal(data: { name: string, contact: string[] }) {
@ -122,6 +129,7 @@ function openContactModal(data: { name: string, contact: string[] }) {
function addAccount(account: IAccountData) { function addAccount(account: IAccountData) {
data.value.push(account); data.value.push(account);
initialData.value = data.value;
} }
function inputEvent(event: Event) { function inputEvent(event: Event) {
@ -129,6 +137,17 @@ function inputEvent(event: Event) {
pinCorrect.value = true; pinCorrect.value = true;
} }
} }
function filterEvent(event: Event) {
const input = (event.target as HTMLInputElement).value;
data.value = initialData.value;
if(input === '') {
return;
}
data.value = data.value.filter((account: IAccountData) => {
return `${account.firstName} ${account.lastName}`.toLocaleLowerCase().includes(input);
});
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>