feature: search bar works. Beautiful two return code.
This commit is contained in:
@@ -1,24 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="search_bar_container" class="flex w-[280px] h-8 px-4 items-center border-[#64748B] border-[1px] rounded-full
|
<div id="search_bar_container" class="flex w-[280px] h-8 px-4 items-center border-[#64748B] border-[1px] rounded-full
|
||||||
justify-between">
|
justify-between">
|
||||||
<input id="input_search" class="w-full outline-0" :placeholder="i18next.t('AcctMgmt.Search')"/>
|
<input id="input_search" class="w-full outline-0" :placeholder="i18next.t('AcctMgmt.Search')"
|
||||||
<img src="@/assets/icon-search.svg" class="w-[17px] h-[17px] flex cursor-pointer"/>
|
v-model="inputQuery"
|
||||||
|
/>
|
||||||
|
<img src="@/assets/icon-search.svg" class="w-[17px] h-[17px] flex cursor-pointer" @click="onSearchClick"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { ref, } from 'vue';
|
||||||
import i18next from '@/i18n/i18n.js';
|
import i18next from '@/i18n/i18n.js';
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup(props, { emit, }) {
|
||||||
|
const inputQuery = ref("");
|
||||||
|
|
||||||
|
const onSearchClick = (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
emit('on-search-account-button-click', inputQuery.value);
|
||||||
|
};
|
||||||
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
return {
|
||||||
i18next: i18next,
|
inputQuery,
|
||||||
}
|
onSearchClick,
|
||||||
},
|
i18next,
|
||||||
created() {
|
};
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -6,10 +6,10 @@
|
|||||||
items-center px-6 py-[10px]" @click="onCreateNewClick">
|
items-center px-6 py-[10px]" @click="onCreateNewClick">
|
||||||
{{ i18next.t("AcctMgmt.CreateNew") }}
|
{{ i18next.t("AcctMgmt.CreateNew") }}
|
||||||
</button>
|
</button>
|
||||||
<SearchBar/>
|
<SearchBar @on-search-account-button-click="onSearchAccountButtonClick"/>
|
||||||
</div>
|
</div>
|
||||||
<div id="acct_mgmt_data_grid" class="flex w-full overflow-y-auto h-[570px]" @scroll="handleScroll">
|
<div id="acct_mgmt_data_grid" class="flex w-full overflow-y-auto h-[570px]" @scroll="handleScroll">
|
||||||
<DataTable :value="infiniteAcctData" dataKey="username" tableClass="w-full mt-4 text-sm relative table-fixed"
|
<DataTable :value="accountSearchResults" dataKey="username" tableClass="w-full mt-4 text-sm relative table-fixed"
|
||||||
:rowClass="getRowClass"
|
:rowClass="getRowClass"
|
||||||
>
|
>
|
||||||
<Column field="username" :header="i18next.t('AcctMgmt.Account')" bodyClass="font-medium" sortable>
|
<Column field="username" :header="i18next.t('AcctMgmt.Account')" bodyClass="font-medium" sortable>
|
||||||
@@ -145,7 +145,7 @@ function repeatAccountList(accountList, N) {
|
|||||||
const repeatedAccountList = repeatAccountList(accountList, 20);
|
const repeatedAccountList = repeatAccountList(accountList, 20);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup(props, { emit, }) {
|
||||||
const acctMgmtStore = useAcctMgmtStore();
|
const acctMgmtStore = useAcctMgmtStore();
|
||||||
const loadingStore = LoadingStore();
|
const loadingStore = LoadingStore();
|
||||||
const modalStore = useModalStore();
|
const modalStore = useModalStore();
|
||||||
@@ -162,6 +162,8 @@ export default {
|
|||||||
const isOneAccountJustCreate = computed(() => acctMgmtStore.isOneAccountJustCreate);
|
const isOneAccountJustCreate = computed(() => acctMgmtStore.isOneAccountJustCreate);
|
||||||
const justCreateUsername = computed(() => acctMgmtStore.justCreateUsername);
|
const justCreateUsername = computed(() => acctMgmtStore.justCreateUsername);
|
||||||
|
|
||||||
|
const inputQuery = ref('');
|
||||||
|
|
||||||
const fetchLoginUserData = async () => {
|
const fetchLoginUserData = async () => {
|
||||||
await loginStore.getUserData();
|
await loginStore.getUserData();
|
||||||
loginUserData.value = loginStore.userData;
|
loginUserData.value = loginStore.userData;
|
||||||
@@ -191,6 +193,13 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const accountSearchResults = computed(() => {
|
||||||
|
if(!inputQuery.value) {
|
||||||
|
return infiniteAcctData.value;
|
||||||
|
}
|
||||||
|
return acctMgmtStore.allUserAccoutList.filter (user => user.username.includes(inputQuery.value));
|
||||||
|
});
|
||||||
|
|
||||||
const onCreateNewClick = () => {
|
const onCreateNewClick = () => {
|
||||||
acctMgmtStore.clearCurrentViewingUser();
|
acctMgmtStore.clearCurrentViewingUser();
|
||||||
modalStore.openModal(MODAL_CREATE_NEW);
|
modalStore.openModal(MODAL_CREATE_NEW);
|
||||||
@@ -256,6 +265,10 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onSearchAccountButtonClick = (inputQueryString) => {
|
||||||
|
inputQuery.value = inputQueryString;
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await fetchLoginUserData();
|
await fetchLoginUserData();
|
||||||
await acctMgmtStore.getAllUserAccounts();
|
await acctMgmtStore.getAllUserAccounts();
|
||||||
@@ -298,6 +311,7 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
accountSearchResults,
|
||||||
isLoading,
|
isLoading,
|
||||||
modalStore,
|
modalStore,
|
||||||
loginUserData,
|
loginUserData,
|
||||||
@@ -306,6 +320,7 @@ export default {
|
|||||||
justCreateUsername,
|
justCreateUsername,
|
||||||
onCreateNewClick,
|
onCreateNewClick,
|
||||||
onAcctDoubleClick,
|
onAcctDoubleClick,
|
||||||
|
onSearchAccountButtonClick,
|
||||||
handleScroll,
|
handleScroll,
|
||||||
getRowClass,
|
getRowClass,
|
||||||
onDeleteBtnClick,
|
onDeleteBtnClick,
|
||||||
|
|||||||
Reference in New Issue
Block a user