--- a/src/main/scala/fis/geo/model/GeoSchema.scala Tue Jun 05 15:40:43 2012 +0200
+++ b/src/main/scala/fis/geo/model/GeoSchema.scala Tue Jun 05 15:40:44 2012 +0200
@@ -52,4 +52,10 @@
where(l.address === a.id) select(l) orderBy(l.name asc))
}
+object CountryCities {
+ def apply(country: Country): Iterable[City] =
+ from(GeoSchema.countryCities.left(country))(c =>
+ select(c) orderBy(c.name asc))
+}
+
// vim: set ts=2 sw=2 et:
--- a/src/main/scala/fis/geo/ui/CitySnipppet.scala Tue Jun 05 15:40:43 2012 +0200
+++ b/src/main/scala/fis/geo/ui/CitySnipppet.scala Tue Jun 05 15:40:44 2012 +0200
@@ -90,11 +90,6 @@
private def fields(c: City) = List(c.name, c.country, c.note)
- private object CityTable extends FieldTable[City] {
- def fields(c: City) = EntityLink(c) ++ Seq(c.country, c.note)
- def apply(l: Iterable[City]) = build(City, l)
- }
-
private case class CityLink(c: City) extends EntityLink[City](c, url.view)
EntityLink.register[City](CityLink(_))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/scala/fis/geo/ui/CityTable.scala Tue Jun 05 15:40:44 2012 +0200
@@ -0,0 +1,28 @@
+/*
+ * 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.geo.ui
+
+import fis.base.ui._
+import fis.geo.model._
+
+trait CityTable extends FieldTable[City] {
+ def fields(c: City) = EntityLink(c) ++ Seq(c.country, c.note)
+ def apply(l: Iterable[City]) = build(City, l)
+}
+
+object CityTable extends CityTable
+
+// vim: set ts=2 sw=2 et:
--- a/src/main/scala/fis/geo/ui/CountrySnippet.scala Tue Jun 05 15:40:43 2012 +0200
+++ b/src/main/scala/fis/geo/ui/CountrySnippet.scala Tue Jun 05 15:40:44 2012 +0200
@@ -41,7 +41,8 @@
private val viewPre = Menu.param[Country]("country.view", l10n("Country"), parse,
encode) / prefix / * >> Title(c => i18n("Country %s", c.linkName)) >>
- locTpl("entity/view") >> Snippet("panel", panel) >> Hidden
+ locTpl("country/view") >> Snippet("panel", panel) >>
+ Snippet("cities", cities) >> Hidden
private val editPre = Menu.param[Country]("country.edit", l10n("Edit"), parse,
encode) / prefix / * / EDIT >>
@@ -72,6 +73,13 @@
private def panel: CssTr = "*" #> cur.map(CountryPanel(_))
+ private def cities: CssTr = "*" #> cur.map { c =>
+ (new CityTable {
+ override def fields(c: City) =
+ super.fields(c) filterNot(_.name == City.country.name)
+ })(CountryCities(c))
+ }
+
object url {
def view: Country => Box[String] = (viewLoc.calcHref _) andThen (Box !! _)
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/country/view.html Tue Jun 05 15:40:44 2012 +0200
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
+ <title>Country View</title>
+ </head>
+ <body class="lift:content_id=main">
+ <div id="main" class="lift:surround?with=default;at=content">
+ <div class="row">
+ <div class="span12">
+ <span class="lift:panel"></span>
+ </div>
+ </div> <!-- /row -->
+ <div class="row section">
+ <div class="span12">
+ <h3><span class="lift:loc?locid=country.cities"></span></h3>
+ <span class="lift:cities"></span>
+ </div>
+ </div> <!-- /row -->
+ </div>
+ </body>
+</html>
+
+
--- a/src/main/webapp/templates-hidden/_resources.html Tue Jun 05 15:40:43 2012 +0200
+++ b/src/main/webapp/templates-hidden/_resources.html Tue Jun 05 15:40:44 2012 +0200
@@ -116,6 +116,7 @@
<res name="country.note" lang="en" default="true">Note</res>
<res name="country.iso2" lang="en" default="true">ISO2</res>
<res name="country.iso3" lang="en" default="true">ISO3</res>
+ <res name="country.cities" lang="en" default="true">Cities</res>
<!-- city
--- a/src/main/webapp/templates-hidden/_resources_cs.html Tue Jun 05 15:40:43 2012 +0200
+++ b/src/main/webapp/templates-hidden/_resources_cs.html Tue Jun 05 15:40:44 2012 +0200
@@ -111,6 +111,7 @@
<res name="country.note" lang="cs">Poznámka</res>
<res name="country.iso2" lang="cs">ISO2 kód</res>
<res name="country.iso3" lang="cs">ISO3 kód</res>
+ <res name="country.cities" lang="cs">Města</res>
<!-- city -->