Add hashtag

This commit is contained in:
Eugene Burmakin 2025-11-18 21:24:14 +01:00
parent 807672170f
commit bce1052608
7 changed files with 8 additions and 8 deletions

View file

@ -483,7 +483,7 @@ export default class extends BaseController {
if (this.userTags && this.userTags.length > 0) { if (this.userTags && this.userTags.length > 0) {
this.userTags.forEach(tag => { this.userTags.forEach(tag => {
const icon = tag.icon || '📍'; const icon = tag.icon || '📍';
const label = `${icon} ${tag.name}`; const label = `${icon} #${tag.name}`;
const tagLayer = this.placesManager?.createFilteredLayer([tag.id]) || L.layerGroup(); const tagLayer = this.placesManager?.createFilteredLayer([tag.id]) || L.layerGroup();
this.placesFilteredLayers[label] = tagLayer; this.placesFilteredLayers[label] = tagLayer;
placesChildren.push({ placesChildren.push({

View file

@ -133,9 +133,9 @@ export class PlacesManager {
} }
createPopupContent(place) { createPopupContent(place) {
const tags = place.tags.map(tag => const tags = place.tags.map(tag =>
`<span class="badge badge-sm" style="background-color: ${tag.color}"> `<span class="badge badge-sm" style="background-color: ${tag.color}">
${tag.icon} ${tag.name} ${tag.icon} #${tag.name}
</span>` </span>`
).join(' '); ).join(' ');

View file

@ -111,7 +111,7 @@ export function createPlacesControl(placesManager, tags, userTheme = 'dark') {
style="margin-right: 8px; cursor: pointer;" style="margin-right: 8px; cursor: pointer;"
${this.activeFilters.has(tag.id) ? 'checked' : ''}> ${this.activeFilters.has(tag.id) ? 'checked' : ''}>
<span style="font-size: 18px; margin-right: 6px;">${tag.icon || '📍'}</span> <span style="font-size: 18px; margin-right: 6px;">${tag.icon || '📍'}</span>
<span style="flex: 1;">${this.escapeHtml(tag.name)}</span> <span style="flex: 1;">#${this.escapeHtml(tag.name)}</span>
${tag.color ? `<span style="width: 12px; height: 12px; border-radius: 50%; background-color: ${tag.color}; margin-left: 4px;"></span>` : ''} ${tag.color ? `<span style="width: 12px; height: 12px; border-radius: 50%; background-color: ${tag.color}; margin-left: 4px;"></span>` : ''}
</label> </label>
`).join('')} `).join('')}

View file

@ -4,7 +4,7 @@ module Taggable
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
has_many :taggings, as: :taggable, dependent: :destroy has_many :taggings, -> { order(created_at: :asc) }, as: :taggable, dependent: :destroy
has_many :tags, through: :taggings has_many :tags, through: :taggings
scope :with_tags, ->(tag_ids) { joins(:taggings).where(taggings: { tag_id: tag_ids }).distinct } scope :with_tags, ->(tag_ids) { joins(:taggings).where(taggings: { tag_id: tag_ids }).distinct }

View file

@ -43,7 +43,7 @@
<label class="cursor-pointer"> <label class="cursor-pointer">
<input type="checkbox" name="tag_ids[]" value="<%= tag.id %>" class="checkbox checkbox-sm hidden peer"> <input type="checkbox" name="tag_ids[]" value="<%= tag.id %>" class="checkbox checkbox-sm hidden peer">
<span class="badge badge-lg peer-checked:badge-primary" style="background-color: <%= tag.color %>"> <span class="badge badge-lg peer-checked:badge-primary" style="background-color: <%= tag.color %>">
<%= tag.icon %> <%= tag.name %> <%= tag.icon %> #<%= tag.name %>
</span> </span>
</label> </label>
<% end %> <% end %>

View file

@ -100,7 +100,7 @@
data-action="change->stat-page#filterPlacesByTags" data-action="change->stat-page#filterPlacesByTags"
class="checkbox checkbox-sm checkbox-primary"> class="checkbox checkbox-sm checkbox-primary">
<span class="text-xl"><%= tag.icon %></span> <span class="text-xl"><%= tag.icon %></span>
<span class="text-sm font-medium"><%= tag.name %></span> <span class="text-sm font-medium">#<%= tag.name %></span>
<% if tag.color.present? %> <% if tag.color.present? %>
<span class="w-3 h-3 rounded-full ml-1" style="background-color: <%= tag.color %>;"></span> <span class="w-3 h-3 rounded-full ml-1" style="background-color: <%= tag.color %>;"></span>
<% end %> <% end %>

View file

@ -20,7 +20,7 @@
<% @tags.each do |tag| %> <% @tags.each do |tag| %>
<tr> <tr>
<td class="text-2xl"><%= tag.icon %></td> <td class="text-2xl"><%= tag.icon %></td>
<td class="font-semibold"><%= tag.name %></td> <td class="font-semibold">#<%= tag.name %></td>
<td> <td>
<% if tag.color.present? %> <% if tag.color.present? %>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">