# HG changeset patch # User Tomas Zeman # Date 1338903644 -7200 # Node ID c92afc825464dcc3cd18572b5a074af2032e4949 # Parent b6a00fd29998b432fd06f8a3f1f734d364d69e2a a839964538894e0a Display cities on country page diff -r b6a00fd29998 -r c92afc825464 src/main/scala/fis/geo/model/GeoSchema.scala --- 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: diff -r b6a00fd29998 -r c92afc825464 src/main/scala/fis/geo/ui/CitySnipppet.scala --- 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(_)) diff -r b6a00fd29998 -r c92afc825464 src/main/scala/fis/geo/ui/CityTable.scala --- /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 + * + * 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: diff -r b6a00fd29998 -r c92afc825464 src/main/scala/fis/geo/ui/CountrySnippet.scala --- 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 !! _) } diff -r b6a00fd29998 -r c92afc825464 src/main/webapp/country/view.html --- /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 @@ + + + + + Country View + + +
+
+
+ +
+
+
+
+

+ +
+
+
+ + + + diff -r b6a00fd29998 -r c92afc825464 src/main/webapp/templates-hidden/_resources.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 @@ Note ISO2 ISO3 + Cities