-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ui to configure text search services
- Loading branch information
kappu
committed
May 18, 2017
1 parent
2a9f77a
commit 7425b0d
Showing
20 changed files
with
1,334 additions
and
14 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,51 @@ | ||
/** | ||
* Copyright 2017, 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'); | ||
var { | ||
SET_SEARCH_CONFIG_PROP, | ||
RESET_SEARCH_CONFIG, | ||
UPDATE_SERVICE, | ||
setSearchConfigProp, | ||
restServiceConfig, | ||
updateService | ||
} = require('../searchconfig'); | ||
|
||
describe('Test correctness of the searchconfig actions', () => { | ||
|
||
|
||
it('resetServiceConfig', () => { | ||
const testPage = 1; | ||
var retval = restServiceConfig(testPage); | ||
|
||
expect(retval).toExist(); | ||
expect(retval.type).toBe(RESET_SEARCH_CONFIG); | ||
expect(retval.page).toBe(testPage); | ||
}); | ||
|
||
it('setSearchConfigProp', () => { | ||
const testProperty = 'prop'; | ||
const testValue = 'val'; | ||
var retval = setSearchConfigProp(testProperty, testValue); | ||
|
||
expect(retval).toExist(); | ||
expect(retval.type).toBe(SET_SEARCH_CONFIG_PROP); | ||
expect(retval.property).toBe(testProperty); | ||
expect(retval.value).toBe(testValue); | ||
}); | ||
|
||
it('updateService', () => { | ||
const testService = "service"; | ||
const testIdx = 1; | ||
var retval = updateService(testService, testIdx); | ||
expect(retval).toExist(); | ||
expect(retval.type).toBe(UPDATE_SERVICE); | ||
expect(retval.service).toBe(testService); | ||
expect(retval.idx).toBe(testIdx); | ||
}); | ||
}); |
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,53 @@ | ||
/** | ||
* Copyright 2017, 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 SET_SEARCH_CONFIG_PROP = 'SET_SEARCH_CONFIG_PROP'; | ||
const RESET_SEARCH_CONFIG = 'RESET_SEARCH_CONFIG'; | ||
const UPDATE_SERVICE = 'UPDATE_SERVICE'; | ||
|
||
/** | ||
* Sets a property | ||
* @memberof actions.search | ||
* @param {string} property the property to set | ||
* @param {string|number|boolean|object} value the value to set or to check for toggling | ||
* @return {object} of type `SET_SEARCH_CONFIG_PROP` with property and value params | ||
*/ | ||
function setSearchConfigProp(property, value) { | ||
return { | ||
type: SET_SEARCH_CONFIG_PROP, | ||
property, | ||
value | ||
}; | ||
} | ||
|
||
function restServiceConfig(page = 0 ) { | ||
return { | ||
type: RESET_SEARCH_CONFIG, | ||
page | ||
}; | ||
} | ||
function updateService(service, idx = -1) { | ||
return { | ||
type: UPDATE_SERVICE, | ||
service, | ||
idx | ||
}; | ||
} | ||
|
||
/** | ||
* Actions for search | ||
* @name actions.searchconfig | ||
*/ | ||
module.exports = { | ||
SET_SEARCH_CONFIG_PROP, | ||
RESET_SEARCH_CONFIG, | ||
UPDATE_SERVICE, | ||
setSearchConfigProp, | ||
restServiceConfig, | ||
updateService | ||
}; |
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
76 changes: 76 additions & 0 deletions
76
web/client/components/mapcontrols/searchservicesconfig/ResultsProps.jsx
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,76 @@ | ||
/** | ||
* Copyright 2017, 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 {FormGroup, ControlLabel, FormControl, Label} = require('react-bootstrap'); | ||
const Message = require('../../I18N/Message'); | ||
const Slider = require('react-nouislider'); | ||
const assign = require('object-assign'); | ||
function validate(service = {}) { | ||
return service.displayName && service.displayName.length > 0; | ||
} | ||
const ResultsProps = React.createClass({ | ||
propTypes: { | ||
service: React.PropTypes.object, | ||
onPropertyChange: React.PropTypes.func | ||
}, | ||
getDefaultProps() { | ||
return { | ||
service: {}, | ||
onPropertyChange: () => {} | ||
}; | ||
}, | ||
render() { | ||
const {service} = this.props; | ||
return ( | ||
<form> | ||
<span className="wfs-required-props-title"><Message msgId="search.s_result_props_label" /></span> | ||
<FormGroup> | ||
<ControlLabel> | ||
<Message msgId="search.s_title" /> | ||
</ControlLabel> | ||
<FormControl | ||
value={service.displayName} | ||
key="displayName" | ||
type="text" | ||
placeholder={'e.g. "${properties.name}\"'} | ||
onChange={this.updateProp.bind(null, "displayName")}/> | ||
</FormGroup> | ||
<FormGroup> | ||
<ControlLabel> | ||
<Message msgId="search.s_description" /> | ||
</ControlLabel> | ||
<FormControl | ||
value={service.subTitle} | ||
key="subTitle" | ||
type="text" | ||
onChange={this.updateProp.bind(null, "subTitle")}/> | ||
</FormGroup> | ||
<FormGroup> | ||
<ControlLabel> | ||
<Message msgId="search.s_priority" /> | ||
<Label key="priority-labeel" className="slider-label">{parseInt(service.priority || 1, 10)}</Label> | ||
</ControlLabel> | ||
<Slider key="priority" start={[service.priority || 1]} | ||
range={{min: 1, max: 10}} | ||
onSlide={this.updatePriority} | ||
/> | ||
<span className="priority-info"><Message msgId="search.s_priority_info" /></span> | ||
</FormGroup> | ||
</form>); | ||
}, | ||
updateProp(prop, event) { | ||
const value = event.target.value; | ||
this.props.onPropertyChange("service", assign({}, this.props.service, {[prop]: value})); | ||
}, | ||
updatePriority(val) { | ||
this.props.onPropertyChange("service", assign({}, this.props.service, {priority: parseFloat(val[0], 10)})); | ||
} | ||
}); | ||
|
||
module.exports = { Element: ResultsProps, validate}; |
Oops, something went wrong.