Mobile Layout: neue Layouts für Login, Menü, Stylesheet + Menüdatei
authorSven Schöling <s.schoeling@googlemail.com>
Wed, 20 Jan 2021 10:10:31 +0000 (11:10 +0100)
committerSven Schöling <s.schoeling@googlemail.com>
Fri, 25 Jun 2021 13:51:32 +0000 (15:51 +0200)
Menü zeigt aus Platzgründen nur Top-Level Einträge in der menu.yml an.

SL/Layout/Dispatcher.pm
SL/Layout/Material.pm [new file with mode: 0644]
SL/Layout/MaterialMenu.pm [new file with mode: 0644]
SL/Layout/MaterialStyle.pm [new file with mode: 0644]
SL/Layout/MobileLogin.pm [new file with mode: 0644]
menus/mobile/00-erp.yaml [new file with mode: 0644]
templates/webpages/menu/material.html [new file with mode: 0644]

index fa63337..4d0345c 100644 (file)
@@ -8,6 +8,8 @@ use SL::Layout::Login;
 use SL::Layout::Classic;
 use SL::Layout::V3;
 use SL::Layout::Javascript;
+use SL::Layout::Material;
+use SL::Layout::MobileLogin;
 
 sub new {
   my ($class, %params) = @_;
@@ -18,6 +20,8 @@ sub new {
   return SL::Layout::Admin->new      if $params{style} eq 'admin';
   return SL::Layout::AdminLogin->new if $params{style} eq 'admin_login';
   return SL::Layout::Login->new      if $params{style} eq 'login';
+  return SL::Layout::Material->new   if $params{style} eq 'mobile';
+  return SL::Layout::MobileLogin->new if $params{style} eq 'mobile_login';
   return SL::Layout::None->new;
 }
 
diff --git a/SL/Layout/Material.pm b/SL/Layout/Material.pm
new file mode 100644 (file)
index 0000000..c683172
--- /dev/null
@@ -0,0 +1,25 @@
+package SL::Layout::Material;
+
+use strict;
+use parent qw(SL::Layout::Base);
+
+use SL::Layout::None;
+use SL::Layout::MaterialMenu;
+use SL::Layout::MaterialStyle;
+use SL::Layout::Content;
+
+sub get_stylesheet_for_user {
+  # overwrite kivitendo fallback
+  'css/material';
+}
+
+sub init_sub_layouts {
+  [
+    SL::Layout::None->new,
+    SL::Layout::MaterialStyle->new,
+    SL::Layout::MaterialMenu->new,
+    SL::Layout::Content->new,
+  ]
+}
+
+1;
diff --git a/SL/Layout/MaterialMenu.pm b/SL/Layout/MaterialMenu.pm
new file mode 100644 (file)
index 0000000..4ae4da3
--- /dev/null
@@ -0,0 +1,16 @@
+package SL::Layout::MaterialMenu;
+
+use strict;
+use parent qw(SL::Layout::Base);
+use SL::Menu;
+use SL::Controller::Base;
+
+sub init_menu {
+  SL::Menu->new('mobile');
+}
+
+sub pre_content {
+  $_[0]->presenter->render('menu/material', menu => $_[0]->menu, C => SL::Controller::Base->new);
+}
+
+1;
diff --git a/SL/Layout/MaterialStyle.pm b/SL/Layout/MaterialStyle.pm
new file mode 100644 (file)
index 0000000..bb224ad
--- /dev/null
@@ -0,0 +1,24 @@
+package SL::Layout::MaterialStyle;
+
+use strict;
+use parent qw(SL::Layout::Base);
+
+sub use_stylesheet {
+  "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css",
+  "https://fonts.googleapis.com/icon?family=Material+Icons";
+}
+
+sub use_javascript {
+  "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js";
+}
+
+sub javascripts_inline {
+  "M.AutoInit();";
+}
+
+sub get_stylesheet_for_user {
+  # overwrite kivitendo fallback
+  'css/material';
+}
+
+1;
diff --git a/SL/Layout/MobileLogin.pm b/SL/Layout/MobileLogin.pm
new file mode 100644 (file)
index 0000000..91a010e
--- /dev/null
@@ -0,0 +1,21 @@
+package SL::Layout::MobileLogin;
+
+use strict;
+use parent qw(SL::Layout::Base);
+use SL::Layout::MaterialStyle;
+use SL::Layout::MaterialMenu;
+
+sub get_stylesheet_for_user {
+  # overwrite kivitendo fallback
+  'css/material';
+}
+
+sub init_sub_layouts {
+  [
+    SL::Layout::None->new,
+    SL::Layout::MaterialStyle->new,
+    SL::Layout::MaterialMenu->new,
+  ]
+}
+
+1;
diff --git a/menus/mobile/00-erp.yaml b/menus/mobile/00-erp.yaml
new file mode 100644 (file)
index 0000000..ab19733
--- /dev/null
@@ -0,0 +1,38 @@
+# This is the main menu config file for mobile user space menu entries.
+#
+# Th structure is the same as in user/, but currently infinite nesting is not supported.
+#
+---
+- id: test_entry
+  name: Test
+  icon: test
+  order: 100
+  access: customer_vendor_edit|customer_vendor_all_edit
+  params:
+    action: CustomerVendor/add
+    db: customer
+- id: warehouse_produce_assembly
+  name: Produce Assembly
+  icon: assembly_produce
+  order: 200
+  access: warehouse_management
+  module: wh.pl
+  params:
+    action: transfer_warehouse_selection
+    trans_type: assembly
+- id: warehouse_transfer
+  name: Transfer
+  order: 300
+  access: warehouse_management
+  module: wh.pl
+  params:
+    action: transfer_warehouse_selection
+    trans_type: transfer
+- id: warehouse_removal
+  name: Removal
+  order: 400
+  access: warehouse_management
+  module: wh.pl
+  params:
+    action: transfer_warehouse_selection
+    trans_type: removal
diff --git a/templates/webpages/menu/material.html b/templates/webpages/menu/material.html
new file mode 100644 (file)
index 0000000..8650cfa
--- /dev/null
@@ -0,0 +1,39 @@
+[%- USE T8 %]
+[%- USE L %]
+[%- USE HTML %]
+[%- USE LxERP -%]
+<nav>
+  <div class="nav-wrapper">
+    <a class="brand-logo">Kivitendo</a>
+    <a href="#" data-target="nav-mobile" class="sidenav-trigger"><i class="material-icons">menu</i></a>
+    <ul id="nav" class="right hide-on-med-and-down">
+      [% PROCESS menu_items %]
+    </ul>
+  </div>
+</nav>
+
+<ul id="nav-mobile" class="sidenav">
+  [% PROCESS menu_items %]
+</ul>
+
+
+[%- BLOCK menu_items %]
+ [%- IF MYCONFIG.login %]
+  <li><a>[% 'User' | $T8 %]: [% MYCONFIG.login | html %]</a></li>
+ [%- ELSE %]
+  <li>[% L.link(C.url_for(controller='LoginScreen', action='user_login'), LxERP.t8('Login')) %]</li>
+ [%- END %]
+
+  <li><div class="divider"></div></li>
+
+  [%- FOREACH node = menu.tree %]
+    [%- NEXT UNLESS node.visible %]
+    <li>[% L.link(menu.href_for_node(node) || '#', menu.name_for_node(node), target=node.target) %]</li>
+  [%- END %]
+
+  <li><div class="divider"></div></li>
+
+ [%- IF MYCONFIG.login %]
+  <li>[% L.link(C.url_for(controller='LoginScreen', action='logout'), LxERP.t8('Logout')) %]</li>
+ [%- END %]
+[% END %]