mirror of
https://github.com/we-promise/sure.git
synced 2026-07-13 21:35:20 +00:00
When a rule is re-applied from the UI, RulesController passes ignore_attribute_locks: true, but Enrichable#enrich_attributes still rejected locked attributes unconditionally, so locked (manually edited or import-locked) transactions were silently skipped and reported as blocked. Thread the flag through enrich_attribute/enrich_attributes as a new ignore_locks keyword (default false, so provider syncs and AI enrichment keep respecting locks) and pass it from the six synchronous rule action executors. Fixes #2051
33 lines
876 B
Ruby
33 lines
876 B
Ruby
class Rule::ActionExecutor::SetTransactionName < Rule::ActionExecutor
|
|
def type
|
|
"text"
|
|
end
|
|
|
|
def options
|
|
nil
|
|
end
|
|
|
|
def execute(transaction_scope, value: nil, ignore_attribute_locks: false, rule_run: nil)
|
|
return 0 if value.blank?
|
|
|
|
scope = transaction_scope.with_entry
|
|
unless ignore_attribute_locks
|
|
# Filter by entry's locked_attributes, not transaction's
|
|
# Since name is on Entry, not Transaction, we need to check entries.locked_attributes
|
|
scope = scope.where.not(
|
|
Arel.sql("entries.locked_attributes ? 'name'")
|
|
)
|
|
end
|
|
|
|
count_modified_resources(scope) do |txn|
|
|
# enrich_attribute returns true if the entry was actually modified, false otherwise
|
|
txn.entry.enrich_attribute(
|
|
:name,
|
|
value,
|
|
source: "rule",
|
|
ignore_locks: ignore_attribute_locks
|
|
)
|
|
end
|
|
end
|
|
end
|