mega_bar 0.0.1

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.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +31 -0
  4. data/Rakefile +23 -0
  5. data/app/assets/javascripts/mega_bar/application.js +13 -0
  6. data/app/assets/stylesheets/mega_bar/application.css +15 -0
  7. data/app/controllers/mega_bar/application_controller.rb +28 -0
  8. data/app/controllers/mega_bar/checkboxes_controller.rb +19 -0
  9. data/app/controllers/mega_bar/field_displays_controller.rb +11 -0
  10. data/app/controllers/mega_bar/fields_controller.rb +11 -0
  11. data/app/controllers/mega_bar/grid_html.rb +27 -0
  12. data/app/controllers/mega_bar/mega_bar_concern.rb +169 -0
  13. data/app/controllers/mega_bar/model_displays_controller.rb +11 -0
  14. data/app/controllers/mega_bar/models_controller.rb +14 -0
  15. data/app/controllers/mega_bar/profile_table.rb +27 -0
  16. data/app/controllers/mega_bar/radio_buttons_controller.rb +18 -0
  17. data/app/controllers/mega_bar/records_formats_controller.rb +10 -0
  18. data/app/controllers/mega_bar/selects_controller.rb +12 -0
  19. data/app/controllers/mega_bar/testers_controller.rb +11 -0
  20. data/app/controllers/mega_bar/tests_controller.rb +5 -0
  21. data/app/controllers/mega_bar/textboxes_controller.rb +11 -0
  22. data/app/controllers/mega_bar/textreads_controller.rb +10 -0
  23. data/app/controllers/mega_bar/tmp_field_displays_controller.rb +18 -0
  24. data/app/controllers/mega_bar/tmp_fields_controller.rb +18 -0
  25. data/app/controllers/mega_bar/tmp_model_displays_controller.rb +18 -0
  26. data/app/controllers/mega_bar/tmp_models_controller.rb +16 -0
  27. data/app/controllers/mega_bar/tmp_records_formats_controller.rb +18 -0
  28. data/app/controllers/mega_bar/tmp_selects_controller.rb +18 -0
  29. data/app/controllers/mega_bar/tmp_textboxes_controller.rb +18 -0
  30. data/app/controllers/mega_bar/tmp_textreads_controller.rb +18 -0
  31. data/app/helpers/mega_bar/application_helper.rb +41 -0
  32. data/app/helpers/mega_bar/fields_helper.rb +13 -0
  33. data/app/helpers/mega_bar/models_helper.rb +13 -0
  34. data/app/models/mega_bar/checkbox.rb +8 -0
  35. data/app/models/mega_bar/field.rb +31 -0
  36. data/app/models/mega_bar/field_display.rb +25 -0
  37. data/app/models/mega_bar/mega_bar_model_concern.rb +20 -0
  38. data/app/models/mega_bar/model.rb +35 -0
  39. data/app/models/mega_bar/model_display.rb +10 -0
  40. data/app/models/mega_bar/radio_button.rb +6 -0
  41. data/app/models/mega_bar/records_format.rb +5 -0
  42. data/app/models/mega_bar/select.rb +9 -0
  43. data/app/models/mega_bar/test.rb +2 -0
  44. data/app/models/mega_bar/tester.rb +5 -0
  45. data/app/models/mega_bar/textarea.rb +9 -0
  46. data/app/models/mega_bar/textbox.rb +8 -0
  47. data/app/models/mega_bar/textread.rb +9 -0
  48. data/app/models/mega_bar/tmp_field.rb +6 -0
  49. data/app/models/mega_bar/tmp_field_display.rb +6 -0
  50. data/app/models/mega_bar/tmp_model.rb +6 -0
  51. data/app/models/mega_bar/tmp_model_display.rb +6 -0
  52. data/app/models/mega_bar/tmp_records_format.rb +6 -0
  53. data/app/models/mega_bar/tmp_select.rb +6 -0
  54. data/app/models/mega_bar/tmp_textbox.rb +6 -0
  55. data/app/models/mega_bar/tmp_textread.rb +6 -0
  56. data/app/views/mega_bar/application/_hello.html.erb +1 -0
  57. data/app/views/mega_bar/application/_mega_bar_read.html.erb +38 -0
  58. data/app/views/mega_bar/application/_mega_bar_write.html.erb +27 -0
  59. data/app/views/mega_bar/application/mega_bar.html.erb +62 -0
  60. data/app/views/textboxes/_form.html.erb +0 -0
  61. data/app/views/textboxes/edit.html.erb +0 -0
  62. data/app/views/textboxes/index.html.erb +0 -0
  63. data/app/views/textboxes/index.json.jbuilder +4 -0
  64. data/app/views/textboxes/new.html.erb +0 -0
  65. data/app/views/textboxes/show.html.erb +5 -0
  66. data/app/views/textboxes/show.json.jbuilder +1 -0
  67. data/app/views/textreads/_form.html.erb +0 -0
  68. data/app/views/textreads/edit.html.erb +0 -0
  69. data/app/views/textreads/index.html.erb +0 -0
  70. data/app/views/textreads/index.json.jbuilder +4 -0
  71. data/app/views/textreads/new.html.erb +0 -0
  72. data/app/views/textreads/show.html.erb +1 -0
  73. data/app/views/textreads/show.html.erb.orig.rhtml +0 -0
  74. data/app/views/textreads/show.json.jbuilder +1 -0
  75. data/config/routes.rb +30 -0
  76. data/db/mega_bar.seeds.rb +814 -0
  77. data/db/migrate/20140505150251_create_models.rb +12 -0
  78. data/db/migrate/20140505174947_create_model_displays.rb +11 -0
  79. data/db/migrate/20140505195607_create_records_formats.rb +11 -0
  80. data/db/migrate/20140505211530_create_textreads.rb +12 -0
  81. data/db/migrate/20140505214403_create_textboxes.rb +10 -0
  82. data/db/migrate/20140521220256_create_fields.rb +12 -0
  83. data/db/migrate/20140521222528_create_field_displays.rb +12 -0
  84. data/db/migrate/20140523160810_create_selects.rb +16 -0
  85. data/db/migrate/20140523200921_create_testers.rb +11 -0
  86. data/db/migrate/20140618170624_create_tests.rb +9 -0
  87. data/db/migrate/20141227235653_create_tmp_models.rb +11 -0
  88. data/db/migrate/20141228061208_create_mega_bar_tmp_fields.rb +12 -0
  89. data/db/migrate/20141228163900_create_mega_bar_tmp_model_displays.rb +11 -0
  90. data/db/migrate/20141228163956_create_mega_bar_tmp_field_displays.rb +11 -0
  91. data/db/migrate/20141228164052_create_mega_bar_tmp_records_formats.rb +10 -0
  92. data/db/migrate/20141228164245_create_mega_bar_tmp_textboxes.rb +10 -0
  93. data/db/migrate/20141228164314_create_mega_bar_tmp_textreads.rb +12 -0
  94. data/db/migrate/20141228164350_create_mega_bar_tmp_selects.rb +16 -0
  95. data/db/migrate/20141229173832_create_mega_bar_checkboxes.mega_bar.rb +8 -0
  96. data/db/migrate/20141229180849_create_mega_bar_radio_buttons.mega_bar.rb +8 -0
  97. data/db/migrate/20141230171751_create_mega_bar_textareas.mega_bar.rb +8 -0
  98. data/db/migrate/20141230173142_create_mega_bar_checkboxes.mega_bar.rb +9 -0
  99. data/lib/generators/mega_bar/mega_bar/USAGE +8 -0
  100. data/lib/generators/mega_bar/mega_bar/mega_bar_generator.rb +91 -0
  101. data/lib/generators/mega_bar/mega_bar/templates/generic_controller.rb +18 -0
  102. data/lib/generators/mega_bar/mega_bar/templates/generic_model.rb +6 -0
  103. data/lib/generators/mega_bar/mega_bar_fields/USAGE +8 -0
  104. data/lib/generators/mega_bar/mega_bar_fields/mega_bar_fields_generator.rb +13 -0
  105. data/lib/generators/mega_bar/mega_bar_fields/templates/generic_controller.rb +15 -0
  106. data/lib/generators/mega_bar/mega_bar_fields/templates/generic_model.rb +6 -0
  107. data/lib/mega_bar/engine.rb +15 -0
  108. data/lib/mega_bar/generators/mega_bar_generator.rb +6 -0
  109. data/lib/mega_bar/version.rb +3 -0
  110. data/lib/mega_bar.rb +4 -0
  111. data/lib/tasks/mega_bar_tasks.rake +270 -0
  112. metadata +393 -0
@@ -0,0 +1,18 @@
1
+
2
+ module MegaBar
3
+ class TmpTextreadsController < ApplicationController
4
+ include MegaBarConcern
5
+ before_action ->{ myinit 16 }, only: [:index, :show, :edit, :new]
6
+
7
+
8
+ private
9
+ def _params
10
+ permits = []
11
+ controller_name.classify.constantize.attribute_names.each do |att|
12
+ permits << att unless ['id', 'created_at', 'updated_at'].include?(att)
13
+ end
14
+ params.require(controller_name.singularize).permit(permits)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ module MegaBar
2
+ module ApplicationHelper
3
+ def sortable(column, title=nil)
4
+ title ||= column.titleize
5
+ css_class = column == sort_column ? "current #{sort_direction}" : nil
6
+ direction = column == sort_column && sort_direction == 'asc' ? 'desc' : 'asc'
7
+ link_to title, {:sort => column, :direction => direction}, class: css_class
8
+ end
9
+
10
+ def link_path(action = nil, id = nil)
11
+ # application helper
12
+ action ||= params[:action]
13
+ case action
14
+ when 'index' #untested
15
+ url_for(controller: params[:controller].to_s,
16
+ action: params[:action],
17
+ only_path: true)
18
+ when 'new'
19
+ url_for(controller: params[:controller].to_s,
20
+ action: 'new',
21
+ only_path: true)
22
+ when 'edit' #untested
23
+ url_for(controller: params[:controller].to_s,
24
+ action: 'edit',
25
+ :id=>id,#catch errors
26
+ only_path: true)
27
+ when 'show' #untested
28
+ url_for(controller: params[:controller].to_s,
29
+ :id => id,
30
+ action: 'show',
31
+ only_path: true
32
+ )
33
+ else
34
+ form_path = 'tbd'
35
+ end
36
+ end
37
+ def pre_render
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,13 @@
1
+ module MegaBar
2
+ module FieldsHelper
3
+ def pre_render
4
+ if params[:action] == 'edit'
5
+ # these are for some virtual attributes.
6
+ @index_field_display = FieldDisplay.by_fields(@model.id).by_action('index').present? ? 'y':''
7
+ @show_field_display = FieldDisplay.by_fields(@model.id).by_action('show').present? ? 'y':''
8
+ @new_field_display = FieldDisplay.by_fields(@model.id).by_action('new').present? ? 'y':''
9
+ @edit_field_display = FieldDisplay.by_fields(@model.id).by_action('edit').present? ? 'y':''
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module MegaBar
2
+ module ModelsHelper
3
+ def pre_render
4
+ if params[:action] == 'edit'
5
+ # these are for viratual attributes
6
+ @index_model_display = ModelDisplay.by_model(@model.id).by_action('index').present? ? 'y':''
7
+ @show_model_display = ModelDisplay.by_model(@model.id).by_action('show').present? ? 'y':''
8
+ @new_model_display = ModelDisplay.by_model(@model.id).by_action('new').present? ? 'y':''
9
+ @edit_model_display = ModelDisplay.by_model(@model.id).by_action('edit').present? ? 'y':''
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ module MegaBar
2
+ class Checkbox < ActiveRecord::Base
3
+ scope :by_field_display_id, ->(field_display_id) { where(field_display_id: field_display_id)}
4
+ def get_model_id
5
+ 9
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,31 @@
1
+ module MegaBar
2
+ class Field < ActiveRecord::Base
3
+ belongs_to :model
4
+ has_many :field_display
5
+ after_create :make_field_displays #, :only => [:create] #add update.
6
+ after_create :make_migration #, :only => [:create] #add update.
7
+ after_save :make_field_displays
8
+ attr_accessor :new_field_display, :edit_field_display, :index_field_display, :show_field_display
9
+
10
+ #after_create :make_migration
11
+ scope :by_model, ->(model_id) { where(model_id: model_id) if model_id.present? }
12
+ def make_field_displays
13
+ return if ENV['mega_bar_data_loading'] == 'yes'
14
+ actions = []
15
+ actions << {:format=>'textread', :action=>'index', :field_id=>self.id, :header=>self.field.pluralize} if (!FieldDisplay.by_fields(self.id).by_action('index').present? && @index_field_display == 'y')
16
+ actions << {:format=>'textread', :action=>'show', :field_id=>self.id, :header=>self.field} if (!FieldDisplay.by_fields(self.id).by_action('show').present? && @show_field_display == 'y')
17
+ actions << {:format=>'textbox', :action=>'new', :field_id=>self.id, :header=>self.field} if (!FieldDisplay.by_fields(self.id).by_action('new').present? && @new_field_display == 'y')
18
+ actions << {:format=>'textbox', :action=>'edit', :field_id=>self.id, :header=>self.field} if (!FieldDisplay.by_fields(self.id).by_action('edit').present? && @edit_field_display == 'y')
19
+ actions.each do | action |
20
+ FieldDisplay.create(:field_id=>self.id, :format=>action[:format], :action=>action[:action], :header=>action[:header])
21
+ end
22
+ end
23
+ def make_migration
24
+ return if ENV['mega_bar_data_loading'] == 'yes'
25
+ return if Model.connection.column_exists?(self.tablename, self.field)
26
+ system 'rails g mega_bar:mega_bar_fields ' + self.tablename + ' ' + self.field + ' ' + 'string'
27
+ ActiveRecord::Migrator.migrate "db/migrate"
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,25 @@
1
+ module MegaBar
2
+ class FieldDisplay < ActiveRecord::Base
3
+ after_save :make_data_display
4
+ belongs_to :field
5
+ scope :by_fields, ->(fields) { where(field_id: fields) }
6
+ scope :by_action, ->(action) { where(action: action) }
7
+ def make_data_display
8
+ return if ENV['mega_bar_data_loading'] == 'yes'
9
+ data_display_class = ("MegaBar::" + self.format.to_s.classify).constantize
10
+ data_display_obj = data_display_class.new
11
+ model_id = data_display_obj.get_model_id
12
+ fields = Field.by_model(model_id)
13
+ fields_defaults = {}
14
+ fields.each do |field|
15
+ unless field.default_value.nil?
16
+ fields_defaults[field.field.parameterize.underscore.to_sym] = field.default_value
17
+ end
18
+ end
19
+ fields_defaults[:field_display_id] = self.id
20
+ data_display_class.where(:field_display_id => self.id).first_or_create(fields_defaults)
21
+ f = Field.where(id: self.field_id)
22
+ #logger.info 'make_data_display: made a ' + data_display_class + ' for field_display ' + self.id + ' (action: ' + self.action + ', table: ' + f[0][:tablename] + ', field: ' + f[0][:field] + ') with values: ' + fields_defaults.inspect
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ module MegaBar
2
+ module MegaBarModelConcern
3
+ module ClassMethods
4
+ def get_path(action = nil)
5
+ binding.pry # is this needed here?
6
+ action ||= params[:action]
7
+ case action
8
+ when 'index'
9
+ url_for(controller: params[:controller].to_s, action: params[:action], only_path: true)
10
+ when 'new'
11
+ url_for(controller: params[:controller].to_s, action: 'create', only_path: true)
12
+ when 'edit'
13
+ url_for(controller: params[:controller].to_s, action: 'update', only_path: true)
14
+ else
15
+ form_path = 'ack'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,35 @@
1
+ module MegaBar
2
+ class Model < ActiveRecord::Base
3
+ self.table_name = "mega_bar_models"
4
+ include MegaBar::MegaBarModelConcern
5
+ after_create :make_model_displays
6
+ after_create :make_all_files
7
+ after_save :make_model_displays
8
+ #has_many :attributes #ack you can't do this! http://reservedwords.herokuapp.com/words/attributes
9
+ attr_accessor :model_id, :new_model_display, :edit_model_display, :index_model_display, :show_model_display
10
+ attr_writer :model_id
11
+ scope :by_model, ->(model_id) { where(id: model_id) if model_id.present? }
12
+ def make_model_displays
13
+ return if ENV['mega_bar_data_loading'] == 'yes'
14
+ actions = []
15
+ actions << {:format=>2, :action=>'new', :header=>'Create ' + self.name} if (!ModelDisplay.by_model(self.id).by_action('new').present? && @new_model_display == 'y')
16
+ actions << {:format=>2, :action=>'edit', :header=>'Edit ' + self.name} if (!ModelDisplay.by_model(self.id).by_action('edit').present? && @edit_model_display == 'y')
17
+ actions << {:format=>1, :action=>'index', :header=>self.name.pluralize} if (!ModelDisplay.by_model(self.id).by_action('index').present? && @index_model_display == 'y')
18
+ actions << {:format=>2, :action=>'show', :header=>'Show' + self.name} if (!ModelDisplay.by_model(self.id).by_action('show').present? && @show_model_display == 'y')
19
+ log_arr = []
20
+ actions.each do | action |
21
+ ModelDisplay.create(:model_id=>self.id, :format=>action[:format], :action=>action[:action], :header=>action[:header])
22
+ # log_arr << 'format: ' + action[:format] + ', action: ' + action[:action]
23
+ end
24
+ logger.info 'Made model displays for:' + log_arr.join(', ')
25
+ end
26
+ def make_all_files
27
+ return if ENV['mega_bar_data_loading'] == 'yes'
28
+ # generate 'active_record:model', [self.classname]
29
+ logger.info("creating scaffold for " + self.classname + 'via: ' + 'rails g mega_bar:mega_bar ' + self.classname + ' ' + self.id.to_s)
30
+ system 'rails g mega_bar:mega_bar ' + self.classname + ' ' + self.id.to_s
31
+ ActiveRecord::Migrator.migrate "db/migrate"
32
+ end
33
+ end
34
+ end
35
+ #<Model id: 12, classname: nil, schema: "sqlite", tablename: "testers", name: "Tester", created_at: "2014-05-23 20:32:46", updated_at: "2014-05-23 20:32:46", default_sort_field: "id">
@@ -0,0 +1,10 @@
1
+ module MegaBar
2
+ class ModelDisplay < ActiveRecord::Base
3
+ self.table_name = "mega_bar_model_displays"
4
+
5
+ belongs_to :models
6
+ scope :by_model, ->(model_id) { where(model_id: model_id) if model_id.present? }
7
+ scope :by_action, ->(action) { where(action: action) if action.present? }
8
+
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module MegaBar
3
+ class RadioButton < ActiveRecord::Base
4
+
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module MegaBar
2
+ class RecordsFormat < ActiveRecord::Base
3
+ self.table_name = 'mega_bar_records_formats'
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module MegaBar
2
+ class Select < ActiveRecord::Base
3
+ self.table_name = "mega_bar_selects"
4
+ scope :by_field_display_id, ->(field_display_id) { where(field_display_id: field_display_id)}
5
+ def get_model_id
6
+ 8
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ class Test < ActiveRecord::Base
2
+ end
@@ -0,0 +1,5 @@
1
+ class Tester < ActiveRecord::Base
2
+ def get_model_id
3
+ 12
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module MegaBar
2
+ class Textarea < ActiveRecord::Base
3
+ self.table_name = "mega_bar_textareas"
4
+ scope :by_field_display_id, ->(field_display_id) { where(field_display_id: field_display_id)}
5
+ def get_model_id
6
+ # tbd
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module MegaBar
2
+ class Textbox < ActiveRecord::Base
3
+ scope :by_field_display_id, ->(field_display_id) { where(field_display_id: field_display_id)}
4
+ def get_model_id
5
+ 6
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ module MegaBar
2
+ class Textread < ActiveRecord::Base
3
+ scope :by_field_display_id, ->(field_display_id) { where(field_display_id: field_display_id)}
4
+ def get_model_id
5
+ 7
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module MegaBar
3
+ class TmpField < ActiveRecord::Base
4
+
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module MegaBar
3
+ class TmpFieldDisplay < ActiveRecord::Base
4
+
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module MegaBar
3
+ class TmpModel < ActiveRecord::Base
4
+
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module MegaBar
3
+ class TmpModelDisplay < ActiveRecord::Base
4
+
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module MegaBar
3
+ class TmpRecordsFormat < ActiveRecord::Base
4
+
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module MegaBar
3
+ class TmpSelect < ActiveRecord::Base
4
+
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module MegaBar
3
+ class TmpTextbox < ActiveRecord::Base
4
+
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module MegaBar
3
+ class TmpTextread < ActiveRecord::Base
4
+
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ hi there, I'm hello
@@ -0,0 +1,38 @@
1
+
2
+ <%= form_tag @mega_bar[:form_path] do |f| %>
3
+ <%=@mega_bar[:app_format].app_wrapper.html_safe%>
4
+ <% if @mega_bar[:app_format].separate_header_row %>
5
+ <% @mega_bar[:displayable_fields].each do | displayable_field | %>
6
+ <%= @mega_bar[:app_format].field_header_wrapper.html_safe%>
7
+ <%= sortable displayable_field[:field].field %>
8
+ <%= @mega_bar[:app_format].field_header_wrapper_end.html_safe%>
9
+ <% end %>
10
+ <% end %>
11
+
12
+ <% @models.each do |model| %>
13
+ <%= @mega_bar[:app_format].record_wrapper.html_safe%>
14
+ <% @mega_bar[:displayable_fields].each do | displayable_field | %>
15
+ <% if @mega_bar[:app_format].app_format == 'profile_table' %>
16
+ <tr><th><%=displayable_field[:field_display].header %></th><td>
17
+ <% end %>
18
+ <%= @mega_bar[:app_format].field_wrapper.html_safe%>
19
+
20
+ <%=render template: displayable_field[:field_display].format.tableize + "/show", locals: {displayable_field: displayable_field, obj: model} %>
21
+ <%= @mega_bar[:app_format].field_wrapper_end.html_safe %>
22
+ <% if @mega_bar[:app_format].app_format == 'profile_table' %>
23
+ </td>
24
+ <% end %>
25
+ <% end %>
26
+ <% if @mega_bar[:app_format].app_format == 'grid' %>
27
+ <%# abort(model.inspect) %>
28
+
29
+ <td><%= link_to 'Show', link_path('show', model.id) %></td>
30
+ <td><%= link_to 'Edit', link_path('edit', model.id) %></td>
31
+ <td><%= link_to 'Destroy', model, method: :delete, data: { confirm: 'Are you sure?' } %></td>
32
+ <% end %>
33
+ <%= @mega_bar[:app_format].record_wrapper_end.html_safe%>
34
+ <% end %>
35
+
36
+ <%=@mega_bar[:app_format].app_wrapper_end.html_safe%>
37
+ <br><%= submit_tag %>
38
+ <% end %>
@@ -0,0 +1,27 @@
1
+ <%= form_for(@model) do |f| %>
2
+ <%=@mega_bar[:app_format].app_wrapper.html_safe%>
3
+ <%=@mega_bar[:app_format].record_wrapper.html_safe%>
4
+ <% @mega_bar[:displayable_fields].each do | displayable_field | %>
5
+ <% if @mega_bar[:app_format].app_format == 'profile_table' %>
6
+ <tr><th><%=displayable_field[:field_display].header %></th>
7
+ <% end %>
8
+ <%= @mega_bar[:app_format].field_wrapper.html_safe%>
9
+ <%
10
+ instance_value = instance_variable_get("@" + displayable_field[:field].field)
11
+ if instance_value.present? && (displayable_field[:field].field != 'field' and params[:action] == 'edit')
12
+ value = instance_value
13
+ else
14
+ if params[:action] == 'edit'
15
+ value= @model.read_attribute(displayable_field[:field].field)
16
+ else
17
+ value = displayable_field[:field].default_value
18
+ end
19
+ end
20
+ %>
21
+ <%=render template: displayable_field[:field_display].format.tableize + "/show", locals: {displayable_field: displayable_field, obj: @model, mega_bar: @mega_bar, value: value} %>
22
+ <%= @mega_bar[:app_format].field_wrapper_end.html_safe %>
23
+ <%end %>
24
+ <%= @mega_bar[:app_format].record_wrapper_end.html_safe%>
25
+ <tr><th>Save</th><td><%= submit_tag %></td><th></tr>
26
+ <%=@mega_bar[:app_format].app_wrapper_end.html_safe%>
27
+ <% end %>
@@ -0,0 +1,62 @@
1
+ <% pre_render %>
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title>MEGA BAR yo</title>
6
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
7
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <body>
11
+ <%= link_to 'Models', mega_bar.models_path %> | <%= link_to 'Fields', mega_bar.fields_path %> | <%= link_to 'Model Displays', mega_bar.model_displays_path %> | <%= link_to 'Field Displays', mega_bar.field_displays_path %> | <%= link_to 'Record Formats', mega_bar.records_formats_path %> |<%= link_to 'Textboxes', mega_bar.textboxes_path %> | <%= link_to 'Text Reads', mega_bar.textreads_path %> | <%= link_to 'Selects', mega_bar.selects_path %> | <%= link_to 'Testers', mega_bar.testers_path %>
12
+
13
+ <% if flash[:notice] %>
14
+ <div id="notice"><%= flash[:notice] %></div>
15
+ <% end %>
16
+ <h1><%= @mega_bar[:model_display].header %></h1>
17
+
18
+
19
+ <%= render partial: "hello" %>
20
+
21
+
22
+ <%if ['index', 'show'].include? params[:action]%>
23
+ <%= render partial: "mega_bar_read" %>
24
+ <%else %>
25
+ <%= render partial: "mega_bar_write" %>
26
+ <% end%>
27
+
28
+
29
+
30
+ <%= link_to 'New', link_path('new') %>
31
+
32
+
33
+
34
+ <pre>
35
+
36
+ DEBUG INFO:
37
+
38
+ </pre>
39
+ <hr>record_format.name:
40
+ <%= @mega_bar[:record_format].name %>
41
+ <BR> fields:
42
+ <% @mega_bar[:fields].each do |field| %>
43
+ <br><%= field.field %>
44
+ <% end %>
45
+
46
+ <hR> field id:
47
+ <% @mega_bar[:field_ids].each do |field| %>
48
+ <br><%= field %>
49
+ <% end %>
50
+ <hR> field disp:
51
+ <% @mega_bar[:field_displays].each do |field| %>
52
+ <br><%= field.header %>
53
+ <% end %>
54
+
55
+
56
+ <hR> format:
57
+
58
+
59
+ </body>
60
+ </html>
61
+
62
+
File without changes
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ json.array!(@textboxes) do |textbox|
2
+ json.extract! textbox, :id, :fieldDisplayId, :size
3
+ json.url textbox_url(textbox, format: :json)
4
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ <br><%=text_field_tag(
2
+ displayable_field[:field].tablename.singularize + "[" + displayable_field[:field].field + "]",
3
+ value,
4
+ size: displayable_field[:display_format].size
5
+ )%>
@@ -0,0 +1 @@
1
+ json.extract! @textbox, :id, :fieldDisplayId, :size, :created_at, :updated_at
File without changes
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ json.array!(@textreads) do |textread|
2
+ json.extract! textread, :id, :fieldDisplayId, :truncation, :truncation_format, :transformation
3
+ json.url textread_url(textread, format: :json)
4
+ end
File without changes
@@ -0,0 +1 @@
1
+ <%= obj.read_attribute(displayable_field[:field].field) %>
File without changes
@@ -0,0 +1 @@
1
+ json.extract! @textread, :id, :fieldDisplayId, :truncation, :truncation_format, :transformation, :created_at, :updated_at
data/config/routes.rb ADDED
@@ -0,0 +1,30 @@
1
+ MegaBar::Engine.routes.draw do
2
+
3
+ resources :tests
4
+
5
+ resources :testers
6
+
7
+ resources :selects
8
+
9
+ resources :field_displays
10
+
11
+ resources :fields
12
+
13
+ resources :textboxes
14
+
15
+ resources :textreads
16
+
17
+ resources :records_formats
18
+
19
+ resources :attribute_displays
20
+
21
+ resources :model_displays
22
+
23
+ resources :attributes
24
+
25
+ resources :models
26
+
27
+ resources :tmp_models
28
+
29
+ resources :tmp_fields
30
+ end