Class: Marty::ImportView
Constant Summary
Extras::Layout::BOOL_MAP, Extras::Layout::MAP_BOOL
Constants included
from Permissions
Permissions::ALL_ROLES, Permissions::REQ_ROLES
Instance Method Summary
collapse
#bool_getter, #bool_setter, #dispfield, #enum_array, #enum_column, #enum_setter, #fieldset, #get_sorter, #hbox, #hspacer, #jsonb_field, #nullable_bool_column, #range_column, #range_field, #range_getter, #range_setter, #textarea_field, #tooltip, #vbox, #vspacer
#can_perform_action?, #can_perform_actions, #current_user_roles, #has_any_perm?, #has_marty_permissions
Constructor Details
#initialize(args, kwargs) ⇒ ImportView
Returns a new instance of ImportView.
14
15
16
17
18
19
20
|
# File 'app/components/marty/import_view.rb', line 14
def initialize args, kwargs
super(args, kwargs)
@model_view = model_view.camelize.constantize if model_view
@parent_model = parent_model.camelize.constantize if parent_model
@import_model = import_model.camelize.constantize if import_model
@record = nil
end
|
Instance Method Details
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'app/components/marty/import_view.rb', line 98
def configure(c)
super
c.title = nil
c.items =
[
textarea_field(:import_data,
height: 300,
hide_label: true,
min_width: 10000,
),
:result,
]
end
|
50
51
52
53
54
55
56
57
58
|
# File 'app/components/marty/import_view.rb', line 50
def format_message k, v
case k
when :clean then "#{v} record(s) cleaned."
when :same then "#{v} record(s) unchanged."
when :create then "#{v} record(s) created."
when :update then "#{v} record(s) updated."
when :blank then "#{v} empty lines."
end
end
|
#import(data) ⇒ Object
45
46
47
48
|
# File 'app/components/marty/import_view.rb', line 45
def import data
Marty::DataImporter.
do_import_summary(@import_model, data, 'infinity', nil, nil)
end
|
#import_model ⇒ Object
11
|
# File 'app/components/marty/import_view.rb', line 11
def import_model; end
|
#model_view ⇒ Object
12
|
# File 'app/components/marty/import_view.rb', line 12
def model_view; end
|
#parent_model ⇒ Object
10
|
# File 'app/components/marty/import_view.rb', line 10
def parent_model; end
|
#post_import ⇒ Object
41
42
43
|
# File 'app/components/marty/import_view.rb', line 41
def post_import
nil
end
|
#process_additional_fields ⇒ Object
33
34
35
|
# File 'app/components/marty/import_view.rb', line 33
def process_additional_fields
nil
end
|
#process_import_data ⇒ Object
37
38
39
|
# File 'app/components/marty/import_view.rb', line 37
def process_import_data
CSV.new(@import_data, headers: true, col_sep: "\t")
end
|
#validate ⇒ Object
28
29
30
31
|
# File 'app/components/marty/import_view.rb', line 28
def validate
return client.netzke_notify("Must provide import data.") if
@import_data.empty?
end
|