Skip to content

Commit

Permalink
fix: status-field dynamic filter missing some options (#2191)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev authored Dec 18, 2023
1 parent 7764e44 commit 3c4af00
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/avo/fields/status_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ def initialize(id, **args, &block)
@loading_when = args[:loading_when].present? ? [args[:loading_when]].flatten.map(&:to_sym) : [:waiting, :running]
@failed_when = args[:failed_when].present? ? [args[:failed_when]].flatten.map(&:to_sym) : [:failed]
@success_when = args[:success_when].present? ? [args[:success_when]].flatten.map(&:to_sym) : []
@neutral_when = args[:neutral_when].present? ? [args[:neutral_when]].flatten.map(&:to_sym) : nil
end

def status
status = "neutral"

if value.present?
status = "failed" if @failed_when.include? value.to_sym
status = "loading" if @loading_when.include? value.to_sym
Expand All @@ -21,7 +23,7 @@ def status
end

def options_for_filter
[@failed_when, @loading_when].flatten
[@failed_when, @loading_when, @success_when, @neutral_when].flatten.uniq
end
end
end
Expand Down

0 comments on commit 3c4af00

Please sign in to comment.