sub action_list {
my ($self) = @_;
+ $self->setup_list_action_bar;
$self->render('simple_system_setting/list', title => $self->config->{titles}->{list});
}
my $sub_form_template = SL::System::Process->exe_dir . '/templates/webpages/simple_system_setting/_' . $self->type . '_form.html';
+ $self->setup_render_form_action_bar;
$self->render(
'simple_system_setting/form',
%params,
$self->{dateformats} = [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ];
}
+#
+# action bar
+#
+
+sub setup_list_action_bar {
+ my ($self, %params) = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ link => [
+ t8('Add'),
+ link => $self->url_for(action => 'new', type => $self->type),
+ ],
+ );
+ }
+}
+
+sub setup_render_form_action_bar {
+ my ($self) = @_;
+
+ my $is_new = !$self->object->id;
+ my $can_be_deleted = !$is_new
+ && (!$self->object->can("orphaned") || $self->object->orphaned)
+ && (!$self->object->can("can_be_deleted") || $self->object->can_be_deleted);
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => 'SimpleSystemSetting/' . ($is_new ? 'create' : 'update') } ],
+ checks => [ 'kivi.validate_form' ],
+ accesskey => 'enter',
+ ],
+
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => 'SimpleSystemSetting/delete' } ],
+ confirm => t8('Do you really want to delete this object?'),
+ disabled => $is_new ? t8('This object has not been saved yet.')
+ : !$can_be_deleted ? t8('The object is in use and cannot be deleted.')
+ : undef,
+ ],
+
+ link => [
+ t8('Abort'),
+ link => $self->list_url,
+ ],
+ );
+ }
+}
+
1;
__END__
[%- SET sub_file = "simple_system_setting/_" _ sub_form_template _ "_form.html";
INCLUDE $sub_file %]
-
- <p>
- [% L.hidden_tag("action", "SimpleSystemSetting/dispatch") %]
- [% L.submit_tag("action_" _ (SELF.object.id ? "update" : "create"), LxERP.t8("Save"), onclick="return kivi.validate_form('#form');") %]
- [%- IF SELF.object.id && (!SELF.object.can("orphaned") || SELF.object.orphaned) && (!SELF.object.can("can_be_deleted") || SELF.object.can_be_deleted) -%]
- [% L.submit_tag("action_delete", LxERP.t8("Delete"), confirm=LxERP.t8("Do you really want to delete this object?")) %]
- [%- END %]
- <a href="[% SELF.list_url %]">[%- LxERP.t8("Cancel") %]</a>
- </p>
</form>