Skip to content
Merged
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
9 changes: 8 additions & 1 deletion app/controllers/curator/locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ def needs_photos
@locations = @locations.having("COUNT(active_storage_attachments.id) <= ?", params[:max_photos].to_i)
end

@locations = @locations.page(params[:page]).per(30)
page = params[:items_page] || params[:page] || 1
@locations = @locations.page(page).per(12)

# Handle partial loading for load-more
if params[:partial] == "items" && request.xhr?
return render partial: "curator/locations/needs_photo_items", locals: { locations: @locations }, layout: false
end

@city_names = Location.where.not(city: [ nil, "" ]).distinct.pluck(:city).sort
end

Expand Down
60 changes: 2 additions & 58 deletions app/views/curator/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,8 @@
</div>
</div>

<!-- Reviews & Audio Stats -->
<div class="grid grid-cols-2 gap-3 sm:gap-5 sm:grid-cols-4">
<div class="overflow-hidden rounded-lg bg-white dark:bg-gray-800 px-4 py-4 shadow">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400"><%= t("curator.dashboard.total_reviews") %></dt>
<dd class="mt-1 text-xl font-semibold tracking-tight text-gray-900 dark:text-white"><%= @stats[:reviews_count] %></dd>
<dd class="text-sm text-gray-500 dark:text-gray-400">
<span class="inline-flex items-center">
<svg class="h-4 w-4 text-yellow-400 mr-1" fill="currentColor" viewBox="0 0 20 20">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
</svg>
<%= @stats[:average_rating] %> <%= t("curator.dashboard.avg") %>
</span>
</dd>
</div>
<div class="overflow-hidden rounded-lg bg-white dark:bg-gray-800 px-4 py-4 shadow">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400"><%= t("curator.dashboard.recent_reviews") %></dt>
<dd class="mt-1 text-xl font-semibold tracking-tight text-gray-900 dark:text-white"><%= @stats[:pending_reviews] %></dd>
<dd class="text-sm text-gray-500 dark:text-gray-400"><%= t("curator.dashboard.last_7_days") %></dd>
</div>
<!-- Audio Stats -->
<div class="grid grid-cols-2 gap-3 sm:gap-5">
Comment thread
misabegovic marked this conversation as resolved.
<div class="overflow-hidden rounded-lg bg-white dark:bg-gray-800 px-4 py-4 shadow">
<dt class="truncate text-sm font-medium text-gray-500 dark:text-gray-400"><%= t("curator.dashboard.audio_tours") %></dt>
<dd class="mt-1 text-xl font-semibold tracking-tight text-gray-900 dark:text-white"><%= @stats[:audio_tours_with_audio] %>/<%= @stats[:audio_tours_count] %></dd>
Expand Down Expand Up @@ -175,45 +158,6 @@
</div>
</div>

<!-- Recent Reviews -->
<div class="rounded-lg bg-white dark:bg-gray-800 shadow">
<div class="px-4 py-4 sm:py-5 sm:px-6">
<div class="flex items-center justify-between">
<h2 class="text-base sm:text-lg font-medium text-gray-900 dark:text-white"><%= t("curator.dashboard.recent_reviews_title") %></h2>
<%= link_to curator_reviews_path, class: "text-sm text-emerald-600 dark:text-emerald-400 hover:text-emerald-900 dark:hover:text-emerald-300" do %>
<%= t("common.view_all") %>
<% end %>
</div>
<ul class="mt-3 sm:mt-4 divide-y divide-gray-200 dark:divide-gray-700">
<% @stats[:recent_reviews].each do |review| %>
<li class="py-3">
<%= link_to curator_review_path(review), class: "block hover:bg-gray-50 dark:hover:bg-gray-700 -mx-2 px-2 py-1 rounded-md" do %>
<div class="flex items-center justify-between">
<div class="min-w-0 flex-1">
<div class="flex items-center gap-1">
<% review.rating.times do %>
<svg class="h-3 w-3 text-yellow-400" fill="currentColor" viewBox="0 0 20 20">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
</svg>
<% end %>
<span class="text-xs text-gray-500 dark:text-gray-400 ml-1"><%= review.reviewable_type %></span>
</div>
<div class="text-sm text-gray-500 dark:text-gray-400 truncate"><%= review.comment.presence&.truncate(50) || t("curator.reviews.no_comment") %></div>
</div>
<svg class="h-5 w-5 text-gray-400 dark:text-gray-500 flex-shrink-0 ml-2" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
</svg>
</div>
<% end %>
</li>
<% end %>
<% if @stats[:recent_reviews].empty? %>
<li class="py-4 text-center text-gray-500 dark:text-gray-400 text-sm"><%= t("curator.dashboard.no_reviews") %></li>
<% end %>
</ul>
</div>
</div>

<!-- Recent Public Plans -->
<div class="rounded-lg bg-white dark:bg-gray-800 shadow">
<div class="px-4 py-4 sm:py-5 sm:px-6">
Expand Down
18 changes: 18 additions & 0 deletions app/views/curator/locations/_needs_photo_item.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="flex items-center justify-between gap-3 p-3 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700">
<div class="flex-1 min-w-0">
<%= link_to location.name, curator_location_path(location),
class: "font-medium text-gray-900 dark:text-white hover:text-emerald-600 dark:hover:text-emerald-400 truncate block" %>
<p class="text-sm text-gray-500 dark:text-gray-400 truncate"><%= location.city %></p>
</div>

<% photos_count = location.photos_count.to_i %>
<span class="flex-shrink-0 inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium
<%= photos_count == 0 ? 'bg-red-100 dark:bg-red-900/40 text-red-800 dark:text-red-300' : 'bg-yellow-100 dark:bg-yellow-900/40 text-yellow-800 dark:text-yellow-300' %>">
<%= photos_count %>
</span>

<%= link_to new_curator_location_photo_suggestion_path(location),
class: "flex-shrink-0 rounded-md bg-emerald-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-emerald-500" do %>
+ <%= t("curator.locations.needs_photos.add_photo") %>
<% end %>
</div>
3 changes: 3 additions & 0 deletions app/views/curator/locations/_needs_photo_items.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% locations.each do |location| %>
<%= render "curator/locations/needs_photo_item", location: location %>
<% end %>
86 changes: 25 additions & 61 deletions app/views/curator/locations/needs_photos.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,68 +32,32 @@

<%# Results %>
<% if @locations.any? %>
<div class="bg-white dark:bg-gray-800 shadow rounded-lg overflow-hidden">
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
<thead class="bg-gray-50 dark:bg-gray-700">
<tr>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
<%= t("curator.locations.name") %>
</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
<%= t("curator.locations.city") %>
</th>
<th scope="col" class="px-4 py-3 text-center text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
<%= t("curator.locations.needs_photos.photo_count") %>
</th>
<th scope="col" class="px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
<%= t("common.actions") %>
</th>
</tr>
</thead>
<tbody class="bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700">
<% @locations.each do |location| %>
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700">
<td class="px-4 py-3">
<div class="flex items-center gap-3">
<% if location.photos.attached? && location.photos.first.present? %>
<%= image_tag rails_blob_path(location.photos.first.variant(:thumb), disposition: "inline"),
class: "h-10 w-10 rounded-lg object-cover flex-shrink-0" %>
<% else %>
<div class="h-10 w-10 rounded-lg bg-gray-200 dark:bg-gray-700 flex items-center justify-center flex-shrink-0">
<svg class="h-5 w-5 text-gray-400 dark:text-gray-500" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z" />
</svg>
</div>
<% end %>
<div class="min-w-0">
<%= link_to location.name, curator_location_path(location),
class: "text-sm font-medium text-gray-900 dark:text-white hover:text-emerald-600 dark:hover:text-emerald-400 truncate block" %>
</div>
</div>
</td>
<td class="px-4 py-3 text-sm text-gray-500 dark:text-gray-400">
<%= location.city %>
</td>
<td class="px-4 py-3 text-center">
<% photos_count = location.photos_count.to_i %>
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium
<%= photos_count == 0 ? 'bg-red-100 dark:bg-red-900/40 text-red-800 dark:text-red-300' : photos_count < 3 ? 'bg-yellow-100 dark:bg-yellow-900/40 text-yellow-800 dark:text-yellow-300' : 'bg-green-100 dark:bg-green-900/40 text-green-800 dark:text-green-300' %>">
<%= photos_count %> <%= t("curator.locations.needs_photos.photos") %>
</span>
</td>
<td class="px-4 py-3 text-right text-sm">
<%= link_to t("curator.locations.needs_photos.add_photo"),
new_curator_location_photo_suggestion_path(location),
class: "text-emerald-600 dark:text-emerald-400 hover:text-emerald-800 dark:hover:text-emerald-300 font-medium" %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div data-controller="load-more"
data-load-more-url-value="<%= needs_photos_curator_locations_path %>"
data-load-more-resource-type-value="items"
data-load-more-page-value="1"
data-load-more-total-count-value="<%= @locations.total_count %>"
data-load-more-per-page-value="12">

<div class="space-y-2" data-load-more-target="container">
<%= render "curator/locations/needs_photo_items", locations: @locations %>
</div>

<div class="mt-4">
<%= paginate @locations %>
<%# Load More %>
<div class="mt-6 text-center">
<button type="button"
class="hidden inline-flex items-center justify-center gap-2 rounded-md bg-white dark:bg-gray-800 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 shadow-sm ring-1 ring-inset ring-gray-300 dark:ring-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700"
data-load-more-target="button"
data-action="click->load-more#loadMore">
<%= t("common.load_more", default: "Load More") %>
</button>
<div class="hidden" data-load-more-target="loading">
<svg class="animate-spin h-5 w-5 text-emerald-600 mx-auto" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
</div>
</div>
</div>
<% else %>
<div class="text-center py-12 bg-white dark:bg-gray-800 rounded-lg shadow">
Expand Down
Loading