Skip to content

Commit

Permalink
Created methods to create edit buttons for the different generated pa…
Browse files Browse the repository at this point in the history
…ges.

Closes #1123
  • Loading branch information
tuhlmann committed Oct 4, 2011
1 parent 9a0a4e8 commit c6ec24f
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions persistence/proto/src/main/scala/net/liftweb/proto/ProtoUser.scala
Expand Up @@ -742,11 +742,15 @@ trait ProtoUser {

def innerSignup = bind("user",
signupXhtml(theUser),
"submit" -> SHtml.submit(S.??("sign.up"), testSignup _))
"submit" -> signupSubmitButton(S.??("sign.up"), testSignup _))

innerSignup
}

def signupSubmitButton(name: String, func: () => Any = () => {}): NodeSeq = {
standardSubmitButton(name, func)
}

def emailFrom = "noreply@"+S.hostName

def bccEmail: Box[String] = Empty
Expand Down Expand Up @@ -851,7 +855,15 @@ trait ProtoUser {
bind("user", loginXhtml,
"email" -> (FocusOnLoad(<input type="text" name="username"/>)),
"password" -> (<input type="password" name="password"/>),
"submit" -> (<input type="submit" value={S.??("log.in")}/>))
"submit" -> loginSubmitButton(S.??("log.in")))
}

def loginSubmitButton(name: String, func: () => Any = () => {}): NodeSeq = {
standardSubmitButton(name, func)
}

def standardSubmitButton(name: String, func: () => Any = () => {}) = {
SHtml.submit(name, func)
}

def lostPasswordXhtml = {
Expand Down Expand Up @@ -932,7 +944,11 @@ trait ProtoUser {
def lostPassword = {
bind("user", lostPasswordXhtml,
"email" -> SHtml.text("", sendPasswordReset _),
"submit" -> <input type="submit" value={S.??("send.it")} />)
"submit" -> lostPasswordSubmitButton(S.??("send.it")))
}

def lostPasswordSubmitButton(name: String, func: () => Any = () => {}): NodeSeq = {
standardSubmitButton(name, func)
}

def passwordResetXhtml = {
Expand Down Expand Up @@ -962,10 +978,14 @@ trait ProtoUser {
bind("user", passwordResetXhtml,
"pwd" -> SHtml.password_*("",(p: List[String]) =>
user.setPasswordFromListString(p)),
"submit" -> SHtml.submit(S.??("set.password"), finishSet _))
"submit" -> resetPasswordSubmitButton(S.??("set.password"), finishSet _))
case _ => S.error(S.??("password.link.invalid")); S.redirectTo(homePage)
}

def resetPasswordSubmitButton(name: String, func: () => Any = () => {}): NodeSeq = {
standardSubmitButton(name, func)
}

def changePasswordXhtml = {
(<form method="post" action={S.uri}>
<table><tr><td colspan="2">{S.??("change.password")}</td></tr>
Expand Down Expand Up @@ -996,7 +1016,11 @@ trait ProtoUser {
bind("user", changePasswordXhtml,
"old_pwd" -> SHtml.password("", s => oldPassword = s),
"new_pwd" -> SHtml.password_*("", LFuncHolder(s => newPassword = s)),
"submit" -> SHtml.submit(S.??("change"), testAndSet _))
"submit" -> changePasswordSubmitButton(S.??("change"), testAndSet _))
}

def changePasswordSubmitButton(name: String, func: () => Any = () => {}): NodeSeq = {
standardSubmitButton(name, func)
}

def editXhtml(user: TheUserType) = {
Expand Down Expand Up @@ -1042,11 +1066,15 @@ trait ProtoUser {
}

def innerEdit = bind("user", editXhtml(theUser),
"submit" -> SHtml.submit(S.??("edit"), testEdit _))
"submit" -> editSubmitButton(S.??("edit"), testEdit _))

innerEdit
}

def editSubmitButton(name: String, func: () => Any = () => {}): NodeSeq = {
standardSubmitButton(name, func)
}

def logout = {
logoutCurrentUser
S.redirectTo(homePage)
Expand Down

0 comments on commit c6ec24f

Please sign in to comment.