Skip to content

Commit eb25718

Browse files
committed
Merge branch 'laos-dirty-quick-fix' of https://github.com/OpenSPP/openspp-modules into 369-add-events-data-models-and-ui-for-laos-farmer-registry-module
2 parents 3ad3790 + a9283f8 commit eb25718

File tree

6 files changed

+31
-1
lines changed

6 files changed

+31
-1
lines changed

spp_base_demo/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"g2p_programs",
1515
# "spp_helpdesk",
1616
"product",
17+
"stock",
1718
],
1819
"data": [
1920
"data/users_data.xml",

spp_base_gis/controllers/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ class MainController(http.Controller):
66
@http.route("/get_maptiler_api_key", type="json", auth="user")
77
def get_maptiler_api_key(self):
88
map_tiler_api_key = request.env["ir.config_parameter"].sudo().get_param("spp_base_gis.map_tiler_api_key")
9-
return {"mapTilerKey": map_tiler_api_key}
9+
web_base_url = request.env["ir.config_parameter"].sudo().get_param("web.base.url")
10+
return {"mapTilerKey": map_tiler_api_key, "webBaseUrl": web_base_url}

spp_base_gis/static/src/js/widgets/gis_edit_map/field_gis_edit_map.esm.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class FieldGisEditMap extends Component {
6363
const response = await this.rpc("/get_maptiler_api_key");
6464
if (response.mapTilerKey) {
6565
this.mapTilerKey = response.mapTilerKey;
66+
this.webBaseUrl = response.webBaseUrl;
6667
} else {
6768
console.log("Error: Api Key not found.");
6869
}
@@ -202,6 +203,22 @@ export class FieldGisEditMap extends Component {
202203

203204
this.map.on("draw.create", updateArea);
204205
this.map.on("draw.update", updateArea);
206+
207+
const model = this.props.record._config.resModel;
208+
const url = `${this.webBaseUrl}/web/image?model=${model}&id=${this.props.record._config.resId}&field=geo_img_file`;
209+
210+
this.map.on("click", `${this.sourceId}-polygon-layerid`, (e) => {
211+
new maptilersdk.Popup()
212+
.setLngLat(e.lngLat)
213+
.setHTML(`<img src="${url}" height="200" width="300" alt="Placeholder Image">`)
214+
.addTo(this.map);
215+
});
216+
this.map.on("click", `${this.sourceId}-point-layerid`, (e) => {
217+
new maptilersdk.Popup()
218+
.setLngLat(e.lngLat)
219+
.setHTML(`<img src="${url}" height="200" width="300" alt="Placeholder Image">`)
220+
.addTo(this.map);
221+
});
205222
}
206223

207224
addDrawInteractionStyle() {

spp_base_gis/static/src/js/widgets/gis_edit_map/field_gis_edit_map.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@
1111
width: 100%;
1212
height: 100%;
1313
}
14+
15+
/* Increasing specificity */
16+
.maplibregl-popup .maplibregl-popup-content {
17+
width: 320px !important; /* Custom width */
18+
height: 220px !important; /* Custom height */
19+
}

spp_farmer_registry_laos/models/farmer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class Farmer(models.Model):
1414
("married_polygamous", "Married Polygamous"),
1515
]
1616
)
17+
geo_img_file = fields.Binary(string="Geometry Image File")
18+
geo_img_file_filename = fields.Char(string="File Name")
1719

1820

1921
class TempFarmer(models.Model):

spp_farmer_registry_laos/views/group_view.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
<field name="land_geo_polygon" />
6666
</page>
6767
</xpath>
68+
<xpath expr="//field[@name='disabled_reason']" position="after">
69+
<field name="geo_img_file" filename="geo_img_file_filename" />
70+
</xpath>
6871
</field>
6972
</record>
7073

0 commit comments

Comments
 (0)