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 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>
31 lines
940 B
Ruby
31 lines
940 B
Ruby
module AccountAuthorizable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
include StreamExtensions
|
|
end
|
|
|
|
private
|
|
|
|
def require_account_permission!(account, level = :write, redirect_path: nil)
|
|
permission = account.permission_for(Current.user)
|
|
|
|
allowed = case level
|
|
when :write then permission.in?([ :owner, :full_control ])
|
|
when :annotate then permission.in?([ :owner, :full_control, :read_write ])
|
|
when :owner then permission == :owner
|
|
else false
|
|
end
|
|
|
|
return true if allowed
|
|
|
|
path = redirect_path || account_path(account)
|
|
respond_to do |format|
|
|
format.html { redirect_back_or_to path, alert: t("accounts.not_authorized") }
|
|
format.turbo_stream { stream_redirect_back_or_to(path, alert: t("accounts.not_authorized")) }
|
|
format.json { render json: { error: t("accounts.not_authorized") }, status: :forbidden }
|
|
end
|
|
false
|
|
end
|
|
end
|