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
@ -1,5 +1,5 @@
|
||||
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
|
||||
@ -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):
|
||||
"""Get paginated job table data with filtering and sorting support."""
|
||||
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)
|
||||
|
||||
|
||||
# Handle count with proper OR filter support
|
||||
if is_or:
|
||||
count = frappe.db.sql(*get_count_or_filters("Project", processed_filters))[0][0]
|
||||
else:
|
||||
count = frappe.db.count("Project", filters=processed_filters)
|
||||
|
||||
|
||||
projects = frappe.db.get_all(
|
||||
"Project",
|
||||
fields=["*"],
|
||||
@ -27,7 +27,7 @@ def get_jobs_table_data(filters={}, sortings=[], page=1, page_size=10):
|
||||
start=(page - 1) * page_size,
|
||||
order_by=processed_sortings
|
||||
)
|
||||
|
||||
|
||||
tableRows = []
|
||||
for project in projects:
|
||||
tableRow = {}
|
||||
@ -37,13 +37,14 @@ def get_jobs_table_data(filters={}, sortings=[], page=1, page_size=10):
|
||||
tableRow["customer"] = project.get("customer", "")
|
||||
tableRow["status"] = project.get("status", "")
|
||||
tableRow["percent_complete"] = project.get("percent_complete", 0)
|
||||
tableRows.append(tableRow)
|
||||
|
||||
return build_datatable_response(data=tableRows, count=count, page=page, page_size=page_size)
|
||||
tableRows.append(tableRow)
|
||||
|
||||
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()
|
||||
def upsert_job(data):
|
||||
"""Create or update a job (project)."""
|
||||
# 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_ESTIMATE_UPDATE_RESPONSE_METHOD = "custom_ui.api.db.estimates.manual_response";
|
||||
// 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_GET_JOB_TASK_LIST_METHOD = "custom_ui.api.db.get_job_task_list";
|
||||
// Invoice methods
|
||||
|
||||
@ -104,6 +104,7 @@
|
||||
:totalRecords="totalRecords"
|
||||
:loading="isLoading"
|
||||
@lazy-load="handleLazyLoad"
|
||||
@row-click="handleRowClick"
|
||||
/>
|
||||
</div>
|
||||
</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
|
||||
onMounted(async () => {
|
||||
notifications.addWarning("Jobs page coming soon");
|
||||
// Initialize pagination and filters
|
||||
// paginationStore.initializeTablePagination("jobs", { rows: 10 });
|
||||
// filtersStore.initializeTableFilters("jobs", columns);
|
||||
// filtersStore.initializeTableSorting("jobs");
|
||||
paginationStore.initializeTablePagination("jobs", { rows: 10 });
|
||||
filtersStore.initializeTableFilters("jobs", columns);
|
||||
filtersStore.initializeTableSorting("jobs");
|
||||
|
||||
// // Load first page
|
||||
// const initialPagination = paginationStore.getTablePagination("jobs");
|
||||
// const initialFilters = filtersStore.getTableFilters("jobs");
|
||||
// const initialSorting = filtersStore.getTableSorting("jobs");
|
||||
const initialPagination = paginationStore.getTablePagination("jobs");
|
||||
const initialFilters = filtersStore.getTableFilters("jobs");
|
||||
const initialSorting = filtersStore.getTableSorting("jobs");
|
||||
|
||||
// await handleLazyLoad({
|
||||
// page: initialPagination.page,
|
||||
// rows: initialPagination.rows,
|
||||
// first: initialPagination.first,
|
||||
// sortField: initialSorting.field || initialPagination.sortField,
|
||||
// sortOrder: initialSorting.order || initialPagination.sortOrder,
|
||||
// filters: initialFilters,
|
||||
// });
|
||||
await handleLazyLoad({
|
||||
page: initialPagination.page,
|
||||
rows: initialPagination.rows,
|
||||
first: initialPagination.first,
|
||||
sortField: initialSorting.field || initialPagination.sortField,
|
||||
sortOrder: initialSorting.order || initialPagination.sortOrder,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style lang="css">
|
||||
|
||||
@ -11,6 +11,7 @@ import Warranties from "./components/pages/Warranties.vue";
|
||||
import Home from "./components/pages/Home.vue";
|
||||
import Client from "./components/pages/Client.vue";
|
||||
import Estimate from "./components/pages/Estimate.vue";
|
||||
import Job from "./components/pages/Job.vue";
|
||||
|
||||
const routes = [
|
||||
{
|
||||
@ -21,6 +22,7 @@ const routes = [
|
||||
{ path: "/clients", component: Clients },
|
||||
{ path: "/client", component: Client },
|
||||
{ path: "/jobs", component: Jobs },
|
||||
{ path: "/job", component: Job },
|
||||
{ path: "/invoices", component: Invoices },
|
||||
{ path: "/estimates", component: Estimates },
|
||||
{ path: "/estimate", component: Estimate },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user