File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed
Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+
Original file line number Diff line number Diff line change 1+ module Plugins
2+ module Core
3+ class AuthorCell < Plugins ::Core ::Cell
4+ def input
5+ render
6+ end
7+
8+ private
9+
10+ def current_user
11+ "#{ @options [ :current_user ] . firstname } #{ @options [ :current_user ] . lastname } "
12+ end
13+ end
14+ end
15+ end
Original file line number Diff line number Diff line change 1+ class AuthorFieldType < FieldType
2+ attr_accessor :author_name
3+ jsonb_accessor :data , author_name : :string
4+
5+ validates :author_name , presence : true , if : :validate_presence?
6+
7+ def data = ( data_hash )
8+ @author_name = data_hash . deep_symbolize_keys [ :author_name ]
9+ end
10+
11+ def field_item_as_indexed_json_for_field_type ( field_item , options = { } )
12+ json = { }
13+ json [ mapping_field_author_name ] = field_item . data [ 'author_name' ]
14+ json
15+ end
16+
17+ def mapping
18+ { author_name : mapping_field_name , type : :string , analyzer : :snowball }
19+ end
20+
21+ private
22+
23+ def mapping_field_name
24+ "#{ field_name . parameterize ( '_' ) } _author_name"
25+ end
26+
27+ def author_name_present
28+ errors . add ( :author_name , 'must be present' ) if @author_name . empty?
29+ end
30+
31+ def validate_uniqueness?
32+ @validations . key? :uniqueness
33+ end
34+
35+ def validate_presence?
36+ @validations . key? :presence
37+ end
38+
39+ def validate_length?
40+ @validations . key? :length
41+ end
42+ end
You can’t perform that action at this time.
0 commit comments