kuppayam 0.1.4 → 0.1.5dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/kuppayam/utilities.js +28 -0
- data/app/assets/stylesheets/kuppayam/custom.css +8 -1
- data/app/controllers/kuppayam/base_controller.rb +11 -1
- data/app/controllers/kuppayam/documents_controller.rb +4 -0
- data/app/helpers/flash_helper.rb +1 -1
- data/app/helpers/render_helper.rb +11 -2
- data/app/helpers/resource_helper.rb +13 -3
- data/app/models/kuppayam/application_record.rb +4 -0
- data/app/uploaders/document_uploader.rb +3 -3
- data/app/views/kuppayam/documents/create.html.erb +1 -1
- data/app/views/kuppayam/documents/edit.js.erb +1 -1
- data/app/views/kuppayam/documents/new.js.erb +1 -1
- data/app/views/kuppayam/documents/update.html.erb +1 -1
- data/app/views/kuppayam/http_status/404.html.erb +1 -0
- data/app/views/kuppayam/images/create.html.erb +2 -2
- data/app/views/kuppayam/images/crop.html.erb +1 -1
- data/app/views/kuppayam/images/edit.js.erb +3 -3
- data/app/views/kuppayam/images/new.js.erb +1 -1
- data/app/views/kuppayam/images/update.html.erb +3 -3
- data/app/views/kuppayam/import_data/new.js.erb +1 -1
- data/app/views/kuppayam/import_data/update.html.erb +1 -1
- data/app/views/kuppayam/workflows/parrot/create.js.erb +11 -6
- data/app/views/kuppayam/workflows/parrot/edit.js.erb +1 -1
- data/app/views/kuppayam/workflows/parrot/new.js.erb +2 -2
- data/app/views/kuppayam/workflows/parrot/row.js.erb +1 -1
- data/app/views/kuppayam/workflows/parrot/update.js.erb +10 -5
- data/app/views/kuppayam/workflows/peacock/create.js.erb +11 -6
- data/app/views/kuppayam/workflows/peacock/edit.js.erb +2 -2
- data/app/views/kuppayam/workflows/peacock/new.js.erb +2 -2
- data/app/views/kuppayam/workflows/peacock/row.js.erb +1 -1
- data/app/views/kuppayam/workflows/peacock/update.js.erb +11 -6
- data/app/views/layouts/kuppayam/_footer.html.erb +1 -0
- data/app/views/layouts/kuppayam/_horizontal_menu.html.erb +932 -0
- data/app/views/layouts/kuppayam/_sidebar.html.erb +3 -0
- data/app/views/layouts/kuppayam/admin.html.erb +63 -6
- data/app/views/layouts/kuppayam/blank.html.erb +62 -5
- data/app/views/layouts/kuppayam/document_upload.html.erb +3 -2
- data/app/views/layouts/kuppayam/image_upload.html.erb +3 -2
- data/app/views/layouts/kuppayam/layout_horizontal_menu.html.erb +116 -0
- data/app/views/layouts/kuppayam/print_a4.html.erb +32 -0
- data/config/locales/kuppayam/general.yml +1 -0
- data/lib/kuppayam/action_view/form_helper.rb +1 -1
- data/lib/kuppayam/action_view/theme_helper.rb +1 -1
- data/lib/kuppayam/engine.rb +2 -0
- data/lib/kuppayam/extras/kuppayam/importer.rb +156 -0
- data/lib/kuppayam/version.rb +1 -1
- data/vendor/assets/fonts/fontawesome/css/font-awesome.css +5 -2
- data/vendor/assets/fonts/linecons/css/linecons.css +6 -6
- metadata +29 -5
- data/app/views/layouts/kuppayam/_overlays.html.erb +0 -47
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
</li>
|
|
61
61
|
</ul>
|
|
62
62
|
</li>
|
|
63
|
+
|
|
63
64
|
<li>
|
|
64
65
|
<a href="/xenon/xenon-files/html/dashboard-1.html">
|
|
65
66
|
<i class="linecons-cog"></i>
|
|
@@ -99,6 +100,7 @@
|
|
|
99
100
|
</li>
|
|
100
101
|
</ul>
|
|
101
102
|
</li>
|
|
103
|
+
|
|
102
104
|
<li>
|
|
103
105
|
<a href="/xenon/xenon-files/html/layout-variants.html">
|
|
104
106
|
<i class="linecons-desktop"></i>
|
|
@@ -167,6 +169,7 @@
|
|
|
167
169
|
</li>
|
|
168
170
|
</ul>
|
|
169
171
|
</li>
|
|
172
|
+
|
|
170
173
|
<li>
|
|
171
174
|
<a href="/xenon/xenon-files/html/ui-panels.html">
|
|
172
175
|
<i class="linecons-note"></i>
|
|
@@ -41,13 +41,70 @@
|
|
|
41
41
|
|
|
42
42
|
</div>
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
<div id="div_modal_generic" class="modal" style="z-index: 1056;">
|
|
45
|
+
<div class="modal-dialog">
|
|
46
|
+
<div class="modal-content">
|
|
47
|
+
<div class="modal-header">
|
|
48
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
49
|
+
<h3 class="modal-title">Modal title</h3>
|
|
50
|
+
</div>
|
|
51
|
+
<div class="modal-body-main"></div>
|
|
52
|
+
</div><!-- /.modal-content -->
|
|
53
|
+
</div><!-- /.modal-dialog -->
|
|
54
|
+
</div><!-- /.modal -->
|
|
55
|
+
|
|
56
|
+
<div id="div_modal_large" class="modal">
|
|
57
|
+
<div class="modal-dialog modal-lg" style="width: 96%">
|
|
58
|
+
<div class="modal-content">
|
|
59
|
+
<div class="modal-header">
|
|
60
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
61
|
+
<h3 class="modal-title">Modal title</h3>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="modal-body-main"></div>
|
|
64
|
+
</div><!-- /.modal-content -->
|
|
65
|
+
</div><!-- /.modal-dialog -->
|
|
66
|
+
</div><!-- /.modal -->
|
|
67
|
+
|
|
68
|
+
<div id="div_modal_message" class="modal fade">
|
|
69
|
+
<div class="modal-dialog">
|
|
70
|
+
<div class="modal-content">
|
|
71
|
+
<div class="modal-header">
|
|
72
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
73
|
+
<h3 class="modal-title">Modal title</h3>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="modal-body">
|
|
76
|
+
<p>One fine body…</p>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="modal-footer">
|
|
79
|
+
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
|
|
80
|
+
</div>
|
|
81
|
+
</div><!-- /.modal-content -->
|
|
82
|
+
</div><!-- /.modal-dialog -->
|
|
83
|
+
</div><!-- /.modal -->
|
|
84
|
+
|
|
85
|
+
<div id="div_modal_image_upload" class="modal" style="z-index: 1057;">
|
|
86
|
+
<div class="modal-dialog">
|
|
87
|
+
<div class="modal-content">
|
|
88
|
+
<div class="modal-header">
|
|
89
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
90
|
+
<h3 class="modal-title">Modal title</h3>
|
|
91
|
+
</div>
|
|
92
|
+
<div class="modal-body-main"></div>
|
|
93
|
+
</div><!-- /.modal-content -->
|
|
94
|
+
</div><!-- /.modal-dialog -->
|
|
95
|
+
</div><!-- /.modal -->
|
|
96
|
+
|
|
97
|
+
<script type="text/javascript">
|
|
98
|
+
$('.modal').on('shown.bs.modal', function(e){
|
|
99
|
+
$(this).modal('handleUpdate'); //Update backdrop on modal show
|
|
100
|
+
$(this).scrollTop(0); //reset modal to top position
|
|
101
|
+
});
|
|
102
|
+
</script>
|
|
48
103
|
|
|
49
|
-
|
|
50
|
-
|
|
104
|
+
<!-- Page Loading Overlay -->
|
|
105
|
+
<!-- <div class="page-loading-overlay">
|
|
106
|
+
<div class="loader-3"></div>
|
|
107
|
+
</div> -->
|
|
51
108
|
|
|
52
109
|
<%#* Loading Javascripts -%>
|
|
53
110
|
<%= javascript_include_tag @javascript_filename -%>
|
|
@@ -19,13 +19,70 @@
|
|
|
19
19
|
|
|
20
20
|
</div>
|
|
21
21
|
|
|
22
|
+
<div id="div_modal_generic" class="modal" style="z-index: 1056;">
|
|
23
|
+
<div class="modal-dialog">
|
|
24
|
+
<div class="modal-content">
|
|
25
|
+
<div class="modal-header">
|
|
26
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
27
|
+
<h3 class="modal-title">Modal title</h3>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="modal-body-main"></div>
|
|
30
|
+
</div><!-- /.modal-content -->
|
|
31
|
+
</div><!-- /.modal-dialog -->
|
|
32
|
+
</div><!-- /.modal -->
|
|
33
|
+
|
|
34
|
+
<div id="div_modal_large" class="modal">
|
|
35
|
+
<div class="modal-dialog modal-lg" style="width: 96%">
|
|
36
|
+
<div class="modal-content">
|
|
37
|
+
<div class="modal-header">
|
|
38
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
39
|
+
<h3 class="modal-title">Modal title</h3>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="modal-body-main"></div>
|
|
42
|
+
</div><!-- /.modal-content -->
|
|
43
|
+
</div><!-- /.modal-dialog -->
|
|
44
|
+
</div><!-- /.modal -->
|
|
45
|
+
|
|
46
|
+
<div id="div_modal_message" class="modal fade">
|
|
47
|
+
<div class="modal-dialog">
|
|
48
|
+
<div class="modal-content">
|
|
49
|
+
<div class="modal-header">
|
|
50
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
51
|
+
<h3 class="modal-title">Modal title</h3>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="modal-body">
|
|
54
|
+
<p>One fine body…</p>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="modal-footer">
|
|
57
|
+
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
|
|
58
|
+
</div>
|
|
59
|
+
</div><!-- /.modal-content -->
|
|
60
|
+
</div><!-- /.modal-dialog -->
|
|
61
|
+
</div><!-- /.modal -->
|
|
62
|
+
|
|
63
|
+
<div id="div_modal_image_upload" class="modal" style="z-index: 1057;">
|
|
64
|
+
<div class="modal-dialog">
|
|
65
|
+
<div class="modal-content">
|
|
66
|
+
<div class="modal-header">
|
|
67
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
68
|
+
<h3 class="modal-title">Modal title</h3>
|
|
69
|
+
</div>
|
|
70
|
+
<div class="modal-body-main"></div>
|
|
71
|
+
</div><!-- /.modal-content -->
|
|
72
|
+
</div><!-- /.modal-dialog -->
|
|
73
|
+
</div><!-- /.modal -->
|
|
74
|
+
|
|
75
|
+
<script type="text/javascript">
|
|
76
|
+
$('.modal').on('shown.bs.modal', function(e){
|
|
77
|
+
$(this).modal('handleUpdate'); //Update backdrop on modal show
|
|
78
|
+
$(this).scrollTop(0); //reset modal to top position
|
|
79
|
+
});
|
|
80
|
+
</script>
|
|
81
|
+
|
|
22
82
|
<!-- Page Loading Overlay -->
|
|
23
|
-
<div class="page-loading-overlay">
|
|
83
|
+
<!-- <div class="page-loading-overlay">
|
|
24
84
|
<div class="loader-2"></div>
|
|
25
|
-
</div>
|
|
26
|
-
|
|
27
|
-
<%#* Display Hidden Overlays -%>
|
|
28
|
-
<%#= render :partial=>"/layouts/kuppayam/overlays" -%>
|
|
85
|
+
</div> -->
|
|
29
86
|
|
|
30
87
|
<%#* Loading Javascripts -%>
|
|
31
88
|
<%= javascript_include_tag @javascript_filename -%>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<!-- Head -->
|
|
5
|
+
<%= render :partial=>"/layouts/kuppayam/head" -%>
|
|
6
|
+
</head>
|
|
7
|
+
|
|
8
|
+
<body class="page-body">
|
|
9
|
+
|
|
10
|
+
<!-- <div class="settings-pane" id="settings_pane">
|
|
11
|
+
<%#= render :partial=>"/layouts/kuppayam/settings_pane" -%>
|
|
12
|
+
</div> -->
|
|
13
|
+
|
|
14
|
+
<%= render :partial=>"/layouts/kuppayam/horizontal_menu" -%>
|
|
15
|
+
|
|
16
|
+
<div class="page-container">
|
|
17
|
+
|
|
18
|
+
<div class="main-content">
|
|
19
|
+
|
|
20
|
+
<!-- Heading & Breadcrumbs -->
|
|
21
|
+
<%= render :partial=>"/layouts/kuppayam/heading" -%>
|
|
22
|
+
|
|
23
|
+
<%#* Show flash messages if controller has set any. -%>
|
|
24
|
+
<div id="div_flash_message" class="mt-10">
|
|
25
|
+
<%= flash_message(false) if defined?(flash) -%>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<%#* Page Content Starts here -%>
|
|
29
|
+
<div id="div_page_content_main">
|
|
30
|
+
<%= yield %>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<!-- Footer -->
|
|
34
|
+
<%= render :partial=>"/layouts/kuppayam/footer" -%>
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div id="div_modal_generic" class="modal" style="z-index: 1056;">
|
|
41
|
+
<div class="modal-dialog">
|
|
42
|
+
<div class="modal-content">
|
|
43
|
+
<div class="modal-header">
|
|
44
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
45
|
+
<h3 class="modal-title">Modal title</h3>
|
|
46
|
+
</div>
|
|
47
|
+
<div class="modal-body-main"></div>
|
|
48
|
+
</div><!-- /.modal-content -->
|
|
49
|
+
</div><!-- /.modal-dialog -->
|
|
50
|
+
</div><!-- /.modal -->
|
|
51
|
+
|
|
52
|
+
<div id="div_modal_large" class="modal">
|
|
53
|
+
<div class="modal-dialog modal-lg" style="width: 96%">
|
|
54
|
+
<div class="modal-content">
|
|
55
|
+
<div class="modal-header">
|
|
56
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
57
|
+
<h3 class="modal-title">Modal title</h3>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="modal-body-main"></div>
|
|
60
|
+
</div><!-- /.modal-content -->
|
|
61
|
+
</div><!-- /.modal-dialog -->
|
|
62
|
+
</div><!-- /.modal -->
|
|
63
|
+
|
|
64
|
+
<div id="div_modal_message" class="modal fade">
|
|
65
|
+
<div class="modal-dialog">
|
|
66
|
+
<div class="modal-content">
|
|
67
|
+
<div class="modal-header">
|
|
68
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
69
|
+
<h3 class="modal-title">Modal title</h3>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="modal-body">
|
|
72
|
+
<p>One fine body…</p>
|
|
73
|
+
</div>
|
|
74
|
+
<div class="modal-footer">
|
|
75
|
+
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
|
|
76
|
+
</div>
|
|
77
|
+
</div><!-- /.modal-content -->
|
|
78
|
+
</div><!-- /.modal-dialog -->
|
|
79
|
+
</div><!-- /.modal -->
|
|
80
|
+
|
|
81
|
+
<div id="div_modal_image_upload" class="modal" style="z-index: 1057;">
|
|
82
|
+
<div class="modal-dialog">
|
|
83
|
+
<div class="modal-content">
|
|
84
|
+
<div class="modal-header">
|
|
85
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
86
|
+
<h3 class="modal-title">Modal title</h3>
|
|
87
|
+
</div>
|
|
88
|
+
<div class="modal-body-main"></div>
|
|
89
|
+
</div><!-- /.modal-content -->
|
|
90
|
+
</div><!-- /.modal-dialog -->
|
|
91
|
+
</div><!-- /.modal -->
|
|
92
|
+
|
|
93
|
+
<script type="text/javascript">
|
|
94
|
+
$('.modal').on('shown.bs.modal', function(e){
|
|
95
|
+
$(this).modal('handleUpdate'); //Update backdrop on modal show
|
|
96
|
+
$(this).scrollTop(0); //reset modal to top position
|
|
97
|
+
});
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<!-- Page Loading Overlay -->
|
|
101
|
+
<!-- <div class="page-loading-overlay">
|
|
102
|
+
<div class="loader-3"></div>
|
|
103
|
+
</div> -->
|
|
104
|
+
|
|
105
|
+
<%#* Loading Javascripts -%>
|
|
106
|
+
<%= javascript_include_tag @javascript_filename -%>
|
|
107
|
+
|
|
108
|
+
<%= yield :javascript_footer -%>
|
|
109
|
+
|
|
110
|
+
<iframe id="iframe_document" name="iframe_document" width="100%" style="display:none"></iframe>
|
|
111
|
+
|
|
112
|
+
<iframe id="iframe_image" name="iframe_image" width="100%" style="display:none"></iframe>
|
|
113
|
+
|
|
114
|
+
</body>
|
|
115
|
+
|
|
116
|
+
</html>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<!-- Head -->
|
|
5
|
+
<%= render :partial=>"/layouts/kuppayam/head" -%>
|
|
6
|
+
|
|
7
|
+
<!-- <style type="text/css">
|
|
8
|
+
@page {
|
|
9
|
+
size: A4;
|
|
10
|
+
margin: 0;
|
|
11
|
+
}
|
|
12
|
+
@media print {
|
|
13
|
+
html, body {
|
|
14
|
+
width: 210mm;
|
|
15
|
+
height: 297mm;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
</style> -->
|
|
19
|
+
|
|
20
|
+
</head>
|
|
21
|
+
|
|
22
|
+
<body class="page-body">
|
|
23
|
+
|
|
24
|
+
<div class="page-container">
|
|
25
|
+
<div class="main-content">
|
|
26
|
+
<%= yield %>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
</body>
|
|
31
|
+
|
|
32
|
+
</html>
|
|
@@ -23,6 +23,7 @@ en:
|
|
|
23
23
|
updated: "%{item} has been updated successfully."
|
|
24
24
|
deleted: "%{item} has been deleted successfully."
|
|
25
25
|
removed: "%{item} has been removed successfully."
|
|
26
|
+
uploaded: "%{item} has been uploaded successfully."
|
|
26
27
|
no_results_found: "No results found."
|
|
27
28
|
state:
|
|
28
29
|
changed: "%{item} has been %{new_state}."
|
|
@@ -145,7 +145,7 @@ module Kuppayam
|
|
|
145
145
|
when :text, :email, :search, :password, :date, :time, :tel, :url, :month, :number
|
|
146
146
|
text_field_tag(options[:param_name], object.send(field_name.to_s), **options[:html_options])
|
|
147
147
|
when :textarea
|
|
148
|
-
options[:html_options].
|
|
148
|
+
options[:html_options].reverse_merge!(style: "height: 140px;")
|
|
149
149
|
text_area_tag(options[:param_name], object.send(field_name.to_s), **options[:html_options])
|
|
150
150
|
when :file
|
|
151
151
|
file_field_tag(options[:param_name], **options[:html_options])
|
|
@@ -130,7 +130,7 @@ module Kuppayam
|
|
|
130
130
|
# "No Results found"
|
|
131
131
|
# </div>
|
|
132
132
|
def theme_panel_message(message)
|
|
133
|
-
content_tag(:div, class: "panel panel-default panel-message text-color-grey p-80 text-align-center", style: "height:200px;") do
|
|
133
|
+
content_tag(:div, class: "panel panel-default panel-message text-color-grey p-80 text-align-center", style: "height:200px;width:100%;") do
|
|
134
134
|
raw(message)
|
|
135
135
|
end
|
|
136
136
|
end
|
data/lib/kuppayam/engine.rb
CHANGED
|
@@ -4,6 +4,8 @@ module Kuppayam
|
|
|
4
4
|
require 'kaminari'
|
|
5
5
|
require 'jquery-rails'
|
|
6
6
|
|
|
7
|
+
config.autoload_paths << File.expand_path("../extras", __FILE__)
|
|
8
|
+
|
|
7
9
|
initializer "kuppayam.assets.precompile" do |app|
|
|
8
10
|
app.config.assets.precompile += %w( kuppayam.js jquery_with_ujs.js kuppayam.css wysiwyg-color.css)
|
|
9
11
|
end
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# require 'axlsx'
|
|
2
|
+
require 'colorized_string'
|
|
3
|
+
|
|
4
|
+
module Kuppayam
|
|
5
|
+
|
|
6
|
+
module Importer
|
|
7
|
+
|
|
8
|
+
class ErrorHash
|
|
9
|
+
|
|
10
|
+
attr_accessor :warnings,
|
|
11
|
+
:errors
|
|
12
|
+
|
|
13
|
+
def initialize
|
|
14
|
+
@warnings = []
|
|
15
|
+
@errors = []
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def warnings?
|
|
19
|
+
@warnings.any?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def errors?
|
|
23
|
+
@errors.any?
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def print_dot
|
|
27
|
+
if self.warnings?
|
|
28
|
+
print ".".yellow
|
|
29
|
+
elsif self.errors?
|
|
30
|
+
print ".".red
|
|
31
|
+
else
|
|
32
|
+
print ".".green
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def print_all
|
|
37
|
+
self.warnings.each do |item|
|
|
38
|
+
puts "Summary: #{item[:summary]}".yellow
|
|
39
|
+
puts "Details: #{item[:details]}".yellow if item[:details]
|
|
40
|
+
puts "Stack Trace: #{item[:stack_trace]}".yellow if item[:stack_trace]
|
|
41
|
+
puts ""
|
|
42
|
+
end
|
|
43
|
+
self.errors.each do |item|
|
|
44
|
+
puts "Summary: #{item[:summary]}".red
|
|
45
|
+
puts "Details: #{item[:details]}".red if item[:details]
|
|
46
|
+
puts "Stack Trace: #{item[:stack_trace]}".red if item[:stack_trace]
|
|
47
|
+
puts ""
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class DataError
|
|
53
|
+
|
|
54
|
+
attr_accessor :errors, :columns
|
|
55
|
+
|
|
56
|
+
def initialize
|
|
57
|
+
@errors = {}
|
|
58
|
+
@columns = []
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def add_column_error(name, value, errors, row_number)
|
|
62
|
+
if @errors[row_number].blank?
|
|
63
|
+
@errors[row_number] = {
|
|
64
|
+
name => { value: value, errors: errors }
|
|
65
|
+
}
|
|
66
|
+
else
|
|
67
|
+
@errors[row_number][name] = { value: value, errors: errors }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def generate_error_file
|
|
72
|
+
|
|
73
|
+
# binding.pry
|
|
74
|
+
|
|
75
|
+
axlsx_package = Axlsx::Package.new
|
|
76
|
+
wb = axlsx_package.workbook
|
|
77
|
+
|
|
78
|
+
normal_cell = s.add_style :bg_color => "FFFFFF", :fg_color => "4B4B4B", :sz => 14, :alignment => { :horizontal=> :center }
|
|
79
|
+
error_cell = s.add_style :bg_color => "FFE2E2", :fg_color => "4B4B4B", :sz => 14, :alignment => { :horizontal=> :center }
|
|
80
|
+
|
|
81
|
+
wb.add_worksheet(:name => "Errors") do |sheet|
|
|
82
|
+
|
|
83
|
+
sheet.add_row self.columns
|
|
84
|
+
|
|
85
|
+
self.errors.each do |row_number, values|
|
|
86
|
+
row_data = self.columns.map{|col| values[col][:value] }
|
|
87
|
+
sheet.add_row row_data
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
axlsx_package.serialize("tmp/example.xlsx")
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def import_from_csv(csv_path, verbose=true)
|
|
99
|
+
|
|
100
|
+
csv_table = CSV.table(csv_path, {headers: true, converters: nil, header_converters: :symbol})
|
|
101
|
+
headers = csv_table.headers
|
|
102
|
+
|
|
103
|
+
errors = []
|
|
104
|
+
|
|
105
|
+
csv_table.each do |row|
|
|
106
|
+
error_object = save_row_data(row)
|
|
107
|
+
errors << error_object if error_object
|
|
108
|
+
error_object.print_dot if error_object
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if verbose
|
|
112
|
+
puts ""
|
|
113
|
+
errors.each do |error_object|
|
|
114
|
+
error_object.print_all if error_object
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def import_data(engine, path, dummy=true, verbose=true)
|
|
120
|
+
if dummy
|
|
121
|
+
# Check for the file in the application path
|
|
122
|
+
# If not found, check it in engine path
|
|
123
|
+
csv_file_path = Rails.root.join('db', 'import_data', 'dummy', "#{self.table_name}.csv")
|
|
124
|
+
unless File.exists?(csv_file_path)
|
|
125
|
+
csv_file_path = engine.root.join('db', 'import_data', 'dummy', "#{self.table_name}.csv")
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
if File.exists?(csv_file_path)
|
|
129
|
+
self.import_from_csv(csv_file_path.to_s, verbose)
|
|
130
|
+
else
|
|
131
|
+
puts "CSV file not found at '#{csv_file_path.to_s}'.".red if verbose
|
|
132
|
+
end
|
|
133
|
+
else
|
|
134
|
+
if path
|
|
135
|
+
# If path is given, check if the file exists
|
|
136
|
+
if File.exists?(path)
|
|
137
|
+
import_from_csv(path, verbose)
|
|
138
|
+
else
|
|
139
|
+
puts "CSV file not found at '#{path}'. Please give absolute path.".red if verbose
|
|
140
|
+
end
|
|
141
|
+
else
|
|
142
|
+
csv_file_path = Rails.root.join('db', 'import_data', "#{self.table_name}.csv")
|
|
143
|
+
unless File.exists?(csv_file_path)
|
|
144
|
+
csv_file_path = engine.root.join('db', 'import_data', "#{self.table_name}.csv")
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
if File.exists?(csv_file_path)
|
|
148
|
+
self.import_from_csv(csv_file_path.to_s, verbose)
|
|
149
|
+
else
|
|
150
|
+
puts "CSV file not found at '#{csv_file_path.to_s}'.".red if verbose
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|