This commit is contained in:
2026-06-06 11:41:24 -04:00
parent d4aae96187
commit 01e984c560

View File

@@ -3,7 +3,7 @@
/**
* Association Profile — Management Renderer
* Operator-only. Called from assoc_profile.php content router.
* v0.2.0 — search, filter, paginate, bulk export, import with diff, delete.
* v0.3.0 — tabbed edit form; all other functions unchanged from v0.2.0.
*/
// ----------------------------------------------------------------------------
@@ -165,7 +165,7 @@ function assoc_render_add_association_form() {
}
// ----------------------------------------------------------------------------
// EDIT ASSOCIATION
// EDIT ASSOCIATION — tabbed by field group
// ----------------------------------------------------------------------------
function assoc_render_edit_association_form($slug) {
@@ -183,6 +183,15 @@ function assoc_render_edit_association_form($slug) {
$name = $entry['assoc_legal_name'] ?? $slug;
// Short tab labels — operator-defined groups map to shorter labels for tab nav
$tab_labels = [
'Identity' => 'Identity',
'Physical Structure' => 'Buildings',
'Governance and Management' => 'Governance',
'Legal and Compliance' => 'Compliance',
'Record' => 'Record',
];
$out = '<div class="assoc-manage">';
$out .= '<header class="civicinfra-manage-header">';
$out .= '<div>';
@@ -203,12 +212,39 @@ function assoc_render_edit_association_form($slug) {
$out .= '<input type="hidden" name="assoc_action" value="save_association">';
$out .= '<input type="hidden" name="assoc_slug" value="' . assoc_h($slug) . '">';
// Tab nav
$out .= '<ul class="nav nav-tabs assoc-edit-tabs mb-0" id="assocEditTabs" role="tablist">';
$first = true;
foreach ($groups as $group) {
$group_fields = $by_group[$group] ?? [];
if (empty($group_fields)) continue;
$tab_id = 'tab-' . preg_replace('/[^a-z0-9]/', '-', strtolower($group));
$label = $tab_labels[$group] ?? $group;
$active = $first ? 'active' : '';
$selected = $first ? 'true' : 'false';
$out .= '<li class="nav-item" role="presentation">';
$out .= '<button class="nav-link ' . $active . '" id="' . assoc_h($tab_id) . '-btn"
data-bs-toggle="tab"
data-bs-target="#' . assoc_h($tab_id) . '-pane"
type="button" role="tab"
aria-selected="' . $selected . '">'
. assoc_h($label) . '</button>';
$out .= '</li>';
$first = false;
}
$out .= '</ul>';
$out .= '<section class="civicinfra-form-section">';
$out .= '<h2 class="civicinfra-record-heading">' . assoc_h($group) . '</h2>';
// Tab panes
$out .= '<div class="tab-content assoc-edit-tab-content" id="assocEditTabContent">';
$first = true;
foreach ($groups as $group) {
$group_fields = $by_group[$group] ?? [];
if (empty($group_fields)) continue;
$tab_id = 'tab-' . preg_replace('/[^a-z0-9]/', '-', strtolower($group));
$active = $first ? 'show active' : '';
$out .= '<div class="tab-pane fade ' . $active . ' civicinfra-form-section assoc-tab-pane"'
. ' id="' . assoc_h($tab_id) . '-pane" role="tabpanel">';
foreach ($group_fields as $f) {
$nick = $f['nickname'];
@@ -239,30 +275,35 @@ function assoc_render_edit_association_form($slug) {
}
$out .= '</select>';
} else {
$width = in_array($nick, ['assoc_legal_name','assoc_street','assoc_cai_listing',
$wide = in_array($nick, ['assoc_legal_name','assoc_street','assoc_cai_listing',
'assoc_bbb_standing','assoc_idfpr_complaint',
'assoc_litigation_active','assoc_liens_active',
'assoc_mgmt_contact']) ? '100%' : '24rem';
'assoc_mgmt_contact']);
$out .= '<input type="text" class="form-control form-control-sm"
id="' . assoc_h($nick) . '" name="' . assoc_h($nick) . '"
value="' . assoc_h($val) . '"
style="max-width:' . $width . ';">';
value="' . assoc_h($val) . '"'
. ($wide ? '' : ' style="max-width:24rem;"') . '>';
}
$out .= '</div>';
}
$out .= '</section>';
}
$out .= '<div class="d-flex gap-2 mt-4">';
$out .= '</div>'; // tab-pane
$first = false;
}
$out .= '</div>'; // tab-content
// Save bar below tabs
$out .= '<div class="assoc-save-bar">';
$out .= '<button type="submit" class="btn btn-primary">Save</button> ';
$out .= '<a href="' . z_root() . '/assoc_profile/manage" class="btn btn-outline-secondary">Cancel</a>';
$out .= '</div></form>';
$out .= '</div>';
$out .= '</form>';
// Delete section
$out .= '<div class="assoc-delete-confirm">';
$out .= '<h5>Delete Association</h5>';
$out .= '<p class="civicinfra-help-text">This removes <strong>' . assoc_h($name) . '</strong> from the registry permanently. ';
$out .= 'You must also remove the corresponding entry from <code>vs01/config.json</code> manually.</p>';
$out .= '<p class="civicinfra-help-text">Permanently removes <strong>' . assoc_h($name) . '</strong> from the registry. ';
$out .= 'You must also remove the entry from <code>vs01/config.json</code> manually.</p>';
$out .= '<form method="post" action="' . z_root() . '/assoc_profile/manage"
onsubmit="return confirm(\'Permanently delete ' . addslashes(assoc_h($name)) . '? This cannot be undone.\')">';
$out .= assoc_csrf_token();