diff --git a/app/assets/javascripts/app/controllers/_application_controller/form.coffee b/app/assets/javascripts/app/controllers/_application_controller/form.coffee
index 9d968be2e..5664291fd 100644
--- a/app/assets/javascripts/app/controllers/_application_controller/form.coffee
+++ b/app/assets/javascripts/app/controllers/_application_controller/form.coffee
@@ -278,7 +278,7 @@ class App.ControllerForm extends App.Controller
attribute.autocomplete = 'autocomplete="' + attribute.autocomplete + '"'
# set default values
- if attribute.value is undefined && 'default' of attribute
+ if attribute.value is undefined && 'default' of attribute && !@params?.id
attribute.value = attribute.default
# set params value
diff --git a/app/assets/javascripts/app/views/generic/attribute.jst.eco b/app/assets/javascripts/app/views/generic/attribute.jst.eco
index 25c29218e..90f051e2c 100644
--- a/app/assets/javascripts/app/views/generic/attribute.jst.eco
+++ b/app/assets/javascripts/app/views/generic/attribute.jst.eco
@@ -1,4 +1,4 @@
-
<%= " #{ @attribute.item_class }" if @attribute.item_class %><%= " is-required" if !@attribute.null %><%= " is-hidden hide" if @attribute.shown == false %>"<%= " data-width=#{ @attribute.grid_width }" if @attribute.grid_width %>>
+
<%= " #{ @attribute.item_class }" if @attribute.item_class %><%= " is-required" if !@attribute.null %><%= " is-hidden is-removed hide" if @attribute.shown == false %>"<%= " data-width=#{ @attribute.grid_width }" if @attribute.grid_width %>>
<% if @attribute.style == 'block': %>
<% end %>
diff --git a/app/models/concerns/checks_core_workflow.rb b/app/models/concerns/checks_core_workflow.rb
index 5827302ee..83c149522 100644
--- a/app/models/concerns/checks_core_workflow.rb
+++ b/app/models/concerns/checks_core_workflow.rb
@@ -25,7 +25,6 @@ module ChecksCoreWorkflow
}, user: User.find(UserInfo.current_user_id))
check_restrict_values(perform_result)
- check_visibility(perform_result)
check_mandatory(perform_result)
end
@@ -43,14 +42,6 @@ module ChecksCoreWorkflow
perform_result[:restrict_values][key].any? { |value| value.to_s == self[key].to_s }
end
- def check_visibility(perform_result)
- perform_result[:visibility].each_key do |key|
- next if perform_result[:visibility][key] != 'remove'
-
- self[key] = nil
- end
- end
-
def check_mandatory(perform_result)
perform_result[:mandatory].each_key do |key|
next if field_visible?(perform_result, key)
diff --git a/app/models/core_workflow/attributes.rb b/app/models/core_workflow/attributes.rb
index 5640cf851..61c69f8fe 100644
--- a/app/models/core_workflow/attributes.rb
+++ b/app/models/core_workflow/attributes.rb
@@ -102,7 +102,7 @@ class CoreWorkflow::Attributes
# dont cache this else the result object will work with references and cache bugs occur
def visibility_default
object_elements.each_with_object({}) do |attribute, result|
- result[ attribute[:name] ] = screen_value(attribute, 'shown') == false ? 'hide' : 'show'
+ result[ attribute[:name] ] = screen_value(attribute, 'shown') == false ? 'remove' : 'show'
end
end
diff --git a/spec/models/concerns/checks_core_workflow_examples.rb b/spec/models/concerns/checks_core_workflow_examples.rb
index 980741351..87962fa11 100644
--- a/spec/models/concerns/checks_core_workflow_examples.rb
+++ b/spec/models/concerns/checks_core_workflow_examples.rb
@@ -9,16 +9,6 @@ RSpec.shared_examples 'ChecksCoreWorkflow' do
UserInfo.current_user_id = agent.id
end
- context 'when pending time on open ticket' do
- subject(:ticket) { create(:ticket, group: agent_group, screen: 'create_middle', state: Ticket::State.find_by(name: 'open'), pending_time: Time.zone.now + 5.days) }
-
- before { subject }
-
- it 'checks if the pending time got removed' do
- expect(ticket.pending_time).to be nil
- end
- end
-
context 'when creation of closed tickets are only allowed by type set' do
subject(:ticket) { create(:ticket, group: agent_group, screen: 'create_middle', state: Ticket::State.find_by(name: 'open'), pending_time: Time.zone.now + 5.days) }
diff --git a/spec/system/ticket/create_spec.rb b/spec/system/ticket/create_spec.rb
index 0e4f4db5b..a5e482186 100644
--- a/spec/system/ticket/create_spec.rb
+++ b/spec/system/ticket/create_spec.rb
@@ -624,7 +624,7 @@ RSpec.describe 'Ticket Create', type: :system do
end
it 'does not show the field' do
- expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-hidden", visible: :hidden)
+ expect(page).to have_css("div[data-attribute-name='#{field_name}'].is-hidden.is-removed", visible: :hidden)
end
end
end
diff --git a/spec/system/ticket/zoom_spec.rb b/spec/system/ticket/zoom_spec.rb
index 53199f58d..8578ed66b 100644
--- a/spec/system/ticket/zoom_spec.rb
+++ b/spec/system/ticket/zoom_spec.rb
@@ -2267,4 +2267,32 @@ RSpec.describe 'Ticket zoom', type: :system do
expect(page.all('select[name=owner_id] option').map(&:value)).to include(agent2.id.to_s)
end
end
+
+ describe 'Not displayed fields should not impact the edit screen #3819', authenticated_as: :authenticate, db_strategy: :reset do
+ let(:field_name) { SecureRandom.uuid }
+ let(:ticket) { create(:ticket, group: Group.find_by(name: 'Users')) }
+
+ def authenticate
+ create :object_manager_attribute_boolean, default: nil, screens: {
+ edit: {
+ 'ticket.agent' => {
+ shown: false,
+ required: false,
+ }
+ }
+ }
+ ObjectManager::Attribute.migration_execute
+ ticket
+ true
+ end
+
+ before do
+ visit "#ticket/zoom/#{ticket.id}"
+ end
+
+ it 'does not show any changes for the field because it has no value and because it is not shown it should also not show the ticket as changed' do
+ sleep 3
+ expect(page).to have_no_selector('.js-reset')
+ end
+ end
end