Skip to content

Commit

Permalink
Fixed bugs with the next step button not enabling/disabling at the co…
Browse files Browse the repository at this point in the history
…rrect times
  • Loading branch information
iambrandonn committed Dec 16, 2015
1 parent cdf2788 commit 4ae9ffe
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ V1.0.3
they will be brought back to where they were. The data has always been
saved. This will simply return them to that place in the process.
* Fixed bug which prevented adding new relationships to existing entities
* Fixed bugs with the next step button not enabling/disabling at the correct times

V1.0.2

Expand Down
61 changes: 38 additions & 23 deletions client/scripts/components/User/Disclosure.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,29 @@ export class Disclosure extends React.Component {
if (!entities || !projects) {
return false;
}
else if (!relations && (entities.length > 0 || projects.length > 0)) {
if (!relations && (entities.length > 0 || projects.length > 0)) {
return true;
}

let undefinedFound = false;
entities.forEach(entity => {
projects.forEach(project => {
const existingRelation = relations.find(relation => {
return relation.finEntityId === entity.id &&
(
relation.projectId === project.id
);
});
entities
.filter(entity => {
return entity.active === 1;
})
.forEach(entity => {
projects.forEach(project => {
const existingRelation = relations.find(relation => {
return relation.finEntityId === entity.id &&
(
relation.projectId === project.id
);
});

if (!existingRelation) {
undefinedFound = true;
}
if (!existingRelation || !existingRelation.typeCd) {
undefinedFound = true;
}
});
});
});

return undefinedFound;
}
Expand All @@ -99,15 +103,19 @@ export class Disclosure extends React.Component {
}

let undefinedFound = false;
entities.forEach(entity => {
const existingRelation = relations.find(relation => {
return relation.finEntityId === entity.id && relation.manualId === disclosure.projectId;
});
entities
.filter(entity => {
return entity.active === 1;
})
.forEach(entity => {
const existingRelation = relations.find(relation => {
return relation.finEntityId === entity.id && relation.manualId === disclosure.projectId;
});

if (!existingRelation) {
undefinedFound = true;
}
});
if (!existingRelation || !existingRelation.typeCd) {
undefinedFound = true;
}
});

return undefinedFound;
}
Expand All @@ -117,13 +125,20 @@ export class Disclosure extends React.Component {
return false;
}

const entityInProgress = this.state.applicationState.entityInProgress;
if (entityInProgress && entityInProgress.name) {
return true;
}

let incompleteEntity = false;
entities.filter(entity => {
return entity.active === 1;
})
.forEach(entity => {
if (!DisclosureStore.entityInformationStepComplete(entity.id)
|| !DisclosureStore.entityRelationshipsAreSubmittable(entity.id)) {
if (
!DisclosureStore.entityInformationStepComplete(entity.id) ||
!DisclosureStore.entityRelationshipsAreSubmittable(entity.id)
) {
incompleteEntity = true;
}
});
Expand Down
10 changes: 9 additions & 1 deletion client/scripts/components/User/NavSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ export class NavSidebar extends React.Component {
constructor() {
super();

this.nextClicked = this.nextClicked.bind(this);
this.submitDisclosure = this.submitDisclosure.bind(this);
}

nextClicked() {
if (!this.props.nextDisabled) {
DisclosureActions.nextStep();
}
}

submitDisclosure() {
if (!this.props.submitDisabled) {
DisclosureActions.submitDisclosure();
Expand Down Expand Up @@ -58,7 +65,8 @@ export class NavSidebar extends React.Component {
if (this.props.showNextLink) {
nextLink = (
<NextLink
onClick={DisclosureActions.nextStep}
onClick={this.nextClicked}
disabled={this.props.nextDisabled}
style={styles.link}
/>
);
Expand Down
15 changes: 12 additions & 3 deletions client/scripts/components/User/NextLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,32 @@ export default function NextLink(props: Object): React.Element {
const styles = {
container: {
fontSize: 15,
cursor: 'pointer',
cursor: props.disabled ? 'default' : 'pointer',
color: window.colorBlindModeOn ? 'black' : '#555555'
},
icons: {
icon: {
color: window.colorBlindModeOn ? 'black' : '#F57C00',
fontSize: 29,
marginRight: 6,
verticalAlign: 'middle'
},
stepLabel: {
verticalAlign: 'middle'
},
disabled: {
color: '#AAA',
cursor: 'default'
}
};

if (props.disabled) {
styles.container.color = '#AAA';
styles.icon.color = '#AAA';
}

return (
<div onClick={props.onClick} style={merge(styles.container, props.style)}>
<i className="fa fa-arrow-circle-right" style={styles.icons}></i>
<i className="fa fa-arrow-circle-right" style={styles.icon}></i>
<span style={styles.stepLabel}>
NEXT STEP
</span>
Expand Down
2 changes: 1 addition & 1 deletion client/scripts/components/User/undefinedRelationExists.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function undefinedRelationExists(type, itemsNeedingDisclosures, relations
return relation.finEntityId === item.id;
});

return !existingRelation;
return !existingRelation || !existingRelation.typeCd;
});

return undeclaredRelation !== undefined;
Expand Down

0 comments on commit 4ae9ffe

Please sign in to comment.