forked from geosolutions-it/MapStore2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
35 changed files
with
1,107 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2019, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
var expect = require('expect'); | ||
const { | ||
OPEN_QUERY_BUILDER, | ||
openQueryBuilder, | ||
INIT_FILTER_HISTORY, | ||
initFilterHistory, | ||
APPLIED_FILTER, | ||
storeAppliedFilter, | ||
STORE_CURRENT_APPLIED_FILTER, | ||
storeCurrentFilter, | ||
RESTORE_CURRENT_SAVED_FILTER, | ||
restoreCurrentSavedFilter, | ||
applyFilter, | ||
APPLY_FILTER | ||
} = require('../filterHistory'); | ||
|
||
|
||
describe('Test correctness of the filterHistory actions', () => { | ||
|
||
it('openQueryBuilder', () => { | ||
var retval = openQueryBuilder(); | ||
expect(retval).toExist(); | ||
expect(retval.type).toBe(OPEN_QUERY_BUILDER); | ||
}); | ||
|
||
it('initFilterHistory', () => { | ||
var retval = initFilterHistory(); | ||
expect(retval).toExist(); | ||
expect(retval.type).toBe(INIT_FILTER_HISTORY); | ||
}); | ||
|
||
it('storeAppliedFilter', () => { | ||
const filter = {}; | ||
var retval = storeAppliedFilter(filter); | ||
expect(retval).toExist(); | ||
expect(retval.type).toBe(APPLIED_FILTER); | ||
expect(retval.filter).toBe(filter); | ||
}); | ||
|
||
it('storeCurrentFilter', () => { | ||
var retval = storeCurrentFilter(); | ||
expect(retval).toExist(); | ||
expect(retval.type).toBe(STORE_CURRENT_APPLIED_FILTER); | ||
}); | ||
|
||
it('restoreCurrentSavedFilter', () => { | ||
var retval = restoreCurrentSavedFilter(); | ||
expect(retval).toExist(); | ||
expect(retval.type).toBe(RESTORE_CURRENT_SAVED_FILTER); | ||
}); | ||
|
||
it('applyFilter', () => { | ||
var retval = applyFilter(); | ||
expect(retval).toExist(); | ||
expect(retval.type).toBe(APPLY_FILTER); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2019, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const INIT_FILTER_HISTORY = 'FILTER_HISTORY:INIT_FILTER_HISTORY'; | ||
const APPLIED_FILTER = 'FILTER_HISTORY:APPLIED_FILTER'; | ||
const STORE_CURRENT_APPLIED_FILTER = 'FILTER_HISTORY:STORE_CURRENT_APPLIED_FILTER'; | ||
const RESTORE_CURRENT_SAVED_FILTER = 'FILTER_HISTORY:RESTORE_CURRENT_SAVED_FILTER'; | ||
const APPLY_FILTER = 'FILTER_HISTORY:APPLY_FILTER'; | ||
const OPEN_QUERY_BUILDER = 'LAYER_FILTER:OPEN_QUERY_BUILDER'; | ||
|
||
function storeCurrentFilter() { | ||
return { | ||
type: STORE_CURRENT_APPLIED_FILTER | ||
}; | ||
} | ||
function restoreCurrentSavedFilter() { | ||
return { | ||
type: RESTORE_CURRENT_SAVED_FILTER | ||
}; | ||
} | ||
function openQueryBuilder() { | ||
return { | ||
type: OPEN_QUERY_BUILDER | ||
}; | ||
} | ||
function storeAppliedFilter(filter) { | ||
return { | ||
type: APPLIED_FILTER, | ||
filter | ||
}; | ||
} | ||
function applyFilter() { | ||
return { | ||
type: APPLY_FILTER | ||
}; | ||
} | ||
|
||
function initFilterHistory(filter) { | ||
return { | ||
type: INIT_FILTER_HISTORY, | ||
filter | ||
}; | ||
} | ||
module.exports = { | ||
OPEN_QUERY_BUILDER, | ||
openQueryBuilder, | ||
INIT_FILTER_HISTORY, | ||
initFilterHistory, | ||
APPLIED_FILTER, | ||
storeAppliedFilter, | ||
STORE_CURRENT_APPLIED_FILTER, | ||
storeCurrentFilter, | ||
RESTORE_CURRENT_SAVED_FILTER, | ||
restoreCurrentSavedFilter, | ||
applyFilter, | ||
APPLY_FILTER | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2019, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const React = require('react'); | ||
const PropTypes = require('prop-types'); | ||
const {Glyphicon, Tooltip} = require('react-bootstrap'); | ||
const Message = require('../../I18N/Message'); | ||
const OverlayTrigger = require('../../misc/OverlayTrigger'); | ||
|
||
class ToggleFilter extends React.Component { | ||
static propTypes = { | ||
node: PropTypes.object, | ||
propertiesChangeHandler: PropTypes.func | ||
}; | ||
|
||
static inheritedPropTypes = ['node']; | ||
|
||
static defaultProps = { | ||
node: null, | ||
propertiesChangeHandler: () => {} | ||
}; | ||
render() { | ||
const {layerFilter} = this.props.node || {}; | ||
const {disabled} = layerFilter || {}; | ||
return !!layerFilter && ( | ||
<OverlayTrigger | ||
placement="bottom" | ||
overlay={<Tooltip id="toc-filter-icon">{<Message msgId={!disabled ? 'toc.filterIconEnabled' : 'toc.filterIconDisabled'} />}</Tooltip>}> | ||
<Glyphicon onClick={this.onClick} className={`toc-filter-icon ${!!disabled ? "disabled" : ""}`} glyph="filter" /> | ||
</OverlayTrigger> | ||
); | ||
} | ||
onClick = () => { | ||
const {layerFilter} = this.props.node || {}; | ||
this.props.propertiesChangeHandler(this.props.node.id, {layerFilter: {...layerFilter, disabled: !layerFilter.disabled}}); | ||
} | ||
} | ||
|
||
module.exports = ToggleFilter; |
Oops, something went wrong.