Skip to content
Open
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
4 changes: 3 additions & 1 deletion base_geoengine/models/geo_raster_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class GeoRasterLayer(models.Model):
params = fields.Char(help="Dictiorary of values for dimensions as JSON")

# wms options
params_wms = fields.Char(help="Need to provide at least a LAYERS param")
params_wms = fields.Char(
"Params WMS", help="Need to provide at least a LAYERS param"
)
server_type = fields.Char(
help="The type of the remote WMS server: mapserver, \
geoserver, carmentaserver, or qgis",
Expand Down
19 changes: 17 additions & 2 deletions base_geoengine/models/geo_vector_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ class GeoVectorLayer(models.Model):
ondelete="cascade",
domain=[("ttype", "ilike", "geo_")],
)
attribute_field_id = fields.Many2one(
"ir.model.fields", "Attribute field", domain=[("ttype", "in", SUPPORTED_ATT)]

attribute_field_id_domain = fields.Binary(
compute="_compute_attribute_field_id_domain", readonly=True, store=False
)
attribute_field_id = fields.Many2one("ir.model.fields", "Attribute field")

model_id = fields.Many2one(
"ir.model",
"Model to use",
Expand Down Expand Up @@ -155,3 +158,15 @@ def _compute_model_id(self):
rec.model_id = ""
else:
rec.model_id = ""

@api.depends("geo_field_id")
def _compute_attribute_field_id_domain(self):
for rec in self:
rec.attribute_field_id_domain = (
[
("ttype", "in", SUPPORTED_ATT),
("model", "=", rec.geo_field_id.model_id.model),
]
if rec.geo_field_id
else [("ttype", "in", SUPPORTED_ATT)]
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @odoo-module */
/* globals window */

/**
* Copyright 2023 ACSONE SA/NV
Expand Down Expand Up @@ -129,6 +130,22 @@ export class GeoengineController extends Component {
});
}

/**
* Allow you to edit form view for the filled-in model
* from new tab in the browser window.
* @param {*} resModel
* @param {*} resId
*/
async editRecord(resModel, resId) {
const url = window.location.href;
const action_url = url.split("?")[0] + "/" + resId;
this.actionService.doAction({
type: "ir.actions.act_url",
target: "_blank",
url: action_url,
});
}

/**
* When you finished drawing a new shape, this method is called to open form view and create the record.
* @param {*} resModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
data="model.root"
editable="editable"
openRecord.bind="openRecord"
editRecord.bind="editRecord"
updateRecord.bind="updateRecord"
onClickDiscard.bind="onClickDiscard"
createRecord.bind="createRecord"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,14 @@ export class GeoengineRenderer extends Component {
this.props.openRecord(this.record.resModel, this.record.resId, formViewId);
}

/**
* When you click on the edit button, it calls the controller's
* editRecord method.
*/
onEditButtonClicked() {
this.props.editRecord(this.record.resModel, this.record.resId);
}

/**
* Allows you to change the visibility of layers. This method is called
* when the user changes raster layers.
Expand Down Expand Up @@ -1309,6 +1317,7 @@ GeoengineRenderer.props = {
archInfo: {type: Object},
data: {type: Object},
openRecord: {type: Function},
editRecord: {type: Function},
editable: {type: Boolean, optional: true},
updateRecord: {type: Function},
onClickDiscard: {type: Function},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,14 @@
.ol-popup-closer:after {
content: "✖";
}
.ol-popup-editor {
text-decoration: none;
position: absolute;
top: 1px;
right: 25px;
}
.ol-popup-editor:after {
font-family: FontAwesome;
content: "\f040";
cursor: pointer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
/>
</div>
<div id="popup" class="ol-popup text-start">
<div
id="popup-editor"
class="ol-popup-editor text-primary"
t-on-click="onEditButtonClicked"
/>
<div
id="popup-closer"
class="ol-popup-closer text-primary"
Expand Down
4 changes: 4 additions & 0 deletions base_geoengine/views/geo_vector_layer_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
<field name="name" />
<field name="view_id" />
<field name="geo_field_id" />
<field name="attribute_field_id_domain" invisible="1" />
<field
name="attribute_field_id"
required="geo_repr in ['choropleth', 'proportion', 'colored']"
domain="attribute_field_id_domain"
/>
<field name="active_on_startup" />
<field name="display_polygon_labels" />
Expand Down Expand Up @@ -81,9 +83,11 @@
<group string="General" col="4">
<field name="name" />
<field name="geo_field_id" />
<field name="attribute_field_id_domain" invisible="1" />
<field
name="attribute_field_id"
required="geo_repr in ['choropleth', 'proportion', 'colored']"
domain="attribute_field_id_domain"
/>
<field name="display_polygon_labels" />
<field name="sequence" readonly="1" />
Expand Down