Browse Source

NavBar modules list

Vova Tkach 6 years ago
parent
commit
d688c1f47c

+ 5 - 2
engine/backend/backend.go

@@ -29,6 +29,7 @@ type TmplData struct {
 	UserEmail          string
 	UserPassword       string
 	UserAvatarLink     string
+	NavBarModules      template.HTML
 	ModuleCurrentAlias string
 	SidebarLeft        template.HTML
 	Content            template.HTML
@@ -70,16 +71,17 @@ func (this *Backend) Run() bool {
 	body_class := "cp"
 
 	// Get module content here
-	page_sb_left := ""
 	page_content := ""
 	page_sb_right := ""
 
 	mdl := modules.New(this.wrapper, this.db, this.user, this.urls)
+	page_sb_left := mdl.GetSidebarLeft()
+	nav_bar_modules := mdl.GetNavMenuModules()
+
 	if mdl.Run() {
 		page_content = mdl.GetContent()
 		page_sb_right = mdl.GetSidebarRight()
 	}
-	page_sb_left = mdl.GetSidebarLeft()
 
 	// If right sidebar and content need to show
 	if page_sb_left != "" {
@@ -111,6 +113,7 @@ func (this *Backend) Run() bool {
 			UserEmail:          this.user.A_email,
 			UserPassword:       "",
 			UserAvatarLink:     "https://s.gravatar.com/avatar/" + utils.GetMd5(this.user.A_email) + "?s=80&r=g",
+			NavBarModules:      template.HTML(nav_bar_modules),
 			ModuleCurrentAlias: malias,
 			SidebarLeft:        template.HTML(page_sb_left),
 			Content:            template.HTML(page_content),

+ 18 - 1
engine/backend/modules/modules.go

@@ -90,7 +90,24 @@ func (this *Module) Run() bool {
 }
 
 func (this *Module) GetNavMenuModules() string {
-	return ""
+	html := ""
+	aType := reflect.TypeOf(this)
+	for i := 0; i < aType.NumMethod(); i++ {
+		aMethod := aType.Method(i)
+		if strings.HasPrefix(aMethod.Name, "Module_") && strings.HasSuffix(aMethod.Name, "_alias") {
+			// Extract module alias
+			alias := aMethod.Name[7:][:5]
+			if this.module_get_display(alias) {
+				// Item active class
+				class := ""
+				if alias == this.mmod {
+					class = " active"
+				}
+				html += `<a class="dropdown-item` + class + `" href="/cp/` + alias + `/">` + this.module_get_name(alias) + `</a>`
+			}
+		}
+	}
+	return html
 }
 
 func (this *Module) GetSidebarLeft() string {

File diff suppressed because it is too large
+ 0 - 0
engine/wrapper/resources/templates/cp.base.go


+ 1 - 1
engine/wrapper/resources/templates/cp.base.html

@@ -62,7 +62,7 @@
 							Modules
 						</a>
 						<div class="dropdown-menu" aria-labelledby="nbModulesDropdown">
-							<a class="dropdown-item active" href="/cp/">Pages</a>
+							{{$.Data.NavBarModules}}
 						</div>
 					</li>
 					<li class="nav-item dropdown">

Some files were not shown because too many files changed in this diff