Skip to content

Commit

Permalink
Merge branch 'TAN-515-remove-continuous-code-engines' into TAN-515-re…
Browse files Browse the repository at this point in the history
…name-factories
  • Loading branch information
jamesspeake committed Nov 22, 2023
2 parents 6d5c8c4 + d169cb6 commit cbf8e6a
Show file tree
Hide file tree
Showing 6 changed files with 700 additions and 679 deletions.
10 changes: 10 additions & 0 deletions back/app/services/form_logic_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ def valid?
end
end

def remove_select_logic_option_from_custom_fields(frozen_custom_field_option)
custom_field = frozen_custom_field_option.custom_field

return unless custom_field&.logic.present? &&
custom_field.logic['rules'].pluck('if').include?(frozen_custom_field_option.id)

custom_field.logic['rules'].reject! { |rule| rule['if'] == frozen_custom_field_option.id }
custom_field.save!
end

private

attr_reader :fields, :field_index, :option_index
Expand Down
6 changes: 6 additions & 0 deletions back/app/services/side_fx_custom_field_option_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def before_destroy(custom_field_option, _current_user)
end

def after_destroy(frozen_custom_field_option, current_user)
custom_field = frozen_custom_field_option.custom_field
if custom_field&.resource_type == 'CustomForm' && custom_field&.input_type == 'select'
FormLogicService.new([frozen_custom_field_option.custom_field])
.remove_select_logic_option_from_custom_fields(frozen_custom_field_option)
end

serialized_custom_field_option = clean_time_attributes(frozen_custom_field_option.attributes)
LogActivityJob.perform_later(
encode_frozen_resource(frozen_custom_field_option),
Expand Down
Loading

0 comments on commit cbf8e6a

Please sign in to comment.