app/models/carnival/field.rb in carnival-0.0.55 vs app/models/carnival/field.rb in carnival-0.0.56

- old
+ new

@@ -59,35 +59,60 @@ end end return :asc end + def depends_on + @params[:depends_on] + end + def nested_form? @params[:nested_form] end def nested_form_allow_destroy? @params[:nested_form_allow_destroy] end def nested_form_modes? (mode) + associate = get_associate_nested_form_mode + return true if associate.present? && mode == :associate return @params[:nested_form_modes].include?(mode) unless @params[:nested_form_modes].nil? return false end + def nested_form_scope + return nil if !nested_form_modes? :associate + associate_mode = get_associate_nested_form_mode + return nil if associate_mode.is_a? Symbol + return associate_mode[:scope] if associate_mode[:scope].present? + end + def sortable? - @params[:sortable] + return true if @params[:sortable] + return true if @params[:sortable].class == Hash + return false end + def sortable_params + return false if !sortable? + return @params[:sortable].to_json if @params[:sortable].class == Hash + return true + end + def searchable? @params[:searchable] end def advanced_searchable? @params[:advanced_search] end + def show_as_list + @params[:show_as_list] + end + def advanced_search_operator return @params[:advanced_search][:operator] if advanced_searchable? and @params[:advanced_search][:operator].present? :like end @@ -108,8 +133,19 @@ if @params[:position].present? @line = @params[:position][:line] @column = @params[:position][:column] @size = @params[:position][:size] end + end + + def get_associate_nested_form_mode + @params[:nested_form_modes].each do |mode| + if mode.is_a? Hash + return mode[:associate] if mode[:associate].present? + elsif mode.is_a? Symbol + return mode if mode == :associate + end + end + nil end end end