bootbox_crud 0.1.1.6 → 0.1.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +21 -0
  3. data/.eslintrc +212 -0
  4. data/.gitignore +5 -0
  5. data/.rubocop.yml +1156 -0
  6. data/.travis.yml +11 -0
  7. data/Gemfile +14 -0
  8. data/README.md +4 -2
  9. data/Rakefile +33 -0
  10. data/bootbox_crud.gemspec +2 -0
  11. data/lib/bootbox_crud/action_view/helpers.rb +1 -1
  12. data/lib/bootbox_crud/engine.rb +1 -1
  13. data/lib/bootbox_crud/version.rb +1 -1
  14. data/lib/generators/bootbox_crud/install_generator.rb +5 -5
  15. data/lib/generators/bootbox_crud/templates/config/initializers/simple_form_bootstrap.rb +54 -50
  16. data/lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb +2 -2
  17. data/lib/generators/rails/haml_modal_crud/templates/create.js.erb +1 -1
  18. data/lib/generators/rails/haml_modal_crud/templates/destroy.js.erb +1 -1
  19. data/lib/generators/rails/haml_modal_crud/templates/update.js.erb +1 -1
  20. data/lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb +1 -1
  21. data/test/dummy/README.rdoc +28 -0
  22. data/test/dummy/Rakefile +6 -0
  23. data/test/dummy/app/assets/images/.keep +0 -0
  24. data/test/dummy/app/assets/javascripts/application.js +19 -0
  25. data/test/dummy/app/assets/javascripts/models.js +8 -0
  26. data/test/dummy/app/assets/stylesheets/application.css +17 -0
  27. data/test/dummy/app/assets/stylesheets/bootstrap_main.scss +2 -0
  28. data/test/dummy/app/controllers/application_controller.rb +5 -0
  29. data/test/dummy/app/controllers/blocks_controller.rb +92 -0
  30. data/test/dummy/app/controllers/concerns/.keep +0 -0
  31. data/test/dummy/app/helpers/.keep +0 -0
  32. data/test/dummy/app/mailers/.keep +0 -0
  33. data/test/dummy/app/models/.keep +0 -0
  34. data/test/dummy/app/models/block.rb +2 -0
  35. data/test/dummy/app/models/concerns/.keep +0 -0
  36. data/test/dummy/app/views/blocks/_form.html.haml +13 -0
  37. data/test/dummy/app/views/blocks/create.js.erb +2 -0
  38. data/test/dummy/app/views/blocks/destroy.js.erb +1 -0
  39. data/test/dummy/app/views/blocks/edit.html.haml +2 -0
  40. data/test/dummy/app/views/blocks/index.html.haml +38 -0
  41. data/test/dummy/app/views/blocks/new.html.haml +2 -0
  42. data/test/dummy/app/views/blocks/show.html.haml +8 -0
  43. data/test/dummy/app/views/blocks/update.js.erb +1 -0
  44. data/test/dummy/app/views/layouts/application.html.haml +11 -0
  45. data/test/dummy/bin/bundle +3 -0
  46. data/test/dummy/bin/rails +4 -0
  47. data/test/dummy/bin/rake +4 -0
  48. data/test/dummy/bin/setup +29 -0
  49. data/test/dummy/config/application.rb +34 -0
  50. data/test/dummy/config/boot.rb +5 -0
  51. data/test/dummy/config/database.yml +25 -0
  52. data/test/dummy/config/environment.rb +5 -0
  53. data/test/dummy/config/environments/development.rb +41 -0
  54. data/test/dummy/config/environments/production.rb +79 -0
  55. data/test/dummy/config/environments/test.rb +42 -0
  56. data/test/dummy/config/initializers/assets.rb +11 -0
  57. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  58. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  59. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  60. data/test/dummy/config/initializers/inflections.rb +16 -0
  61. data/test/dummy/config/initializers/mime_types.rb +4 -0
  62. data/test/dummy/config/initializers/session_store.rb +3 -0
  63. data/test/dummy/config/initializers/simple_form.rb +142 -0
  64. data/test/dummy/config/initializers/simple_form_bootstrap.rb +167 -0
  65. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/test/dummy/config/locales/en.yml +23 -0
  67. data/test/dummy/config/routes.rb +58 -0
  68. data/test/dummy/config/secrets.yml +22 -0
  69. data/test/dummy/config.ru +4 -0
  70. data/test/dummy/db/migrate/20160328122748_create_blocks.rb +12 -0
  71. data/test/dummy/lib/assets/.keep +0 -0
  72. data/test/dummy/log/.keep +0 -0
  73. data/test/dummy/public/404.html +67 -0
  74. data/test/dummy/public/422.html +67 -0
  75. data/test/dummy/public/500.html +66 -0
  76. data/test/dummy/public/favicon.ico +0 -0
  77. data/test/dummy/spec/javascripts/alert_spec.js.es6 +5 -0
  78. data/test/dummy/spec/javascripts/bb_crud_spec.js.es6 +5 -0
  79. data/test/dummy/spec/javascripts/helpers/.gitkeep +0 -0
  80. data/test/dummy/spec/javascripts/modals_spec.js.es6 +5 -0
  81. data/test/dummy/spec/javascripts/models_spec.js.es6 +5 -0
  82. data/test/dummy/spec/javascripts/support/jasmine.yml +50 -0
  83. data/test/dummy/spec/javascripts/support/jasmine_helper.rb +14 -0
  84. data/test/dummy/test/controllers/blocks_controller_test.rb +49 -0
  85. data/test/dummy/test/fixtures/blocks.yml +19 -0
  86. data/test/dummy/test/models/block_test.rb +11 -0
  87. data/test/generators/generator_test_base.rb +7 -0
  88. data/test/generators/haml_modal_crud_generator_test.rb +15 -0
  89. data/test/generators/install_generator_test.rb +14 -0
  90. data/test/generators/modal_crud_route_generator_test.rb +22 -0
  91. data/test/test_helper.rb +37 -0
  92. data/vendor/assets/javascripts/bootbox_crud_modals.js +33 -20
  93. data/vendor/assets/javascripts/sortable.js +11 -10
  94. data/vendor/assets/stylesheets/{bootbox_crud.css.scss → bootbox_crud.scss} +0 -0
  95. data/vendor/assets/stylesheets/bootbox_crud_main.scss +2 -0
  96. metadata +110 -6
  97. data/vendor/assets/stylesheets/bootbox_crud_main.css.scss +0 -2
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.1
5
+ - 2.2.4
6
+ before_install:
7
+ - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
8
+ - "export DISPLAY=:99.0"
9
+ - "export JASMINE_BROWSER=firefox"
10
+ before_script:
11
+ - "cd test/dummy && bundle exec rake db:migrate RAILS_ENV=test && cd ../.."
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 4.2.5'
6
+ gem 'sprockets', '>= 3.0'
7
+ gem 'sprockets-es6', '~> 0.9'
8
+ gem 'sqlite3', '~> 1.3'
9
+
10
+ group :development, :test do
11
+ gem 'codeclimate-test-reporter', require: nil
12
+ # gem 'jasmine', '~> 2.4'
13
+ gem 'jasmine-rails', '~> 0.12'
14
+ end
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ [![Build Status](https://travis-ci.org/Virtualmaster/bootbox_crud.png)](https://travis-ci.org/Virtualmaster/bootbox_crud)
2
+ [![Test Coverage](https://codeclimate.com/github/Virtualmaster/bootbox_crud/badges/coverage.png)](https://codeclimate.com/github/Virtualmaster/bootbox_crud/coverage)
3
+ [![Code Climate](https://codeclimate.com/github/Virtualmaster/bootbox_crud.png)](https://codeclimate.com/github/Virtualmaster/bootbox_crud)
1
4
  # Bootbox modal CRUD
2
5
 
3
6
  Provides Rails modal CRUD scaffolding powered by bootstrap & bootbox & simple_form. Built for use with Turbolinks, jQuery and Twitter Bootstrap 3.
@@ -24,7 +27,7 @@ Add bootbox alert markup into the main container of your ```app/views/layouts/ap
24
27
 
25
28
  %body
26
29
  .container
27
- = yeild
30
+ = yield
28
31
  = bb_alert
29
32
 
30
33
  Run the install generator to copy over default simple_form initializers and models.js for defining modal CRUD enabled models
@@ -298,4 +301,3 @@ If you want have a peek or override some of the scaffolding templates, here is a
298
301
 
299
302
  * I18n support on client side
300
303
  * Improve BBCrud.Alert / integration with Rails flash messages
301
- * Generator tests
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ require 'bundler'
2
+ begin
3
+ Bundler.setup
4
+ Bundler::GemHelper.install_tasks
5
+ rescue
6
+ raise 'You need to install the bundle first.'
7
+ end
8
+
9
+ require 'rake/testtask'
10
+ require 'fileutils'
11
+
12
+ desc 'Default: run generator and javascript tests'
13
+ task default: [:test, :test_javascript]
14
+
15
+ Rake::TestTask.new(:test) do |t|
16
+ t.libs << 'lib'
17
+ t.libs << 'test'
18
+ t.pattern = 'test/**/*_test.rb'
19
+ t.verbose = true
20
+ t.warning = false
21
+ end
22
+
23
+ task :test_javascript do
24
+ exec 'cd test/dummy && bundle exec rake spec:javascript'
25
+ end
26
+
27
+ task :clean_tmp do
28
+ FileUtils.rm_rf('test/tmp')
29
+ end
30
+
31
+ Rake::Task['test'].enhance do
32
+ Rake::Task['clean_tmp'].invoke
33
+ end
data/bootbox_crud.gemspec CHANGED
@@ -25,4 +25,6 @@ Gem::Specification.new do |gem|
25
25
  gem.add_dependency "jquery-turbolinks", "~> 2.1"
26
26
  gem.add_dependency "remotipart", "~> 1.2"
27
27
  gem.add_development_dependency "bundler", "~> 1.0"
28
+ gem.add_development_dependency "minitest-rails", "~> 2.2.0"
29
+ gem.add_development_dependency "mocha", "~> 1.1.0"
28
30
  end
@@ -30,7 +30,7 @@ module BootboxCrud
30
30
  end
31
31
 
32
32
  def remote_form_options
33
- { remote: true }.merge(form_options)
33
+ { remote: true, authenticity_token: true }.merge(form_options)
34
34
  end
35
35
  end
36
36
  end
@@ -9,7 +9,7 @@ module BootboxCrud
9
9
  require 'jquery-turbolinks'
10
10
  require 'remotipart'
11
11
 
12
- initializer "bootbox_crud.configure_view" do |app|
12
+ initializer 'bootbox_crud.configure_view' do
13
13
  ActiveSupport.on_load :action_view do
14
14
  include BootboxCrud::ActionView::Helpers
15
15
  end
@@ -1,5 +1,5 @@
1
1
  module BootboxCrud
2
2
  module Rails
3
- VERSION = "0.1.1.6"
3
+ VERSION = '0.1.1.7'
4
4
  end
5
5
  end
@@ -1,16 +1,16 @@
1
1
  class BootboxCrud::InstallGenerator < ::Rails::Generators::Base
2
- desc "Copies BootboxCrud default files"
2
+ desc 'Copies BootboxCrud default files'
3
3
  source_root File.expand_path('../templates', __FILE__)
4
4
 
5
5
  def copy_config
6
- template "config/initializers/simple_form.rb"
7
- template "config/initializers/simple_form_bootstrap.rb"
8
- template "app/assets/javascripts/models.js"
6
+ template 'config/initializers/simple_form.rb'
7
+ template 'config/initializers/simple_form_bootstrap.rb'
8
+ template 'app/assets/javascripts/models.js'
9
9
  end
10
10
 
11
11
  def show_readme
12
12
  if behavior == :invoke
13
- readme "README"
13
+ readme 'README'
14
14
  end
15
15
  end
16
16
  end
@@ -1,26 +1,53 @@
1
1
  # Use this setup block to configure all options available in SimpleForm.
2
+
3
+ def html5_placeholder(wrapper)
4
+ wrapper.use :html5
5
+ wrapper.use :placeholder
6
+ end
7
+
8
+ def html5_readonly_label(input)
9
+ input.use :html5
10
+ input.optional :readonly
11
+ input.use :label, class: 'col-sm-5 control-label'
12
+ end
13
+
14
+ def input(input)
15
+ input.wrapper tag: 'div', class: 'input-group col-sm-12' do |append|
16
+ append.use :input, class: 'form-control'
17
+ end
18
+ input.use :error, wrap_with: { tag: 'span', class: 'help-block' }
19
+ input.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
20
+ end
21
+
22
+ def form_optional(form)
23
+ form.optional :maxlength
24
+ form.optional :pattern
25
+ form.optional :min_max
26
+ form.optional :readonly
27
+ end
28
+
29
+ def form_input_error_hint(form)
30
+ form.use :input, class: 'form-control'
31
+ form.use :error, wrap_with: { tag: 'span', class: 'help-block' }
32
+ form.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
33
+ end
34
+
2
35
  SimpleForm.setup do |config|
3
36
  config.error_notification_class = 'alert alert-danger'
4
37
  config.button_class = 'btn btn-success'
5
38
  config.boolean_label_class = nil
6
39
 
7
40
  config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
8
- b.use :html5
9
- b.use :placeholder
10
- b.optional :maxlength
11
- b.optional :pattern
12
- b.optional :min_max
13
- b.optional :readonly
41
+ html5_placeholder b
42
+ form_optional b
43
+
14
44
  b.use :label, class: 'control-label'
15
45
 
16
- b.use :input, class: 'form-control'
17
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
18
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
46
+ form_input_error_hint b
19
47
  end
20
48
 
21
49
  config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
22
- b.use :html5
23
- b.use :placeholder
50
+ html5_placeholder b
24
51
  b.optional :maxlength
25
52
  b.optional :readonly
26
53
  b.use :label, class: 'control-label'
@@ -52,8 +79,7 @@ SimpleForm.setup do |config|
52
79
  end
53
80
 
54
81
  config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
55
- b.use :html5
56
- b.use :placeholder
82
+ html5_placeholder b
57
83
  b.optional :maxlength
58
84
  b.optional :pattern
59
85
  b.optional :min_max
@@ -68,8 +94,7 @@ SimpleForm.setup do |config|
68
94
  end
69
95
 
70
96
  config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
71
- b.use :html5
72
- b.use :placeholder
97
+ html5_placeholder b
73
98
  b.optional :maxlength
74
99
  b.optional :readonly
75
100
  b.use :label, class: 'col-sm-5 control-label'
@@ -82,10 +107,7 @@ SimpleForm.setup do |config|
82
107
  end
83
108
 
84
109
  config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
85
- b.use :html5
86
- b.optional :readonly
87
-
88
- b.use :label, class: 'col-sm-5 control-label'
110
+ html5_readonly_label b
89
111
 
90
112
  b.wrapper tag: 'div', class: 'col-sm-7' do |ba|
91
113
  ba.use :input
@@ -95,10 +117,7 @@ SimpleForm.setup do |config|
95
117
  end
96
118
 
97
119
  config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
98
- b.use :html5
99
- b.optional :readonly
100
-
101
- b.use :label, class: 'col-sm-5 control-label'
120
+ html5_readonly_label b
102
121
 
103
122
  b.wrapper tag: 'div', class: 'col-sm-7' do |ba|
104
123
  ba.use :input
@@ -108,44 +127,29 @@ SimpleForm.setup do |config|
108
127
  end
109
128
 
110
129
  config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
111
- b.use :html5
112
- b.use :placeholder
113
- b.optional :maxlength
114
- b.optional :pattern
115
- b.optional :min_max
116
- b.optional :readonly
130
+ html5_placeholder b
131
+ form_optional b
132
+
117
133
  b.use :label, class: 'sr-only'
118
134
 
119
- b.use :input, class: 'form-control'
120
- b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
121
- b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
135
+ form_input_error_hint b
122
136
  end
123
137
 
124
138
  config.wrappers :vertical_input_group, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
125
- b.use :html5
126
- b.use :placeholder
139
+ html5_placeholder b
127
140
  b.use :label, class: 'control-label'
128
141
 
129
142
  b.wrapper tag: 'div' do |ba|
130
- ba.wrapper tag: 'div', class: 'input-group col-sm-12' do |append|
131
- append.use :input, class: 'form-control'
132
- end
133
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
134
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
143
+ input ba
135
144
  end
136
145
  end
137
146
 
138
147
  config.wrappers :horizontal_input_group, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
139
- b.use :html5
140
- b.use :placeholder
148
+ html5_placeholder b
141
149
  b.use :label, class: 'col-sm-3 control-label'
142
150
 
143
151
  b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
144
- ba.wrapper tag: 'div', class: 'input-group col-sm-12' do |append|
145
- append.use :input, class: 'form-control'
146
- end
147
- ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
148
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
152
+ input ba
149
153
  end
150
154
  end
151
155
 
@@ -155,9 +159,9 @@ SimpleForm.setup do |config|
155
159
  # buttons and other elements.
156
160
  config.default_wrapper = :vertical_form
157
161
  config.wrapper_mappings = {
158
- check_boxes: :vertical_radio_and_checkboxes,
159
- radio_buttons: :vertical_radio_and_checkboxes,
160
- file: :vertical_file_input,
161
- boolean: :vertical_boolean,
162
+ check_boxes: :vertical_radio_and_checkboxes,
163
+ radio_buttons: :vertical_radio_and_checkboxes,
164
+ file: :vertical_file_input,
165
+ boolean: :vertical_boolean,
162
166
  }
163
167
  end
@@ -3,12 +3,12 @@ require 'rails/generators/resource_helpers'
3
3
 
4
4
  class Rails::HamlModalCrudGenerator < Rails::Generators::NamedBase
5
5
  include Rails::Generators::ResourceHelpers
6
- argument :attributes, type: :array, default: [], banner: "field:type field:type"
6
+ argument :attributes, type: :array, default: [], banner: 'field:type field:type'
7
7
  source_root File.expand_path('../templates', __FILE__)
8
8
 
9
9
  def copy_view_files
10
10
  available_actions.each do |view|
11
- template "#{view}.js.erb", File.join("app/views", controller_file_path, "#{view}.js.erb")
11
+ template "#{view}.js.erb", File.join('app/views', controller_file_path, "#{view}.js.erb")
12
12
  end
13
13
  run_haml
14
14
  end
@@ -1,2 +1,2 @@
1
- <%%= render partial: 'modals/create', locals: { model: @<%= singular_table_name %>, form_path: '<%= plural_table_name %>/form' } %>
1
+ <%%= render partial: 'modals/create', locals: { model: @<%= singular_table_name %>, form_path: '<%= plural_table_name %>/form', visit_path: '/<%= plural_table_name %>' } %>
2
2
 
@@ -1 +1 @@
1
- <%%= render partial: 'modals/destroy', locals: { model: @<%= singular_table_name %>, form_path: '<%= plural_table_name %>/form' } %>
1
+ <%%= render partial: 'modals/destroy', locals: { model: @<%= singular_table_name %>, form_path: '<%= plural_table_name %>/form', visit_path: '/<%= plural_table_name %>' } %>
@@ -1 +1 @@
1
- <%%= render partial: 'modals/update', locals: { model: @<%= singular_table_name %>, form_path: '<%= plural_table_name %>/form' } %>
1
+ <%%= render partial: 'modals/update', locals: { model: @<%= singular_table_name %>, form_path: '<%= plural_table_name %>/form', visit_path: '/<%= plural_table_name %>' } %>
@@ -4,7 +4,7 @@ class Rails::ModalCrudRouteGenerator < Rails::Generators::NamedBase
4
4
 
5
5
  def add_resource_route
6
6
  if Rails.application.assets.find_asset('models.js').blank?
7
- copy_file "models.js", "app/assets/javascripts/models.js"
7
+ copy_file 'models.js', 'app/assets/javascripts/models.js'
8
8
  end
9
9
  inject_into_file 'app/assets/javascripts/models.js', after: "//!!! Generator adds after this line, do not delete it !!!\n" do
10
10
  "BBCrud.Models.add('#{name}', '/#{controller_name.underscore}/', '#{name.underscore}');\n"
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,19 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery.turbolinks
15
+ //= require jquery_ujs
16
+ //= require bootbox
17
+ //= require bootbox_crud_main
18
+ //= require turbolinks
19
+ //= require_tree .
@@ -0,0 +1,8 @@
1
+ // Put custom actions below this line
2
+ // e.g. BBCrud.Models.addAction('Event', '/events/', 'event', 'close');
3
+
4
+
5
+ //!!! Generator adds after this line, do not delete it !!!
6
+ BBCrud.Models.add('Block', '/blocks/', 'block');
7
+ // e.g. BBCrud.Models.add('Customer', '/customers/', 'customer');
8
+
@@ -0,0 +1,17 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require bootstrap_main
14
+ *= require bootbox_crud_main
15
+ *= require_tree .
16
+ *= require_self
17
+ */
@@ -0,0 +1,2 @@
1
+ @import "bootstrap-sprockets";
2
+ @import "bootstrap";
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,92 @@
1
+ class BlocksController < ApplicationController
2
+ before_action :set_block, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /blocks
5
+ def index
6
+ @blocks = Block.order('lower(name)').all
7
+ respond_to do |format|
8
+ format.html
9
+ format.json { render json: @blocks }
10
+ end
11
+ end
12
+
13
+ # GET /blocks/1
14
+ def show
15
+ respond_to do |format|
16
+ format.html { render layout: false }
17
+ format.json { render json: @block }
18
+ end
19
+ end
20
+
21
+ # GET /blocks/new
22
+ def new
23
+ @block = Block.new
24
+ respond_to do |format|
25
+ format.html { render layout: false }
26
+ format.json { render json: @block }
27
+ end
28
+ end
29
+
30
+ # GET /blocks/1/edit
31
+ def edit
32
+ render layout: false
33
+ end
34
+
35
+ # POST /blocks
36
+ def create
37
+ @block = Block.new(block_params)
38
+
39
+ respond_to do |format|
40
+ if @block.save
41
+ format.html { redirect_to @block }
42
+ format.json { render json: @block, status: :created }
43
+ format.js
44
+ else
45
+ format.html { render :new }
46
+ format.json { render json: @block.errors, status: :unprocessable_entity }
47
+ format.js
48
+ end
49
+ end
50
+ end
51
+
52
+ # PATCH/PUT /blocks/1
53
+ def update
54
+ respond_to do |format|
55
+ if @block.update(block_params)
56
+ format.html { redirect_to @block }
57
+ format.json { head :no_content }
58
+ format.js
59
+ else
60
+ format.html { render :edit }
61
+ format.json { render json: @block.errors, status: :unprocessable_entity }
62
+ format.js
63
+ end
64
+ end
65
+ end
66
+
67
+ # DELETE /blocks/1
68
+ def destroy
69
+ respond_to do |format|
70
+ if @block.destroy
71
+ format.html { redirect_to blocks_url }
72
+ format.json { head :no_content }
73
+ format.js
74
+ else
75
+ format.html { redirect_to blocks_url }
76
+ format.json { render json: @block.errors, status: :forbidden }
77
+ format.js { render status: :forbidden }
78
+ end
79
+ end
80
+ end
81
+
82
+ private
83
+ # Use callbacks to share common setup or constraints between actions.
84
+ def set_block
85
+ @block = Block.find(params[:id])
86
+ end
87
+
88
+ # Only allow a trusted parameter "white list" through.
89
+ def block_params
90
+ params.require(:block).permit(:name, :width, :height, :depth)
91
+ end
92
+ end
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ class Block < ActiveRecord::Base
2
+ end
File without changes
@@ -0,0 +1,13 @@
1
+ .container-fluid
2
+ = simple_form_for(@block, remote_form_options) do |f|
3
+ = f.error_notification
4
+ = f.error :base, :error_method => :to_sentence
5
+
6
+ .form-inputs
7
+ = f.input :name
8
+ = f.input :width
9
+ = f.input :height
10
+ = f.input :depth
11
+
12
+ .form-actions.col-sm-7.col-sm-offset-5
13
+ = f.button :submit
@@ -0,0 +1,2 @@
1
+ <%= render partial: 'modals/create', locals: { model: @block, form_path: 'blocks/form', visit_path: '/blocks' } %>
2
+
@@ -0,0 +1 @@
1
+ <%= render partial: 'modals/destroy', locals: { model: @block, form_path: 'blocks/form', visit_path: '/blocks' } %>
@@ -0,0 +1,2 @@
1
+ #content
2
+ = render 'form'
@@ -0,0 +1,38 @@
1
+ .container-fluid
2
+ %h1 Listing blocks
3
+
4
+
5
+ .table_responsive
6
+ %table.table.table-hover.table-striped.sortable-theme-minimal{data: {sortable: ''}}
7
+ %thead
8
+ %tr
9
+ %th
10
+ ID
11
+ %th{data:{sorted: 'true', sorted_direction: 'ascending' }}
12
+ Name
13
+ %th Width
14
+ %th Height
15
+ %th Depth
16
+ %th{data:{sortable: 'false'}}
17
+
18
+ %tbody
19
+ - @blocks.each do |block|
20
+ %tr
21
+ %td
22
+ = block.id
23
+ %td{data:{value: block.name.gsub(' ', '').downcase, entity: 'Block', action: 'show', id: (block.id) }}
24
+ = link_to block.name, '#'
25
+
26
+ %td= block.width
27
+ %td= block.height
28
+ %td= block.depth
29
+ %td
30
+ = link_to '#', :class => 'btn-sm btn-primary', data: { entity: 'Block', action: 'update', id: (block.id) } do
31
+ %i.fa.fa-edit
32
+ EDIT
33
+
34
+ %hr
35
+ %p
36
+ = link_to '#', :class => 'btn btn-success', data: { entity: 'Block', action: 'create' } do
37
+ %i.fa.fa-plus
38
+ = 'New Block'
@@ -0,0 +1,2 @@
1
+ #content
2
+ = render 'form'
@@ -0,0 +1,8 @@
1
+ #content.show
2
+ %p#notice= notice
3
+
4
+ .form-horizontal
5
+ = show_value 'Name', @block.name
6
+ = show_value 'Width', @block.width
7
+ = show_value 'Height', @block.height
8
+ = show_value 'Depth', @block.depth
@@ -0,0 +1 @@
1
+ <%= render partial: 'modals/update', locals: { model: @block, form_path: 'blocks/form', visit_path: '/blocks' } %>
@@ -0,0 +1,11 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title Bootbox CRUD dummy app
5
+ = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
6
+ = javascript_include_tag 'application', 'data-turbolinks-track' => true
7
+ = csrf_meta_tags
8
+ %body
9
+ .container
10
+ = yield
11
+ = bb_alert