bootbox_crud 0.1.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf24369f6333a8c7321af19175eed6e5c36ebb75
4
- data.tar.gz: 90bbab5b20cc2322cbd1d016668c1a77a0a3c2f6
3
+ metadata.gz: ccbdc14dcd7da2f93390a0d66070dd0dab61464a
4
+ data.tar.gz: 9bd017ce47ff303ab88fc40deffb6a3011a6231f
5
5
  SHA512:
6
- metadata.gz: 8ba3a59b1d598b3b1f2559ce9f3b36c2d49f7092be574cfc1fb523b9b4d259ad37d7192117d042b6f474ed922fedc240638abca86da35493a1287d7faf5d6ca6
7
- data.tar.gz: 0cdf0ae1ec61d42566ee805c7bfb4343205471e53c5db01ada2ce00fc3147c9b0cca57dcdd80c052c864a81d2793ffaada9f3e8085d2aa5c0ee2bafe2caddc8b
6
+ metadata.gz: 7e4a066583e3a4cd8956e7afb3dc69ffe18505912f96d80b6859103ffb35183f132739a24f4fe8992f12890b2e9f58b42bc2b9d8444d211e3536e7fce0eab8b5
7
+ data.tar.gz: 14e85e099a16b8a9bd7852c4c717e4ed69dd3c7bd0afdaa1a92d3b5f9675127260bfe10e03e8ae6777db56ba4f2ad19f54b92257b86e1d1956f600c0fd93d04d
data/README.md CHANGED
@@ -5,6 +5,14 @@
5
5
 
6
6
  Provides Rails modal CRUD scaffolding powered by bootstrap & bootbox & simple_form. Built for use with Turbolinks, jQuery and Twitter Bootstrap 3.
7
7
 
8
+ ![Screenshots](/screenshots/bbcrud.gif?raw=true "Scaffold example screenshots")
9
+
10
+ This is what you get after running ```rails g model Block name width:integer height:integer depth:integer``` with this gem setup in your rails application.
11
+
12
+ All modal views are using AJAX and template partials, which makes it behave faster compared to full page reloads.
13
+
14
+ Makes it easy to open up a modal for selected action and model on click by [setting](#user-content-links-to-modals) data attributes to HTML tags, no additional javascript needed.
15
+
8
16
  ## Initial setup
9
17
 
10
18
  Set custom scaffolding generators in your ```config/application.rb```
@@ -193,24 +201,24 @@ Adding ```class='show'``` to root node with ```id='content'``` is mandatory to g
193
201
  Making links modal enabled is done via data attributes.
194
202
 
195
203
  data-entity='Model'
196
- data-action='update'
204
+ data-action='edit'
197
205
  data-id='1'
198
206
 
199
207
  In haml:
200
208
 
201
- = link_to '#', :class => 'btn btn-primary btn-sm', data: { id: @model.id, entity: 'Model', action: 'update' } do
209
+ = link_to '#', :class => 'btn btn-primary btn-sm', data: { id: @model.id, entity: 'Model', action: 'edit' } do
202
210
  %i.fa.fa-edit
203
211
  edit
204
212
 
205
213
  There is a global button handler searching for any DOM nodes with 'data-entity' attribute. Click events of such nodes lead to modals.
206
214
  The logic is simple, clicking on a node with the above values will lead to this function invocation:
207
215
 
208
- BBCrud.Model.update({id: 1})
216
+ BBCrud.Model.edit({id: 1})
209
217
 
210
218
  Available actions are:
211
219
 
212
- * create
213
- * update
220
+ * new
221
+ * edit
214
222
  * show
215
223
 
216
224
  #### Adding a new model to modals on the client side
@@ -229,9 +237,9 @@ Filled in for unipolars:
229
237
 
230
238
  The above function invocation creates these functions:
231
239
 
232
- BBCrud.Unipolar.create
233
- BBCrud.Unipolar.update
234
- BBCrud.Unipolar.show
240
+ BBCrud.Models.Unipolar.new
241
+ BBCrud.Models.Unipolar.edit
242
+ BBCrud.Models.Unipolar.show
235
243
 
236
244
  Now you should be all set to click your data-entity links and call the functions from your scripts if needed.
237
245
 
@@ -266,7 +274,7 @@ The important detail to notice is the use of ```modals/form``` partial, which wa
266
274
  * Make sure your form has ```remote: true``` or preferably ```remote_form_options``` with simple\_form, the layout should be the same as in the example in form section of this README
267
275
  * Add create, update and destroy .js.erb files to the view directory and fill them according to this guide
268
276
  * Add your model definition as a new line to models.js
269
- * Add ```data-entity```, ```data-action``` and ```data-id``` with the right values to an element on the page and click it, or call ``BBCrud.ModelName.create/update/show()`` from your javascript to show the modal
277
+ * Add ```data-entity```, ```data-action``` and ```data-id``` with the right values to an element on the page and click it, or call ``BBCrud.Models.ModelName.new/edit/show()`` from your javascript to show the modal
270
278
 
271
279
 
272
280
  ## Custom scaffold source files
@@ -297,6 +305,13 @@ If you want have a peek or override some of the scaffolding templates, here is a
297
305
 
298
306
  lib/templates/rails/scaffold_controller/controller.rb
299
307
 
308
+ # Changelog
309
+ **0.2.0** - some breaking changes
310
+
311
+ * defined model actions moved to BBCrud.Models.<ModelName>, declaring them directly on BBCrud.<ModelName> was dangerous, new models could overwrite basic functionality [Models, Modals, Alert]
312
+ * renamed actions on models to new, edit, show [previously was create, update, show]
313
+ * added a few more jasmine specs
314
+
300
315
  # TODOs
301
316
 
302
317
  * I18n support on client side
@@ -1,5 +1,5 @@
1
1
  module BootboxCrud
2
2
  module Rails
3
- VERSION = '0.1.1.7'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -40,12 +40,12 @@
40
40
  %td= <%= singular_table_name %>.<%= attribute.name %>
41
41
  <% end -%>
42
42
  %td
43
- = link_to '#', :class => 'btn-sm btn-primary', data: { entity: '<%= class_name %>', action: 'update', id: (<%= singular_table_name %>.id) } do
43
+ = link_to '#', :class => 'btn-sm btn-primary', data: { entity: '<%= class_name %>', action: 'edit', id: (<%= singular_table_name %>.id) } do
44
44
  %i.fa.fa-edit
45
45
  EDIT
46
46
 
47
47
  %hr
48
48
  %p
49
- = link_to '#', :class => 'btn btn-success', data: { entity: '<%= class_name %>', action: 'create' } do
49
+ = link_to '#', :class => 'btn btn-success', data: { entity: '<%= class_name %>', action: 'new' } do
50
50
  %i.fa.fa-plus
51
51
  = 'New <%= human_name %>'
Binary file
@@ -27,12 +27,12 @@
27
27
  %td= block.height
28
28
  %td= block.depth
29
29
  %td
30
- = link_to '#', :class => 'btn-sm btn-primary', data: { entity: 'Block', action: 'update', id: (block.id) } do
30
+ = link_to '#', :class => 'btn-sm btn-primary', data: { entity: 'Block', action: 'edit', id: (block.id) } do
31
31
  %i.fa.fa-edit
32
32
  EDIT
33
33
 
34
34
  %hr
35
35
  %p
36
- = link_to '#', :class => 'btn btn-success', data: { entity: 'Block', action: 'create' } do
36
+ = link_to '#', :class => 'btn btn-success', data: { entity: 'Block', action: 'new' } do
37
37
  %i.fa.fa-plus
38
38
  = 'New Block'
@@ -1,5 +1,8 @@
1
1
  describe("BBCrud.Alert", () => {
2
2
  it("BBCrud.Alert is defined", () => {
3
3
  expect(BBCrud.Alert).toBeDefined();
4
+ expect(BBCrud.Alert.init).toBeDefined();
5
+ expect(BBCrud.Alert.show).toBeDefined();
6
+ expect(BBCrud.Alert.hide).toBeDefined();
4
7
  });
5
8
  });
@@ -1,5 +1,12 @@
1
1
  describe("BBCrud.Modals", () => {
2
2
  it("BBCrud.Modals is defined", () => {
3
3
  expect(BBCrud.Modals).toBeDefined();
4
+ expect(BBCrud.Modals.create).toBeDefined();
5
+ expect(BBCrud.Modals.update).toBeDefined();
6
+ expect(BBCrud.Modals.show).toBeDefined();
7
+ expect(BBCrud.Modals.delete).toBeDefined();
8
+ expect(BBCrud.Modals.form).toBeDefined();
9
+ expect(BBCrud.Modals.other).toBeDefined();
10
+ expect(BBCrud.Modals.initBtnHandler).toBeDefined();
4
11
  });
5
12
  });
@@ -1,5 +1,25 @@
1
1
  describe("BBCrud.Models", () => {
2
2
  it("BBCrud.Models is defined", () => {
3
3
  expect(BBCrud.Models).toBeDefined();
4
+ expect(BBCrud.Models.add).toBeDefined();
5
+ expect(BBCrud.Models.addAction).toBeDefined();
6
+ });
7
+ });
8
+
9
+ describe("BBCrud.Models.add", () => {
10
+ it("Creates new model object on BBCrud.Models", () => {
11
+ BBCrud.Models.add('Box', '/boxes/', 'box');
12
+ expect(BBCrud.Models.Box).toBeDefined();
13
+ expect(BBCrud.Models.Box.create).toBeDefined();
14
+ expect(BBCrud.Models.Box.update).toBeDefined();
15
+ expect(BBCrud.Models.Box.show).toBeDefined();
16
+ });
17
+ });
18
+
19
+ describe("BBCrud.Models.addAction", () => {
20
+ it("Creates a new model, if it wasn't previously defined and adds a function to it", () => {
21
+ BBCrud.Models.addAction('Sphere', '/spheres/', 'sphere', 'tessellate');
22
+ expect(BBCrud.Models.Sphere).toBeDefined();
23
+ expect(BBCrud.Models.Sphere.tessellate).toBeDefined();
4
24
  });
5
25
  });
@@ -149,7 +149,7 @@ BBCrud.Modals = (function () {
149
149
  var args = $.extend({}, link.data());
150
150
  delete args['entity'];
151
151
  delete args['action'];
152
- BBCrud[link.data('entity')][link.data('action')].call(link, args);
152
+ BBCrud.Models[link.data('entity')][link.data('action')].call(link, args);
153
153
  return false;
154
154
  });
155
155
  }
@@ -161,10 +161,10 @@ BBCrud.Modals.initBtnHandler();
161
161
 
162
162
  BBCrud.Models = (function () {
163
163
  function defineModelActions(modelName, actions) {
164
- if (typeof BBCrud[modelName] === 'undefined') {
165
- BBCrud[modelName] = actions;
164
+ if (typeof BBCrud.Models[modelName] === 'undefined') {
165
+ BBCrud.Models[modelName] = actions;
166
166
  } else {
167
- $.extend(BBCrud[modelName], actions);
167
+ $.extend(BBCrud.Models[modelName], actions);
168
168
  }
169
169
  }
170
170
 
@@ -174,10 +174,10 @@ BBCrud.Models = (function () {
174
174
  var baseUrl = url;
175
175
 
176
176
  return {
177
- create: function (data) {
177
+ new: function (data) {
178
178
  BBCrud.Modals.create('Create ' + titleName, baseUrl, null, data);
179
179
  },
180
- update: function (data) {
180
+ edit: function (data) {
181
181
  BBCrud.Modals.update(data.id, 'Edit ' + titleName, baseUrl, undefined, false, undefined, undefined, data);
182
182
  },
183
183
  show: function (data) {
@@ -200,7 +200,6 @@ BBCrud.Models = (function () {
200
200
  }());
201
201
  defineModelActions(modelName, action);
202
202
  }
203
-
204
203
  };
205
204
  }());
206
205
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootbox_crud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiri Kaipr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -256,6 +256,7 @@ files:
256
256
  - lib/templates/haml/scaffold/new.html.haml
257
257
  - lib/templates/haml/scaffold/show.html.haml
258
258
  - lib/templates/rails/scaffold_controller/controller.rb
259
+ - screenshots/bbcrud.gif
259
260
  - test/dummy/README.rdoc
260
261
  - test/dummy/Rakefile
261
262
  - test/dummy/app/assets/images/.keep