Sync remote addons before module update and add zone map preview
This commit is contained in:
@@ -18,6 +18,11 @@ class RepairFsmZone(models.Model):
|
||||
tracking=True,
|
||||
help="GeoJSON Polygon geometry. Coordinates order: [longitude, latitude].",
|
||||
)
|
||||
polygon_map_preview = fields.Html(
|
||||
string="Polygon Map Preview",
|
||||
compute="_compute_polygon_map_preview",
|
||||
sanitize=False,
|
||||
)
|
||||
state = fields.Selection(
|
||||
selection=[
|
||||
("draft", "Draft"),
|
||||
@@ -121,6 +126,18 @@ class RepairFsmZone(models.Model):
|
||||
"target": "new",
|
||||
}
|
||||
|
||||
@api.depends("polygon_geojson")
|
||||
def _compute_polygon_map_preview(self):
|
||||
for rec in self:
|
||||
if not rec.polygon_geojson:
|
||||
rec.polygon_map_preview = "<div>No polygon yet.</div>"
|
||||
continue
|
||||
encoded = quote(rec.polygon_geojson)
|
||||
rec.polygon_map_preview = (
|
||||
f'<iframe src="https://geojson.io/#data=data:application/json,{encoded}" '
|
||||
'style="width:100%;height:420px;border:1px solid #d9d9d9;border-radius:6px;"></iframe>'
|
||||
)
|
||||
|
||||
@api.constrains("polygon_geojson")
|
||||
def _check_polygon_geojson(self):
|
||||
for rec in self:
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
<group>
|
||||
<field name="polygon_geojson" widget="text" placeholder='{"type":"Polygon","coordinates":[[[-84.55,33.60],[-84.20,33.60],[-84.20,33.90],[-84.55,33.90],[-84.55,33.60]]]}'/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="polygon_map_preview" widget="html" readonly="1" nolabel="1"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<chatter/>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user