Class: Marty::ImportView
Constant Summary
Extras::Layout::BOOL_MAP, Extras::Layout::MAP_BOOL
Constants included
from Permissions
Permissions::NETZKE_ENDPOINTS
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_call_endpoint?, #can_perform_action?, #can_perform_actions, #current_user_roles, extended, #has_any_perm?, #has_marty_permissions, #has_perm?
Constructor Details
#initialize(args, kwargs) ⇒ ImportView
Returns a new instance of ImportView.
16
17
18
19
20
21
22
|
# File 'app/components/marty/import_view.rb', line 16
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
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'app/components/marty/import_view.rb', line 99
def configure(c)
super
c.title = nil
c.items =
[
textarea_field(:import_data,
height: 300,
hide_label: true,
min_width: 10000,
),
:result,
]
end
|
52
53
54
55
56
57
58
59
60
|
# File 'app/components/marty/import_view.rb', line 52
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
47
48
49
50
|
# File 'app/components/marty/import_view.rb', line 47
def import data
Marty::DataImporter.
do_import_summary(@import_model, data, 'infinity', nil, nil)
end
|
#import_model ⇒ Object
12
|
# File 'app/components/marty/import_view.rb', line 12
def import_model; end
|
#model_view ⇒ Object
14
|
# File 'app/components/marty/import_view.rb', line 14
def model_view; end
|
#parent_model ⇒ Object
10
|
# File 'app/components/marty/import_view.rb', line 10
def parent_model; end
|
#post_import ⇒ Object
43
44
45
|
# File 'app/components/marty/import_view.rb', line 43
def post_import
nil
end
|
#process_additional_fields ⇒ Object
35
36
37
|
# File 'app/components/marty/import_view.rb', line 35
def process_additional_fields
nil
end
|
#process_import_data ⇒ Object
39
40
41
|
# File 'app/components/marty/import_view.rb', line 39
def process_import_data
CSV.new(@import_data, headers: true, col_sep: "\t")
end
|
#validate ⇒ Object
30
31
32
33
|
# File 'app/components/marty/import_view.rb', line 30
def validate
return client.netzke_notify('Must provide import data.') if
@import_data.empty?
end
|