Skip to content

Commit b97d1f4

Browse files
committed
adding fix for multi polygon
1 parent 9153848 commit b97d1f4

File tree

3 files changed

+49
-63
lines changed

3 files changed

+49
-63
lines changed

packages/tdb-documents-ui/src/arrayTypeFrames/arrayTypeFrames.js

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,18 @@ function gatherItems (item, dimension, type) {
4444

4545
// multi polygon
4646
if(dimension === CONST.POLYGON_TYPE_DIMENSION && type === CONST.MULTIPOLYGON) {
47-
let multipolygon=[]
48-
49-
let polygonLayout= {
50-
type: "array",
51-
[CONST.DIMENSION]: dimension,
52-
items: [{
53-
title: item,
54-
type: "array",
55-
items: helper.POINT_TYPE_LAYOUT
56-
}],
57-
additionalItems: {
58-
title: item,
47+
return {
48+
type: "array",
49+
title: "Polygon",
50+
description: "Add a polygon",
51+
items: {
5952
type: "array",
60-
items: helper.POINT_TYPE_LAYOUT
53+
title: "coordinates",
54+
description: "Add coordinates",
55+
items: [ {type: CONST.STRING_TYPE}, {type: CONST.STRING_TYPE} ]
6156
}
6257
}
63-
64-
let multiPolygonLayout = {
65-
type: "array",
66-
title: "polygon",
67-
[CONST.DIMENSION]: dimension,
68-
items: [polygonLayout],
69-
additionalItems: polygonLayout
70-
}
71-
multipolygon.push(multiPolygonLayout)
72-
return multipolygon
58+
7359
}
7460

7561
// mostly b_box
@@ -110,40 +96,48 @@ function gatherUIItems (frame, item, documentation, dimension, type) {
11096
}
11197
}
11298
else if (dimension === CONST.POLYGON_TYPE_DIMENSION && type === CONST.MULTIPOLYGON) {
113-
let uiPolygon = {
114-
"items": helper.POINT_TYPE_UI_LAYOUT
115-
}
116-
117-
let ui={
118-
//"ui:title": "test",
119-
"ui:description": "Add a new Polygon ...",
120-
"classNames": "tdb__input tdb__multipolygon__input",
121-
"items": {
99+
let uiMultiPolygionLayout={
100+
"ui:title": "MultiPolygon",
101+
"ui:description": "MultiPolygon",
102+
"classNames": "card border border-secondary p-2",
103+
items: {
104+
"ui:title": "Polygon",
105+
"ui:description": "Add Polygon ...",
122106
"ui:ArrayFieldTemplate": ArrayFieldTemplate,
123107
"ui:options" : {
124108
addable: true,
125109
orderable: true,
126110
removable: true
127111
},
128-
"items" : helper.POINT_TYPE_UI_LAYOUT,
129-
"additionalItems": helper.POINT_TYPE_UI_LAYOUT
130-
}
131-
}
132-
133-
return {
134-
"ui:title": "polygon",
135-
"items": {
136-
137-
"ui:ArrayFieldTemplate": ArrayFieldTemplate,
138-
"ui:options" : {
139-
addable: true,
140-
orderable: true,
141-
removable: true
142-
},
143-
"items" : ui,
144-
"additionalItems": ui
112+
items: {
113+
"ui:title": "Coordinates",
114+
"ui:description": "Add Coordinates ...",
115+
"ui:ArrayFieldTemplate": ArrayFieldTemplate,
116+
"ui:options" : {
117+
addable: true,
118+
orderable: true,
119+
removable: true
120+
},
121+
items: [
122+
{
123+
"ui:placeholder": `Enter latitude ...`,
124+
classNames: "tdb__input mb-3"
125+
},
126+
{
127+
"ui:placeholder": `Enter longitude ...`,
128+
classNames: "tdb__input mb-3"
129+
}
130+
]
131+
}
132+
},
133+
"ui:ArrayFieldTemplate": ArrayFieldTemplate,
134+
"ui:options" : {
135+
addable: true,
136+
orderable: true,
137+
removable: true
145138
}
146139
}
140+
return uiMultiPolygionLayout
147141
}
148142
else {
149143
// for points and line strings

packages/tdb-documents-ui/src/dataTypeFrames/dataType.utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ export function getUILayout(frame, item, uiFrame, mode, formData, documentation)
1515
let data = formData && formData.hasOwnProperty(item) ? formData[item] : null
1616
let uiLayout=helper.getUIBasedOnType(frame, item, uiFrame, mode, data, documentation)
1717
// if property is lexical key then make read only
18-
if(mode !== CONST.CREATE && frame && frame.hasOwnProperty("@key") && util.checkIfKey(item, frame["@key"])) {
19-
//uiLayout["ui:readonly"] = true
18+
if(mode === CONST.EDIT && frame && frame.hasOwnProperty("@key") && util.checkIfKey(item, frame["@key"])) {
2019
uiLayout["classNames"] = uiLayout["classNames"] + " tdb__key__field "
2120
}
21+
else if(mode === CONST.VIEW) {
22+
uiLayout["ui:readonly"] = true
23+
}
2224
//let addedCustomUI=util.addCustomUI(item, uiFrame, uiLayout)
2325
return uiLayout
2426
}

packages/tdb-documents-ui/src/maps/polygonMapViewer.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,10 @@ export const polygonMapViewer = (args) => {
1515

1616
useEffect(() => {
1717
map()
18-
}, [])
18+
}, [])
1919

2020
const map = () => {
21-
//var latlngs = [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]];
22-
/*documents = [
23-
[ // first polygon
24-
[[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring
25-
[[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole
26-
],
27-
[ // second polygon
28-
[[41, -111.03],[45, -111.04],[45, -104.05],[41, -104.05]]
29-
]
30-
];*/
31-
21+
3222
let mapOptions = customMapOptions(zoom, [37, -109.05], documents, type)
3323
let markerOptions= customMarkerOptions(icon)
3424

0 commit comments

Comments
 (0)