@@ -7,11 +7,18 @@ import {
7
7
removeManager ,
8
8
addOwner ,
9
9
removeOwner ,
10
- getOrgTeams ,
10
+ getOrgLocations ,
11
11
getOrgStaff ,
12
12
} from '../../../lib/org-api'
13
13
import { getUserOrgProfile } from '../../../lib/profiles-api'
14
- import { Box , Container , Heading , Button , Flex } from '@chakra-ui/react'
14
+ import {
15
+ Box ,
16
+ Checkbox ,
17
+ Container ,
18
+ Heading ,
19
+ Button ,
20
+ Flex ,
21
+ } from '@chakra-ui/react'
15
22
import Table from '../../../components/tables/table'
16
23
import { AddMemberByIdForm } from '../../../components/add-member-form'
17
24
import ProfileModal from '../../../components/profile-modal'
@@ -66,6 +73,8 @@ class Organization extends Component {
66
73
profileInfo : [ ] ,
67
74
profileUserId : '' ,
68
75
teams : [ ] ,
76
+ searchOnMapMove : false ,
77
+ mapBounds : undefined ,
69
78
managers : [ ] ,
70
79
owners : [ ] ,
71
80
page : 0 ,
@@ -75,14 +84,15 @@ class Organization extends Component {
75
84
76
85
this . closeProfileModal = this . closeProfileModal . bind ( this )
77
86
this . renderBadges = this . renderBadges . bind ( this )
87
+ this . renderMap = this . renderMap . bind ( this )
78
88
}
79
89
80
90
async componentDidMount ( ) {
81
91
this . setState ( { session : await getSession ( ) } )
82
92
await this . getOrg ( )
83
93
await this . getOrgStaff ( )
84
94
await this . getBadges ( )
85
- await this . getOrgTeams ( )
95
+ await this . getOrgLocations ( )
86
96
}
87
97
88
98
async openProfileModal ( user ) {
@@ -165,10 +175,10 @@ class Organization extends Component {
165
175
}
166
176
}
167
177
168
- async getOrgTeams ( ) {
178
+ async getOrgLocations ( ) {
169
179
const { id } = this . props
170
180
try {
171
- let teams = await getOrgTeams ( id )
181
+ let teams = await getOrgLocations ( id )
172
182
this . setState ( {
173
183
teams,
174
184
} )
@@ -258,6 +268,28 @@ class Organization extends Component {
258
268
) : null
259
269
}
260
270
271
+ /**
272
+ * Bounds is a WESN box, refresh teams
273
+ */
274
+ onMapBoundsChange ( bounds ) {
275
+ if ( this . state . searchOnMapMove ) {
276
+ this . setState ( {
277
+ mapBounds : bounds ,
278
+ } )
279
+ } else {
280
+ this . setState ( { mapBounds : null } )
281
+ }
282
+ }
283
+
284
+ setSearchOnMapMove ( e ) {
285
+ this . setState (
286
+ {
287
+ searchOnMapMove : e . target . checked ,
288
+ } ,
289
+ ( ) => this . getOrgLocations ( )
290
+ )
291
+ }
292
+
261
293
renderMap ( teams ) {
262
294
const { data } = teams
263
295
@@ -275,20 +307,41 @@ class Organization extends Component {
275
307
)
276
308
277
309
return (
278
- < Map
279
- markers = { centers }
280
- style = { {
281
- height : '360px' ,
282
- zIndex : '10' ,
283
- marginBottom : '1rem' ,
284
- } }
285
- onBoundsChange = { ( ) => { } }
286
- />
310
+ < >
311
+ < Map
312
+ markers = { centers }
313
+ style = { {
314
+ height : '360px' ,
315
+ zIndex : '10' ,
316
+ marginBottom : '1rem' ,
317
+ } }
318
+ onBoundsChange = { this . onMapBoundsChange . bind ( this ) }
319
+ />
320
+ < Checkbox
321
+ border = { '2px' }
322
+ marginTop = { '-5rem' }
323
+ marginLeft = { '1rem' }
324
+ position = 'absolute'
325
+ zIndex = '2000'
326
+ borderColor = 'brand.600'
327
+ p = { 2 }
328
+ bg = 'white'
329
+ name = 'map-bounds-filter'
330
+ id = 'map-bounds-filter'
331
+ type = 'checkbox'
332
+ colorScheme = { 'brand' }
333
+ isChecked = { this . state . searchOnMapMove }
334
+ onChange = { ( e ) => this . setSearchOnMapMove ( e ) }
335
+ >
336
+ Filter teams by map
337
+ </ Checkbox >
338
+ </ >
287
339
)
288
340
}
289
341
290
342
render ( ) {
291
- const { org, managers, owners, error, teams } = this . state
343
+ const { org, managers, owners, error, teams, searchOnMapMove, mapBounds } =
344
+ this . state
292
345
const userId = parseInt ( this . state ?. session ?. user_id )
293
346
294
347
// Handle org loading errors
@@ -367,7 +420,11 @@ class Organization extends Component {
367
420
< Box layerStyle = { 'shadowed' } as = 'section' >
368
421
< Heading variant = 'sectionHead' > Teams</ Heading >
369
422
{ this . renderMap ( teams ) }
370
- < TeamsTable type = 'org-teams' orgId = { org . data . id } />
423
+ < TeamsTable
424
+ type = 'org-teams'
425
+ orgId = { org . data . id }
426
+ bbox = { searchOnMapMove ? mapBounds : null }
427
+ />
371
428
</ Box >
372
429
373
430
{ isStaff ? (
0 commit comments