mirror of
https://github.com/we-promise/sure.git
synced 2026-06-04 02:09:01 +00:00
feat(transactions): add inline tag creation and search in txn form (#1719)
* feat(transactions): add inline tag creation and search in transaction forms * fix(transactions): add tag-only update endpoint for edit drawer * feat(transactions): implement TagSelectComponent for improved tag selection and management * feat(tag-select): refactor tag selection component for improved functionality and accessibility * feat(tag-select): implement inline tag rendering and error handling in tag selection component * refactor(tag-select): remove unused list target from tag select controller * fix: return forbidden JSON for denied tag updates * fix: lock transaction tags when clearing them * refactor: move tag select into DS namespace * refactor: add multiselect trigger form field style * fix: auto-position tag select dropdowns * feat: add keyboard navigation to tag select * feat: add create tag and search placeholder to transaction forms in multiple languages * style: tighten tag select option spacing * fix: align tag select spacing and focus behavior * refactor: render tag badges with DS pill --------- Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
committed by
GitHub
parent
f4eb58d5d6
commit
5e558fa3ab
@@ -2,6 +2,7 @@ class TransactionsController < ApplicationController
|
||||
include EntryableResource
|
||||
|
||||
before_action :set_entry_for_unlock, only: :unlock
|
||||
before_action :set_entry_for_tags, only: :update_tags
|
||||
before_action :store_params!, only: :index
|
||||
|
||||
def new
|
||||
@@ -176,6 +177,20 @@ class TransactionsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def update_tags
|
||||
return unless require_account_permission!(@entry.account, :annotate, redirect_path: transaction_path(@entry))
|
||||
|
||||
tag_ids = Current.family.tags.where(id: tag_ids_param).pluck(:id)
|
||||
|
||||
@entry.transaction.tag_ids = tag_ids
|
||||
@entry.lock_saved_attributes!
|
||||
@entry.mark_user_modified!
|
||||
@entry.transaction.lock_attr!(:tag_ids)
|
||||
@entry.sync_account_later
|
||||
|
||||
render json: { tag_ids: @entry.transaction.tag_ids }
|
||||
end
|
||||
|
||||
def merge_duplicate
|
||||
transaction = accessible_transactions.includes(entry: :account).find(params[:id])
|
||||
|
||||
@@ -466,6 +481,14 @@ class TransactionsController < ApplicationController
|
||||
entry_params
|
||||
end
|
||||
|
||||
def tag_ids_param
|
||||
Array(params[:tag_ids]).reject(&:blank?)
|
||||
end
|
||||
|
||||
def set_entry_for_tags
|
||||
set_entry
|
||||
end
|
||||
|
||||
# Filters entry_params based on the user's permission on the account.
|
||||
# read_write users can only annotate (category, tags, notes, merchant).
|
||||
# read_only users cannot update anything.
|
||||
|
||||
Reference in New Issue
Block a user