Revert "Fixed issue #1653: Default value not set for attributes of type input, select, tree_select, richtext, textarea, checkbox."
This reverts commit93c5708ba8
andc2bdbe62d8
.
This commit is contained in:
parent
37687e32a1
commit
01729584f0
2 changed files with 7 additions and 44 deletions
|
@ -110,7 +110,7 @@ add a new attribute entry for an object
|
||||||
created_at: '2014-06-04 10:00:00',
|
created_at: '2014-06-04 10:00:00',
|
||||||
updated_at: '2014-06-04 10:00:00',
|
updated_at: '2014-06-04 10:00:00',
|
||||||
|
|
||||||
force: true,
|
force: true
|
||||||
editable: false,
|
editable: false,
|
||||||
to_migrate: false,
|
to_migrate: false,
|
||||||
to_create: false,
|
to_create: false,
|
||||||
|
@ -329,12 +329,8 @@ possible types
|
||||||
if record[:data_option] != data[:data_option]
|
if record[:data_option] != data[:data_option]
|
||||||
|
|
||||||
# do we need a database migration?
|
# do we need a database migration?
|
||||||
%i[maxlength default].each do |option|
|
if record[:data_option][:maxlength] && data[:data_option][:maxlength] && record[:data_option][:maxlength].to_s != data[:data_option][:maxlength].to_s
|
||||||
next if record[:data_option][option]&.to_s == data[:data_option][option]&.to_s
|
|
||||||
|
|
||||||
data[:to_migrate] = true
|
data[:to_migrate] = true
|
||||||
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
|
||||||
record[:data_option_new] = data[:data_option]
|
record[:data_option_new] = data[:data_option]
|
||||||
|
@ -664,7 +660,7 @@ to send no browser reload event, pass false
|
||||||
end
|
end
|
||||||
|
|
||||||
if attribute.data_type == 'select' && attribute.data_option[:options]
|
if attribute.data_type == 'select' && attribute.data_option[:options]
|
||||||
attribute.data_option[:historical_options] = Hash(attribute.data_option[:historical_options]).merge(attribute.data_option[:options])
|
attribute.data_option[:historical_options] = attribute.data_option[:options]
|
||||||
end
|
end
|
||||||
|
|
||||||
data_type = nil
|
data_type = nil
|
||||||
|
@ -687,9 +683,8 @@ to send no browser reload event, pass false
|
||||||
model.table_name,
|
model.table_name,
|
||||||
attribute.name,
|
attribute.name,
|
||||||
data_type,
|
data_type,
|
||||||
limit: attribute.data_option[:maxlength],
|
limit: attribute.data_option[:maxlength],
|
||||||
default: attribute.data_option[:default],
|
null: true
|
||||||
null: true
|
|
||||||
)
|
)
|
||||||
elsif attribute.data_type.match?(/^integer|user_autocompletion|datetime|date$/)
|
elsif attribute.data_type.match?(/^integer|user_autocompletion|datetime|date$/)
|
||||||
ActiveRecord::Migration.change_column(
|
ActiveRecord::Migration.change_column(
|
||||||
|
@ -727,9 +722,8 @@ to send no browser reload event, pass false
|
||||||
model.table_name,
|
model.table_name,
|
||||||
attribute.name,
|
attribute.name,
|
||||||
data_type,
|
data_type,
|
||||||
limit: attribute.data_option[:maxlength],
|
limit: attribute.data_option[:maxlength],
|
||||||
default: attribute.data_option[:default],
|
null: true
|
||||||
null: true
|
|
||||||
)
|
)
|
||||||
elsif attribute.data_type.match?(/^integer|user_autocompletion$/)
|
elsif attribute.data_type.match?(/^integer|user_autocompletion$/)
|
||||||
ActiveRecord::Migration.add_column(
|
ActiveRecord::Migration.add_column(
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
class Issue1653DefaultValueNotSetForSelectInputEtc < ActiveRecord::Migration[5.2]
|
|
||||||
def change
|
|
||||||
# return if it's a new setup
|
|
||||||
return if !Setting.find_by(name: 'system_init_done')
|
|
||||||
|
|
||||||
ObjectManager::Attribute.all.each do |attribute|
|
|
||||||
next if !attribute.data_type.match?(/^input|select|tree_select|richtext|textarea|checkbox$/)
|
|
||||||
next if attribute.data_option[:default].blank?
|
|
||||||
|
|
||||||
ObjectManager::Attribute.add(
|
|
||||||
object: ObjectLookup.by_id(attribute.object_lookup_id),
|
|
||||||
name: attribute.name,
|
|
||||||
display: attribute.display,
|
|
||||||
data_type: attribute.data_type,
|
|
||||||
data_option: attribute.data_option,
|
|
||||||
active: attribute.active,
|
|
||||||
screens: attribute.screens,
|
|
||||||
position: attribute.position,
|
|
||||||
created_by_id: attribute.created_by_id,
|
|
||||||
updated_by_id: attribute.updated_by_id,
|
|
||||||
created_at: attribute.created_at,
|
|
||||||
updated_at: attribute.updated_at,
|
|
||||||
editable: attribute.editable,
|
|
||||||
to_migrate: true,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
# ATTENTION: this may take a while
|
|
||||||
ObjectManager::Attribute.migration_execute
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue