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

Feature/issue 343 update datasets list UI #463

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
466 changes: 240 additions & 226 deletions Gemfile.lock

Large diffs are not rendered by default.

83 changes: 37 additions & 46 deletions app/assets/stylesheets/layouts/dataset_index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
.dataset_page {
.dataset_list {
h2 {
letter-spacing: 0.025rem;
}

.dataset {
font-size: 1.1rem;

h3 {
color: var(--primary);
}

.region {
font-size: 0.9rem;
}

.link_container a {
color: var(--primary);
}
}

hr {
border-top: 1px solid #a0a0a0;
}
}

.dataportals {
padding-top: 0;
display: flex;
Expand All @@ -24,7 +50,9 @@
align-items: stretch;
}

h3, h4, p {
h3,
h4,
p {
color: #fff;
}

Expand All @@ -37,82 +65,44 @@
transition: all 0.4s ease;
}

&:nth-of-type(3n+1) div {
&:nth-of-type(3n + 1) div {
background-color: rgba(202, 30, 86, 0.5);
border-bottom: 1em solid var(--primary);
overflow: hidden;
}

&:nth-of-type(3n+2) div {
&:nth-of-type(3n + 2) div {
background-color: rgba(76, 154, 210, 0.5);
border-bottom: 1em solid var(--secondary);
overflow: hidden;
}

&:nth-of-type(3n+0) div {
&:nth-of-type(3n + 0) div {
background-color: rgba(113, 113, 113, 0.5);
border-bottom: 1em solid #717171;
overflow: hidden;
}

&:nth-of-type(3n+1) div:hover {
&:nth-of-type(3n + 1) div:hover {
background-color: rgba(253, 37, 107, 0.5);
border-bottom: 1em solid var(--primary);
overflow: hidden;
}

&:nth-of-type(3n+2) div:hover {
&:nth-of-type(3n + 2) div:hover {
background-color: rgba(94, 191, 261, 0.5);
border-bottom: 1em solid var(--secondary);
overflow: hidden;
}

&:nth-of-type(3n+0) div:hover {
&:nth-of-type(3n + 0) div:hover {
background-color: rgba(161, 161, 161, 0.5);
border-bottom: 1em solid #a0a0a0;
overflow: hidden;
}
}
}

table {
box-sizing: border-box;
margin-top: 2em;
border-collapse: collapse;

.dataseturl {
font-size: small;
}

border: 1px solid var(--primary);
box-sizing: border-box;
}

th, td {
border: 1px solid var(--primary);
padding: 0.25em 1em;
box-sizing: border-box;
}

tr td {
&:nth-of-type(1), &:nth-of-type(3) {
width: 25%;
}

&:nth-of-type(2) {
width: 40%;
}

&:nth-of-type(4) {
width: 10%;
}
}

th {
background-color: var(--primary);
color: #fff;
}

form {
box-sizing: border-box;
padding: 2em 2em;
Expand All @@ -132,7 +122,8 @@
font-size: 1.15em;
}

input, textarea {
input,
textarea {
box-sizing: border-box;
width: 50%;
padding-left: 1em;
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/regions/challenges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def challenge_params
params.require(:challenge).permit(
:name, :short_desc, :long_desc, :eligibility, :video_url, :approved,
:banner_image, :image, :pdf, :pdf_preview, :nation_wide, :teaser,
:outcome_expectations, :sponsor_values
:outcome_expectations, :sponsor_values,
)
end
end
3 changes: 1 addition & 2 deletions app/controllers/challenges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ def check_competition_start!
@challenge = Challenge.find_by identifier: params[:identifier]
@challenge = Challenge.find(params[:identifier]) if @challenge.nil?
@region = @challenge.region
return if @region.is_show == 1 || @competition.started?(@region.time_zone) ||
return if @region.is_show == 1 || @competition.started?(@region.time_zone) ||
(@region.international? && @competition.started?(FIRST_COMPETITION_TIME_ZONE))


flash[:alert] = 'Challenges will become visible at the start of the competition'
redirect_to root_path
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/regions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def check_show
end

def eligible_locations
#@eligible_locations = [
# @eligible_locations = [
# {label: 'NSW', path: 'new_south_wales_2024'},
# {label: 'QLD', path: 'queensland_2024'},
# {label: 'VIC', path: 'victoria_2024'},
Expand All @@ -91,16 +91,15 @@ def eligible_locations
# {label: 'Australia', path: 'australia2024'},
# {label: 'New Zealand', path: 'new_zealand2024'},
# {label: 'International', path: 'international_2024'},
#]
# ]

regions = @competition.regions.order(:category, :name)

@eligible_locations = regions.map do |region|
{
label: region.name,
path: region.identifier
path: region.identifier,
}
end

end
end
2 changes: 1 addition & 1 deletion app/models/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def average_score
total_score += score
voted += 1
end
return (total_score / voted) unless voted.zero?
(total_score / voted) unless voted.zero?
end

# Returns a count of the number of judges that have completed votes for an
Expand Down
11 changes: 4 additions & 7 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,12 @@ def available_checkpoints(challenge)
# taking into only challenges already entered.
# ENHANCEMENT: Move to controller or helper.
def admin_available_checkpoints(_challenge)
valid_checkpoints = []
competition.checkpoints.each do |checkpoint|
competition.checkpoints.map do |checkpoint|
# ERROR: Not working correctly at the moment
# next if checkpoint.limit_reached?(self, challenge_region)

valid_checkpoints << checkpoint
checkpoint
end
valid_checkpoints
end

# Returns true if all the checkpoints have passed for a given team. false
Expand Down Expand Up @@ -179,10 +177,9 @@ def available_challenges(challenge_type)
# for.
# ENHANCEMENT: Move to active record query.
def member_competition_events
events = []
comp = competition
confirmed_members.each do |user|
events << user.participating_competition_event(comp)
events = confirmed_members.map do |user|
user.participating_competition_event(comp)
end
events.uniq
end
Expand Down
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def category
return 'Participant' if participant?
return 'Mentor' if mentor?
return 'Industry' if industry?
return 'Support' if support?

'Support' if support?
end

enum region: {
Expand Down
3 changes: 2 additions & 1 deletion app/services/demographics_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def initialize(competition, fieldtype)
@profiles = @competition.profiles.preload(:employment_status).compact
end

def report # rubocop:disable
# rubocop:disable
def report
grouped_data = case @fieldtype
when 'age'
@profiles.group_by(&:age)
Expand Down
11 changes: 4 additions & 7 deletions app/services/mailing_list_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,22 @@ def to_csv
def to_csv_by_date
CSV.generate do |csv|
csv << (USER_COLUMNS2 + ['region'])

# Collect all users across all regions
all_users = competition.regions.flat_map do |region|
region_users_all(region)
end.uniq

# Sort users by ID in descending order
sorted_users = all_users.sort_by(&:id).reverse

# Write sorted users to CSV
sorted_users.each do |user|
# Assuming you still want to include the region for each user
region_name = competition.regions.find { |region| region_users_all(region).include?(user) }&.name
csv << (user.attributes.values_at(*USER_COLUMNS2) + [region_name])
end
end

end

private
Expand All @@ -62,8 +61,6 @@ def region_users(region)
end

def region_users_all(region)
region.events.preload(:users).map do |event|
event.users
end.flatten.uniq
region.events.preload(:users).map(&:users).flatten.uniq
end
end
71 changes: 31 additions & 40 deletions app/views/data_sets/index.erb
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
<% content_for :title, "Datasets for #{@competition.name}" %>
<% content_for :title, "GovHack Datasets" %>
<main class="dataset_page">
<h1>
<%= yield :title %>
</h1>
<% if @data_sets.present? %>
<%= link_to 'Download CSV', data_sets_path(format: 'csv'), class: 'download-csv' %>
<table class="projects-table" data-turbolinks="false" id="dataset_table">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Dataset URL</th>
<th>Jurisdiction</th>
</tr>
</thead>
<tbody>
<% @data_sets.each do |data_set| %>
<tr>
<td>
<%= link_to data_set.name, data_set_path(data_set) %>
</td>
<td>
<%= markdown truncate(data_set.description, length: 100, omission: '... ') %>
</td>
<td>
<%= link_to data_set.url, visits_path(visit: {visitable_type: 'DataSet', visitable_id: data_set.id}), class: 'dataseturl' %>
</td>
<td>
<%= data_set.region.name %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p>
<strong>No Data Set Highlights saved for <%= @competition.name %> at this time.</strong>
</p>
<% end %>
<section>
<h1 class="mx-3">
<%= yield :title %>
</h1>
</section>
<section class="dataset_list">
<% if @data_sets.present? %>
<h2 class="mx-3 mb-5 fw-bold"><%= @data_sets.length %> Datasets available</h2>
<% @data_sets.each do |data_set| %>
<section class="dataset d-flex justify-content-between align-items-center mx-3 my-5">
<div>
<h3 class="mb-3"><%= data_set.name %></h3>
<p class="mb-2"><%= data_set.description %></p>
<p class="region"><%= data_set.region.name %></p>
</div>
<div class="link_container">
<%= link_to "Go to Dataset", data_set_path(data_set) %>
</div>
</section>
<% unless data_set == @data_sets.last %>
<hr/>
<% end %>
<% end %>
<% else %>
<p>
<strong>No matching datasets at this time.</strong>
</p>
<% end %>
</section>
<%= link_to 'Back to Resources', resources_path %>
</main>
<%= link_to 'Back to Resources', resources_path %>
Loading