chore: fix Select dropdowns - load options from Settings via JS
This commit is contained in:
parent
df81309281
commit
7243188e97
4 changed files with 56 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Service Factory — ERPNext Custom App Project
|
||||
|
||||
> **Current Version: V0.1.0016** — Each completed prompt/step increments the patch number by 1 (V0.1.0000 → V0.1.0001 → V0.1.0002…). The agent automatically commits and pushes after every step.
|
||||
> **Current Version: V0.1.0017** — Each completed prompt/step increments the patch number by 1 (V0.1.0000 → V0.1.0001 → V0.1.0002…). The agent automatically commits and pushes after every step.
|
||||
|
||||
## Project Overview
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
frappe.ui.form.on("Engagement Card", {
|
||||
refresh: function (frm) {
|
||||
// Load dynamic options from Settings
|
||||
load_options(frm);
|
||||
|
||||
// Quick status actions
|
||||
if (frm.doc.status === "Discovery") {
|
||||
frm.add_custom_button(__("Move to Delivery"), function () {
|
||||
|
|
@ -63,6 +66,45 @@ frappe.ui.form.on("Engagement Card", {
|
|||
},
|
||||
});
|
||||
|
||||
function load_options(frm) {
|
||||
// Fetch task options from Settings
|
||||
frappe.call({
|
||||
method: "frappe.client.get_single_value",
|
||||
args: {
|
||||
doctype: "Service Factory Settings",
|
||||
},
|
||||
callback: function (r) {
|
||||
if (!r.message) return;
|
||||
|
||||
// Get task types - need full doc for table fields
|
||||
frappe.call({
|
||||
method: "frappe.client.get",
|
||||
args: {
|
||||
doctype: "Service Factory Settings",
|
||||
name: "Service Factory Settings",
|
||||
},
|
||||
callback: function (resp) {
|
||||
let doc = resp.message;
|
||||
if (doc.task_types) {
|
||||
let task_options = doc.task_types
|
||||
.map((t) => t.task_type_name)
|
||||
.join("\n");
|
||||
frm.set_df_property("task", "options", "\n" + task_options);
|
||||
frm.refresh_field("task");
|
||||
}
|
||||
if (doc.teams) {
|
||||
let team_options = doc.teams
|
||||
.map((t) => t.team_name)
|
||||
.join("\n");
|
||||
frm.set_df_property("team", "options", "\n" + team_options);
|
||||
frm.refresh_field("team");
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Time log rollup
|
||||
frappe.ui.form.on("Engagement Card Time Log", {
|
||||
hours: function (frm) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Task",
|
||||
"options": "service_factory.service_factory.doctype.service_factory_settings.service_factory_settings.get_task_type_options",
|
||||
"options": "",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
|
|
@ -112,7 +112,7 @@
|
|||
"fieldname": "team",
|
||||
"fieldtype": "Select",
|
||||
"label": "Team",
|
||||
"options": "service_factory.service_factory.doctype.service_factory_settings.service_factory_settings.get_team_options"
|
||||
"options": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_desc",
|
||||
|
|
|
|||
|
|
@ -83,6 +83,17 @@ class EngagementCard(Document):
|
|||
assignment.logged_hours = employee_hours[emp]
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_options_for(fieldname):
|
||||
"""Return dynamic options for Select fields on Engagement Card."""
|
||||
settings = frappe.get_single("Service Factory Settings")
|
||||
if fieldname == "task":
|
||||
return [r.task_type_name for r in settings.task_types]
|
||||
elif fieldname == "team":
|
||||
return [r.team_name for r in settings.teams]
|
||||
return []
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_kpi_data():
|
||||
"""Return dashboard KPI data for Engagement Cards."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue