ActionBar: Verwendung bei »System« → »Benutzer«
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 24 Mar 2017 14:08:27 +0000 (15:08 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 24 Mar 2017 14:08:27 +0000 (15:08 +0100)
SL/Controller/Employee.pm
templates/webpages/employee/_form.html [deleted file]
templates/webpages/employee/edit.html

index 265d1db..6792272 100644 (file)
@@ -5,6 +5,7 @@ use parent qw(SL::Controller::Base);
 
 use SL::DB::Employee;
 use SL::Helper::Flash;
+use SL::Locale::String qw(t8);
 
 __PACKAGE__->run_before('check_auth');
 __PACKAGE__->run_before('load_all');
@@ -23,9 +24,10 @@ sub action_edit {
   my ($self, %params) = @_;
 
   if ($self->{employee}) {
+    $self->setup_edit_action_bar;
     $self->render('employee/edit', title => $::locale->text('Edit Employee #1', $self->{employee}->safe_name));
   } else {
-    flash('error', $::locale->text('Could not load employee'));
+    flash_later('error', $::locale->text('Could not load employee'));
     $self->redirect_to(action => 'list');
   }
 }
@@ -35,7 +37,7 @@ sub action_save {
 
   $self->{employee}->save;
 
-  flash('info', $::locale->text('Employee #1 saved!'));
+  flash('info', $::locale->text('Employee #1 saved!', $self->{employee}->safe_name));
 
   $self->redirect_to(action => 'edit', 'employee.id' => $self->{employee}->id);
 }
@@ -63,6 +65,26 @@ sub assign_from_form {
   return 1;
 }
 
+sub setup_edit_action_bar {
+  my ($self) = @_;
+
+  for my $bar ($::request->layout->get('actionbar')) {
+    $bar->add(
+      action => [
+        t8('Save'),
+        submit    => [ '#form', { action => 'Employee/save' } ],
+        accesskey => 'enter',
+      ],
+
+      'separator',
+
+      link => [
+        t8('Abort'),
+        link => $self->url_for(action => 'list'),
+      ],
+    );
+  }
+}
 
 ######################## behaviour ##########################
 
diff --git a/templates/webpages/employee/_form.html b/templates/webpages/employee/_form.html
deleted file mode 100644 (file)
index 841cdc5..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-[%- USE HTML %]
-[%- USE LxERP %]
-[%- USE T8 %]
-[%- USE L %]
-
-<form action='controller.pl' method='POST'>
-
-<table>
-<tr>
- <td align='right' class=''>[% 'Login of User' | $T8 %]:</td>
- <td>[% employee.login | html %]</td>
-</tr>
-<tr>
- <td align='right'>[% 'Name' | $T8 %]:</td>
- <td>[% employee.name | html %]</td>
-</tr>
-<tr>
- <td align='right'>[% 'Deleted' | $T8 %]:</td>
- <td> [% L.radio_button_tag('employee.deleted', value=1, checked=employee.deleted, label=LxERP.t8('Yes')) %]
-      [% L.radio_button_tag('employee.deleted', value=0, checked=!employee.deleted, label=LxERP.t8('No')) %]
- </td>
-</tr>
-</table>
-
-[%- L.hidden_tag('employee.id', employee.id) %]
-[%- L.hidden_tag('action',  'Employee/dispatch')  %]
-[%- L.submit_tag('action_save',  LxERP.t8('Save'))  %]
-</form>
-
index d4b3ed8..63e6f5c 100644 (file)
@@ -1,9 +1,25 @@
-<h1>[% title | html %]</h1>
+[%- USE LxERP -%][%- USE L -%][%- USE T8 -%]<h1>[% title | html %]</h1>
 
-[% PROCESS 'common/flash.html' %]
+[% PROCESS "common/flash.html" %]
 
-[% PROCESS 'employee/_form.html' employee=SELF.employee %]
+<form action="controller.pl" method="POST" id="form">
 
-<hr>
+ <table>
+  <tr>
+   <td align="right" class="">[% "Login of User" | $T8 %]:</td>
+   <td>[% SELF.employee.login | html %]</td>
+  </tr>
+  <tr>
+   <td align="right">[% "Name" | $T8 %]:</td>
+   <td>[% SELF.employee.name | html %]</td>
+  </tr>
+  <tr>
+   <td align="right">[% "Deleted" | $T8 %]:</td>
+   <td> [% L.radio_button_tag("SELF.employee.deleted", value=1, checked=SELF.employee.deleted, label=LxERP.t8("Yes")) %]
+    [% L.radio_button_tag("SELF.employee.deleted", value=0, checked=!SELF.employee.deleted, label=LxERP.t8("No")) %]
+   </td>
+  </tr>
+ </table>
 
-[% PROCESS 'employee/_list.html' %]
+ [%- L.hidden_tag("employee.id", SELF.employee.id) %]
+</form>