Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions buzz/api/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from frappe.utils.data import cstr, sbool

LAYOUT_FIELDTYPES = set(display_fieldtypes)
LAYOUT_BREAK_FIELDTYPES = {"Column Break", "Section Break"}

EVENT_PROPOSAL_EXCLUDE_FIELDS = DEFAULT_FIELDS | {
"naming_series",
Expand Down Expand Up @@ -49,13 +50,21 @@ def _get_dial_codes() -> list:
return codes


def get_form_fields(doctype: str, exclude_fields: set) -> list:
def get_form_fields(doctype: str, exclude_fields: set, with_layout_breaks: bool = False) -> list:
meta = frappe.get_meta(doctype)
fields = []
for df in meta.fields:
if df.fieldname in exclude_fields:
continue
if df.fieldtype in LAYOUT_FIELDTYPES:
if with_layout_breaks and df.fieldtype in LAYOUT_BREAK_FIELDTYPES:
fields.append(
{
"fieldname": df.fieldname,
"fieldtype": df.fieldtype,
"label": df.label or "",
}
)
continue
if df.hidden:
continue
Expand Down Expand Up @@ -306,7 +315,7 @@ def validate_event_proposal_settings():
@frappe.whitelist(allow_guest=True) # nosemgrep: frappe-semgrep-rules.rules.security.guest-whitelisted-method
def get_event_proposal_form_data() -> dict:
settings = validate_event_proposal_settings()
form_fields = get_form_fields("Event Proposal", EVENT_PROPOSAL_EXCLUDE_FIELDS)
form_fields = get_form_fields("Event Proposal", EVENT_PROPOSAL_EXCLUDE_FIELDS, with_layout_breaks=True)

return {
"form_fields": form_fields,
Expand Down
11 changes: 3 additions & 8 deletions buzz/proposals/doctype/event_proposal/event_proposal.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"engine": "InnoDB",
"field_order": [
"title",
"category",
"free_webinar",
"medium",
"column_break_bixo",
"category",
"medium",
"status",
"naming_series",
"section_break_psfj",
Expand All @@ -21,7 +21,6 @@
"end_time",
"section_break_zajc",
"short_description",
"column_break_yxbj",
"about",
"host_tab",
"host",
Expand Down Expand Up @@ -128,10 +127,6 @@
"label": "About the event",
"reqd": 1
},
{
"fieldname": "column_break_yxbj",
"fieldtype": "Column Break"
},
{
"fieldname": "short_description",
"fieldtype": "Small Text",
Expand Down Expand Up @@ -178,7 +173,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2025-12-11 11:36:40.618179",
"modified": "2026-05-11 07:52:43.388259",
"modified_by": "Administrator",
"module": "Proposals",
"name": "Event Proposal",
Expand Down
55 changes: 47 additions & 8 deletions dashboard/src/pages/EventProposalForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,29 @@
</h1>
</div>

<div class="p-6 space-y-4">
<CustomFieldInput
v-for="field in form_data.form_fields"
:key="field.fieldname"
:field="{ ...field, mandatory: field.reqd }"
:model-value="form_values[field.fieldname]"
@update:model-value="form_values[field.fieldname] = $event"
/>
<div class="p-6 space-y-6">
<div
v-for="(section, section_index) in field_sections"
:key="section_index"
class="grid gap-4"
:style="{
gridTemplateColumns: `repeat(${section.length}, minmax(0, 1fr))`,
}"
>
<div
v-for="(column, column_index) in section"
:key="column_index"
class="space-y-4"
>
<CustomFieldInput
v-for="field in column"
:key="field.fieldname"
:field="{ ...field, mandatory: field.reqd }"
:model-value="form_values[field.fieldname]"
@update:model-value="form_values[field.fieldname] = $event"
/>
</div>
</div>
</div>

<div class="px-6 pb-6">
Expand Down Expand Up @@ -96,6 +111,30 @@ const rendered_success_message = computed(() => {
return marked(msg);
});

const field_sections = computed(() => {
const fields = form_data.value?.form_fields || [];
const sections = [];
let current_section = [[]];
for (const field of fields) {
if (field.fieldtype === "Section Break") {
if (current_section.some((col) => col.length)) {
sections.push(current_section);
}
current_section = [[]];
continue;
}
if (field.fieldtype === "Column Break") {
current_section.push([]);
continue;
}
current_section[current_section.length - 1].push(field);
}
if (current_section.some((col) => col.length)) {
sections.push(current_section);
}
return sections;
});

const form_data_resource = createResource({
url: "buzz.api.forms.get_event_proposal_form_data",
auto: true,
Expand Down
Loading