Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team management page updates #14926

Merged
merged 16 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions app/controllers/team_management_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ def index
format.html { render template: "queue/index" }
format.json do
render json: {
judge_teams: JudgeTeam.all.order(:id).map { |jt| serialize_org(jt) },
private_bars: PrivateBar.all.order(:id).map { |private_bar| serialize_org(private_bar) },
vsos: Vso.all.order(:id).map { |vso| serialize_org(vso) },
judge_teams: JudgeTeam.order(:name).map { |jt| serialize_org(jt) },
private_bars: PrivateBar.order(:name).map { |private_bar| serialize_org(private_bar) },
vsos: Vso.order(:name).map { |vso| serialize_org(vso) },
Copy link
Contributor Author

@hschallhorn hschallhorn Aug 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Order by team name

.all is not needed here

other_orgs: other_orgs.map { |org| serialize_org(org) }
}
end
Expand Down Expand Up @@ -70,17 +70,10 @@ def update_params
end

def other_orgs
Organization.all.order(:id).reject { |org| org.is_a?(JudgeTeam) || org.is_a?(Representative) }
Organization.order(:name).reject { |org| org.is_a?(JudgeTeam) || org.is_a?(Representative) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Order by team name

.all is not needed here

end

def serialize_org(org)
{
id: org.id,
name: org.name,
participant_id: org.participant_id,
type: org.type,
url: org.url,
user_admin_path: org.user_admin_path
Copy link
Contributor

@lomky lomky Sep 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we lost this along the way, link no longer works in this PR - checking Stack PR 3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works in the final PR - not sweating it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

}
org.serialize
lomky marked this conversation as resolved.
Show resolved Hide resolved
end
end
10 changes: 10 additions & 0 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ def completed_tasks_tab
::OrganizationCompletedTasksTab.new(assignee: self, show_regional_office_column: show_regional_office_in_queue?)
end

def serialize
{
id: id,
name: is_a?(JudgeTeam) ? judge.full_name.titleize : name,
participant_id: participant_id,
type: type,
url: url
}
end

private

def clean_url
Expand Down
4 changes: 4 additions & 0 deletions app/models/organizations/judge_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def selectable_in_queue?
false
end

def serialize
super.merge(name: judge.full_name.titleize)
Copy link
Contributor Author

@hschallhorn hschallhorn Aug 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Use judge full names as team name

end

private

def use_judge_team_roles?
Expand Down
49 changes: 28 additions & 21 deletions client/app/queue/TeamManagement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class TeamManagement extends React.PureComponent {
<OrgHeader>
VSOs <Button name={COPY.TEAM_MANAGEMENT_ADD_VSO_BUTTON} onClick={this.addIhpWritingVso} />
</OrgHeader>
<OrgList orgs={this.props.vsos} showBgsParticipantId />
<OrgList orgs={this.props.vsos} isRepresentative />

<OrgHeader>
Private Bar
Expand All @@ -79,7 +79,7 @@ class TeamManagement extends React.PureComponent {
/>
</span>
</OrgHeader>
<OrgList orgs={this.props.privateBars} showBgsParticipantId />
<OrgList orgs={this.props.privateBars} isRepresentative />

<OrgHeader>Other teams</OrgHeader>
<OrgList orgs={this.props.otherOrgs} />
Expand Down Expand Up @@ -153,27 +153,26 @@ class OrgList extends React.PureComponent {
render = () => {
return <React.Fragment>
<tr {...labelRowStyling}>
<td>{COPY.TEAM_MANAGEMENT_ID_COLUMN_HEADING}</td>
Copy link
Contributor Author

@hschallhorn hschallhorn Aug 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No ID column

<td>{COPY.TEAM_MANAGEMENT_NAME_COLUMN_HEADING}</td>
<td>{COPY.TEAM_MANAGEMENT_URL_COLUMN_HEADING}</td>
<td>{ this.props.showBgsParticipantId && COPY.TEAM_MANAGEMENT_PARTICIPANT_ID_COLUMN_HEADING}</td>
<td>{this.props.isRepresentative && COPY.TEAM_MANAGEMENT_URL_COLUMN_HEADING}</td>
Copy link
Contributor Author

@hschallhorn hschallhorn Aug 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No URL column for non representatives (VSO and private bars)

<td>{this.props.isRepresentative && COPY.TEAM_MANAGEMENT_PARTICIPANT_ID_COLUMN_HEADING}</td>
<td></td>
<td></td>
</tr>
{ this.props.orgs.map((org) =>
<OrgRow {...org} key={org.id} showBgsParticipantId={this.props.showBgsParticipantId} />
<OrgRow {...org} key={org.id} isRepresentative={this.props.isRepresentative} />
) }
</React.Fragment>;
}
}

OrgList.defaultProps = {
showBgsParticipantId: false
isRepresentative: false
};

OrgList.propTypes = {
orgs: PropTypes.array,
showBgsParticipantId: PropTypes.bool
isRepresentative: PropTypes.bool
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We show participant ids for all representatives. We also allow editing of names, urls, and participant ids for all representatives. Rename bool to be less specific

};

class OrgRow extends React.PureComponent {
Expand Down Expand Up @@ -222,27 +221,28 @@ class OrgRow extends React.PureComponent {
// TODO: Indicate that changes have been made to the row by enabling the submit changes button. Default to disabled.
render = () => {
return <tr>
<td>{ this.props.id }</td>
Copy link
Contributor Author

@hschallhorn hschallhorn Aug 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No ID column

<td>
<TextField
name={`${COPY.TEAM_MANAGEMENT_NAME_COLUMN_HEADING}-${this.props.id}`}
label={false}
useAriaLabel
value={this.state.name}
onChange={this.changeName}
readOnly={!this.props.isRepresentative}
Copy link
Contributor Author

@hschallhorn hschallhorn Aug 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No text field editing for non representatives (VSO and private bars)

/>
</td>
<td>
<TextField
{ this.props.isRepresentative && <TextField
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No URL column for non representatives (VSO and private bars)

name={`${COPY.TEAM_MANAGEMENT_URL_COLUMN_HEADING}-${this.props.id}`}
label={false}
useAriaLabel
value={this.state.url}
onChange={this.changeUrl}
/>
readOnly={!this.props.isRepresentative}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No text field editing for non representatives (VSO and private bars)

/> }
</td>
<td>
{ this.props.showBgsParticipantId &&
{ this.props.isRepresentative &&
<TextField
name={`${COPY.TEAM_MANAGEMENT_PARTICIPANT_ID_COLUMN_HEADING}-${this.props.id}`}
label={false}
Expand All @@ -253,29 +253,36 @@ class OrgRow extends React.PureComponent {
}
</td>
<td>
<Button
name={COPY.TEAM_MANAGEMENT_UPDATE_ROW_BUTTON}
id={`${this.props.id}`}
classNames={['usa-button-secondary']}
onClick={this.submitUpdate}
/>
{ this.props.isRepresentative &&
<Button
name={COPY.TEAM_MANAGEMENT_UPDATE_ROW_BUTTON}
id={`${this.props.id}`}
classNames={['usa-button-secondary']}
onClick={this.submitUpdate}
/>
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No update button for non representatives (VSO and private bars)

</td>
<td>
{ this.state.url && <Link to={this.state.user_admin_path}>Org admin page</Link> }
{ this.state.url && <Link to={this.state.user_admin_path}>
<Button
name="Org Admin Page"
classNames={['usa-button-secondary']}
/>
</Link> }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Use button styling for org admin page

</td>
</tr>;
}
}

OrgRow.defaultProps = {
showBgsParticipantId: false
isRepresentative: false
};

OrgRow.propTypes = {
id: PropTypes.number,
name: PropTypes.string,
participant_id: PropTypes.number,
showBgsParticipantId: PropTypes.bool,
isRepresentative: PropTypes.bool,
url: PropTypes.string,
user_admin_path: PropTypes.string
};