zet-lib 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/zAppRouter.js CHANGED
@@ -622,7 +622,7 @@ router.get("/layout_changes/:layout", access, async (req, res) => {
622
622
  req.session.user.layout = selectedLayout;
623
623
  }
624
624
  res.locals.layout = selectedLayout;
625
- global.layout = selectedLayout;
625
+ ///global.layout = selectedLayout;
626
626
  } catch (err) {
627
627
  debug(req, res, err);
628
628
  }
package/lib/zapp.js CHANGED
@@ -33,7 +33,6 @@ module.exports = (req,res,next) => {
33
33
  res.locals.backend_layouts = [];
34
34
  res.locals.isLogin = false;
35
35
  res.locals.objectStores = {};
36
- global.layout = "backend";
37
36
  if (req.session) {
38
37
  let reqSession = req.session;
39
38
  if (reqSession.hasOwnProperty('user')) {
@@ -48,6 +47,7 @@ module.exports = (req,res,next) => {
48
47
  res.locals.companyId = tUser.company.id;
49
48
  res.locals.userAvatar = tUser.image ? tUser.image.indexOf("http") > -1 ? tUser.image : "/uploads/zuser/" + tUser.image : "/img/user.png";
50
49
  res.locals.zcompanies = tUser.companies;
50
+ res.locals.zcompany = tUser.company;
51
51
  if(tUser.language){
52
52
  let objLanguage = {
53
53
  1 : "lang_en",
@@ -69,6 +69,25 @@ module.exports = (req,res,next) => {
69
69
  global.USER_ID = res.locals.userId;
70
70
  res.locals.LANGUAGE = global.LANGUAGE;
71
71
 
72
- next();
72
+ const path = req.route && req.route.path ? req.route.path : req.path;
73
+
74
+ const MYMODELS = myCache.get("MYMODELS");
75
+ // Mapping manual per route
76
+ let map = {
77
+ '/dashboard': { title: 'Dashboard', subtitle: 'Systems' },
78
+ '/users': { title: 'Users', subtitle: 'List' },
79
+ '/users/new': { title: 'Users', subtitle: 'Create' },
80
+ };
81
+ for(let key in MYMODELS) {
82
+ map[`/${key}`] = {title : MYMODELS[key].name, subtitle:'List'}
83
+ map[`/${key}/create`] = {title : MYMODELS[key].name, subtitle:'Create'}
84
+ map[`/${key}/update`] = {title : MYMODELS[key].name, subtitle:'Update'}
85
+ map[`/${key}/view`] = {title : MYMODELS[key].name, subtitle:'View'}
86
+ }
87
+
88
+ const info = map[path] || {};
89
+ res.locals.pagetitle = info.title || 'Dashboard';
90
+ res.locals.pagesubtitle = info.subtitle || '';
73
91
 
74
- };
92
+ next();
93
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"