work on categories: generalizign tempalte engine, adding functions
This commit is contained in:
parent
2598dd481b
commit
47d1bdadd1
|
@ -21,4 +21,12 @@ $(document).ready( function () {
|
||||||
$(".add-category-col").addClass("has-error");
|
$(".add-category-col").addClass("has-error");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".category-change-parent").change(function (e) {
|
||||||
|
$.post("/categories/change-parent",
|
||||||
|
{target: this.name,
|
||||||
|
value: this.value},
|
||||||
|
function(data) { alert("reload"); location.reload(); },
|
||||||
|
"json");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -257,6 +257,13 @@ func categoriesPostHandler(w http.ResponseWriter, r *http.Request, user *user.Us
|
||||||
http.Redirect(w, r, "/categories", http.StatusFound)
|
http.Redirect(w, r, "/categories", http.StatusFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func categoryChangeParentHandler(w http.ResponseWriter, r *http.Request, user *user.User) {
|
||||||
|
fmt.Println("categoryChangeParentHandler")
|
||||||
|
session, _ := store.Get(r, "c_user")
|
||||||
|
session.AddFlash("change parent")
|
||||||
|
session.Save(r, w)
|
||||||
|
}
|
||||||
|
|
||||||
func ServeFileHandler(res http.ResponseWriter, req *http.Request) {
|
func ServeFileHandler(res http.ResponseWriter, req *http.Request) {
|
||||||
fname := path.Base(req.URL.Path)
|
fname := path.Base(req.URL.Path)
|
||||||
http.ServeFile(res, req, "./"+fname)
|
http.ServeFile(res, req, "./"+fname)
|
||||||
|
@ -279,6 +286,7 @@ func init_route_handlers() {
|
||||||
r.HandleFunc("/added", userHandler(addedHandler))
|
r.HandleFunc("/added", userHandler(addedHandler))
|
||||||
|
|
||||||
r.HandleFunc("/categories", getPostHandler(userHandler(categoriesFormHandler), userHandler(categoriesPostHandler)))
|
r.HandleFunc("/categories", getPostHandler(userHandler(categoriesFormHandler), userHandler(categoriesPostHandler)))
|
||||||
|
r.HandleFunc("/categories/change-parent", userHandler(categoryChangeParentHandler))
|
||||||
|
|
||||||
http.Handle("/", r)
|
http.Handle("/", r)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,12 @@
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="/">transmet</a>
|
<a class="navbar-brand" href="/">transmet</a>
|
||||||
<a class="navbar-brand" href="/categories">categories</a>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse navbar-collapse">
|
<div class="collapse navbar-collapse">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li><a href="/add">add</a></li>
|
<li><a href="/add">add</a></li>
|
||||||
|
<li><a href="/categories">categories</a></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
{{if .user}}
|
{{if .user}}
|
||||||
|
|
Loading…
Reference in New Issue