@(cluster: HotelClusterInfo)
@import ru.yandex.tours.model.hotels.Features
@import views.Utils
@import ru.yandex.tours.db.model.DbPartnerHotel
@import hotels.cluster.hotel_ref
@import ru.yandex.tours.util.Collections._
@allFeatures = @{
cluster.core.map(h => h -> h.hotel.getRawHotel.getFeaturesList)
.flatMap { case (h, fs) => fs.map(f => f.getName ->(h, f.getValue)) }
.toMultiMap
.mapValues(_.toMultiMap.toSeq.sortBy(p => cluster.indexFor(p._1.id)))
.toSeq.sortBy(_._1)
}
@row(name: String, hotel: DbPartnerHotel, values: Seq[String], idx: Int, size: Int) = {
@if(idx == 0) {
@Utils.featureName(name) |
}
@hotel_ref(hotel.id, cluster) @cluster.nameFor(hotel) – @cluster.partnerFor(hotel) |
@values.mkString(", ") |
|
@if(idx == 0) {
|
}
}
Фича |
Отель |
Значения |
|
|
@for((name, allValues) <- allFeatures) {
@for(((hotel, values), idx) <- allValues.zipWithIndex) {
@row(name, hotel, values, idx, allValues.size)
}
}
@import helper._
@import views.forms.FormHelpers.simple
@form(routes.HotelsController.addHotelFeature(cluster.head.id), 'class -> "form-horizontal") {
@defining(AddFeatureRequest.form.fill(AddFeatureRequest("", ""))) { form =>
@select(
form("name"),
Features.name2feature.keys.toSeq.sorted.map(n => n -> Utils.featureName(n)),
'_label -> "",
'class -> "form-control",
'placeholder -> "Feature"
)
@inputText(
form("value"),
'_label -> "",
'_default -> "",
'class -> "form-control",
'placeholder -> "Value..."
)
}
}