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
25 changes: 18 additions & 7 deletions base_geoengine/static/src/js/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
{
"globals": {
"$": false,
"_": false,
"ol": false,
"chroma": false,
"geostats": false
}
"globals": {
"$": false,
"_": false,
"ol": false,
"chroma": false,
"geostats": false
},
"plugins": [
"jsdoc"
],
"rules": {
"jsdoc/check-tag-names": [
"warn",
{
"definedTags": ["odoo-module"]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import {Field} from "@web/views/fields/field";
import {Widget} from "@web/views/widgets/widget";
import {_t} from "@web/core/l10n/translation";
import {getActiveActions} from "@web/views/utils";
import {exprToBoolean} from "@web/core/utils/strings";
import {getActiveActions} from "@web/views/utils";
import {visitXML} from "@web/core/utils/xml";

export const INFO_BOX_ATTRIBUTE = "info_box";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import {Component, useState} from "@odoo/owl";
import {useOwnedDialogs, useService} from "@web/core/utils/hooks";
import {FormViewDialog} from "@web/views/view_dialogs/form_view_dialog";
import {Layout} from "@web/search/layout";
import {SearchBar} from "@web/search/search_bar/search_bar";
Expand All @@ -15,7 +16,6 @@ import {extractFieldsFromArchInfo} from "@web/model/relational_model/utils";
import {session} from "@web/session";
import {standardViewProps} from "@web/views/standard_view_props";
import {useModelWithSampleData} from "@web/model/model";
import {useOwnedDialogs, useService} from "@web/core/utils/hooks";
import {usePager} from "@web/search/pager_hook";
import {useSearchBarToggler} from "@web/search/search_bar/search_bar_toggler";

Expand All @@ -40,11 +40,10 @@ export class GeoengineController extends Component {
*/
usePager(() => {
const list = this.model.root;
const {count, limit, offset} = list;
return {
offset: offset,
limit: limit,
total: count,
offset: list.offset,
limit: list.limit,
total: list.count,
onUpdate: async ({offset, limit}) => {
await list.load({limit, offset});
this.render(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* Copyright 2023 ACSONE SA/NV
*/

import {Component, onWillUpdateProps} from "@odoo/owl";
import {Field} from "@web/views/fields/field";
import {GeoengineCompiler} from "../geoengine_compiler.esm";
import {INFO_BOX_ATTRIBUTE} from "../geoengine_arch_parser.esm";
import {registry} from "@web/core/registry";
import {useViewCompiler} from "@web/views/view_compiler";
import {Component, onWillUpdateProps} from "@odoo/owl";
import {user} from "@web/core/user";

const formatters = registry.category("formatters");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ import {
reactive,
useState,
} from "@odoo/owl";
import {GeoengineRecord} from "../geoengine_record/geoengine_record.esm";
import {LayersPanel} from "../layers_panel/layers_panel.esm";
import {RecordsPanel} from "../records_panel/records_panel.esm";
import {RelationalModel} from "@web/model/relational_model/relational_model";
import {
addFieldDependencies,
extractFieldsFromArchInfo,
} from "@web/model/relational_model/utils";
import {evaluateExpr} from "@web/core/py_js/py";
import {loadBundle, loadJS} from "@web/core/assets";
import {GeoengineRecord} from "../geoengine_record/geoengine_record.esm";
import {LayersPanel} from "../layers_panel/layers_panel.esm";
import {RecordsPanel} from "../records_panel/records_panel.esm";
import {RelationalModel} from "@web/model/relational_model/relational_model";
import {evaluateExpr} from "@web/core/py_js/py";
import {getTemplate} from "@web/core/templates";
import {parseXML} from "@web/core/utils/xml";
import {rasterLayersStore} from "../../../raster_layers_store.esm";
import {registry} from "@web/core/registry";
import {user} from "@web/core/user";
import {useService} from "@web/core/utils/hooks";
import {user} from "@web/core/user";
import {vectorLayersStore} from "../../../vector_layers_store.esm";

/* CONSTANTS */
Expand Down Expand Up @@ -503,37 +503,35 @@ export class GeoengineRenderer extends Component {
*/
updateInfoBox(features) {
const feature = features.item(0);
if (feature !== undefined) {
if (feature === undefined) {
this.hidePopup();
} else {
const popup = this.getPopup();
if (feature !== undefined) {
var attributes = feature.get("attributes");
var attributes = feature.get("attributes");

if (this.cfg_models.includes(feature.get("model"))) {
const model = this.models.find(
(el) => el.model.resModel === feature.get("model")
);
this.mountGeoengineRecord({
popup,
archInfo: model.archInfo,
templateDocs: model.archInfo.templateDocs,
model: model.model,
attributes,
});
} else {
this.mountGeoengineRecord({
popup,
archInfo: this.props.archInfo,
templateDocs: this.props.archInfo.templateDocs,
model: this.props.data,
attributes,
});
}

var coord = ol.extent.getCenter(feature.getGeometry().getExtent());
this.overlay.setPosition(coord);
if (this.cfg_models.includes(feature.get("model"))) {
const model = this.models.find(
(el) => el.model.resModel === feature.get("model")
);
this.mountGeoengineRecord({
popup,
archInfo: model.archInfo,
templateDocs: model.archInfo.templateDocs,
model: model.model,
attributes,
});
} else {
this.mountGeoengineRecord({
popup,
archInfo: this.props.archInfo,
templateDocs: this.props.archInfo.templateDocs,
model: this.props.data,
attributes,
});
}
} else {
this.hidePopup();

var coord = ol.extent.getCenter(feature.getGeometry().getExtent());
this.overlay.setPosition(coord);
}
}

Expand Down Expand Up @@ -697,9 +695,9 @@ export class GeoengineRenderer extends Component {
`legend-${vector.resId}`
);
if (legend !== null) {
void (vector.isVisible
? (legend.style.display = "block")
: (legend.style.display = "none"));
legend.style.display = vector.isVisible
? "block"
: "none";
}
}
if (vector.onDomainChanged) {
Expand Down Expand Up @@ -1112,6 +1110,7 @@ export class GeoengineRenderer extends Component {
if (val) {
return chroma(val).alpha(opacity).css();
}
return undefined;
});
} else {
colors = scale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,38 @@
.ol-popup-closer {
text-decoration: none;
position: absolute;
top: 2px;
top: 8px;
right: 8px;
}
.ol-popup-closer:after {
content: "✖";
font-family: FontAwesome;
content: "\f00d";
display: inline-block;
padding: 4px 6px;
border-radius: 4px;
font-size: 18px;
transition: background-color 0.15s ease;
cursor: pointer;
}
.ol-popup-closer:hover:after {
background-color: rgba(0, 0, 0, 0.06);
}
.ol-popup-editor {
text-decoration: none;
position: absolute;
top: 1px;
right: 25px;
top: 8px;
right: 40px;
}
.ol-popup-editor:after {
font-family: FontAwesome;
content: "\f040";
display: inline-block;
padding: 4px 6px;
border-radius: 4px;
font-size: 18px;
transition: background-color 0.15s ease;
cursor: pointer;
}
.ol-popup-editor:hover:after {
background-color: rgba(0, 0, 0, 0.06);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* Copyright 2023 ACSONE SA/NV
*/

import {CheckBox} from "@web/core/checkbox/checkbox";
import {Component, onWillStart, useRef, useState} from "@odoo/owl";
import {useOwnedDialogs, useService} from "@web/core/utils/hooks";
import {CheckBox} from "@web/core/checkbox/checkbox";
import {DomainSelectorGeoFieldDialog} from "../../../widgets/domain_selector_geo_field/domain_selector_geo_field_dialog/domain_selector_geo_field_dialog.esm";
import {FormViewDialog} from "@web/views/view_dialogs/form_view_dialog";
import {_t} from "@web/core/l10n/translation";
import {rasterLayersStore} from "../../../raster_layers_store.esm";
import {rpc} from "@web/core/network/rpc";
import {useOwnedDialogs, useService} from "@web/core/utils/hooks";
import {user} from "@web/core/user";
import {useSortable} from "@web/core/utils/sortable_owl";
import {user} from "@web/core/user";
import {vectorLayersStore} from "../../../vector_layers_store.esm";

export class LayersPanel extends Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
/**
* Copyright 2023 ACSONE SA/NV
*/
import {SearchBarRecords} from "./search_bar_records/search_bar_records.esm";
import {useService} from "@web/core/utils/hooks";

import {
Component,
onWillRender,
onWillStart,
onWillUpdateProps,
useState,
} from "@odoo/owl";
import {SearchBarRecords} from "./search_bar_records/search_bar_records.esm";
import {useService} from "@web/core/utils/hooks";

export class RecordsPanel extends Component {
setup() {
Expand Down Expand Up @@ -70,7 +69,7 @@ export class RecordsPanel extends Component {
filterItems(value, items) {
const lowerValue = value.toLowerCase();
return items.filter(
(item) => item.data.display_name.toLowerCase().indexOf(lowerValue) >= 0
(item) => item.data.name.toLowerCase().indexOf(lowerValue) >= 0
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
t-on-click="() => this.onDisplayPopupRecord(record)"
>
<span>
<t t-esc="record.data.display_name" />
<t t-esc="record.data.name" />
</span>
</button>
<t t-if="state.isClicked === record.resId">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,29 +170,10 @@ export class FieldGeoEngineEditMap extends Component {
* Allow you to setup the trash button and the draw interaction.
*/
setupControls() {
if (!this.props.record.data[this.props.name]) {
void (
this.selectInteraction !== undefined &&
this.map.removeInteraction(this.selectInteraction)
);
void (
this.modifyInteraction !== undefined &&
this.map.removeInteraction(this.modifyInteraction)
);
this.drawInteraction = new ol.interaction.Draw({
type: this.geoType,
source: this.source,
});
this.map.addInteraction(this.drawInteraction);

this.drawInteraction.on("drawend", (e) => {
this.onUIChange(e.feature.getGeometry());
});
} else {
void (
this.drawInteraction !== undefined &&
this.map.removeInteraction(this.drawInteraction)
);
if (this.props.record.data[this.props.name]) {
if (this.drawInteraction !== undefined) {
this.map.removeInteraction(this.drawInteraction);
}
this.selectInteraction = new ol.interaction.Select();
this.modifyInteraction = new ol.interaction.Modify({
features: this.selectInteraction.getFeatures(),
Expand All @@ -205,6 +186,22 @@ export class FieldGeoEngineEditMap extends Component {
this.onUIChange(item.getGeometry());
});
});
} else {
if (this.selectInteraction !== undefined) {
this.map.removeInteraction(this.selectInteraction);
}
if (this.modifyInteraction !== undefined) {
this.map.removeInteraction(this.modifyInteraction);
}
this.drawInteraction = new ol.interaction.Draw({
type: this.geoType,
source: this.source,
});
this.map.addInteraction(this.drawInteraction);

this.drawInteraction.on("drawend", (e) => {
this.onUIChange(e.feature.getGeometry());
});
}

const element = this.createTrashControl();
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const config = [{
strict: ["error", "function"],
"use-isnan": "error",

"jsdoc/check-tag-names": "warn",
"jsdoc/check-tag-names": ["warn", { definedTags: ["odoo-module"] }],
"jsdoc/check-types": "warn",
"jsdoc/require-param-description": "off",
"jsdoc/require-return": "off",
Expand Down
Loading