kuppayam 0.1.5dev4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/kuppayam.js +0 -3
  3. data/app/assets/javascripts/kuppayam/utilities.js +0 -28
  4. data/app/assets/stylesheets/kuppayam.css +0 -1
  5. data/app/controllers/kuppayam/base_controller.rb +1 -11
  6. data/app/controllers/kuppayam/documents_controller.rb +0 -4
  7. data/app/helpers/breadcrumbs_helper.rb +1 -1
  8. data/app/helpers/filter_helper.rb +3 -9
  9. data/app/helpers/render_helper.rb +2 -11
  10. data/app/helpers/resource_helper.rb +3 -13
  11. data/app/models/kuppayam/application_record.rb +0 -3
  12. data/app/uploaders/document_uploader.rb +3 -3
  13. data/app/views/kuppayam/documents/create.html.erb +1 -1
  14. data/app/views/kuppayam/documents/edit.js.erb +1 -1
  15. data/app/views/kuppayam/documents/new.js.erb +1 -1
  16. data/app/views/kuppayam/documents/update.html.erb +1 -1
  17. data/app/views/kuppayam/images/create.html.erb +2 -2
  18. data/app/views/kuppayam/images/crop.html.erb +1 -1
  19. data/app/views/kuppayam/images/edit.js.erb +3 -3
  20. data/app/views/kuppayam/images/new.js.erb +1 -1
  21. data/app/views/kuppayam/images/update.html.erb +3 -3
  22. data/app/views/kuppayam/import_data/new.js.erb +1 -1
  23. data/app/views/kuppayam/import_data/update.html.erb +1 -1
  24. data/app/views/kuppayam/workflows/parrot/create.js.erb +6 -11
  25. data/app/views/kuppayam/workflows/parrot/edit.js.erb +1 -1
  26. data/app/views/kuppayam/workflows/parrot/new.js.erb +2 -2
  27. data/app/views/kuppayam/workflows/parrot/row.js.erb +1 -1
  28. data/app/views/kuppayam/workflows/parrot/update.js.erb +5 -10
  29. data/app/views/kuppayam/workflows/peacock/create.js.erb +6 -11
  30. data/app/views/kuppayam/workflows/peacock/edit.js.erb +2 -2
  31. data/app/views/kuppayam/workflows/peacock/new.js.erb +2 -2
  32. data/app/views/kuppayam/workflows/peacock/row.js.erb +1 -1
  33. data/app/views/kuppayam/workflows/peacock/update.js.erb +6 -11
  34. data/app/views/layouts/kuppayam/_footer.html.erb +0 -1
  35. data/app/views/layouts/kuppayam/_head.html.erb +1 -1
  36. data/app/views/layouts/kuppayam/_overlays.html.erb +47 -0
  37. data/app/views/layouts/kuppayam/_sidebar.html.erb +0 -3
  38. data/app/views/layouts/kuppayam/admin.html.erb +6 -63
  39. data/app/views/layouts/kuppayam/blank.html.erb +5 -62
  40. data/app/views/layouts/kuppayam/document_upload.html.erb +2 -3
  41. data/app/views/layouts/kuppayam/image_upload.html.erb +2 -3
  42. data/config/initializers/kuppayam_validators.rb +76 -0
  43. data/config/locales/kuppayam/general.yml +0 -1
  44. data/lib/kuppayam/action_view/form_helper.rb +1 -1
  45. data/lib/kuppayam/action_view/theme_helper.rb +1 -1
  46. data/lib/kuppayam/engine.rb +0 -2
  47. data/lib/kuppayam/version.rb +1 -1
  48. metadata +6 -33
  49. data/app/views/kuppayam/filters/_display_dropdown_filters.html.erb +0 -11
  50. data/app/views/kuppayam/filters/_display_filters.html.erb +0 -29
  51. data/app/views/kuppayam/http_status/404.html.erb +0 -1
  52. data/app/views/layouts/kuppayam/_horizontal_menu.html.erb +0 -932
  53. data/app/views/layouts/kuppayam/layout_horizontal_menu.html.erb +0 -116
  54. data/app/views/layouts/kuppayam/print_a4.html.erb +0 -32
  55. data/config/initializers/importer.rb +0 -156
  56. data/config/initializers/validators.rb +0 -78
  57. data/vendor/assets/stylesheets/custom.css +0 -0
@@ -1,116 +0,0 @@
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">&times;</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">&times;</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">&times;</button>
69
- <h3 class="modal-title">Modal title</h3>
70
- </div>
71
- <div class="modal-body">
72
- <p>One fine body&hellip;</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">&times;</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>
@@ -1,32 +0,0 @@
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>
@@ -1,156 +0,0 @@
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
@@ -1,78 +0,0 @@
1
- module Kuppayam
2
- module Validators
3
-
4
- def generate_validation_options(attribute, options)
5
- {a: 1}
6
- reg_exp = /\A[a-zA-Z1-9\-\ \(\)\.+]*\z/i
7
- options.reverse_merge!(
8
- presence: true,
9
- min_length: 3,
10
- max_length: 256,
11
- format: reg_exp,
12
- uniqueness: false,
13
- mandatory: false
14
- )
15
-
16
- if options.has_key?(:condition_method) && !options[:condition_method].blank?
17
- condition_proc = proc {|obj| obj.send(options[:condition_method])}
18
- elsif options.has_key?(:mandatory) && options[:mandatory] == false
19
- condition_proc = proc {|obj| !obj.send(attribute).blank?}
20
- else
21
- condition_proc = nil
22
- end
23
-
24
- voptions = {
25
- presence: options[:presence],
26
- length: { minimum: options[:min_length], maximum: options[:max_length]},
27
- format: {:with => options[:format]}
28
- }
29
- voptions.merge!(uniqueness: options[:uniqueness]) if options[:uniqueness]
30
- voptions.merge!(if: condition_proc) if condition_proc
31
-
32
- voptions
33
- end
34
-
35
- def validate_string(attribute, **options)
36
- voptions = generate_validation_options(attribute, options)
37
- validates attribute, **voptions
38
- end
39
-
40
- def validate_username(attribute, **options)
41
- reg_exp = /\A[a-zA-Z0-9\_\.]*\z/
42
- options.merge!(mandatory: true, min_length: 3, max_length: 128, format: reg_exp, :uniqueness => {:case_sensitive => false})
43
- voptions = generate_validation_options(attribute, options)
44
- validates attribute, **voptions
45
- end
46
-
47
- def validate_email(attribute, **options)
48
- reg_exp = /\A(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})\z/i
49
- options.merge!(mandatory: true, format: reg_exp, :uniqueness => {:case_sensitive => false})
50
- voptions = generate_validation_options(attribute, options)
51
- validates attribute, **voptions
52
- end
53
-
54
- # format can be either :us or :indian
55
- def validate_phone(attribute, **options)
56
- options.reverse_merge!(phone_format: :india)
57
- if options[:phone_format] == :us
58
- reg_exp = /\A[0-9]{3}[-][0-9]{3}[-][0-9]{4}\z/
59
- length = 12
60
- else
61
- reg_exp = /\A[0-9]{10}\z/
62
- length = 10
63
- end
64
- options.merge!(format: reg_exp, min_length: length, max_length: length)
65
- options.reverse_merge!(numericality: true, mandatory: true, uniqueness: true)
66
- voptions = generate_validation_options(attribute, options)
67
- validates attribute, **voptions
68
- end
69
-
70
- def validate_password(attribute, **options)
71
- reg_exp = /\A(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9!@$#&*_\.,;:])/
72
- options.merge!(mandatory: true, format: reg_exp, min_length: 7, max_length: 256)
73
- voptions = generate_validation_options(attribute, options)
74
- validates attribute, **voptions
75
- end
76
-
77
- end
78
- end
File without changes