Add category add button on new thread

This commit is contained in:
Joey Yakimowich-Payne 2018-08-08 19:10:46 +09:00
commit d5df46823a
2 changed files with 11 additions and 3 deletions

View file

@ -83,7 +83,7 @@ proc render(): VNode =
route([ route([
r("/newthread", r("/newthread",
(params: Params) => (params: Params) =>
(render(state.newThread)) (render(state.newThread, getLoggedInUser()))
), ),
r("/profile/@username", r("/profile/@username",
(params: Params) => (params: Params) =>

View file

@ -5,7 +5,7 @@ when defined(js):
include karax/prelude include karax/prelude
import karax / [kajax, kdom] import karax / [kajax, kdom]
import error, replybox, threadlist, post, category import error, replybox, threadlist, post, category, user
import karaxutils, categorypicker import karaxutils, categorypicker
type type
@ -47,7 +47,15 @@ when defined(js):
ajaxPost(uri, @[], cast[cstring](formData), ajaxPost(uri, @[], cast[cstring](formData),
(s: int, r: kstring) => onCreatePost(s, r, state)) (s: int, r: kstring) => onCreatePost(s, r, state))
proc render*(state: NewThread): VNode = proc render*(state: NewThread, currentUser: Option[User]): VNode =
let loggedIn = currentUser.isSome()
let currentAdmin =
currentUser.isSome() and currentUser.get().rank == Admin
if currentAdmin:
state.categoryPicker.setAddEnabled(true)
result = buildHtml(): result = buildHtml():
section(class="container grid-xl"): section(class="container grid-xl"):
tdiv(id="new-thread"): tdiv(id="new-thread"):