Fixes issue #1752 #1742 with object manager

This commit is contained in:
Muhammad Nuzaihan 2018-01-17 22:24:17 +08:00
parent 119783d48d
commit a316df0829

View file

@ -32,6 +32,7 @@ class ObjectManagerAttributesController < ApplicationController
raise Exceptions::UnprocessableEntity, 'already exists' if exists
local_params = params.permit!.to_h
local_params[:data_option][:null] = true # set data option which can be null
begin
object_manager_attribute = ObjectManager::Attribute.add(
object: local_params[:object],
@ -110,12 +111,33 @@ class ObjectManagerAttributesController < ApplicationController
# rubocop:enable Lint/BooleanSymbol
end
end
if params[:data_option] && !params[:data_option].key?(:default)
params[:data_option][:default] = if params[:data_type].match?(/^(input|select|tree_select)$/)
''
end
if params[:data_option]
if !params[:data_option].key?(:default)
params[:data_option][:default] = if params[:data_type].match?(/^(input|select|tree_select)$/)
''
end
end
if params[:data_option][:null].nil?
params[:data_option][:null] = true
end
if params[:data_option][:options].nil?
params[:data_option][:options] = ''
end
if params[:data_option][:relation].nil?
params[:data_option][:relation] = ''
end
else
params[:data_option] = {
default: '',
options: '',
relation: '',
null: true
}
end
return if !params[:data_option][:null].nil?
params[:data_option][:null] = true
end
end