Browse Source

Modules split add/modify

Vova Tkach 6 years ago
parent
commit
f8f902fa20
3 changed files with 25 additions and 20 deletions
  1. 4 3
      modules/module_index.go
  2. 4 3
      modules/module_users.go
  3. 17 14
      modules/modules.go

+ 4 - 3
modules/module_index.go

@@ -24,8 +24,9 @@ func (this *Modules) RegisterModule_Index() *Module {
 		Order:  0,
 		Icon:   assets.SysSvgIconPage,
 		Sub: &[]MISub{
-			{Mount: "default", Name: "List of Pages", Icon: assets.SysSvgIconList},
-			{Mount: "add", Name: "Add New Page", Icon: assets.SysSvgIconPlus},
+			{Mount: "default", Name: "List of Pages", Show: true, Icon: assets.SysSvgIconList},
+			{Mount: "add", Name: "Add New Page", Show: true, Icon: assets.SysSvgIconPlus},
+			{Mount: "modify", Name: "Modify page", Show: false},
 		},
 	}, func(wrap *wrapper.Wrapper) {
 		// Front-end
@@ -77,7 +78,7 @@ func (this *Modules) RegisterModule_Index() *Module {
 					assets.SysSvgIconEdit + `</a>` +
 					`<a class="ico" href="#">` + assets.SysSvgIconRemove + `</a>`
 			}, "/cp/"+wrap.CurrModule+"/")
-		} else if wrap.CurrSubModule == "add" {
+		} else if wrap.CurrSubModule == "add" || wrap.CurrSubModule == "modify" {
 			content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
 				{Name: "Add New Page"},
 			})

+ 4 - 3
modules/module_users.go

@@ -18,8 +18,9 @@ func (this *Modules) RegisterModule_Users() *Module {
 		System: true,
 		Icon:   assets.SysSvgIconUser,
 		Sub: &[]MISub{
-			{Mount: "default", Name: "List of Users", Icon: assets.SysSvgIconList},
-			{Mount: "modify", Name: "Add New User", Icon: assets.SysSvgIconPlus},
+			{Mount: "default", Name: "List of Users", Show: true, Icon: assets.SysSvgIconList},
+			{Mount: "add", Name: "Add New User", Show: true, Icon: assets.SysSvgIconPlus},
+			{Mount: "modify", Name: "Modify user", Show: false},
 		},
 	}, nil, func(wrap *wrapper.Wrapper) (string, string, string) {
 		content := ""
@@ -58,7 +59,7 @@ func (this *Modules) RegisterModule_Users() *Module {
 					assets.SysSvgIconEdit + `</a>` +
 					`<a class="ico" href="#">` + assets.SysSvgIconRemove + `</a>`
 			}, "/cp/"+wrap.CurrModule+"/")
-		} else if wrap.CurrSubModule == "modify" {
+		} else if wrap.CurrSubModule == "add" || wrap.CurrSubModule == "modify" {
 			content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
 				{Name: "Add New User"},
 			})

+ 17 - 14
modules/modules.go

@@ -18,6 +18,7 @@ type MISub struct {
 	Mount string
 	Name  string
 	Icon  string
+	Show  bool
 }
 
 type MInfo struct {
@@ -140,21 +141,23 @@ func (this *Modules) getSidebarModuleSubMenu(wrap *wrapper.Wrapper, mod *MInfo)
 	html := ``
 	if mod.Sub != nil {
 		for _, item := range *mod.Sub {
-			class := ""
-			if (item.Mount == "default" && len(wrap.UrlArgs) <= 1) || (len(wrap.UrlArgs) >= 2 && item.Mount == wrap.UrlArgs[1]) {
-				class = " active"
-			}
-			icon := item.Icon
-			if icon == "" {
-				icon = assets.SysSvgIconGear
-			}
-			href := "/cp/" + mod.Mount + "/" + item.Mount + "/"
-			if mod.Mount == "index" && item.Mount == "default" {
-				href = "/cp/"
-			} else if item.Mount == "default" {
-				href = "/cp/" + mod.Mount + "/"
+			if item.Show {
+				class := ""
+				if (item.Mount == "default" && len(wrap.UrlArgs) <= 1) || (len(wrap.UrlArgs) >= 2 && item.Mount == wrap.UrlArgs[1]) {
+					class = " active"
+				}
+				icon := item.Icon
+				if icon == "" {
+					icon = assets.SysSvgIconGear
+				}
+				href := "/cp/" + mod.Mount + "/" + item.Mount + "/"
+				if mod.Mount == "index" && item.Mount == "default" {
+					href = "/cp/"
+				} else if item.Mount == "default" {
+					href = "/cp/" + mod.Mount + "/"
+				}
+				html += `<li class="nav-item` + class + `"><a class="nav-link" href="` + href + `">` + icon + item.Name + `</a></li>`
 			}
-			html += `<li class="nav-item` + class + `"><a class="nav-link" href="` + href + `">` + icon + item.Name + `</a></li>`
 		}
 		if html != "" {
 			html = `<ul class="nav flex-column">` + html + `</ul>`