Merge branch 'dev' into fix/basecamp-gpx

This commit is contained in:
Evgenii Burmakin
2025-07-26 15:17:11 +02:00
committed by GitHub
6 changed files with 41 additions and 14 deletions

View File

@@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- The Live Map setting is now respected.
- The Live Map info modal is now displayed. #665
- GPX from Basecamp is now supported. #790
- The "Delete Selected" button is now hidden when no points are selected. #1025
# [0.30.3] - 2025-07-23

View File

@@ -18,7 +18,14 @@ class PointsController < ApplicationController
end
def bulk_destroy
current_user.tracked_points.where(id: params[:point_ids].compact).destroy_all
point_ids = params[:point_ids]&.compact&.reject(&:blank?)
redirect_to points_url(preserved_params),
alert: 'No points selected.',
status: :see_other and return if point_ids.blank?
current_user.tracked_points.where(id: point_ids).destroy_all
redirect_to points_url(preserved_params),
notice: 'Points were successfully destroyed.',
status: :see_other

View File

@@ -2,11 +2,12 @@ import BaseController from "./base_controller"
// Connects to data-controller="checkbox-select-all"
export default class extends BaseController {
static targets = ["parent", "child"]
static targets = ["parent", "child", "deleteButton"]
connect() {
this.parentTarget.checked = false
this.childTargets.map(x => x.checked = false)
this.updateDeleteButtonVisibility()
}
toggleChildren() {
@@ -15,6 +16,7 @@ export default class extends BaseController {
} else {
this.childTargets.map(x => x.checked = false)
}
this.updateDeleteButtonVisibility()
}
toggleParent() {
@@ -23,5 +25,14 @@ export default class extends BaseController {
} else {
this.parentTarget.checked = true
}
this.updateDeleteButtonVisibility()
}
updateDeleteButtonVisibility() {
const hasCheckedItems = this.childTargets.some(target => target.checked)
if (this.hasDeleteButtonTarget) {
this.deleteButtonTarget.style.display = hasCheckedItems ? 'inline-block' : 'none'
}
}
}

View File

@@ -6,34 +6,34 @@
<div class="w-full md:w-2/12">
<div class="flex flex-col space-y-2">
<%= f.label :start_at, class: "text-sm font-semibold" %>
<%= f.datetime_local_field :start_at, class: "rounded-md w-full", value: @start_at %>
<%= f.datetime_local_field :start_at, class: "input input-bordered hover:cursor-pointer hover:input-primary", value: @start_at %>
</div>
</div>
<div class="w-full md:w-2/12">
<div class="flex flex-col space-y-2">
<%= f.label :end_at, class: "text-sm font-semibold" %>
<%= f.datetime_local_field :end_at, class: "rounded-md w-full", value: @end_at %>
<%= f.datetime_local_field :end_at, class: "input input-bordered hover:cursor-pointer hover:input-primary", value: @end_at %>
</div>
</div>
<div class="w-full md:w-2/12">
<div class="flex flex-col space-y-2">
<%= f.label :import, class: "text-sm font-semibold" %>
<%= f.select :import_id, options_for_select(@imports.map { |i| [i.name, i.id] }, params[:import_id]), { include_blank: true }, class: "rounded-md w-full" %>
<%= f.select :import_id, options_for_select(@imports.map { |i| [i.name, i.id] }, params[:import_id]), { include_blank: true }, class: "input input-bordered hover:cursor-pointer hover:input-primary" %>
</div>
</div>
<div class="w-full md:w-1/12">
<div class="flex flex-col space-y-2">
<%= f.submit "Search", class: "px-4 py-2 bg-blue-500 text-white rounded-md" %>
<%= f.submit "Search", class: "btn btn-primary" %>
</div>
</div>
<div class="w-full md:w-2/12">
<div class="flex flex-col space-y-2 text-center">
<%= link_to 'Export as GeoJSON', exports_path(start_at: @start_at, end_at: @end_at, file_format: :json), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points within timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "px-4 py-2 bg-green-500 text-white rounded-md join-item" %>
<%= link_to 'Export as GeoJSON', exports_path(start_at: @start_at, end_at: @end_at, file_format: :json), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points within timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "btn border border-base-300 hover:btn-ghost" %>
</div>
</div>
<div class="w-full md:w-2/12">
<div class="flex flex-col space-y-2 text-center">
<%= link_to 'Export as GPX', exports_path(start_at: @start_at, end_at: @end_at, file_format: :gpx), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points within timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "px-4 py-2 bg-green-500 text-white rounded-md join-item" %>
<%= link_to 'Export as GPX', exports_path(start_at: @start_at, end_at: @end_at, file_format: :gpx), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure? This will start background process of exporting points within timeframe, selected between #{@start_at} and #{@end_at}", turbo_method: :post }, class: "btn border border-base-300 hover:btn-ghost" %>
</div>
</div>
</div>
@@ -46,9 +46,8 @@
<div id="points" class="min-w-full">
<div data-controller='checkbox-select-all'>
<%= form_with url: bulk_destroy_points_path(params.permit!), method: :delete, id: :bulk_destroy_form do |f| %>
<div class="flex justify-between my-5">
<%= f.submit "Delete Selected", class: "px-4 py-2 bg-red-500 text-white rounded-md", data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" } %>
<%= f.submit "Delete Selected", class: "px-4 py-2 bg-red-500 text-white rounded-md", data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?", checkbox_select_all_target: "deleteButton" }, style: "display: none;" %>
<div>
<%= page_entries_info @points, entry_name: 'point' %>
</div>
@@ -64,14 +63,15 @@
<tr>
<th>
<%= label_tag do %>
Select all
<%= check_box_tag 'Select all',
id: :select_all_points,
data: {
checkbox_select_all_target: 'parent',
action: 'change->checkbox-select-all#toggleChildren'
}
},
class: 'mr-2'
%>
Select all
<% end %>
</div>
</th>

View File

@@ -63,5 +63,14 @@ RSpec.describe '/points', type: :request do
expect(response).to redirect_to(points_url(start_at: '2021-01-01', end_at: '2021-01-02'))
end
context 'when no points are selected' do
it 'redirects to the points list' do
delete bulk_destroy_points_url, params: { point_ids: [] }
expect(response).to redirect_to(points_url)
expect(flash[:alert]).to eq('No points selected.')
end
end
end
end

View File

@@ -435,7 +435,7 @@ RSpec.describe 'Map Interaction', type: :system do
end
end
context 'settings panel functionality' do
xcontext 'settings panel functionality' do
include_context 'authenticated map user'
it 'allows updating route opacity settings' do