Skip to content

Commit

Permalink
made independent and deleted searchbar component
Browse files Browse the repository at this point in the history
  • Loading branch information
saidaipparla committed Dec 16, 2016
1 parent ca19f96 commit eeee326
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 110 deletions.
80 changes: 60 additions & 20 deletions web/client/plugins/manager/GroupManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,59 @@ const React = require('react');
const {connect} = require('react-redux');
const {Button, Grid, Glyphicon} = require('react-bootstrap');
const {editGroup} = require('../../actions/usergroups');
const {setControlProperty} = require('../../actions/controls');
const SearchBar = require('./users/SearchBar');
const {getUserGroups, groupSearchTextChanged} = require('../../actions/usergroups');
const SearchBar = require("../../components/mapcontrols/search/SearchBar");
const GroupsGrid = require('./users/GroupGrid');
const GroupDialog = require('./users/GroupDialog');
const GroupDeleteConfirm = require('./users/GroupDeleteConfirm');
const Message = require('../../components/I18N/Message');
const assign = require('object-assign');

const {trim} = require('lodash');
const GroupManager = React.createClass({
propTypes: {
selectedTool: React.PropTypes.string,
selectedGroup: React.PropTypes.string,
onNewGroup: React.PropTypes.func,
onToggleUsersGroups: React.PropTypes.func
className: React.PropTypes.string,
hideOnBlur: React.PropTypes.bool,
placeholderMsgId: React.PropTypes.string,
typeAhead: React.PropTypes.bool,
searchText: React.PropTypes.string,
onSearch: React.PropTypes.func,
onSearchReset: React.PropTypes.func,
onSearchTextChange: React.PropTypes.func,
start: React.PropTypes.number,
limit: React.PropTypes.number
},
getDefaultProps() {
return {
selectedGroup: "groups",
className: "user-search",
hideOnBlur: false,
placeholderMsgId: "usergroups.searchGroups",
typeAhead: false,
searchText: "",
start: 0,
limit: 20,
onNewGroup: () => {},
onToggleUsersGroups: () => {}
onSearch: () => {},
onSearchReset: () => {},
onSearchTextChange: () => {}
};
},
onNew() {
this.props.onNewGroup();
},
render() {
return (<div>
<SearchBar />
{this.toogleTools()}
<SearchBar
className={this.props.className}
hideOnBlur={this.props.hideOnBlur}
placeholderMsgId ={this.props.placeholderMsgId}
onSearch={this.props.onSearch}
onSearchReset={this.props.onSearchReset}
onSearchTextChange={this.props.onSearchTextChange}
typeAhead={this.props.typeAhead}
searchText={this.props.searchText}
start={this.props.start}
limit={this.props.limit} />
<Grid style={{marginBottom: "10px"}} fluid={true}>
<h1 className="usermanager-title"><Message msgId={"usergroups.groups"}/></h1>
<Button style={{marginRight: "10px"}} bsStyle="success" onClick={this.onNew}>
Expand All @@ -48,18 +72,36 @@ const GroupManager = React.createClass({
<GroupDialog />
<GroupDeleteConfirm />
</div>);
},
toogleTools() {
this.props.onToggleUsersGroups(this.props.selectedGroup);
}
});
module.exports = {
GroupManagerPlugin: assign(
connect((state) => ({
selectedTool: state && state.controls && state.controls.managerchoice && state.controls.managerchoice.selectedTool
}), {
connect((state) => {
let searchState = state && state.usergroups;
return {
start: searchState && searchState.start,
limit: searchState && searchState.limit,
searchText: (searchState && searchState.searchText && trim(searchState.searchText, '*')) || ""
};
}, {
onNewGroup: editGroup.bind(null, {}),
onToggleUsersGroups: setControlProperty.bind(null, "managerchoice", "selectedTool")
onSearchTextChange: groupSearchTextChanged,
onSearch: getUserGroups
}, (stateProps, dispatchProps) => {
return {
...stateProps,
...dispatchProps,
onSearchReset: (text) => {
let limit = stateProps.limit;
let searchText = (text && text !== "") ? ("*" + text + "*") : "*";
dispatchProps.onSearch(searchText, {params: {start: 0, limit}});
},
onSearch: (text) => {
let limit = stateProps.limit;
let searchText = (text && text !== "") ? ("*" + text + "*") : "*";
dispatchProps.onSearch(searchText, {params: {start: 0, limit}});
}
};
})(GroupManager), {
hide: true,
Manager: {
Expand All @@ -70,8 +112,6 @@ module.exports = {
glyph: "1-group-mod"
}}),
reducers: {
users: require('../../reducers/users'),
usergroups: require('../../reducers/usergroups'),
controls: require('../../reducers/controls')
usergroups: require('../../reducers/usergroups')
}
};
83 changes: 62 additions & 21 deletions web/client/plugins/manager/UserManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,59 @@ const React = require('react');
const {connect} = require('react-redux');
const {Button, Grid, Glyphicon} = require('react-bootstrap');
const {editUser} = require('../../actions/users');
const {setControlProperty} = require('../../actions/controls');
const SearchBar = require('./users/SearchBar');
const {getUsers, usersSearchTextChanged} = require('../../actions/users');
const SearchBar = require("../../components/mapcontrols/search/SearchBar");
const UserGrid = require('./users/UserGrid');
const UserDialog = require('./users/UserDialog');
const UserDeleteConfirm = require('./users/UserDeleteConfirm');
const Message = require('../../components/I18N/Message');
const assign = require('object-assign');

const {trim} = require('lodash');
const UserManager = React.createClass({
propTypes: {
selectedTool: React.PropTypes.string,
selectedGroup: React.PropTypes.string,
onNewUser: React.PropTypes.func,
onToggleUsersGroups: React.PropTypes.func
className: React.PropTypes.string,
hideOnBlur: React.PropTypes.bool,
placeholderMsgId: React.PropTypes.string,
typeAhead: React.PropTypes.bool,
searchText: React.PropTypes.string,
onSearch: React.PropTypes.func,
onSearchReset: React.PropTypes.func,
onSearchTextChange: React.PropTypes.func,
start: React.PropTypes.number,
limit: React.PropTypes.number
},
getDefaultProps() {
return {
selectedGroup: "users",
onNewUser: () => {},
onToggleUsersGroups: () => {}
className: "user-search",
hideOnBlur: false,
placeholderMsgId: "users.searchUsers",
typeAhead: false,
searchText: "",
start: 0,
limit: 20,
onSearch: () => {},
onSearchReset: () => {},
onSearchTextChange: () => {},
onNewUser: () => {}
};
},
onNew() {
this.props.onNewUser();
},
render() {
return (<div>
<SearchBar />
{this.toogleTools()}
<SearchBar
className={this.props.className}
hideOnBlur={this.props.hideOnBlur}
placeholderMsgId ={this.props.placeholderMsgId}
onSearch={this.props.onSearch}
onSearchReset={this.props.onSearchReset}
onSearchTextChange={this.props.onSearchTextChange}
typeAhead={this.props.typeAhead}
searchText={this.props.searchText}
start={this.props.start}
limit={this.props.limit} />
<Grid style={{marginBottom: "10px"}} fluid={true}>
<h1 className="usermanager-title"><Message msgId={"users.users"}/></h1>
<Button style={{marginRight: "10px"}} bsStyle="success" onClick={this.onNew}><span><Glyphicon glyph="1-user-add" /><Message msgId="users.newUser" /></span></Button>
Expand All @@ -46,18 +70,37 @@ const UserManager = React.createClass({
<UserDialog />
<UserDeleteConfirm />
</div>);
},
toogleTools() {
this.props.onToggleUsersGroups(this.props.selectedGroup);
}
});
module.exports = {
UserManagerPlugin: assign(
connect((state) => ({
selectedTool: state && state.controls && state.controls.managerchoice && state.controls.managerchoice.selectedTool
}), {
connect((state) => {
let searchState = state && state.users;
return {
start: searchState && searchState.start,
limit: searchState && searchState.limit,
searchText: (searchState && searchState.searchText && trim(searchState.searchText, '*')) || ""
};
},
{
onNewUser: editUser.bind(null, {role: "USER", "enabled": true}),
onToggleUsersGroups: setControlProperty.bind(null, "managerchoice", "selectedTool")
onSearchTextChange: usersSearchTextChanged,
onSearch: getUsers
}, (stateProps, dispatchProps) => {
return {
...stateProps,
...dispatchProps,
onSearchReset: (text) => {
let limit = stateProps.limit;
let searchText = (text && text !== "") ? ("*" + text + "*") : "*";
dispatchProps.onSearch(searchText, {params: {start: 0, limit}});
},
onSearch: (text) => {
let limit = stateProps.limit;
let searchText = (text && text !== "") ? ("*" + text + "*") : "*";
dispatchProps.onSearch(searchText, {params: {start: 0, limit}});
}
};
})(UserManager), {
hide: true,
Manager: {
Expand All @@ -68,8 +111,6 @@ module.exports = {
glyph: "1-user-mod"
}}),
reducers: {
users: require('../../reducers/users'),
usergroups: require('../../reducers/usergroups'),
controls: require('../../reducers/controls')
users: require('../../reducers/users')
}
};
69 changes: 0 additions & 69 deletions web/client/plugins/manager/users/SearchBar.jsx

This file was deleted.

0 comments on commit eeee326

Please sign in to comment.