Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
fix(item bank): adds logic to set tab index on item entry table
Browse files Browse the repository at this point in the history
  • Loading branch information
Engineering User committed Oct 29, 2018
1 parent 2f83640 commit b1e55c4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/Assets/Styles/item-bank.less
Expand Up @@ -73,6 +73,7 @@
border-width: 1px;
border-radius: @spacing-item;
table-layout: fixed;
width: 40px;
}

.current-items-table {
Expand Down Expand Up @@ -185,9 +186,10 @@
}

.submit-button {
margin-left: 60px;
width: 80px;
}

.clear-button {
float: right;
width: 80px;
}
8 changes: 6 additions & 2 deletions src/ItemEntryTable/ItemEntryRow.tsx
Expand Up @@ -16,6 +16,7 @@ export interface ItemEntryRowProps {
row: ItemRevisionModel;
namespaces: NamespaceModel[];
isLast: boolean;
tabIndex: number;
}

export interface ItemEntryRowState {
Expand Down Expand Up @@ -104,6 +105,7 @@ export class ItemEntryRow extends React.Component<
onChange={event => onChange(+event.target.value)}
onBlur={this.handleRowUpdate}
disabled={!row.hasBankKey}
tabIndex={this.props.tabIndex + 1}
/>
</td>
);
Expand All @@ -127,6 +129,7 @@ export class ItemEntryRow extends React.Component<
value={rowValue || ""}
onChange={event => onChange(+event.target.value)}
onBlur={this.handleRowUpdate}
tabIndex={this.props.tabIndex + 2}
/>
</td>
);
Expand Down Expand Up @@ -160,6 +163,7 @@ export class ItemEntryRow extends React.Component<
options={options}
onChange={this.handleNamespace}
wrapperClass="section-dd"
tabIndex={this.props.tabIndex}
/>
</td>
);
Expand All @@ -169,11 +173,11 @@ export class ItemEntryRow extends React.Component<
return (
<td className="delete-row">
<input
className="delete-button btn btn-primary bg-light"
className="from-control delete-button btn btn-primary bg-light"
onClick={this.deleteRow}
disabled={this.props.isLast}
type="button"
value="X"
tabIndex={this.props.tabIndex + 3}
/>
</td>
);
Expand Down
39 changes: 22 additions & 17 deletions src/ItemEntryTable/ItemEntryTable.tsx
Expand Up @@ -102,52 +102,57 @@ export class ItemEntryTable extends React.Component<
<th scope="col">Bank</th>
<th scope="col">Item</th>
<th scope="col" />
<th />
</tr>
</thead>
);
}

renderBody() {
const rows = this.state.itemRows.map((row, idx) => (
<ItemEntryRow
row={row}
onRowUpdate={editRow => this.handleRowUpdate(editRow, idx)}
onDeleteRow={deleteRow => this.handleDeleteRow(idx)}
namespaces={this.props.namespaces}
key={idx}
id={idx}
isLast={idx === this.state.itemRows.length - 1}
/>
));

let index = 1;
const rows = this.state.itemRows.map((row, idx) => {
index = idx;
return (
<ItemEntryRow
row={row}
onRowUpdate={editRow => this.handleRowUpdate(editRow, idx)}
onDeleteRow={deleteRow => this.handleDeleteRow(idx)}
namespaces={this.props.namespaces}
key={idx}
id={idx}
isLast={idx === this.state.itemRows.length - 1}
tabIndex={idx * 4 + 1}
/>
);
});
index++;
return (
<tbody>
{rows}
{this.renderFooter()}
{this.renderFooter(index * 4 + 1)}
</tbody>
);
}

renderFooter() {
renderFooter(tabIndex: number) {
return (
<tr>
<td />
<td>
<input
className="btn btn-primary submit-button bg-primary"
onClick={click => this.handleSubmit()}
type="button"
value="apply"
tabIndex={tabIndex}
/>
<input
className="btn btn-default clear-button bg-light"
onClick={click => this.handleClearItems()}
type="button"
value="clear all"
tabIndex={tabIndex + 1}
/>
</td>
<td />
<td />
</tr>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Select/Select.tsx
Expand Up @@ -14,6 +14,7 @@ export interface SelectProps {
className?: string;
labelClass?: string;
wrapperClass?: string;
tabIndex?: number;
}

/**
Expand All @@ -37,6 +38,7 @@ export const Select: React.SFC<SelectProps> = props => {
onChange={e => props.onChange(e.target.value)}
value={props.selected}
disabled={props.disabled}
tabIndex={props.tabIndex}
>
{selectOptions}
</select>
Expand Down

0 comments on commit b1e55c4

Please sign in to comment.