resolves Add Requestor field to Prayer/Alms requests

Fixes #108
This commit is contained in:
meichthys 2026-02-20 06:00:32 +00:00
parent eca9e7da01
commit f355cc4f57
3 changed files with 59 additions and 24 deletions

View File

@ -2,6 +2,12 @@
// For license information, please see license.txt
frappe.ui.form.on('Church Alms Request', {
recipient_type: function(frm) {
// Dynamically update the Recipient field description based on the Recipient Type that is selected
if (frm.doc.recipient_type) {
frm.set_df_property('recipient', 'description', `Alms are requested for this ${frm.doc.recipient_type}.`);
}
},
refresh(frm) {
// Add a custom button that creates an Expense from the Alms Request
if (!frm.is_new()) {
@ -18,6 +24,17 @@ frappe.ui.form.on('Church Alms Request', {
});
}
},
onload: function(frm) {
// Pre-populate the requestor field with the current user's name
if (frm.is_new()) {
frappe.db.get_value('Church Person', {'portal_user': frappe.session.user}, 'name')
.then(r => {
if (r && r.message) {
frm.set_value('requestor', r.message.name);
}
});
}
}
});

View File

@ -1,8 +1,16 @@
// Copyright (c) 2025, meichthys and contributors
// For license information, please see license.txt
// frappe.ui.form.on("Church Prayer Request", {
// refresh(frm) {
// },
// });
frappe.ui.form.on('Church Prayer Request', {
onload: function(frm) {
// Pre-populate the requestor field with the current user's name
if (frm.is_new()) {
frappe.db.get_value('Church Person', {'portal_user': frappe.session.user}, 'name')
.then(r => {
if (r && r.message) {
frm.set_value('requestor', r.message.name);
}
});
}
}
});

View File

@ -10,11 +10,12 @@
"field_order": [
"status",
"type",
"is_private",
"column_break_ynvf",
"related_person",
"requestor",
"recipient",
"section_break_usaz",
"request",
"is_private"
"request"
],
"fields": [
{
@ -35,19 +36,6 @@
"fieldtype": "Column Break",
"placeholder": "If this request is for a specific person, select/add the person here."
},
{
"allow_in_quick_entry": 1,
"description": "If this request is for a specific person, select/add the person here.",
"fieldname": "related_person",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 1,
"in_preview": 1,
"in_standard_filter": 1,
"label": "Related Person",
"options": "Church Person",
"search_index": 1
},
{
"fieldname": "section_break_usaz",
"fieldtype": "Section Break"
@ -84,6 +72,29 @@
"label": "Type",
"options": "Church Prayer Request Type",
"reqd": 1
},
{
"description": "The person who made the request.",
"fieldname": "requestor",
"fieldtype": "Link",
"in_filter": 1,
"in_preview": 1,
"label": "Requestor",
"options": "Church Person",
"reqd": 1
},
{
"allow_in_quick_entry": 1,
"description": "The person for whom prayers will be prayed.",
"fieldname": "recipient",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 1,
"in_preview": 1,
"in_standard_filter": 1,
"label": "Recipient",
"options": "Church Person",
"search_index": 1
}
],
"grid_page_length": 50,
@ -94,7 +105,7 @@
"table_fieldname": "topics"
}
],
"modified": "2025-11-15 00:58:11.484183",
"modified": "2026-02-19 23:26:19.972696",
"modified_by": "Administrator",
"module": "Church Prayers",
"name": "Church Prayer Request",
@ -141,9 +152,8 @@
"write": 1
}
],
"quick_entry": 1,
"row_format": "Dynamic",
"search_fields": "status,type,related_person",
"search_fields": "status,type,recipient",
"show_preview_popup": 1,
"show_title_field_in_link": 1,
"sort_field": "modified",