Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class RoutingRegistryDef extends RoutingRegistry[RoutingState] with Logging {
case "/box" / "function" / exportFunction => DataState(DataKind.FUNCTION,exportFunction)
case "/box" / kind / entity / "page" => FormPageState(kind,entity,"true",false,Layouts.std)
case "/box" / kind / entity / "insert" => EntityFormState(kind,entity,"true",None,false,Layouts.std)
case "/box" / kind / entity / "insert" / layout => EntityFormState(kind,entity,"true",None,false,layout)
case "/box" / kind / entity / "row" / write / id => EntityFormState(kind,entity,write,Some(id),false,Layouts.std)
case "/box" / kind / entity / "row" / write / id / layout => EntityFormState(kind,entity,write,Some(id),false,layout)
case "/box" / kind / entity / "child" / childEntity => MasterChildState(kind,entity,childEntity)
case "/box" / kind / entity => EntityTableState(kind,entity,None,false)
case "/box" / kind / entity / "query" / query => EntityTableState(kind,entity,Some(query),false)
Expand Down
12 changes: 6 additions & 6 deletions client/src/main/scala/ch/wsl/box/client/geo/StandaloneMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ abstract class StandaloneMap(_div:Div, metadata:MapMetadata,properties:ReadableP
}
}
def redrawControl():Unit = {
logger.debug("drawControl")
window.setTimeout(() => {
controlsDiv.children.toSeq.foreach(controlsDiv.removeChild)
controlsBottomDiv.children.toSeq.foreach(controlsBottomDiv.removeChild)
Expand Down Expand Up @@ -215,9 +216,7 @@ abstract class StandaloneMap(_div:Div, metadata:MapMetadata,properties:ReadableP
}
case _ => None
}
layersExtent.tail.foreach{ e =>
extentMod.extend(layersExtent.head,e)
}

if (layersExtent.isEmpty) {
None
} else {
Expand Down Expand Up @@ -324,18 +323,19 @@ abstract class StandaloneMap(_div:Div, metadata:MapMetadata,properties:ReadableP

ready.set(false)

for {
{for {
baseLayers <- Future.sequence(metadata.db.filter(_.autofocus).map(v => dbVectorLayer(v, d, None)))
_ = addLayers(baseLayers.map(x => geomsToLayer(x._1, x._2)),true)
extent = fit()
extraLayers <- Future.sequence(metadata.db.filterNot(_.autofocus).map(v => dbVectorLayer(v, d, Some(extent))))
} yield {

logger.debug("loaded layers")
selectedLayerForEdit.set(selectedLayerForEdit.get, true) // retrigger layer listener
addLayers(extraLayers.map(x => geomsToLayer(x._1, x._2)),false)
redrawControl()
ready.set(true)
}
logger.debug("ready")
}}.recover{ case t => t.printStackTrace()}
}

properties.listen({d =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ import scala.util.{Failure, Success, Try}
*/

case class EntityFormModel(name:String, kind:String, id:Option[String], metadata:Option[JSONMetadata], originalData:Json,data:Json,
error:String, children:Seq[JSONMetadata], navigation: Navigation, changed:Boolean, write:Boolean, public:Boolean, insert:Boolean, showActionPanelMobile: Boolean, localData:Boolean)
error:String, children:Seq[JSONMetadata], navigation: Navigation, changed:Boolean, write:Boolean, public:Boolean, insert:Boolean, showActionPanelMobile: Boolean, localData:Boolean, updateRight:Boolean)

object EntityFormModel extends HasModelPropertyCreator[EntityFormModel] {

val empty = EntityFormModel("","",None,None,Json.Null,Json.Null,"",Seq(), Navigation.empty0,false, true, false, true, false,false)
val empty = EntityFormModel("","",None,None,Json.Null,Json.Null,"",Seq(), Navigation.empty0,false, true, false, true, false,false,false)

implicit val blank: Blank[EntityFormModel] = Blank.Simple(empty)
}
Expand Down Expand Up @@ -146,7 +146,8 @@ case class EntityFormPresenter(model:ModelProperty[EntityFormModel]) extends Pre
state.public,
insert,
false,
localData = record.local_version
localData = record.local_version,
updateRight = rowAccess
)

model.set(stateModel)
Expand Down Expand Up @@ -724,7 +725,10 @@ case class EntityFormView(model:ModelProperty[EntityFormModel], presenter:Entity
}


if((action.updateOnly && _id.isDefined && !model.subProp(_.insert).get) || (action.insertOnly && model.subProp(_.insert).get) || (!action.insertOnly && !action.updateOnly)) {
if(
(!action.needUpdateRight || model.subProp(_.updateRight).get) &&
((action.updateOnly && _id.isDefined && !model.subProp(_.insert).get) || (action.insertOnly && model.subProp(_.insert).get) || (!action.insertOnly && !action.updateOnly))
) {
val actionButton = button(
id := TestHooks.actionButton(action.label),
importance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ch.wsl.box.client.views.components.ui.TwoPanelResize
import ch.wsl.box.client.views.components.widget.DateTimeWidget
import ch.wsl.box.client.views.components.{Debug, MapList, TableFieldsRenderer}
import ch.wsl.box.client.views.elements.Offline
import ch.wsl.box.client.views.helpers.TableColumnDrag
import ch.wsl.box.client.views.helpers.{TableColumnDrag}
import ch.wsl.box.model.shared.EntityKind.VIEW
import ch.wsl.box.model.shared.GeoJson.Polygon
import ch.wsl.box.model.shared.geo.GeoDataRequest
Expand Down Expand Up @@ -372,7 +372,7 @@ case class EntityTablePresenter(model:ModelProperty[EntityTableModel], onSelect:
(ta.target, new_window, url) match {
case (_,_, None) => ()
case (Self, false, Some(url)) => Navigate.toUrl(url)
case (_,_, Some(url)) => window.open(url)
case (NewWindow,_, Some(url)) => window.open(url)
}
true
}
Expand Down
6 changes: 6 additions & 0 deletions db/box_migrations/BOX_V68__form_action_rights.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

alter table form_actions add need_update_right boolean default false not null;
alter table form_actions add need_delete_right boolean default false not null;

alter table form_navigation_actions add need_update_right boolean default false not null;
alter table form_navigation_actions add need_delete_right boolean default false not null;
3 changes: 3 additions & 0 deletions project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ object Settings {
"org.geotools" % "gt-shapefile" % "34.0",
"org.geotools" % "gt-epsg-hsql" % "34.0",
"org.geotools" % "gt-geopkg" % "34.0",
"org.geotools" % "gt-wms" % "34.0",
"org.geotools" % "gt-wmts" % "34.0",
"org.geotools.xsd" % "gt-xsd-sld" % "34.0",
"com.google.zxing" % "core" % "3.5.0",
"com.google.zxing" % "javase" % "3.5.0",
"com.typesafe" %% "ssl-config-core" % "0.6.1",
Expand Down
13 changes: 11 additions & 2 deletions server/src/main/scala/ch/wsl/box/model/boxentities/BoxForm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ object BoxForm {
html_check:Boolean = true,
view_enable:Boolean = true,
edit_enable:Boolean = true,
need_update_right:Boolean = false,
need_delete_right:Boolean = false,
target:Option[String] = None,
enabled_roles:Option[List[String]] = None
)

class BoxForm_actions(_tableTag: Tag) extends profile.api.Table[BoxForm_actions_row](_tableTag,schema, "form_actions") {
def * = (Rep.Some(uuid), form_uuid, action, importance, after_action_goto, label, update_only, insert_only, reload, action_order,confirm_text,execute_function,condition,html_check,view_enable,edit_enable,target,enabled_roles) <> (BoxForm_actions_row.tupled, BoxForm_actions_row.unapply)
def * = (Rep.Some(uuid), form_uuid, action, importance, after_action_goto, label, update_only, insert_only, reload, action_order,confirm_text,execute_function,condition,html_check,view_enable,edit_enable,need_update_right,need_delete_right,target,enabled_roles) <> (BoxForm_actions_row.tupled, BoxForm_actions_row.unapply)

val uuid: Rep[java.util.UUID] = column[java.util.UUID]("uuid", O.AutoInc, O.PrimaryKey)
val form_uuid: Rep[java.util.UUID] = column[java.util.UUID]("form_uuid")
Expand All @@ -143,6 +145,8 @@ object BoxForm {
val condition: Rep[Option[Json]] = column[Option[Json]]("condition")
val view_enable: Rep[Boolean] = column[Boolean]("view_enable")
val edit_enable: Rep[Boolean] = column[Boolean]("edit_enable")
val need_update_right: Rep[Boolean] = column[Boolean]("need_update_right")
val need_delete_right: Rep[Boolean] = column[Boolean]("need_delete_right")
val html_check: Rep[Boolean] = column[Boolean]("html_check")
val enabled_roles: Rep[Option[List[String]]] = column[Option[List[String]]]("enabled_roles")

Expand All @@ -167,10 +171,13 @@ object BoxForm {

view_enable:Boolean = true,
edit_enable:Boolean = true,

need_update_right:Boolean = false,
need_delete_right:Boolean = false,
)

class BoxForm_navigation_actions(_tableTag: Tag) extends profile.api.Table[BoxForm_navigation_actions_row](_tableTag,schema, "form_navigation_actions") {
def * = (Rep.Some(uuid), form_uuid, action, importance, after_action_goto, label, update_only, insert_only, reload, action_order,confirm_text,execute_function,enabled_roles,view_enable,edit_enable) <> (BoxForm_navigation_actions_row.tupled, BoxForm_navigation_actions_row.unapply)
def * = (Rep.Some(uuid), form_uuid, action, importance, after_action_goto, label, update_only, insert_only, reload, action_order,confirm_text,execute_function,enabled_roles,view_enable,edit_enable,need_update_right,need_delete_right) <> (BoxForm_navigation_actions_row.tupled, BoxForm_navigation_actions_row.unapply)

val uuid: Rep[java.util.UUID] = column[java.util.UUID]("uuid", O.AutoInc, O.PrimaryKey)
val form_uuid: Rep[java.util.UUID] = column[java.util.UUID]("form_uuid")
Expand All @@ -187,6 +194,8 @@ object BoxForm {
val enabled_roles: Rep[Option[List[String]]] = column[Option[List[String]]]("enabled_roles")
val view_enable: Rep[Boolean] = column[Boolean]("view_enable")
val edit_enable: Rep[Boolean] = column[Boolean]("edit_enable")
val need_update_right: Rep[Boolean] = column[Boolean]("need_update_right")
val need_delete_right: Rep[Boolean] = column[Boolean]("need_delete_right")

/** Foreign key referencing Field (database name fkey_field) */
lazy val fieldFk = foreignKey("fkey_form", form_uuid, BoxFormTable)(r => r.form_uuid, onUpdate=ForeignKeyAction.Cascade, onDelete=ForeignKeyAction.Cascade)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,7 @@ import scala.concurrent.{ExecutionContext, Future}
object GeoPackageWriter {


def geomSchema(builder:SimpleFeatureTypeBuilder,name:String,geo:Seq[Option[GeoJson.Geometry]],srid:Int) = {
geo.toList.flatten.filterNot(_ == GeoJson.Empty).headOption match {
case Some(value) => {
value match {
case geometry: GeoJson.SingleGeometry => geometry match {
case GeoJson.Point(_, crs) => builder.add(name, classOf[Point], crs.srid)
case GeoJson.LineString(_, crs) => builder.add(name, classOf[LineString], crs.srid)
case GeoJson.Polygon(_, crs) => builder.add(name, classOf[Polygon], crs.srid)
}
case GeoJson.MultiPoint(_, crs) => builder.add(name, classOf[MultiPoint], crs.srid)
case GeoJson.MultiLineString(_, crs) => builder.add(name, classOf[MultiLineString], crs.srid)
case GeoJson.MultiPolygon(_, crs) => builder.add(name, classOf[MultiPolygon], crs.srid)
case GeoJson.GeometryCollection(_, crs) => builder.add(name, classOf[Geometry], crs.srid)
}
}
case None => builder.add(name, classOf[Geometry],srid)
}
}


private def fieldWriter(data:Json, typ: String, featureBuilder: SimpleFeatureBuilder) = {
typ match {
Expand Down Expand Up @@ -115,7 +98,7 @@ object GeoPackageWriter {
t.typ match {
case JSONFieldTypes.INTEGER => builder.add(n, classOf[Integer])
case JSONFieldTypes.NUMBER => builder.add(n, classOf[Double])
case JSONFieldTypes.GEOMETRY if geomNameTrim(geomFieldName) == geomNameTrim(n) => geomSchema(builder, geomName, values.map(x => Some(x._1)), srid)
case JSONFieldTypes.GEOMETRY if geomNameTrim(geomFieldName) == geomNameTrim(n) => GeotoolUtils.geomSchema(builder, geomName, values.map(x => Some(x._1)), srid)
case JSONFieldTypes.GEOMETRY => ()
case _ => builder.add(n, classOf[String])
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ch.wsl.box.rest.io.geotools

import ch.wsl.box.model.shared.GeoJson
import org.geotools.feature.simple.SimpleFeatureTypeBuilder
import org.locationtech.jts.geom.{Geometry, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon}

object GeotoolUtils {

def geomSchema(builder:SimpleFeatureTypeBuilder,name:String,geo:Seq[Option[GeoJson.Geometry]],srid:Int) = {
geo.toList.flatten.filterNot(_ == GeoJson.Empty).headOption match {
case Some(value) => {
value match {
case geometry: GeoJson.SingleGeometry => geometry match {
case GeoJson.Point(_, crs) => builder.add(name, classOf[Point], crs.srid)
case GeoJson.LineString(_, crs) => builder.add(name, classOf[LineString], crs.srid)
case GeoJson.Polygon(_, crs) => builder.add(name, classOf[Polygon], crs.srid)
}
case GeoJson.MultiPoint(_, crs) => builder.add(name, classOf[MultiPoint], crs.srid)
case GeoJson.MultiLineString(_, crs) => builder.add(name, classOf[MultiLineString], crs.srid)
case GeoJson.MultiPolygon(_, crs) => builder.add(name, classOf[MultiPolygon], crs.srid)
case GeoJson.GeometryCollection(_, crs) => builder.add(name, classOf[Geometry], crs.srid)
}
}
case None => builder.add(name, classOf[Geometry],srid)
}
}

}
Loading
Loading