The Jobs page now reads data from Projects List, click on a row and go to a detail page.
This commit is contained in:
parent
b8c264f779
commit
3b2c78e4d4
4 changed files with 32 additions and 24 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import frappe, json
|
import frappe, json
|
||||||
from custom_ui.db_utils import process_query_conditions, build_datatable_response, get_count_or_filters
|
from custom_ui.db_utils import process_query_conditions, build_datatable_dict, get_count_or_filters, build_success_response
|
||||||
|
|
||||||
# ===============================================================================
|
# ===============================================================================
|
||||||
# JOB MANAGEMENT API METHODS
|
# JOB MANAGEMENT API METHODS
|
||||||
|
|
@ -9,15 +9,15 @@ from custom_ui.db_utils import process_query_conditions, build_datatable_respons
|
||||||
def get_jobs_table_data(filters={}, sortings=[], page=1, page_size=10):
|
def get_jobs_table_data(filters={}, sortings=[], page=1, page_size=10):
|
||||||
"""Get paginated job table data with filtering and sorting support."""
|
"""Get paginated job table data with filtering and sorting support."""
|
||||||
print("DEBUG: Raw job options received:", filters, sortings, page, page_size)
|
print("DEBUG: Raw job options received:", filters, sortings, page, page_size)
|
||||||
|
|
||||||
processed_filters, processed_sortings, is_or, page, page_size = process_query_conditions(filters, sortings, page, page_size)
|
processed_filters, processed_sortings, is_or, page, page_size = process_query_conditions(filters, sortings, page, page_size)
|
||||||
|
|
||||||
# Handle count with proper OR filter support
|
# Handle count with proper OR filter support
|
||||||
if is_or:
|
if is_or:
|
||||||
count = frappe.db.sql(*get_count_or_filters("Project", processed_filters))[0][0]
|
count = frappe.db.sql(*get_count_or_filters("Project", processed_filters))[0][0]
|
||||||
else:
|
else:
|
||||||
count = frappe.db.count("Project", filters=processed_filters)
|
count = frappe.db.count("Project", filters=processed_filters)
|
||||||
|
|
||||||
projects = frappe.db.get_all(
|
projects = frappe.db.get_all(
|
||||||
"Project",
|
"Project",
|
||||||
fields=["*"],
|
fields=["*"],
|
||||||
|
|
@ -27,7 +27,7 @@ def get_jobs_table_data(filters={}, sortings=[], page=1, page_size=10):
|
||||||
start=(page - 1) * page_size,
|
start=(page - 1) * page_size,
|
||||||
order_by=processed_sortings
|
order_by=processed_sortings
|
||||||
)
|
)
|
||||||
|
|
||||||
tableRows = []
|
tableRows = []
|
||||||
for project in projects:
|
for project in projects:
|
||||||
tableRow = {}
|
tableRow = {}
|
||||||
|
|
@ -37,13 +37,14 @@ def get_jobs_table_data(filters={}, sortings=[], page=1, page_size=10):
|
||||||
tableRow["customer"] = project.get("customer", "")
|
tableRow["customer"] = project.get("customer", "")
|
||||||
tableRow["status"] = project.get("status", "")
|
tableRow["status"] = project.get("status", "")
|
||||||
tableRow["percent_complete"] = project.get("percent_complete", 0)
|
tableRow["percent_complete"] = project.get("percent_complete", 0)
|
||||||
tableRows.append(tableRow)
|
tableRows.append(tableRow)
|
||||||
|
|
||||||
return build_datatable_response(data=tableRows, count=count, page=page, page_size=page_size)
|
data_table_dict = build_datatable_dict(data=tableRows, count=count, page=page, page_size=page_size)
|
||||||
|
return build_success_response(data_table_dict)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def upsert_job(data):
|
def upsert_job(data):
|
||||||
"""Create or update a job (project)."""
|
"""Create or update a job (project)."""
|
||||||
# TODO: Implement job creation/update logic
|
# TODO: Implement job creation/update logic
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ const FRAPPE_SEND_ESTIMATE_EMAIL_METHOD = "custom_ui.api.db.estimates.send_estim
|
||||||
const FRAPPE_LOCK_ESTIMATE_METHOD = "custom_ui.api.db.estimates.lock_estimate";
|
const FRAPPE_LOCK_ESTIMATE_METHOD = "custom_ui.api.db.estimates.lock_estimate";
|
||||||
const FRAPPE_ESTIMATE_UPDATE_RESPONSE_METHOD = "custom_ui.api.db.estimates.manual_response";
|
const FRAPPE_ESTIMATE_UPDATE_RESPONSE_METHOD = "custom_ui.api.db.estimates.manual_response";
|
||||||
// Job methods
|
// Job methods
|
||||||
const FRAPPE_GET_JOBS_METHOD = "custom_ui.api.db.get_jobs";
|
const FRAPPE_GET_JOBS_METHOD = "custom_ui.api.db.jobs.get_jobs_table_data";
|
||||||
const FRAPPE_UPSERT_JOB_METHOD = "custom_ui.api.db.jobs.upsert_job";
|
const FRAPPE_UPSERT_JOB_METHOD = "custom_ui.api.db.jobs.upsert_job";
|
||||||
const FRAPPE_GET_JOB_TASK_LIST_METHOD = "custom_ui.api.db.get_job_task_list";
|
const FRAPPE_GET_JOB_TASK_LIST_METHOD = "custom_ui.api.db.get_job_task_list";
|
||||||
// Invoice methods
|
// Invoice methods
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@
|
||||||
:totalRecords="totalRecords"
|
:totalRecords="totalRecords"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
@lazy-load="handleLazyLoad"
|
@lazy-load="handleLazyLoad"
|
||||||
|
@row-click="handleRowClick"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -254,27 +255,31 @@ const handleLazyLoad = async (event) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleRowClick = (event) => {
|
||||||
|
const rowData = event.data;
|
||||||
|
router.push(`/job?jobId=${rowData.name}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Load initial data
|
// Load initial data
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
notifications.addWarning("Jobs page coming soon");
|
notifications.addWarning("Jobs page coming soon");
|
||||||
// Initialize pagination and filters
|
// Initialize pagination and filters
|
||||||
// paginationStore.initializeTablePagination("jobs", { rows: 10 });
|
paginationStore.initializeTablePagination("jobs", { rows: 10 });
|
||||||
// filtersStore.initializeTableFilters("jobs", columns);
|
filtersStore.initializeTableFilters("jobs", columns);
|
||||||
// filtersStore.initializeTableSorting("jobs");
|
filtersStore.initializeTableSorting("jobs");
|
||||||
|
|
||||||
// // Load first page
|
// // Load first page
|
||||||
// const initialPagination = paginationStore.getTablePagination("jobs");
|
const initialPagination = paginationStore.getTablePagination("jobs");
|
||||||
// const initialFilters = filtersStore.getTableFilters("jobs");
|
const initialFilters = filtersStore.getTableFilters("jobs");
|
||||||
// const initialSorting = filtersStore.getTableSorting("jobs");
|
const initialSorting = filtersStore.getTableSorting("jobs");
|
||||||
|
|
||||||
// await handleLazyLoad({
|
await handleLazyLoad({
|
||||||
// page: initialPagination.page,
|
page: initialPagination.page,
|
||||||
// rows: initialPagination.rows,
|
rows: initialPagination.rows,
|
||||||
// first: initialPagination.first,
|
first: initialPagination.first,
|
||||||
// sortField: initialSorting.field || initialPagination.sortField,
|
sortField: initialSorting.field || initialPagination.sortField,
|
||||||
// sortOrder: initialSorting.order || initialPagination.sortOrder,
|
sortOrder: initialSorting.order || initialPagination.sortOrder,
|
||||||
// filters: initialFilters,
|
});
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style lang="css">
|
<style lang="css">
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import Warranties from "./components/pages/Warranties.vue";
|
||||||
import Home from "./components/pages/Home.vue";
|
import Home from "./components/pages/Home.vue";
|
||||||
import Client from "./components/pages/Client.vue";
|
import Client from "./components/pages/Client.vue";
|
||||||
import Estimate from "./components/pages/Estimate.vue";
|
import Estimate from "./components/pages/Estimate.vue";
|
||||||
|
import Job from "./components/pages/Job.vue";
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
|
|
@ -21,6 +22,7 @@ const routes = [
|
||||||
{ path: "/clients", component: Clients },
|
{ path: "/clients", component: Clients },
|
||||||
{ path: "/client", component: Client },
|
{ path: "/client", component: Client },
|
||||||
{ path: "/jobs", component: Jobs },
|
{ path: "/jobs", component: Jobs },
|
||||||
|
{ path: "/job", component: Job },
|
||||||
{ path: "/invoices", component: Invoices },
|
{ path: "/invoices", component: Invoices },
|
||||||
{ path: "/estimates", component: Estimates },
|
{ path: "/estimates", component: Estimates },
|
||||||
{ path: "/estimate", component: Estimate },
|
{ path: "/estimate", component: Estimate },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue