Fixes #3819 - Not displayed fields should not impact the edit screen.
This commit is contained in:
parent
fd1a9c179b
commit
41a04193da
7 changed files with 32 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div data-attribute-name="<%= @attribute.name %>" class="<%= @attribute.tag %> form-group<%= " form-group--block" if @attribute.style == 'block' %><%= " #{ @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 %>>
|
||||
<div data-attribute-name="<%= @attribute.name %>" class="<%= @attribute.tag %> form-group<%= " form-group--block" if @attribute.style == 'block' %><%= " #{ @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': %>
|
||||
<h2>
|
||||
<% end %>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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) }
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue