Browse Source

CP main menu modules

Vova Tkach 6 years ago
parent
commit
3e79541677
2 changed files with 32 additions and 2 deletions
  1. 19 2
      modules/module_index.go
  2. 13 0
      modules/modules.go

+ 19 - 2
modules/module_index.go

@@ -36,8 +36,25 @@ func (this *Modules) RegisterModule_Index() *Module {
 		})
 	}, func(wrap *wrapper.Wrapper) {
 		// Back-end
+
+		//page_sb_left := mdl.GetSidebarLeft()
+		//nav_bar_modules_all := mdl.GetNavMenuModules()
+		//nav_bar_modules_sys := mdl.GetNavMenuModulesSys()
+		// If right sidebar and content need to show
+		/*
+			if page_sb_left != "" {
+				body_class = body_class + " cp-sidebar-left"
+			}
+			if page_content == "" {
+				body_class = body_class + " cp-404"
+				page_content = "Panel 404"
+			}
+			if page_sb_right != "" {
+				body_class = body_class + " cp-sidebar-right"
+			}
+		*/
+
 		body_class := "cp"
-		nav_bar_modules_all := ""
 		nav_bar_modules_sys := ""
 		page_sb_left := "Left"
 		page_content := "Content"
@@ -52,7 +69,7 @@ func (this *Modules) RegisterModule_Index() *Module {
 			UserEmail:          wrap.User.A_email,
 			UserPassword:       "",
 			UserAvatarLink:     "https://s.gravatar.com/avatar/" + utils.GetMd5(wrap.User.A_email) + "?s=80&r=g",
-			NavBarModules:      template.HTML(nav_bar_modules_all),
+			NavBarModules:      template.HTML(this.getNavMenuModules(wrap)),
 			NavBarModulesSys:   template.HTML(nav_bar_modules_sys),
 			ModuleCurrentAlias: "index",
 			SidebarLeft:        template.HTML(page_sb_left),

+ 13 - 0
modules/modules.go

@@ -104,6 +104,19 @@ func (this *Modules) getCurrentModule(wrap *wrapper.Wrapper, backend bool) (*Mod
 	return mod, modCurr
 }
 
+// TODO: add module ordering
+func (this *Modules) getNavMenuModules(wrap *wrapper.Wrapper) string {
+	html := ""
+	for _, mod := range this.mods {
+		class := ""
+		if mod.Info.Mount == wrap.CurrModule {
+			class = " active"
+		}
+		html += `<a class="dropdown-item` + class + `" href="/cp/` + mod.Info.Mount + `/">` + mod.Info.Name + `</a>`
+	}
+	return html
+}
+
 func New() *Modules {
 	m := Modules{
 		mods: map[string]*Module{},