• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jumpinjackie / mapguide-react-layout / 25447908521

06 May 2026 04:29PM UTC coverage: 59.713% (+0.04%) from 59.676%
25447908521

Pull #1645

github

web-flow
Merge da9b43160 into 706e3ead7
Pull Request #1645: Fix TS2322: implement client-side QuickPlot PDF generation

3167 of 3888 branches covered (81.46%)

52 of 63 new or added lines in 3 files covered. (82.54%)

2 existing lines in 1 file now uncovered.

15766 of 26403 relevant lines covered (59.71%)

13.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/api/mapguide-commands.ts
1
import { DefaultCommands, registerCommand, openUrlInTarget, CommandConditions } from './registry/command';
×
2
import { SPRITE_MAPTIP, SPRITE_PRINT, SPRITE_OPTIONS, SPRITE_SELECT_RADIUS, SPRITE_SELECT_POLYGON, SPRITE_SELECT_CLEAR, SPRITE_ICON_ZOOMSELECT, SPRITE_BUFFER, SPRITE_SELECT_FEATURES, SPRITE_REDLINE, SPRITE_FEATURE_INFO, SPRITE_QUERY, SPRITE_THEME, SPRITE_SELECT_CENTRE } from '../constants/assets';
×
3
import { setFeatureTooltipsEnabled, setCurrentView, clearClientSelection } from '../actions/map';
×
4
import { ensureParameters } from '../utils/url';
×
5
import { getRuntimeMap, getSelectionSet, Bounds, SelectionVariant } from './common';
×
6
import { getFusionRoot } from './runtime';
×
7
import { tr } from './i18n';
×
8
import { buildTargetedCommand } from './default-commands';
×
9
import { enableRedlineMessagePrompt } from '../containers/viewer-shim';
×
10
import * as olExtent from "ol/extent";
×
11
import { CompositeSelection } from './composite-selection';
×
12

13
export function initMapGuideCommands() {
×
14
    //Feature Tooltips
15
    registerCommand(DefaultCommands.MapTip, {
×
16
        iconClass: SPRITE_MAPTIP,
×
17
        selected: (state) => {
×
18
            return state.featureTooltipsEnabled === true;
×
19
        },
×
20
        enabled: state => !state.stateless,
×
21
        invoke: (dispatch, getState) => {
×
22
            const enabled = getState().viewer.featureTooltipsEnabled;
×
23
            return dispatch(setFeatureTooltipsEnabled(!enabled));
×
24
        }
×
25
    });
×
26
    //Quick Plot
27
    registerCommand(DefaultCommands.QuickPlot, {
×
28
        iconClass: SPRITE_PRINT,
×
29
        selected: () => false,
×
30
        enabled: state => !state.stateless,
×
31
        invoke: (dispatch, getState, _viewer, parameters) => {
×
32
            const config = getState().config;
×
NEW
33
            const isClientSide = parameters?.ClientSide === "true";
×
NEW
34
            const url = isClientSide ? "component://QuickPlot?clientSide=true" : "component://QuickPlot";
×
35
            const cmdDef = buildTargetedCommand(config, parameters);
×
36
            openUrlInTarget(DefaultCommands.QuickPlot, cmdDef, config.capabilities.hasTaskPane, dispatch, url);
×
37
        }
×
38
    });
×
39
    //Viewer Options
40
    registerCommand(DefaultCommands.ViewerOptions, {
×
41
        iconClass: SPRITE_OPTIONS,
×
42
        selected: () => false,
×
43
        enabled: () => true,
×
44
        invoke: (dispatch, getState, _viewer, parameters) => {
×
45
            const config = getState().config;
×
46
            const url = "component://ViewerOptions";
×
47
            const cmdDef = buildTargetedCommand(config, parameters);
×
48
            openUrlInTarget(DefaultCommands.ViewerOptions, cmdDef, config.capabilities.hasTaskPane, dispatch, url, tr("VIEWER_OPTIONS", config.locale));
×
49
        }
×
50
    });
×
51
    //Select Radius
52
    registerCommand(DefaultCommands.SelectRadius, {
×
53
        iconClass: SPRITE_SELECT_RADIUS,
×
54
        selected: () => false,
×
55
        enabled: state => !state.stateless,
×
56
        invoke: (_dispatch, _getState, viewer, parameters) => {
×
57
            if (viewer) {
×
58
                const selMethod = parameters?.["SelectionType"] as SelectionVariant || "INTERSECTS";
×
59
                viewer.digitizeCircle(circle => {
×
60
                    const fact = viewer.getOLFactory();
×
61
                    const geom = fact.createGeomPolygonFromCircle(circle);
×
62
                    viewer.mapguideSupport()?.selectByGeometry(geom, selMethod);
×
63
                });
×
64
            }
×
65
        }
×
66
    });
×
67
    //Select Polygon
68
    registerCommand(DefaultCommands.SelectPolygon, {
×
69
        iconClass: SPRITE_SELECT_POLYGON,
×
70
        selected: () => false,
×
71
        enabled: state => !state.stateless,
×
72
        invoke: (_dispatch, _getState, viewer, parameters) => {
×
73
            if (viewer) {
×
74
                const selMethod = parameters?.["SelectionType"] as SelectionVariant || "INTERSECTS";
×
75
                viewer.digitizePolygon(geom => {
×
76
                    viewer.mapguideSupport()?.selectByGeometry(geom, selMethod);
×
77
                });
×
78
            }
×
79
        }
×
80
    });
×
81
    //Clear Selection
82
    registerCommand(DefaultCommands.ClearSelection, {
×
83
        iconClass: SPRITE_SELECT_CLEAR,
×
84
        selected: () => false,
×
85
        enabled: state => CommandConditions.hasSelection(state) || CommandConditions.hasClientSelection(state),
×
86
        invoke: (dispatch, getState, viewer) => {
×
87
            const st = getState();
×
88
            if (st.config.activeMapName) {
×
89
                dispatch(clearClientSelection(st.config.activeMapName));
×
90
            }
×
91
            viewer?.mapguideSupport()?.clearSelection();
×
92
        }
×
93
    });
×
94
    //Zoom to Selection
95
    registerCommand(DefaultCommands.ZoomToSelection, {
×
96
        iconClass: SPRITE_ICON_ZOOMSELECT,
×
97
        selected: () => false,
×
98
        enabled: state => CommandConditions.hasSelection(state) || CommandConditions.hasClientSelection(state),
×
99
        invoke: (dispatch, getState, viewer) => {
×
100
            if (viewer) {
×
101
                const fact = viewer.getOLFactory();
×
102
                const st = getState();
×
103
                const selection = getSelectionSet(st);
×
104
                let cs;
×
105
                if (st.config.activeMapName) {
×
106
                    cs = st.mapState[st.config.activeMapName].clientSelection;
×
107
                }
×
108
                const compSel = new CompositeSelection(selection?.SelectedFeatures, cs);
×
109
                const bounds = compSel.getBounds();
×
110
                if (bounds) {
×
111
                    const view = viewer.getViewForExtent(bounds);
×
112
                    dispatch(setCurrentView(view));
×
113
                }
×
114
            }
×
115
        }
×
116
    });
×
117
    //Buffer
118
    registerCommand(DefaultCommands.Buffer, {
×
119
        iconClass: SPRITE_BUFFER,
×
120
        selected: () => false,
×
121
        enabled: state => !state.stateless && CommandConditions.hasSelection(state),
×
122
        invoke: (dispatch, getState, _viewer, parameters) => {
×
123
            const state = getState();
×
124
            const map = getRuntimeMap(state);
×
125
            const config = state.config;
×
126
            if (map) {
×
127
                let url = ensureParameters(`${getFusionRoot()}/widgets/BufferPanel/BufferPanel.php`, map.Name, map.SessionId, config.locale, false);
×
128
                url += "&popup=false&us=0";
×
129
                const cmdDef = buildTargetedCommand(config, parameters);
×
130
                openUrlInTarget(DefaultCommands.Buffer, cmdDef, config.capabilities.hasTaskPane, dispatch, url);
×
131
            }
×
132
        }
×
133
    });
×
134
    //Select Within
135
    registerCommand(DefaultCommands.SelectWithin, {
×
136
        iconClass: SPRITE_SELECT_FEATURES,
×
137
        selected: () => false,
×
138
        enabled: (state, parameters) => !state.stateless && !CommandConditions.disabledIfEmptySelection(state, parameters),
×
139
        invoke: (dispatch, getState, _viewer, parameters) => {
×
140
            const state = getState();
×
141
            const map = getRuntimeMap(state);
×
142
            const config = state.config;
×
143
            if (map) {
×
144
                let url = ensureParameters(`${getFusionRoot()}/widgets/SelectWithin/SelectWithinPanel.php`, map.Name, map.SessionId, config.locale, false);
×
145
                url += "&popup=false";
×
146
                const cmdDef = buildTargetedCommand(config, parameters);
×
147
                openUrlInTarget(DefaultCommands.SelectWithin, cmdDef, config.capabilities.hasTaskPane, dispatch, url);
×
148
            }
×
149
        }
×
150
    });
×
151
    //Redline
152
    registerCommand(DefaultCommands.Redline, {
×
153
        iconClass: SPRITE_REDLINE,
×
154
        selected: () => false,
×
155
        enabled: state => !state.stateless && CommandConditions.isNotBusy(state),
×
156
        invoke: (dispatch, getState, viewer, parameters) => {
×
157
            const state = getState();
×
158
            const map = getRuntimeMap(state);
×
159
            const config = state.config;
×
160
            if (map) {
×
161
                let bUseAdvancedStylization = true;
×
162
                let defaultDataStoreFormat = null;
×
163
                let defaultRedlineGeometryType = 0;
×
164
                let bCreateOnStartup = false;
×
165
                if (parameters?.["AutogenerateLayerNames"])
×
166

167
                if (parameters?.["StylizationType"])
×
168
                    bUseAdvancedStylization = (parameters["StylizationType"] == "advanced");
×
169
                
170
                if (parameters?.["DataStoreFormat"] && parameters?.["RedlineGeometryFormat"]) {
×
171
                    if (parameters["DataStoreFormat"] == "SDF" ||
×
172
                        parameters["DataStoreFormat"] == "SHP" ||
×
173
                        parameters["DataStoreFormat"] == "SQLite") {
×
174
                        
175
                        var geomTypes = parseInt(`${parameters["RedlineGeometryFormat"]}`);
×
176
                        if (parameters["DataStoreFormat"] == "SHP") {
×
177
                            //Only accept if geometry type is singular
178
                            if (geomTypes == 1 || geomTypes == 2 || geomTypes == 4) {
×
179
                                defaultDataStoreFormat = parameters["DataStoreFormat"];
×
180
                                defaultRedlineGeometryType = geomTypes;
×
181
                                if (parameters?.["AutoCreateOnStartup"])
×
182
                                    bCreateOnStartup = (parameters["AutoCreateOnStartup"] == "true");
×
183
                            }
×
184
                        } else {
×
185
                            defaultDataStoreFormat = parameters["DataStoreFormat"];
×
186
                            defaultRedlineGeometryType = geomTypes;
×
187
                            if (parameters?.["AutoCreateOnStartup"])
×
188
                                bCreateOnStartup = (parameters["AutoCreateOnStartup"] == "true");
×
189
                        }
×
190
                    }
×
191
                }
×
192

193
                enableRedlineMessagePrompt(parameters?.["UseMapMessage"] == "true");
×
194
                let url = ensureParameters(`${getFusionRoot()}/widgets/Redline/markupmain.php`, map.Name, map.SessionId, config.locale, true);
×
195
                url += "&POPUP=false";
×
196
                if (defaultDataStoreFormat != null && defaultRedlineGeometryType > 0) {
×
197
                    url += `&REDLINEFORMAT=${defaultDataStoreFormat}`;
×
198
                    url += `&REDLINEGEOMTYPE=${defaultRedlineGeometryType}`;
×
199
                    url += `&AUTOCREATE=${bCreateOnStartup ? "1" : "0"}`;
×
200
                }
×
201
                url += `&REDLINESTYLIZATION=${bUseAdvancedStylization ? "ADVANCED" : "BASIC"}`;
×
202
                const cmdDef = buildTargetedCommand(config, parameters);
×
203
                openUrlInTarget(DefaultCommands.Redline, cmdDef, config.capabilities.hasTaskPane, dispatch, url);
×
204
            }
×
205
        }
×
206
    });
×
207
    //Feature Info
208
    registerCommand(DefaultCommands.FeatureInfo, {
×
209
        iconClass: SPRITE_FEATURE_INFO,
×
210
        selected: () => false,
×
211
        enabled: state => !state.stateless && CommandConditions.isNotBusy(state),
×
212
        invoke: (dispatch, getState, _viewer, parameters) => {
×
213
            const state = getState();
×
214
            const map = getRuntimeMap(state);
×
215
            const config = state.config;
×
216
            if (map) {
×
217
                const url = ensureParameters(`${getFusionRoot()}/widgets/FeatureInfo/featureinfomain.php`, map.Name, map.SessionId, config.locale, true);
×
218
                const cmdDef = buildTargetedCommand(config, parameters);
×
219
                openUrlInTarget(DefaultCommands.FeatureInfo, cmdDef, config.capabilities.hasTaskPane, dispatch, url);
×
220
            }
×
221
        }
×
222
    });
×
223
    //Query
224
    registerCommand(DefaultCommands.Query, {
×
225
        iconClass: SPRITE_QUERY,
×
226
        selected: () => false,
×
227
        enabled: state => !state.stateless && CommandConditions.isNotBusy(state),
×
228
        invoke: (dispatch, getState, _viewer, parameters) => {
×
229
            const state = getState();
×
230
            const map = getRuntimeMap(state);
×
231
            const config = state.config;
×
232
            if (map) {
×
233
                const url = ensureParameters(`${getFusionRoot()}/widgets/Query/querymain.php`, map.Name, map.SessionId, config.locale, true);
×
234
                const cmdDef = buildTargetedCommand(config, parameters);
×
235
                openUrlInTarget(DefaultCommands.Query, cmdDef, config.capabilities.hasTaskPane, dispatch, url);
×
236
            }
×
237
        }
×
238
    });
×
239
    //Theme
240
    registerCommand(DefaultCommands.Theme, {
×
241
        iconClass: SPRITE_THEME,
×
242
        selected: () => false,
×
243
        enabled: state => !state.stateless && CommandConditions.isNotBusy(state),
×
244
        invoke: (dispatch, getState, _viewer, parameters) => {
×
245
            const state = getState();
×
246
            const map = getRuntimeMap(state);
×
247
            const config = state.config;
×
248
            if (map) {
×
249
                const url = ensureParameters(`${getFusionRoot()}/widgets/Theme/thememain.php`, map.Name, map.SessionId, config.locale, true);
×
250
                const cmdDef = buildTargetedCommand(config, parameters);
×
251
                openUrlInTarget(DefaultCommands.Theme, cmdDef, config.capabilities.hasTaskPane, dispatch, url);
×
252
            }
×
253
        }
×
254
    });
×
255
    //Center Selection
256
    registerCommand(DefaultCommands.CenterSelection, {
×
257
        iconClass: SPRITE_SELECT_CENTRE,
×
258
        selected: () => false,
×
259
        enabled: state => !state.stateless && CommandConditions.hasSelection(state),
×
260
        invoke: (dispatch, getState, viewer) => {
×
261
            const state = getState();
×
262
            const mapName = state.config.activeMapName;
×
263
            if (mapName && viewer) {
×
264
                const mapState = state.mapState[mapName];
×
265
                const sf = mapState?.mapguide?.selectionSet?.SelectedFeatures;
×
266
                if (sf) {
×
267
                    let bbox;
×
268
                    for (const layer of sf.SelectedLayer) {
×
269
                        for (const f of layer.Feature.filter(f => f.Bounds != null)) {
×
270
                            const b: any = f.Bounds!.split(" ").map(s => parseFloat(s));
×
271
                            if (!bbox) {
×
272
                                bbox = b;
×
273
                            } else {
×
274
                                bbox = olExtent.extend(bbox, b);
×
275
                            }
×
276
                        }
×
277
                    }
×
278
                    if (bbox) {
×
279
                        const view = viewer.getViewForExtent(bbox);
×
280
                        dispatch(setCurrentView(view));
×
281
                    }
×
282
                }
×
283
            }
×
284
        }
×
285
    });
×
286
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc