mvc/view: Create layout_partials/base_apply_button to centralize design of the standard Apply button (#8297)

* mvc/view: Create layout_partials/base_apply_button to centralize design of the standard Apply button

* dhcp/kea: Example implementation of layout_partials/base_apply_button

* mvc/view: Change edit_alert_id to global static default, add data-grid-reload and dynamic ids to base_apply_button partial
This commit is contained in:
Monviech 2025-02-10 16:57:52 +01:00 committed by GitHub
parent 769fa742f7
commit 24a61420cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 29 additions and 21 deletions

1
plist
View File

@ -975,6 +975,7 @@
/usr/local/opnsense/mvc/app/views/OPNsense/Unbound/stats.volt
/usr/local/opnsense/mvc/app/views/OPNsense/Wireguard/diagnostics.volt
/usr/local/opnsense/mvc/app/views/OPNsense/Wireguard/general.volt
/usr/local/opnsense/mvc/app/views/layout_partials/base_apply_button.volt
/usr/local/opnsense/mvc/app/views/layout_partials/base_bootgrid_table.volt
/usr/local/opnsense/mvc/app/views/layout_partials/base_dialog.volt
/usr/local/opnsense/mvc/app/views/layout_partials/base_dialog_processing.volt

View File

@ -290,7 +290,7 @@ class ControllerBase extends ControllerRoot
return [
'table_id' => $basename,
'edit_dialog_id' => 'dialog_' . $basename,
'edit_alert_id' => $edit_alert_id == null ? 'change_message_' . $basename : $edit_alert_id,
'edit_alert_id' => $edit_alert_id == null ? 'change_message_base_form' : $edit_alert_id,
'fields' => array_values($all_data)
];
}

View File

@ -52,13 +52,13 @@ class DhcpController extends \OPNsense\Base\IndexController
$this->view->formGeneralSettings = $this->getForm("generalSettings4");
$this->view->formDialogSubnet = $this->getForm("dialogSubnet4");
$this->view->formGridSubnet = $this->getFormGrid("dialogSubnet4", null, "keaChangeMessage");
$this->view->formGridSubnet = $this->getFormGrid("dialogSubnet4");
$this->view->formDialogReservation = $this->getForm("dialogReservation4");
$this->view->formGridReservation = $this->getFormGrid("dialogReservation4", null, "keaChangeMessage");
$this->view->formGridReservation = $this->getFormGrid("dialogReservation4");
$this->view->formDialogPeer = $this->getForm("dialogPeer4");
$this->view->formGridPeer = $this->getFormGrid("dialogPeer4", null, "keaChangeMessage");
$this->view->formGridPeer = $this->getFormGrid("dialogPeer4");
}
public function leases4Action()

View File

@ -158,23 +158,7 @@
</div>
</div>
<section class="page-content-main">
<div class="content-box">
<div class="col-md-12">
<br/>
<div id="keaChangeMessage" class="alert alert-info" style="display: none" role="alert">
{{ lang._('After changing settings, please remember to apply them.') }}
</div>
<button class="btn btn-primary" id="reconfigureAct"
data-endpoint='/api/kea/service/reconfigure'
data-label="{{ lang._('Apply') }}"
data-error-title="{{ lang._('Error reconfiguring DHCPv4') }}"
type="button"
></button>
<br/><br/>
</div>
</div>
</section>
{{ partial('layout_partials/base_apply_button', {'data_endpoint': '/api/kea/service/reconfigure'}) }}
{{ partial("layout_partials/base_dialog",['fields':formDialogSubnet,'id':formGridSubnet['edit_dialog_id'],'label':lang._('Edit Subnet')])}}
{{ partial("layout_partials/base_dialog",['fields':formDialogReservation,'id':formGridReservation['edit_dialog_id'],'label':lang._('Edit Reservation')])}}

View File

@ -0,0 +1,23 @@
<section class="page-content-main">
<div class="content-box">
<div class="col-md-12">
<br/>
<div id="{{ message_id|default('change_message_base_form') }}" class="alert alert-info" style="display: none" role="alert">
{{ lang._('After changing settings, please remember to apply them.') }}
</div>
<button class="btn btn-primary" id="{{ button_id|default('reconfigureAct') }}"
data-endpoint="{{ data_endpoint }}"
data-label="{{ lang._(data_label|default('Apply')) }}"
data-error-title="{{ lang._(data_error_title|default('Error reconfiguring service.')) }}"
{% if data_service_widget %}
data-service-widget="{{ data_service_widget }}"
{% endif %}
{% if data_grid_reload %}
data-grid-reload="{{ data_grid_reload }}"
{% endif %}
type="button">
</button>
<br/><br/>
</div>
</div>
</section>