mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-09 08:47:11 -05:00
Revert some changes
This commit is contained in:
parent
491767b114
commit
c99f6597f0
18 changed files with 10 additions and 105 deletions
|
|
@ -1,11 +1,10 @@
|
|||
import L from "leaflet";
|
||||
import "leaflet.heat";
|
||||
import { createAllMapLayers } from "../maps/layers";
|
||||
import { PlacesManager } from "../maps/places";
|
||||
import BaseController from "./base_controller";
|
||||
|
||||
export default class extends BaseController {
|
||||
static targets = ["map", "loading", "heatmapBtn", "pointsBtn", "placesBtn"];
|
||||
static targets = ["map", "loading", "heatmapBtn", "pointsBtn"];
|
||||
|
||||
connect() {
|
||||
super.connect();
|
||||
|
|
@ -65,10 +64,6 @@ export default class extends BaseController {
|
|||
this.markersLayer = L.layerGroup(); // Don't add to map initially
|
||||
this.heatmapLayer = null;
|
||||
|
||||
// Initialize Places Manager
|
||||
this.placesManager = new PlacesManager(this.map, this.apiKey);
|
||||
this.placesManager.initialize();
|
||||
|
||||
// Load data for this month
|
||||
this.loadMonthData();
|
||||
|
||||
|
|
@ -233,40 +228,6 @@ export default class extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
togglePlaces() {
|
||||
if (!this.placesManager) {
|
||||
console.warn("Places manager not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.map.hasLayer(this.placesManager.placesLayer)) {
|
||||
// Remove places layer
|
||||
this.map.removeLayer(this.placesManager.placesLayer);
|
||||
if (this.hasPlacesBtnTarget) {
|
||||
this.placesBtnTarget.classList.remove('btn-active');
|
||||
}
|
||||
} else {
|
||||
// Add places layer
|
||||
this.map.addLayer(this.placesManager.placesLayer);
|
||||
if (this.hasPlacesBtnTarget) {
|
||||
this.placesBtnTarget.classList.add('btn-active');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
filterPlacesByTags(event) {
|
||||
if (!this.placesManager) return;
|
||||
|
||||
// Collect all checked tag IDs
|
||||
const checkboxes = event.currentTarget.closest('[data-controller="stat-page"]').querySelectorAll('input[type="checkbox"][data-tag-id]');
|
||||
const selectedTagIds = Array.from(checkboxes)
|
||||
.filter(cb => cb.checked)
|
||||
.map(cb => parseInt(cb.dataset.tagId));
|
||||
|
||||
// Filter places by selected tags (or show all if none selected)
|
||||
this.placesManager.filterByTags(selectedTagIds.length > 0 ? selectedTagIds : null);
|
||||
}
|
||||
|
||||
showLoading(show) {
|
||||
if (this.hasLoadingTarget) {
|
||||
this.loadingTarget.style.display = show ? 'flex' : 'none';
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class Users::ImportData::Places
|
|||
logger.debug "No exact match found for #{name} at (#{latitude}, #{longitude}). Creating new place."
|
||||
|
||||
place_attributes = place_data.except('created_at', 'updated_at', 'latitude', 'longitude')
|
||||
# lonlat will be auto-generated by the Place model's before_validation callback
|
||||
place_attributes['lonlat'] = "POINT(#{longitude} #{latitude})"
|
||||
place_attributes['latitude'] = latitude
|
||||
place_attributes['longitude'] = longitude
|
||||
place_attributes['user_id'] = user.id
|
||||
|
|
|
|||
|
|
@ -70,9 +70,6 @@
|
|||
<button class="btn btn-sm btn-outline" data-stat-page-target="pointsBtn" data-action="click->stat-page#togglePoints">
|
||||
<%= icon 'map-pin' %> Points
|
||||
</button>
|
||||
<button class="btn btn-sm btn-outline" data-stat-page-target="placesBtn" data-action="click->stat-page#togglePlaces">
|
||||
<%= icon 'map-pin-plus' %> Places
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -86,33 +83,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tag Filters -->
|
||||
<% if current_user.tags.any? %>
|
||||
<div class="mt-4 p-4 bg-base-200 rounded-lg">
|
||||
<h3 class="font-semibold mb-3 flex items-center gap-2">
|
||||
<%= icon 'filter' %> Filter Places by Tags
|
||||
</h3>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<% current_user.tags.ordered.each do |tag| %>
|
||||
<label class="flex items-center gap-2 cursor-pointer hover:bg-base-300 px-3 py-2 rounded-lg transition-colors">
|
||||
<input type="checkbox"
|
||||
data-tag-id="<%= tag.id %>"
|
||||
data-action="change->stat-page#filterPlacesByTags"
|
||||
class="checkbox checkbox-sm checkbox-primary">
|
||||
<span class="text-xl"><%= tag.icon %></span>
|
||||
<span class="text-sm font-medium">#<%= tag.name %></span>
|
||||
<% if tag.color.present? %>
|
||||
<span class="w-3 h-3 rounded-full ml-1" style="background-color: <%= tag.color %>;"></span>
|
||||
<% end %>
|
||||
</label>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-base-content/70">
|
||||
<%= icon 'info' %> Select tags to filter places on the map. Uncheck all to show all places.
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Map Stats -->
|
||||
<!--div class="stats grid grid-cols-2 md:grid-cols-4 gap-4 mt-4">
|
||||
<div class="stat">
|
||||
|
|
@ -348,6 +318,3 @@
|
|||
|
||||
<!-- Include Sharing Modal -->
|
||||
<%= render 'shared/sharing_modal' %>
|
||||
|
||||
<!-- Include Place Creation Modal -->
|
||||
<%= render 'shared/place_creation_modal' %>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ RSpec.describe Tag, type: :model do
|
|||
it { is_expected.to have_many(:places).through(:taggings) }
|
||||
|
||||
it { is_expected.to validate_presence_of(:name) }
|
||||
it { is_expected.to validate_length_of(:icon).is_at_most(10) }
|
||||
it { is_expected.to allow_value(nil).for(:icon) }
|
||||
it { is_expected.to validate_numericality_of(:privacy_radius_meters).is_greater_than(0).is_less_than_or_equal_to(5000).allow_nil }
|
||||
|
||||
describe 'validations' do
|
||||
subject { create(:tag) }
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ require 'rails_helper'
|
|||
RSpec.describe 'Api::V1::Maps::Hexagons', type: :request do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
|
||||
|
||||
describe 'GET /api/v1/maps/hexagons' do
|
||||
let(:valid_params) do
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ RSpec.describe 'Family::Invitations', type: :request do
|
|||
let!(:membership) { create(:family_membership, user: user, family: family, role: :owner) }
|
||||
let(:invitation) { create(:family_invitation, family: family, invited_by: user) }
|
||||
|
||||
|
||||
|
||||
describe 'GET /family/invitations' do
|
||||
before { sign_in user }
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ RSpec.describe 'Family Workflows', type: :request do
|
|||
let(:user2) { create(:user, email: 'bob@example.com') }
|
||||
let(:user3) { create(:user, email: 'charlie@example.com') }
|
||||
|
||||
|
||||
|
||||
describe 'Complete family creation and management workflow' do
|
||||
it 'allows creating a family, inviting members, and managing the family' do
|
||||
# Step 1: User1 creates a family
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Imports', type: :request do
|
||||
|
||||
|
||||
describe 'GET /imports' do
|
||||
context 'when user is logged in' do
|
||||
let(:user) { create(:user) }
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Map', type: :request do
|
||||
|
||||
|
||||
describe 'GET /index' do
|
||||
context 'when user signed in' do
|
||||
let(:user) { create(:user) }
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe '/notifications', type: :request do
|
||||
|
||||
|
||||
context 'when user is not logged in' do
|
||||
it 'redirects to the login page' do
|
||||
get notifications_url
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe '/settings/background_jobs', type: :request do
|
||||
|
||||
|
||||
context 'when Dawarich is in self-hosted mode' do
|
||||
before do
|
||||
allow(DawarichSettings).to receive(:self_hosted?).and_return(true)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'settings/maps', type: :request do
|
||||
|
||||
|
||||
context 'when user is authenticated' do
|
||||
let!(:user) { create(:user) }
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe '/stats', type: :request do
|
||||
|
||||
|
||||
context 'when user is not signed in' do
|
||||
describe 'GET /index' do
|
||||
it 'redirects to the sign in page' do
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ RSpec.describe 'Users::Registrations', type: :request do
|
|||
create(:family_invitation, family: family, invited_by: family_owner, email: 'invited@example.com')
|
||||
end
|
||||
|
||||
|
||||
|
||||
describe 'Family Invitation Registration Flow' do
|
||||
context 'when accessing registration with a valid invitation token' do
|
||||
it 'shows family-focused registration page' do
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Users', type: :request do
|
||||
|
||||
|
||||
describe 'GET /users/sign_up' do
|
||||
context 'when self-hosted' do
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ RSpec.describe Api::PlaceSerializer do
|
|||
name: 'Central Park',
|
||||
longitude: -73.9665,
|
||||
latitude: 40.7812,
|
||||
lonlat: 'SRID=4326;POINT(-73.9665 40.7812)',
|
||||
city: 'New York',
|
||||
country: 'United States',
|
||||
source: 'photon',
|
||||
|
|
|
|||
|
|
@ -591,7 +591,7 @@ RSpec.describe ReverseGeocoding::Places::FetchData do
|
|||
end
|
||||
|
||||
context 'when lonlat is already present on existing place' do
|
||||
let!(:existing_place) { create(:place, :with_geodata, latitude: 50.0, longitude: 10.0) }
|
||||
let!(:existing_place) { create(:place, :with_geodata, lonlat: 'POINT(10.0 50.0)') }
|
||||
let(:existing_data) do
|
||||
double(
|
||||
data: {
|
||||
|
|
@ -600,9 +600,7 @@ RSpec.describe ReverseGeocoding::Places::FetchData do
|
|||
'osm_id' => existing_place.geodata.dig('properties', 'osm_id'),
|
||||
'name' => 'Updated Name'
|
||||
}
|
||||
},
|
||||
latitude: 55.0,
|
||||
longitude: 15.0
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
|
|
@ -614,10 +612,7 @@ RSpec.describe ReverseGeocoding::Places::FetchData do
|
|||
service.call
|
||||
|
||||
existing_place.reload
|
||||
# lonlat is auto-generated from latitude/longitude, so it should remain based on original coordinates
|
||||
expect(existing_place.lonlat.to_s).to eq('POINT (10.0 50.0)')
|
||||
expect(existing_place.latitude).to eq(50.0)
|
||||
expect(existing_place.longitude).to eq(10.0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ RSpec.describe Visits::Creator do
|
|||
end
|
||||
|
||||
context 'when a confirmed visit already exists at the same location' do
|
||||
let(:place) { create(:place, user: user, latitude: 40.7128, longitude: -74.0060, name: 'Existing Place') }
|
||||
let(:place) { create(:place, lonlat: 'POINT(-74.0060 40.7128)', name: 'Existing Place') }
|
||||
let!(:existing_visit) do
|
||||
create(
|
||||
:visit,
|
||||
|
|
@ -61,7 +61,7 @@ RSpec.describe Visits::Creator do
|
|||
end
|
||||
|
||||
context 'when a confirmed visit exists but at a different location' do
|
||||
let(:different_place) { create(:place, user: user, latitude: 41.0000, longitude: -73.9000, name: 'Different Place') }
|
||||
let(:different_place) { create(:place, lonlat: 'POINT(-73.9000 41.0000)', name: 'Different Place') }
|
||||
let!(:existing_visit) do
|
||||
create(
|
||||
:visit,
|
||||
|
|
|
|||
Loading…
Reference in a new issue