Skip to content

Commit c433a35

Browse files
committed
[16.0][IMP] base_geoengine: Include edit button in Popup
Added edit button in popup of record shown in geoengine view which allows user to edit values of record from geoengine view.
1 parent 26ac676 commit c433a35

5 files changed

Lines changed: 46 additions & 0 deletions

File tree

base_geoengine/static/src/js/views/geoengine/geoengine_controller/geoengine_controller.esm.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,26 @@ export class GeoengineController extends Component {
129129
});
130130
}
131131

132+
/**
133+
* Allow you to edit form view for the filled-in model
134+
* from new tab in the browser window.
135+
* @param {*} resModel
136+
* @param {*} resId
137+
*/
138+
async editRecord(resModel, resId) {
139+
const url = window.location.href;
140+
const searchParams = new URLSearchParams(url.split("#")[1]);
141+
searchParams.set("view_type", "form");
142+
searchParams.set("id", resId);
143+
searchParams.set("menu_id", searchParams.get("menu_id"));
144+
const action_url = url.split("#")[0] + "#" + searchParams.toString();
145+
this.actionService.doAction({
146+
type: "ir.actions.act_url",
147+
target: "_blank",
148+
url: action_url,
149+
});
150+
}
151+
132152
/**
133153
* When you finished drawing a new shape, this method is called to open form view and create the record.
134154
* @param {*} resModel

base_geoengine/static/src/js/views/geoengine/geoengine_controller/geoengine_controller.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
data="model.root"
3636
editable="editable"
3737
openRecord.bind="openRecord"
38+
editRecord.bind="editRecord"
3839
updateRecord.bind="updateRecord"
3940
onClickDiscard.bind="onClickDiscard"
4041
createRecord.bind="createRecord"

base_geoengine/static/src/js/views/geoengine/geoengine_renderer/geoengine_renderer.esm.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,14 @@ export class GeoengineRenderer extends Component {
648648
this.props.openRecord(this.record.resModel, this.record.resId, formViewId);
649649
}
650650

651+
/**
652+
* When you click on the edit button, it calls the controller's
653+
* editRecord method.
654+
*/
655+
onEditButtonClicked() {
656+
this.props.editRecord(this.record.resModel, this.record.resId);
657+
}
658+
651659
/**
652660
* Allows you to change the visibility of layers. This method is called
653661
* when the user changes raster layers.
@@ -1309,6 +1317,7 @@ GeoengineRenderer.props = {
13091317
archInfo: {type: Object},
13101318
data: {type: Object},
13111319
openRecord: {type: Function},
1320+
editRecord: {type: Function},
13121321
editable: {type: Boolean, optional: true},
13131322
updateRecord: {type: Function},
13141323
onClickDiscard: {type: Function},

base_geoengine/static/src/js/views/geoengine/geoengine_renderer/geoengine_renderer.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,14 @@
6565
.ol-popup-closer:after {
6666
content: "";
6767
}
68+
.ol-popup-editor {
69+
text-decoration: none;
70+
position: absolute;
71+
top: 1px;
72+
right: 25px;
73+
}
74+
.ol-popup-editor:after {
75+
font-family: FontAwesome;
76+
content: "\f040";
77+
cursor: pointer;
78+
}

base_geoengine/static/src/js/views/geoengine/geoengine_renderer/geoengine_renderer.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
/>
1818
</div>
1919
<div id="popup" class="ol-popup text-start">
20+
<div
21+
id="popup-editor"
22+
class="ol-popup-editor text-primary"
23+
t-on-click="onEditButtonClicked"
24+
/>
2025
<div
2126
id="popup-closer"
2227
class="ol-popup-closer text-primary"

0 commit comments

Comments
 (0)