--- a/src/main/scala/fis/crm/ui/ContactSnippet.scala Tue Apr 03 14:55:46 2012 +0200
+++ b/src/main/scala/fis/crm/ui/ContactSnippet.scala Tue Apr 03 15:22:08 2012 +0200
@@ -53,17 +53,20 @@
Title(c => i18n("Delete contact %s", c.linkName)) >>
locTpl("entity/delete") >> Snippet("form", deleteF) >> Hidden
- lazy val viewLoc: Loc[Contact] = viewOp.toLoc
- lazy val editLoc = editOp.toLoc
- lazy val deleteLoc = deleteOp.toLoc
+ private lazy val viewLoc: Loc[Contact] = viewOp.toLoc
+ private lazy val editLoc = editOp.toLoc
+ private lazy val deleteLoc = deleteOp.toLoc
val menu = listOp submenus (viewOp, editOp, createOp, deleteOp)
- def list: CssTr = /*ContactTable(from(CrmSchema.contacts)(c =>
- select(c) orderBy(c.lastName asc, c.firstName asc)))*/ ClearNodes
+ def list: CssTr = ContactTable(CrmSchema.allContacts)
def panel: CssTr = "*" #> viewLoc.currentValue.map { ContactPanel(_) }
+ object url {
+ def view: Contact => Box[String] = (viewLoc.calcHref _) andThen (Box !! _)
+ }
+
object form extends LiftScreen {
object c extends ScreenVar[Contact](Contact.createRecord)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/scala/fis/crm/ui/ContactTable.scala Tue Apr 03 15:22:08 2012 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2012 Tomas Zeman <tzeman@volny.cz>
+ *
+ * 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.crm.ui
+
+import fis.crm.model._
+import net.liftweb.util._
+import net.tz.lift.snippet._
+import scala.xml.Text
+
+object ContactTable {
+
+ def fields(c: Contact) = Seq(ContactLink(c), c.position, c.workMail,
+ c.workPhone, c.workMobile)
+
+ def apply(l: Iterable[Contact]): CssTr =
+ new DataTable(fields(Contact) map { _.displayName } toList,
+ l map { c => fields(c) map { _.asHtml } toList } toList)
+}
+
+case class ContactLink(c: Contact) extends ReadableField {
+ type ValueType = String
+ def name = "linkName"
+ override def asHtml = a(ContactSnippet.url.view(c))(Text(c.linkName))
+ def get = c.linkName
+ def is = c.linkName
+}
+
+// vim: set ts=2 sw=2 et: