-
Notifications
You must be signed in to change notification settings - Fork 187
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
Migrate Create newcomers entry page to react #10732
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
<% provide(:title, 'Finish unfinished persons') %> | ||
|
||
<div class="container"> | ||
<% competition_ids = @finish_persons.competition_ids %> | ||
<% competition_ids = @competition_ids %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is redundant now, if you already have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to re-assign it to "itself" with another name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, instead of changing in many places, I thought of doing this way. Changed all the occurrences. |
||
|
||
<h2> | ||
<%= yield(:title) %> | ||
<%= link_to "Go back", admin_finish_unfinished_persons_path(competition_ids: competition_ids), class: "btn btn-default" %> | ||
<%= link_to "Go back", panel_page_path(id: User.panel_pages[:createNewComers], competition_ids: competition_ids), class: "btn btn-default" %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this work as expected when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing that out, I actually didn't test that portion and realized that it was not even working for single competition ID as it was getting lost during redirection. I've fixed it now. |
||
</h2> | ||
|
||
<% if competition_ids.present? %> | ||
<p>For competition(s):</p> | ||
|
||
<ul> | ||
<% @finish_persons.competitions.each do |competition_id| %> | ||
<% competition_ids.each do |competition_id| %> | ||
<li><code><%= competition_id %></code></li> | ||
<% end %> | ||
</ul> | ||
|
@@ -42,7 +42,7 @@ | |
|
||
<tr class="active"> | ||
<td colspan="8" class="text-center"> | ||
<% if competition_ids.present? && @finish_persons.competitions.length == 1 %> | ||
<% if competition_ids.present? && competition_ids.length == 1 %> | ||
<b><%= p[:person_name] %></b> (ID <code><%= p[:person_id] %></code>) | ||
<% else %> | ||
<b><%= p[:person_name] %></b> (ID <code><%= p[:person_id] %></code>, Competition <code><%= p[:competition_id] %></code>) | ||
|
@@ -116,7 +116,7 @@ | |
<% end %> | ||
<%= f.input :continue_batch, as: :boolean, label: "Continue with the next batch of newcomers if there are more pending entries", hint: "If you are redirected to the 'Create Newcomers' entry point, it means that there are no more pending entries.", input_html: { checked: competition_ids.present? } %> | ||
<%= f.button :submit, value: "Submit changes!", class: "btn-primary" %> | ||
<%= link_to "Go back", admin_finish_unfinished_persons_path(competition_ids: competition_ids), class: "btn btn-default" %> | ||
<%= link_to "Go back", panel_page_path(id: User.panel_pages[:createNewComers], competition_ids: competition_ids), class: "btn btn-default" %> | ||
<% end %> | ||
</div> | ||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import { | ||
Button, Form, Header, HeaderSubheader, | ||
} from 'semantic-ui-react'; | ||
import { IdWcaSearch } from '../../../SearchWidget/WcaSearch'; | ||
import SEARCH_MODELS from '../../../SearchWidget/SearchModel'; | ||
import { viewUrls } from '../../../../lib/requests/routes.js.erb'; | ||
import useQueryParams from '../../../../lib/hooks/useQueryParams'; | ||
import useInputState from '../../../../lib/hooks/useInputState'; | ||
|
||
export default function CompetitionsInput() { | ||
const [queryParams] = useQueryParams(); | ||
const competitionIdsFromQuery = queryParams?.competition_ids?.split(','); | ||
const [competitionIds, setCompetitionIds] = useInputState(competitionIdsFromQuery || []); | ||
|
||
return ( | ||
<Form> | ||
<IdWcaSearch | ||
model={SEARCH_MODELS.competition} | ||
multiple | ||
value={competitionIds} | ||
onChange={setCompetitionIds} | ||
label="Competition(s)" | ||
/> | ||
<Header as="h4"> | ||
<HeaderSubheader> | ||
Leave blank to check for all competitions | ||
</HeaderSubheader> | ||
</Header> | ||
<Button | ||
primary | ||
size="big" | ||
href={viewUrls.admin.completePersons(competitionIds.length > 0 ? competitionIds : null)} | ||
> | ||
Check newcomers | ||
</Button> | ||
</Form> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import { Header, List, ListItem } from 'semantic-ui-react'; | ||
import CompetitionsInput from './CompetitionsInput'; | ||
|
||
export default function CreateNewcomersPage() { | ||
return ( | ||
<> | ||
<Header>Create Newcomers</Header> | ||
<Information /> | ||
<CompetitionsInput /> | ||
</> | ||
); | ||
} | ||
|
||
function Information() { | ||
return ( | ||
<> | ||
<p> | ||
In this script, a "person" always means a triple of (id,name,countryId) and | ||
"similar" always means just name similarity. A person is called | ||
"finished" if it has a non-empty personId. A "semi-id" is the id | ||
without the running number at the end. | ||
</p> | ||
<p> | ||
For each unfinished person in the Results table, I show you the few most similar | ||
persons. Then you make choices and click "update" at the bottom of the page | ||
to show and execute your choices. You can: | ||
</p> | ||
<List bulleted> | ||
<ListItem> | ||
Choose the person as "new", optionally modifying name, country and | ||
semi-id. This will add the person to the Persons table (with appropriately | ||
extended id) and change its Results accordingly. If this person has both roman and | ||
local names, the syntax for the names to be inserted correctly is | ||
"romanName (localName)". | ||
</ListItem> | ||
<ListItem> | ||
Choose another person. This will overwrite the person's (id,name,countryId) | ||
triple in the Results table with those of the other person. | ||
</ListItem> | ||
<ListItem> | ||
Skip it if you're not sure yet. | ||
</ListItem> | ||
</List> | ||
</> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to wrap this in an array? Passing it as a string should be just fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it do accept single string as well I guess, but there are cases where multiple competitions are also needed to be given as input. So, to make the type of
competition_ids
as a single type (array of string) instead of multiple type (array of string or single string), I thought of doing this way. Is it fine?