Hook up 'x' remove button; rename ListItem component.

This commit is contained in:
kialam
2019-01-14 09:45:49 -05:00
parent c5cd659c83
commit 215c23609c
5 changed files with 26 additions and 16 deletions

View File

@@ -135,7 +135,7 @@
cursor: pointer; cursor: pointer;
} }
} }
.awx-pill { .awx-c-tag--pill {
color: white; color: white;
background-color: rgb(0, 123, 186); background-color: rgb(0, 123, 186);
border-radius: 3px; border-radius: 3px;
@@ -151,17 +151,27 @@
flex-direction: row; flex-direction: row;
justify-content: flex-end; justify-content: flex-end;
} }
//
// list styles
//
.awx-c-list { .awx-c-list {
border-top: 1px solid #d7d7d7; border-top: 1px solid #d7d7d7;
border-bottom: 1px solid #d7d7d7; border-bottom: 1px solid #d7d7d7;
} }
//
// pf modal overrides
//
.awx-c-modal { .awx-c-modal {
width: 550px; width: 550px;
margin: 0; margin: 0;
} }
.awx-c-icon--remove {
padding-left: 10px;
&:hover {
cursor: pointer;
}
}
.pf-c-modal-box__footer { .pf-c-modal-box__footer {
--pf-c-modal-box__footer--PaddingTop: 0; --pf-c-modal-box__footer--PaddingTop: 0;
--pf-c-modal-box__footer--PaddingBottom: 0; --pf-c-modal-box__footer--PaddingBottom: 0;
@@ -177,4 +187,4 @@
.pf-c-modal-box__body { .pf-c-modal-box__body {
--pf-c-modal-box__body--PaddingLeft: 20px; --pf-c-modal-box__body--PaddingLeft: 20px;
--pf-c-modal-box__body--PaddingRight: 20px; --pf-c-modal-box__body--PaddingRight: 20px;
} }

View File

@@ -26,9 +26,9 @@ export default ({
</I18n> </I18n>
</div> </div>
<div className="pf-c-data-list__cell"> <div className="pf-c-data-list__cell">
<span id="check-action-item1"> <label htmlFor={`selectd-${itemId}`} id="check-action-item1">
<b>{name}</b> <b>{name}</b>
</span> </label>
</div> </div>
</li> </li>
); );

View File

@@ -1,3 +1,3 @@
import ListItem from './ListItem'; import CheckboxListItem from './CheckboxListItem';
export default ListItem; export default CheckboxListItem;

View File

@@ -9,7 +9,7 @@ import {
ToolbarGroup, ToolbarGroup,
} from '@patternfly/react-core'; } from '@patternfly/react-core';
import ListItem from '../ListItem' import CheckboxListItem from '../CheckboxListItem'
class Lookup extends React.Component { class Lookup extends React.Component {
constructor(props) { constructor(props) {
@@ -21,6 +21,7 @@ class Lookup extends React.Component {
this.onLookup = this.onLookup.bind(this); this.onLookup = this.onLookup.bind(this);
this.onChecked = this.onChecked.bind(this); this.onChecked = this.onChecked.bind(this);
this.wrapTags = this.wrapTags.bind(this); this.wrapTags = this.wrapTags.bind(this);
this.onRemove = this.onRemove.bind(this);
} }
handleModalToggle() { handleModalToggle() {
@@ -37,10 +38,13 @@ class Lookup extends React.Component {
this.props.lookupChange(evt.target.value); this.props.lookupChange(evt.target.value);
}; };
onRemove(evt) {
this.props.lookupChange(evt.target.id);
}
wrapTags(tags) { wrapTags(tags) {
return tags.filter(tag => tag.isChecked).map((tag, index) => { return tags.filter(tag => tag.isChecked).map((tag, index) => {
return ( return (
<span className="awx-pill" key={index}>{tag.name}</span> <span className="awx-c-tag--pill" key={index}>{tag.name}<span className="awx-c-icon--remove" id={tag.id} onClick={this.onRemove}>x</span></span>
) )
}) })
} }
@@ -53,7 +57,6 @@ class Lookup extends React.Component {
<span className="pf-c-input-group__text" aria-label="search" id="search" onClick={this.onLookup}><SearchIcon /></span> <span className="pf-c-input-group__text" aria-label="search" id="search" onClick={this.onLookup}><SearchIcon /></span>
<div className="pf-c-form-control">{this.wrapTags(this.props.data)}</div> <div className="pf-c-form-control">{this.wrapTags(this.props.data)}</div>
<Modal <Modal
isLarge
className="awx-c-modal" className="awx-c-modal"
title={`Select ${this.props.lookup_header}`} title={`Select ${this.props.lookup_header}`}
isOpen={isModalOpen} isOpen={isModalOpen}
@@ -61,7 +64,7 @@ class Lookup extends React.Component {
> >
<ul className="pf-c-data-list awx-c-list"> <ul className="pf-c-data-list awx-c-list">
{data.map(i => {data.map(i =>
<ListItem <CheckboxListItem
key={i.id} key={i.id}
itemId={i.id} itemId={i.id}
name={i.name} name={i.name}

View File

@@ -30,7 +30,6 @@ class OrganizationAdd extends React.Component {
this.onSelectChange = this.onSelectChange.bind(this); this.onSelectChange = this.onSelectChange.bind(this);
this.onLookupChange = this.onLookupChange.bind(this); this.onLookupChange = this.onLookupChange.bind(this);
this.onSubmit = this.onSubmit.bind(this); this.onSubmit = this.onSubmit.bind(this);
this.resetForm = this.resetForm.bind(this);
this.onCancel = this.onCancel.bind(this); this.onCancel = this.onCancel.bind(this);
} }
@@ -75,7 +74,6 @@ class OrganizationAdd extends React.Component {
const data = Object.assign({}, { ...this.state }); const data = Object.assign({}, { ...this.state });
try { try {
const { data: response } = await api.createOrganization(data); const { data: response } = await api.createOrganization(data);
console.log(response);
const url = response.related.instance_groups; const url = response.related.instance_groups;
const selected = this.state.results.filter(group => group.isChecked); const selected = this.state.results.filter(group => group.isChecked);
try { try {
@@ -89,7 +87,7 @@ class OrganizationAdd extends React.Component {
} }
catch (err) { catch (err) {
this.setState({ onSubmitError: err }) this.setState({ onSubmitError: err })
} }
} }
onCancel() { onCancel() {
@@ -153,7 +151,6 @@ class OrganizationAdd extends React.Component {
onChange={this.handleChange} onChange={this.handleChange}
/> />
</FormGroup> </FormGroup>
{/* LOOKUP MODAL PLACEHOLDER */}
<FormGroup label="Instance Groups" fieldId="simple-form-instance-groups"> <FormGroup label="Instance Groups" fieldId="simple-form-instance-groups">
<Lookup <Lookup
lookup_header="Instance Groups" lookup_header="Instance Groups"