lookup focus functionality in client table view
This commit is contained in:
parent
a01f72bbc1
commit
c5c5ffb0fb
@ -27,6 +27,16 @@ const notifications = useNotificationStore();
|
|||||||
const isCollapsed = ref(false);
|
const isCollapsed = ref(false);
|
||||||
const pendingOpen = ref(null);
|
const pendingOpen = ref(null);
|
||||||
|
|
||||||
|
const focusClientInput = (inputId) => {
|
||||||
|
if (typeof document === "undefined") return;
|
||||||
|
nextTick(() => {
|
||||||
|
const el = document.getElementById(inputId);
|
||||||
|
if (el && typeof el.focus === "function") {
|
||||||
|
el.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const toggleSidebar = () => {
|
const toggleSidebar = () => {
|
||||||
isCollapsed.value = !isCollapsed.value;
|
isCollapsed.value = !isCollapsed.value;
|
||||||
};
|
};
|
||||||
@ -44,13 +54,21 @@ const clientButtons = ref([
|
|||||||
{
|
{
|
||||||
label: "Customer Lookup",
|
label: "Customer Lookup",
|
||||||
command: () => {
|
command: () => {
|
||||||
router.push("/clients");
|
if (router.currentRoute.value.path === "/clients") {
|
||||||
|
focusClientInput("customerSearchInput");
|
||||||
|
} else {
|
||||||
|
router.push("/clients?lookup=customer");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Property Lookup",
|
label: "Property Lookup",
|
||||||
command: () => {
|
command: () => {
|
||||||
router.push("/clients");
|
if (router.currentRoute.value.path === "/clients") {
|
||||||
|
focusClientInput("propertySearchInput");
|
||||||
|
} else {
|
||||||
|
router.push("/clients?lookup=property");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -151,7 +169,7 @@ const handleCategoryClick = (category) => {
|
|||||||
'sidebar-button',
|
'sidebar-button',
|
||||||
router.currentRoute.value.path === category.url ? 'active' : '',
|
router.currentRoute.value.path === category.url ? 'active' : '',
|
||||||
]"
|
]"
|
||||||
:key="category.name"
|
:key="`btn-${category.name}`"
|
||||||
@click="handleCategoryClick(category)"
|
@click="handleCategoryClick(category)"
|
||||||
:title="isCollapsed ? category.name : ''"
|
:title="isCollapsed ? category.name : ''"
|
||||||
>
|
>
|
||||||
@ -162,7 +180,7 @@ const handleCategoryClick = (category) => {
|
|||||||
<template v-else>
|
<template v-else>
|
||||||
<SidebarSpeedDial
|
<SidebarSpeedDial
|
||||||
v-if="!isCollapsed"
|
v-if="!isCollapsed"
|
||||||
:key="category.name"
|
:key="`dial-${category.name}`"
|
||||||
:icon="category.icon"
|
:icon="category.icon"
|
||||||
:label="category.name"
|
:label="category.name"
|
||||||
:items="category.buttons"
|
:items="category.buttons"
|
||||||
@ -172,7 +190,7 @@ const handleCategoryClick = (category) => {
|
|||||||
<button
|
<button
|
||||||
v-else
|
v-else
|
||||||
class="sidebar-button"
|
class="sidebar-button"
|
||||||
:key="category.name"
|
:key="`collapsed-${category.name}`"
|
||||||
:title="category.name"
|
:title="category.name"
|
||||||
@click="openSidebarAndDial(category)"
|
@click="openSidebarAndDial(category)"
|
||||||
>
|
>
|
||||||
|
|||||||
@ -10,11 +10,11 @@
|
|||||||
<div class="dt-filter-content">
|
<div class="dt-filter-content">
|
||||||
<div class="dt-filter-grid">
|
<div class="dt-filter-grid">
|
||||||
<div v-for="col in filterableColumns" :key="col.fieldName" class="dt-filter-field">
|
<div v-for="col in filterableColumns" :key="col.fieldName" class="dt-filter-field">
|
||||||
<label :for="`filter-${col.fieldName}`" class="dt-filter-label">
|
<label :for="col.filterInputId || `filter-${col.fieldName}`" class="dt-filter-label">
|
||||||
{{ col.label }}
|
{{ col.label }}
|
||||||
</label>
|
</label>
|
||||||
<InputText
|
<InputText
|
||||||
:id="`filter-${col.fieldName}`"
|
:id="col.filterInputId || col.searchInputId || `filter-${col.fieldName}`"
|
||||||
v-model="pendingFilters[col.fieldName]"
|
v-model="pendingFilters[col.fieldName]"
|
||||||
:placeholder="`Filter by ${col.label.toLowerCase()}...`"
|
:placeholder="`Filter by ${col.label.toLowerCase()}...`"
|
||||||
class="dt-filter-input"
|
class="dt-filter-input"
|
||||||
@ -259,6 +259,7 @@
|
|||||||
>
|
>
|
||||||
<template v-if="col.filterable === true" #filter="{ filterModel, filterCallback }">
|
<template v-if="col.filterable === true" #filter="{ filterModel, filterCallback }">
|
||||||
<InputText
|
<InputText
|
||||||
|
:id="col.filterInputId || col.searchInputId || `inline-filter-${col.fieldName}`"
|
||||||
v-model="filterModel.value"
|
v-model="filterModel.value"
|
||||||
type="text"
|
type="text"
|
||||||
@input="handleFilterInput(col.fieldName, filterModel.value, filterCallback)"
|
@input="handleFilterInput(col.fieldName, filterModel.value, filterCallback)"
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div class="client-page">
|
||||||
<!-- Client Header -->
|
<!-- Client Header -->
|
||||||
<div class="client-header" v-if="client.customerName">
|
<div class="client-header" v-if="client.customerName">
|
||||||
<div class="client-info">
|
<div class="client-info">
|
||||||
@ -43,6 +44,7 @@
|
|||||||
</TabPanel>
|
</TabPanel>
|
||||||
</TabPanels>
|
</TabPanels>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onMounted, ref, watch } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import { useLoadingStore } from "../../stores/loading";
|
|||||||
import { usePaginationStore } from "../../stores/pagination";
|
import { usePaginationStore } from "../../stores/pagination";
|
||||||
import { useFiltersStore } from "../../stores/filters";
|
import { useFiltersStore } from "../../stores/filters";
|
||||||
import { useModalStore } from "../../stores/modal";
|
import { useModalStore } from "../../stores/modal";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import { useNotificationStore } from "../../stores/notifications-primevue";
|
import { useNotificationStore } from "../../stores/notifications-primevue";
|
||||||
|
|
||||||
const notifications = useNotificationStore();
|
const notifications = useNotificationStore();
|
||||||
@ -43,6 +43,7 @@ const paginationStore = usePaginationStore();
|
|||||||
const filtersStore = useFiltersStore();
|
const filtersStore = useFiltersStore();
|
||||||
const modalStore = useModalStore();
|
const modalStore = useModalStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
const tableData = ref([]);
|
const tableData = ref([]);
|
||||||
const totalRecords = ref(0);
|
const totalRecords = ref(0);
|
||||||
@ -51,6 +52,8 @@ const statusCounts = ref({}); // Start with empty object
|
|||||||
const currentWeekParams = ref({});
|
const currentWeekParams = ref({});
|
||||||
const chartLoading = ref(true); // Start with loading state
|
const chartLoading = ref(true); // Start with loading state
|
||||||
|
|
||||||
|
const lookup = route.query.lookup;
|
||||||
|
|
||||||
// Computed property to get current filters for the chart
|
// Computed property to get current filters for the chart
|
||||||
const currentFilters = computed(() => {
|
const currentFilters = computed(() => {
|
||||||
return filtersStore.getTableFilters("clients");
|
return filtersStore.getTableFilters("clients");
|
||||||
@ -115,6 +118,7 @@ const columns = [
|
|||||||
type: "text",
|
type: "text",
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
|
filterInputId: "customerSearchInput",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Address",
|
label: "Address",
|
||||||
@ -122,6 +126,7 @@ const columns = [
|
|||||||
type: "text",
|
type: "text",
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
|
filterInputId: "propertySearchInput",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Appt. Scheduled",
|
label: "Appt. Scheduled",
|
||||||
@ -334,6 +339,13 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
// if lookup has a value (it will either be "customer" or "property", put focus onto the appropriate search input)
|
||||||
|
if (lookup) {
|
||||||
|
const inputElement = document.getElementById(`${lookup}SearchInput`);
|
||||||
|
if (inputElement) {
|
||||||
|
inputElement.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
// Initialize pagination and filters
|
// Initialize pagination and filters
|
||||||
paginationStore.initializeTablePagination("clients", { rows: 10 });
|
paginationStore.initializeTablePagination("clients", { rows: 10 });
|
||||||
filtersStore.initializeTableFilters("clients", columns);
|
filtersStore.initializeTableFilters("clients", columns);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user