Skip to content

Commit 100113a

Browse files
committed
feat: handle blank value for author name
1 parent 9780a41 commit 100113a

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

app/cells/plugins/core/author/input.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
= render_field_id
33
= render_label
44
= render_input
5-
= render_hidden_value
5+
= render_default_value

app/cells/plugins/core/author_cell.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def render_input
2121
@options[:form].text_field 'data[author_name]', value: value, placeholder: @options[:placeholder], class: 'mdl-textfield__input', required: required?
2222
end
2323

24-
def render_hidden_value
24+
def render_default_value
2525
@options[:form].hidden_field 'data[default_author_name]', value: current_user.fullname
2626
end
2727
end

app/models/author_field_type.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
class XAuthorFieldType < FieldType
1+
class AuthorFieldType < FieldType
22
attr_accessor :author_name
33
jsonb_accessor :data, author_name: :string
44

55
validates :author_name, presence: true, if: :validate_presence?
66

77
def data=(data_hash)
8+
data_hash[:author_name] = data_hash[:default_author_name] if data_hash.deep_symbolize_keys[:author_name].blank?
89
@author_name = data_hash.deep_symbolize_keys[:author_name]
910
end
1011

0 commit comments

Comments
 (0)