add table actions to datatable, client page, start writing db method for clients

This commit is contained in:
Casey 2025-11-11 09:50:23 -06:00
parent a67e86af44
commit df1df3f882
9 changed files with 1844 additions and 194 deletions

View file

@ -7,18 +7,16 @@ const FRAPPE_UPSERT_ESTIMATE_METHOD = "custom_ui.api.db.upsert_estimate";
const FRAPPE_UPSERT_JOB_METHOD = "custom_ui.api.db.upsert_job";
const FRAPPE_UPSERT_INVOICE_METHOD = "custom_ui.api.db.upsert_invoice";
const FRAPPE_GET_CLIENT_STATUS_COUNTS_METHOD = "custom_ui.api.db.get_client_status_counts";
const FRAPPE_GET_CLIENT_TABLE_DATA_METHOD = "custom_ui.api.db.get_clients_table_data";
const FRAPPE_GET_CLIENT_METHOD = "custom_ui.api.db.get_client";
class Api {
static async request(frappeMethod, args = {}) {
args = DataUtils.toSnakeCaseObject(args);
console.log("DEBUG: API - Request Args: ", { method: frappeMethod, args });
const request = { method: frappeMethod, args };
console.log("DEBUG: API - Request Args: ", request);
try {
let response = await frappe.call({
method: frappeMethod,
args: {
...args,
},
});
let response = await frappe.call(request);
response = DataUtils.toCamelCaseObject(response);
console.log("DEBUG: API - Request Response: ", response);
return response.message;
@ -33,8 +31,8 @@ class Api {
return await this.request(FRAPPE_GET_CLIENT_STATUS_COUNTS_METHOD, params);
}
static async getClientDetails(options = {}) {
return await this.request("custom_ui.api.db.get_clients", { options });
static async getClientDetails(clientName) {
return await this.request(FRAPPE_GET_CLIENT_DETAILS_METHOD);
}
static async getJobDetails() {
@ -51,13 +49,11 @@ class Api {
};
data.push(tableRow);
}
console.log("DEBUG: API - getJobDetails result: ", data);
return data;
}
static async getServiceData() {
const data = DataUtils.dummyServiceData;
console.log("DEBUG: API - getServiceData result: ", data);
return data;
}
@ -69,8 +65,6 @@ class Api {
route = getDetailedDoc("Pre-Built Routes", rt.name);
let tableRow = {};
}
console.log("DEBUG: API - getRouteData result: ", data);
return data;
}
@ -102,6 +96,10 @@ class Api {
return data;
}
static async getClient(clientName) {
return await this.request(FRAPPE_GET_CLIENT_METHOD, { clientName });
}
/**
* Get paginated client data with filtering and sorting
* @param {Object} paginationParams - Pagination parameters from store
@ -126,10 +124,7 @@ class Api {
: null,
for_table: true,
};
console.log("DEBUG: API - Sending options to backend:", options);
const result = await this.request("custom_ui.api.db.get_clients", { options });
const result = await this.request(FRAPPE_GET_CLIENT_TABLE_DATA_METHOD, { options });
return result;
}