Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve types and its domains #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
"typescript": "5.4.5",
"vue": "2.7.15",
"vue-template-compiler": "2.7.15"
},
"dependencies": {
"mapapps-4-developers": "file:"
}
}
6 changes: 3 additions & 3 deletions src/main/js/apps/sample/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
"storeId": "flurstuecke_store",
"fields": [
{
"name": "NAMGMK",
"name": "namgmk",
"label": "Gemarkung"
},
{
"name": "FLN",
"name": "fln",
"label": "Flur"
},
{
"name": "ZAE",
"name": "zae",
"label": "Flurstück"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ export default class HierarchicalSearchController {
private mapActions: any;
private mapActionsConfig: any;
private widget: any;
private types: any;
private domains: any;
private resolveTypes: boolean;

activate(componentContext: InjectedReference<any>): void {
const bundleContext = this.bundleContext = componentContext.getBundleContext();
const serviceResolver = this.serviceResolver = new ServiceResolver({});
serviceResolver.setBundleCtx(bundleContext);
}

/**
* Method that enables the hierarchical search function of the bundle
* @param event emitted by clickHandler, on click, use to access clicked tool
Expand All @@ -59,11 +63,15 @@ export default class HierarchicalSearchController {
const fields = tool.fields;
this.mapActions = tool.mapActions;
this.mapActionsConfig = tool.mapActionsConfig;
this.resolveTypes = tool.resolveTypes;
this.types = {};
this.domains = {};

const model = this._hierarchicalSearchModel;
const envs = this.bundleContext.getCurrentExecutionEnvironment();
model.isMobile = envs.some((env) => env.name === "Mobile");
model.fields = this.getFields(fields);

this.setUpSelect(0);

let widget;
Expand All @@ -82,10 +90,10 @@ export default class HierarchicalSearchController {
const window: any = ct_util.findEnclosingWindow(widget);
if (window) {
window.set("title", tool.title);
window.on("Close", () => {
window.onHide = () => {
this.hideWidget();
this.resetSearch();
});
};
}
}, 100);
}
Expand Down Expand Up @@ -154,8 +162,10 @@ export default class HierarchicalSearchController {
}
}

private queryDistinctValues(field: Field, index: number): void {
private async queryDistinctValues(field: Field, index: number): void {

const queryUrl = this.store.target;
const model = this._hierarchicalSearchModel;
if (!queryUrl) {
console.error("Store has no target!");
return;
Expand All @@ -170,13 +180,41 @@ export default class HierarchicalSearchController {
});
if (index === 0) {
queryObject.where = "1=1";
if(this.resolveTypes && this.store.layer.types && this.store.layer.typeIdField === fieldName) {
this.store.layer.types.forEach((type) => {
this.types[type.id] = type;
});
}
} else {
const complexQuery = this.getComplexQuery();
queryObject.where = toSQLWhere(complexQuery, {});
if(this.resolveTypes && this.types && this.types[model.fields[0].value.value] && this.types[model.fields[0].value.value].domains[fieldName]) {
this.domains = {};
this.types[model.fields[0].value.value].domains[fieldName].codedValues.forEach((domain) => {
this.domains[domain.code] = domain.name;
});
}
else {
this.domains = undefined;
}
}

const layer = this.store.layer;
const types = this.types;
const domains = this.domains;
const resolveTypes = this.resolveTypes;

query.executeQueryJSON(this.store.target, queryObject).then(function (response) {
response.features.forEach((feature) => {
field.items.push(feature.attributes[fieldName]);
if (resolveTypes && index === 0 && layer.typeIdField == fieldName) {
field.items.push({value: feature.attributes[fieldName], label: types[feature.attributes[fieldName]].name});
}
else if (resolveTypes && index !== 0 && domains ) {
field.items.push({value: feature.attributes[fieldName], label: domains[feature.attributes[fieldName]]});
}
else {
field.items.push({value: feature.attributes[fieldName], label: feature.attributes[fieldName]});
}
});
field.loading = false;
});
Expand Down Expand Up @@ -247,7 +285,7 @@ export default class HierarchicalSearchController {
const searchObj = {};
model.fields.forEach((field: Field) => {
if (field && field.value) {
searchObj[field.name] = field.value;
searchObj[field.name] = field.value.value;
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<v-combobox
v-model="field.value"
:items="field.items"
item-text="label"
item-value="value"
:label="field.label"
:aria-label="field.label"
:disabled="fieldIsDisabled(field)"
Expand Down
7 changes: 5 additions & 2 deletions src/main/js/bundles/dn_hierarchicalsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ The menus will be filled automatically based on the attribute ID and the previou
],
"mapActionsConfig": {
"zoomto-scale": 5000
}
},
"resolveTypes": false
},
{
"id": "adresssuche",
Expand Down Expand Up @@ -84,7 +85,8 @@ The menus will be filled automatically based on the attribute ID and the previou
],
"mapActionsConfig": {
"zoomto-scale": 5000
}
},
"resolveTypes": false
}
]
},
Expand Down Expand Up @@ -134,3 +136,4 @@ The menus will be filled automatically based on the attribute ID and the previou
| field.label | String | | | Label for the drop down element |
| mapActions | Array | ```"zoomto"``` &#124; ```"openPopup"``` &#124; ```"highlight"``` &#124; ```"sendResultToResultUI"``` &#124; ```"sendResultToResultCenter"``` | ```["zoomto", "highlight"]``` | Array map-actions to apply to result |
| mapActionsConfig | Object | see [Configuration Reference](https://demos.conterra.de/mapapps/resources/jsregistry/root/map-actions/4.15.0/README.md#b%3Dmap-actions%3Bv%3D4.15.0%3Bvr%3D%5E4.15%3Bp%3Dmap.apps%3Bf%3Dmap-actions%3B) | ```{"zoomto-scale": 5000}``` | Object containing map-action configruation parameters |
| resolveTypes| Boolean| true/false | false | If the store has types, this parameter should indicate if the codes of the types and domains or the name should be shown. If true the names will be shown. However it is important that the TypeIdField is the first field.
3 changes: 2 additions & 1 deletion src/main/js/bundles/dn_hierarchicalsearch/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
],
"mapActionsConfig": {
"zoomto-scale": 5000
}
},
"resolveTypes" : false
},
"references": [
{
Expand Down
Loading