@corpsmap/corpsmap 3.2.77 → 3.2.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,290 +1,349 @@
1
- import v4 from 'uuid/v4';
1
+ import { v4 } from "uuid/v4";
2
2
 
3
3
  export default {
4
- name: 'ui',
5
-
4
+ name: "ui",
5
+
6
6
  getReducer: () => {
7
7
  const initialData = {
8
- northConfig:{
9
- height: window.innerHeight
8
+ northConfig: {
9
+ height: window.innerHeight,
10
10
  },
11
- southConfig:{
11
+ southConfig: {
12
12
  height: 0,
13
- children: []
13
+ children: [],
14
14
  },
15
- primaryPanelConfig:{
15
+ primaryPanelConfig: {
16
16
  openedBy: null,
17
17
  width: 420,
18
18
  children: [],
19
- options: null
19
+ options: null,
20
20
  },
21
- secondaryPanelConfig:{
21
+ secondaryPanelConfig: {
22
22
  open: false,
23
23
  width: 300,
24
24
  children: [],
25
- options: null
25
+ options: null,
26
26
  },
27
- modalConfig:{
27
+ modalConfig: {
28
28
  children: [],
29
29
  options: null,
30
- openedBy: null
30
+ openedBy: null,
31
31
  },
32
- basicToolbarConfig:{
33
- activeTool: null
32
+ basicToolbarConfig: {
33
+ activeTool: null,
34
34
  },
35
- theme: 'bg-blue-chambray',
36
- shouldUpdateWindowSize: false
37
- }
35
+ theme: "bg-blue-chambray",
36
+ shouldUpdateWindowSize: false,
37
+ };
38
38
 
39
39
  return (state = initialData, { type, payload }) => {
40
-
41
- if(type === 'WINDOW_RESIZE'){
42
- return Object.assign({}, state, {
43
- shouldUpdateWindowSize: true
40
+ if (type === "WINDOW_RESIZE") {
41
+ return Object.assign({}, state, {
42
+ shouldUpdateWindowSize: true,
44
43
  });
45
44
  }
46
45
 
47
- if(type.indexOf('UI_UPDATE_WINDOW_SIZE_') !== -1){
46
+ if (type.indexOf("UI_UPDATE_WINDOW_SIZE_") !== -1) {
48
47
  return Object.assign({}, state, payload);
49
48
  }
50
49
 
51
- if(type === 'UI_RESIZED_NORTH_SOUTH'){
50
+ if (type === "UI_RESIZED_NORTH_SOUTH") {
52
51
  const northConfig = {
53
- height: payload.hNorth
54
- }
52
+ height: payload.hNorth,
53
+ };
55
54
  const southConfig = {
56
55
  height: payload.hSouth,
57
56
  children: state.southConfig.children,
58
- options: state.southConfig.options
59
- }
57
+ options: state.southConfig.options,
58
+ };
60
59
  return Object.assign({}, state, {
61
60
  northConfig: northConfig,
62
- southConfig: southConfig
63
- })
61
+ southConfig: southConfig,
62
+ });
64
63
  }
65
64
 
66
- if(type === 'UI_OPENED_SOUTH_PANEL'){
65
+ if (type === "UI_OPENED_SOUTH_PANEL") {
67
66
  const northConfig = {
68
- height: window.innerHeight / 2
69
- }
67
+ height: window.innerHeight / 2,
68
+ };
70
69
  const southConfig = {
71
70
  height: window.innerHeight / 2,
72
- children: payload.children
73
- }
71
+ children: payload.children,
72
+ };
74
73
  return Object.assign({}, state, {
75
74
  northConfig: northConfig,
76
- southConfig: southConfig
77
- })
75
+ southConfig: southConfig,
76
+ });
78
77
  }
79
78
 
80
- if(type === 'UI_CLOSED_SOUTH_PANEL'){
79
+ if (type === "UI_CLOSED_SOUTH_PANEL") {
81
80
  const northConfig = {
82
- height: window.innerHeight
83
- }
81
+ height: window.innerHeight,
82
+ };
84
83
  const southConfig = {
85
84
  height: 0,
86
- children: []
87
- }
85
+ children: [],
86
+ };
88
87
  return Object.assign({}, state, {
89
88
  northConfig: northConfig,
90
- southConfig: southConfig
91
- })
89
+ southConfig: southConfig,
90
+ });
92
91
  }
93
92
 
94
- if(type === 'UI_CLOSED_SOUTH_TAB'){
93
+ if (type === "UI_CLOSED_SOUTH_TAB") {
95
94
  const southConfig = {
96
- children: payload.children
97
- }
95
+ children: payload.children,
96
+ };
98
97
  return Object.assign({}, state, {
99
- southConfig: southConfig
100
- })
98
+ southConfig: southConfig,
99
+ });
101
100
  }
102
101
 
103
- if(type === 'UI_OPENED_MODAL_WINDOW'){
102
+ if (type === "UI_OPENED_MODAL_WINDOW") {
104
103
  const modalConfig = {
105
104
  children: payload.children,
106
105
  options: payload.options,
107
- openedBy: payload.openedBy
108
- }
106
+ openedBy: payload.openedBy,
107
+ };
109
108
  return Object.assign({}, state, {
110
- modalConfig: modalConfig
111
- })
109
+ modalConfig: modalConfig,
110
+ });
112
111
  }
113
112
 
114
- if(type === 'UI_CLOSED_MODAL_WINDOW'){
113
+ if (type === "UI_CLOSED_MODAL_WINDOW") {
115
114
  const modalConfig = {
116
115
  children: [],
117
116
  options: null,
118
- openedBy: null
119
- }
117
+ openedBy: null,
118
+ };
120
119
  return Object.assign({}, state, {
121
- modalConfig: modalConfig
122
- })
120
+ modalConfig: modalConfig,
121
+ });
123
122
  }
124
123
 
125
- if(type === 'UI_OPENED_PRIMARY_PANEL'){
124
+ if (type === "UI_OPENED_PRIMARY_PANEL") {
126
125
  const primaryPanelConfig = {
127
126
  openedBy: payload.openedBy,
128
127
  width: state.primaryPanelConfig.width,
129
128
  children: payload.children,
130
- options: payload.options
131
- }
129
+ options: payload.options,
130
+ };
132
131
  return Object.assign({}, state, {
133
- primaryPanelConfig: primaryPanelConfig
134
- })
132
+ primaryPanelConfig: primaryPanelConfig,
133
+ });
135
134
  }
136
135
 
137
- if(type === 'UI_CLOSED_PRIMARY_PANEL'){
136
+ if (type === "UI_CLOSED_PRIMARY_PANEL") {
138
137
  const primaryPanelConfig = {
139
138
  openedBy: null,
140
139
  width: state.primaryPanelConfig.width,
141
140
  left: state.primaryPanelConfig.left,
142
141
  children: [],
143
- options: null
144
- }
142
+ options: null,
143
+ };
145
144
  return Object.assign({}, state, {
146
- primaryPanelConfig: primaryPanelConfig
147
- })
145
+ primaryPanelConfig: primaryPanelConfig,
146
+ });
148
147
  }
149
148
 
150
- if(type === 'UI_RESIZED_PRIMARY_PANEL'){
149
+ if (type === "UI_RESIZED_PRIMARY_PANEL") {
151
150
  const primaryPanelConfig = {
152
151
  open: state.primaryPanelConfig.open,
153
152
  width: payload.width,
154
153
  left: state.primaryPanelConfig.left,
155
154
  children: state.primaryPanelConfig.children,
156
155
  options: state.primaryPanelConfig.options,
157
- openedBy: state.primaryPanelConfig.openedBy
158
- }
156
+ openedBy: state.primaryPanelConfig.openedBy,
157
+ };
159
158
  const secondaryPanelConfig = {
160
159
  open: state.secondaryPanelConfig.open,
161
160
  width: state.secondaryPanelConfig.width,
162
161
  left: payload.width,
163
162
  children: state.secondaryPanelConfig.children,
164
163
  options: state.secondaryPanelConfig.options,
165
- openedBy: state.secondaryPanelConfig.openedBy
166
- }
164
+ openedBy: state.secondaryPanelConfig.openedBy,
165
+ };
167
166
  return Object.assign({}, state, {
168
167
  primaryPanelConfig: primaryPanelConfig,
169
- secondaryPanelConfig: secondaryPanelConfig
170
- })
168
+ secondaryPanelConfig: secondaryPanelConfig,
169
+ });
171
170
  }
172
171
 
173
- if(type === 'UI_ACTIVATE_BASIC_TOOL'){
172
+ if (type === "UI_ACTIVATE_BASIC_TOOL") {
174
173
  const basicToolbarConfig = {
175
- activeTool: payload
176
- }
174
+ activeTool: payload,
175
+ };
177
176
  return Object.assign({}, state, {
178
- basicToolbarConfig: basicToolbarConfig
179
- })
177
+ basicToolbarConfig: basicToolbarConfig,
178
+ });
180
179
  }
181
180
 
182
- if(type === 'UI_DEACTIVATE_BASIC_TOOL'){
181
+ if (type === "UI_DEACTIVATE_BASIC_TOOL") {
183
182
  const basicToolbarConfig = {
184
- activeTool: null
185
- }
183
+ activeTool: null,
184
+ };
186
185
  return Object.assign({}, state, {
187
- basicToolbarConfig: basicToolbarConfig
188
- })
186
+ basicToolbarConfig: basicToolbarConfig,
187
+ });
189
188
  }
190
189
 
191
- if(type === 'UI_THEME_CHANGED'){
190
+ if (type === "UI_THEME_CHANGED") {
192
191
  return Object.assign({}, state, {
193
- theme: payload
194
- })
192
+ theme: payload,
193
+ });
195
194
  }
196
195
 
197
196
  return state;
198
- }
197
+ };
199
198
  },
200
199
 
201
200
  // ACTION CREATORS
202
- doUiUpdateWindowSize: () => ({ dispatch, store }) => {
203
- dispatch({ type: 'UI_UPDATE_WINDOW_SIZE_START', payload: { shouldUpdateWindowSize: false }});
204
- const h = store.selectViewportHeight();
205
- const northConfig = store.selectNorthConfig();
206
- const southConfig = store.selectSouthConfig();
207
- const northPortion = northConfig.height / (northConfig.height + southConfig.height);
208
- const southPortion = southConfig.height / (northConfig.height + southConfig.height);
209
- const newPayload = {
210
- northConfig: Object.assign({}, northConfig, { height: h * northPortion }),
211
- southConfig: Object.assign({}, southConfig, { height: h * southPortion })
212
- }
213
- dispatch({ type: 'UI_UPDATE_WINDOW_SIZE_COMPLETE', payload: newPayload});
214
- store.doMapUpdateSize();
215
- },
216
-
217
- doMapUpdateSize: () => ({ dispatch, store }) => {
218
- const map = store.selectMap();
219
- window.setTimeout(() => { map.updateSize(); }, 100);
220
- },
221
-
222
- doSouthRegionOpen: ({ component, options, openedBy, displayName }) => ({ dispatch, store }) => {
223
- const existingChildren = store.selectSouthRegionChildren();
224
- const uid = v4();
225
- dispatch({type:'UI_OPENED_SOUTH_PANEL', payload:{
226
- children: existingChildren.concat([{ component, options, openedBy, displayName, uid }])
227
- }});
228
- store.doMapUpdateSize();
229
- },
230
-
231
- doCloseSouthTab: (child) => ({ dispatch, store }) => {
232
- const children = store.selectSouthRegionChildren().slice();
233
- const idx = children.indexOf(child);
234
- children.splice(idx, 1);
235
- dispatch({type:'UI_CLOSED_SOUTH_TAB', payload: { children: children }});
236
- if(children.length === 0) return store.doCloseSouthRegion();
237
- },
238
-
239
- doCloseSouthRegion: () => ({ dispatch, store }) => {
240
- dispatch({type:'UI_CLOSED_SOUTH_PANEL'});
241
- store.doMapUpdateSize();
242
- },
243
-
244
- doModalOpen: ({ children, options, openedBy }) => ({ dispatch }) => {
245
- dispatch({type:'UI_OPENED_MODAL_WINDOW', payload: {children, options, openedBy }});
246
- },
247
-
248
- doModalClose: () => ({ dispatch }) => {
249
- dispatch({type:'UI_CLOSED_MODAL_WINDOW'});
250
- },
251
-
252
- doPrimaryPanelOpen: ({ children, options, openedBy }) => ({ dispatch }) => {
253
- dispatch({type:'UI_OPENED_PRIMARY_PANEL', payload:{ children, options, openedBy }});
254
- },
255
-
256
- doPrimaryPanelClose: () => ({ dispatch }) => {
257
- dispatch({type:'UI_CLOSED_PRIMARY_PANEL'});
258
- },
259
-
260
- doOpenSecondaryPanel: ({ children, options, openedBy }) => ({ dispatch }) => {
261
- dispatch({type:'UI_OPENED_SECONDARY_PANEL', payload:{ children, options, openedBy }});
262
- },
263
-
264
- doCloseSecondaryPanel: () => ({ dispatch }) => {
265
- dispatch({type:'UI_CLOSED_SECONDARY_PANEL'});
266
- },
267
-
268
- doSetTheme: (newTheme) => ({ dispatch }) => {
269
- dispatch({type:'UI_THEME_CHANGED', payload: newTheme});
270
- },
271
-
272
- doResizeSouthRegion: ({ hNorth, hSouth }) => ({ dispatch, store }) => {
273
- dispatch({type:'UI_RESIZED_NORTH_SOUTH', payload:{ hNorth, hSouth }});
274
- store.doMapUpdateSize()
275
- },
276
-
277
- doPrimaryPanelResize: ({ width }) => ({ dispatch }) => {
278
- dispatch({type:'UI_RESIZED_PRIMARY_PANEL', payload:{ width }});
279
- },
280
-
281
- doBasicToolbarActivate: ({ activeTool }) => ({ dispatch }) => {
282
- dispatch({type:'UI_ACTIVATE_BASIC_TOOL', payload: activeTool });
283
- },
284
-
285
- doBasicToolbarDeactivate: () => ({ dispatch }) => {
286
- dispatch({type:'UI_DEACTIVATE_BASIC_TOOL'});
287
- },
201
+ doUiUpdateWindowSize:
202
+ () =>
203
+ ({ dispatch, store }) => {
204
+ dispatch({
205
+ type: "UI_UPDATE_WINDOW_SIZE_START",
206
+ payload: { shouldUpdateWindowSize: false },
207
+ });
208
+ const h = store.selectViewportHeight();
209
+ const northConfig = store.selectNorthConfig();
210
+ const southConfig = store.selectSouthConfig();
211
+ const northPortion =
212
+ northConfig.height / (northConfig.height + southConfig.height);
213
+ const southPortion =
214
+ southConfig.height / (northConfig.height + southConfig.height);
215
+ const newPayload = {
216
+ northConfig: Object.assign({}, northConfig, {
217
+ height: h * northPortion,
218
+ }),
219
+ southConfig: Object.assign({}, southConfig, {
220
+ height: h * southPortion,
221
+ }),
222
+ };
223
+ dispatch({ type: "UI_UPDATE_WINDOW_SIZE_COMPLETE", payload: newPayload });
224
+ store.doMapUpdateSize();
225
+ },
226
+
227
+ doMapUpdateSize:
228
+ () =>
229
+ ({ dispatch, store }) => {
230
+ const map = store.selectMap();
231
+ window.setTimeout(() => {
232
+ map.updateSize();
233
+ }, 100);
234
+ },
235
+
236
+ doSouthRegionOpen:
237
+ ({ component, options, openedBy, displayName }) =>
238
+ ({ dispatch, store }) => {
239
+ const existingChildren = store.selectSouthRegionChildren();
240
+ const uid = v4();
241
+ dispatch({
242
+ type: "UI_OPENED_SOUTH_PANEL",
243
+ payload: {
244
+ children: existingChildren.concat([
245
+ { component, options, openedBy, displayName, uid },
246
+ ]),
247
+ },
248
+ });
249
+ store.doMapUpdateSize();
250
+ },
251
+
252
+ doCloseSouthTab:
253
+ (child) =>
254
+ ({ dispatch, store }) => {
255
+ const children = store.selectSouthRegionChildren().slice();
256
+ const idx = children.indexOf(child);
257
+ children.splice(idx, 1);
258
+ dispatch({
259
+ type: "UI_CLOSED_SOUTH_TAB",
260
+ payload: { children: children },
261
+ });
262
+ if (children.length === 0) return store.doCloseSouthRegion();
263
+ },
264
+
265
+ doCloseSouthRegion:
266
+ () =>
267
+ ({ dispatch, store }) => {
268
+ dispatch({ type: "UI_CLOSED_SOUTH_PANEL" });
269
+ store.doMapUpdateSize();
270
+ },
271
+
272
+ doModalOpen:
273
+ ({ children, options, openedBy }) =>
274
+ ({ dispatch }) => {
275
+ dispatch({
276
+ type: "UI_OPENED_MODAL_WINDOW",
277
+ payload: { children, options, openedBy },
278
+ });
279
+ },
280
+
281
+ doModalClose:
282
+ () =>
283
+ ({ dispatch }) => {
284
+ dispatch({ type: "UI_CLOSED_MODAL_WINDOW" });
285
+ },
286
+
287
+ doPrimaryPanelOpen:
288
+ ({ children, options, openedBy }) =>
289
+ ({ dispatch }) => {
290
+ dispatch({
291
+ type: "UI_OPENED_PRIMARY_PANEL",
292
+ payload: { children, options, openedBy },
293
+ });
294
+ },
295
+
296
+ doPrimaryPanelClose:
297
+ () =>
298
+ ({ dispatch }) => {
299
+ dispatch({ type: "UI_CLOSED_PRIMARY_PANEL" });
300
+ },
301
+
302
+ doOpenSecondaryPanel:
303
+ ({ children, options, openedBy }) =>
304
+ ({ dispatch }) => {
305
+ dispatch({
306
+ type: "UI_OPENED_SECONDARY_PANEL",
307
+ payload: { children, options, openedBy },
308
+ });
309
+ },
310
+
311
+ doCloseSecondaryPanel:
312
+ () =>
313
+ ({ dispatch }) => {
314
+ dispatch({ type: "UI_CLOSED_SECONDARY_PANEL" });
315
+ },
316
+
317
+ doSetTheme:
318
+ (newTheme) =>
319
+ ({ dispatch }) => {
320
+ dispatch({ type: "UI_THEME_CHANGED", payload: newTheme });
321
+ },
322
+
323
+ doResizeSouthRegion:
324
+ ({ hNorth, hSouth }) =>
325
+ ({ dispatch, store }) => {
326
+ dispatch({ type: "UI_RESIZED_NORTH_SOUTH", payload: { hNorth, hSouth } });
327
+ store.doMapUpdateSize();
328
+ },
329
+
330
+ doPrimaryPanelResize:
331
+ ({ width }) =>
332
+ ({ dispatch }) => {
333
+ dispatch({ type: "UI_RESIZED_PRIMARY_PANEL", payload: { width } });
334
+ },
335
+
336
+ doBasicToolbarActivate:
337
+ ({ activeTool }) =>
338
+ ({ dispatch }) => {
339
+ dispatch({ type: "UI_ACTIVATE_BASIC_TOOL", payload: activeTool });
340
+ },
341
+
342
+ doBasicToolbarDeactivate:
343
+ () =>
344
+ ({ dispatch }) => {
345
+ dispatch({ type: "UI_DEACTIVATE_BASIC_TOOL" });
346
+ },
288
347
 
289
348
  // SELECTORS
290
349
  selectNorthConfig: (state) => {
@@ -340,6 +399,7 @@ export default {
340
399
  },
341
400
 
342
401
  reactShouldUpdateWindowSize: (state) => {
343
- if(state.ui.shouldUpdateWindowSize) return { actionCreator: 'doUiUpdateWindowSize' };
344
- }
345
- }
402
+ if (state.ui.shouldUpdateWindowSize)
403
+ return { actionCreator: "doUiUpdateWindowSize" };
404
+ },
405
+ };