# HG changeset patch # User Tomas Zeman # Date 1338903645 -7200 # Node ID 83d4c4990086cb37de9a5292c743db2ab5bed554 # Parent 66aeb6b3a3a7d9559648437c5297bf1524fca8f0 cdd7280276f85e5b User page - projects diff -r 66aeb6b3a3a7 -r 83d4c4990086 src/main/scala/fis/aaa/ui/UserSnippet.scala --- a/src/main/scala/fis/aaa/ui/UserSnippet.scala Tue Jun 05 15:40:45 2012 +0200 +++ b/src/main/scala/fis/aaa/ui/UserSnippet.scala Tue Jun 05 15:40:45 2012 +0200 @@ -81,11 +81,28 @@ private def panel: CssTr = "*" #> cur.map(UserPanel(_)) + private def allQp(what: String) = + (S param ("all-"+what)) flatMap(asBoolean(_)) openOr false + private def allQp(url: String, what: String, all: Boolean) = + all.box(appendQueryParameters(url, List(("all-"+what) -> "1"))) openOr url + private def projects: CssTr = "*" #> cur.map { u => - ProjectTable(AssignedProjects(u)) } + val qp = allQp("project") + TabPanel(List((false, "projects.unfinished"), (true, "projects.all")) map { p => + val url = allQp(allQp(S.uri, "task", allQp("task")), "project", p._1) + val tab = a(url)(i18n(p._2)) + Either.cond(p._1 == qp, tab, tab) + })(ProjectTable(qp.box(AssignedProjects.all(u)) openOr AssignedProjects(u))) + } private def tasks: CssTr = "*" #> cur.map { u => - TaskTable(AssignedTasks(u)) } + val qp = allQp("task") + TabPanel(List((false, "tasks.unfinished"), (true, "tasks.all")) map { p => + val url = allQp(allQp(S.uri, "project", allQp("project")), "task", p._1) + val tab = a(url)(i18n(p._2)) + Either.cond(p._1 == qp, tab, tab) + })(TaskTable(qp.box(AssignedTasks.all(u)) openOr AssignedTasks(u))) + } object url { def view: User => Box[String] = (viewLoc.calcHref _) andThen (Box !! _) diff -r 66aeb6b3a3a7 -r 83d4c4990086 src/main/scala/fis/base/ui/TabPanel.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/scala/fis/base/ui/TabPanel.scala Tue Jun 05 15:40:45 2012 +0200 @@ -0,0 +1,41 @@ +/* + * Copyright 2012 Tomas Zeman + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package fis.base.ui + +import net.liftweb.http.Templates +import net.liftweb.util._ +import net.liftweb.util.Helpers._ +import scala.xml.NodeSeq + +trait TabPanel { + /** Tab type: Right is active, Left inactive; think of Either.cond(active). */ + type Tab = Either[NodeSeq, NodeSeq] + + protected def load = Templates(List("templates-hidden", "tab-panel")) openOr + NodeSeq.Empty + + def apply(tabs: Iterable[Tab])(content: => NodeSeq) = { + ("li" #> (tabs map { + case Left(ns) =>
  • {ns}
  • + case Right(ns) =>
  • {ns}
  • + }) & + ".content *" #> content)(load) + } +} + +object TabPanel extends TabPanel + +// vim: set ts=2 sw=2 et: diff -r 66aeb6b3a3a7 -r 83d4c4990086 src/main/scala/fis/pm/model/PmSchema.scala --- a/src/main/scala/fis/pm/model/PmSchema.scala Tue Jun 05 15:40:45 2012 +0200 +++ b/src/main/scala/fis/pm/model/PmSchema.scala Tue Jun 05 15:40:45 2012 +0200 @@ -129,12 +129,22 @@ object AssignedTasks { def apply(u: User): Iterable[Task] = + from(PmSchema.taskResponsible.left(u), CodeListSchema.cli)((t, i) => + where(t.stateFld === i.id and TaskState.unfinishedClause(i)) + select(t) orderBy(t.deadline asc)) + + def all(u: User): Iterable[Task] = from(PmSchema.taskResponsible.left(u))(t => select(t) orderBy(t.deadline asc)) } object AssignedProjects { def apply(u: User): Iterable[Project] = + from(PmSchema.projectResponsible.left(u), CodeListSchema.cli)((p, i) => + where(p.stateFld === i.id and ProjectState.unfinishedClause(i)) + select(p) orderBy(p.deadline asc)) + + def all(u: User): Iterable[Project] = from(PmSchema.projectResponsible.left(u))(p => select(p) orderBy(p.name asc)) } diff -r 66aeb6b3a3a7 -r 83d4c4990086 src/main/webapp/templates-hidden/tab-panel.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/templates-hidden/tab-panel.html Tue Jun 05 15:40:45 2012 +0200 @@ -0,0 +1,7 @@ + + +
    +
    +