binda 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/Rakefile +2 -1
- data/app/assets/javascripts/binda/dist/binda.bundle.js +75 -75
- data/app/assets/stylesheets/binda/settings/common.scss +4 -0
- data/app/controllers/binda/application_controller.rb +1 -1
- data/app/controllers/binda/boards_controller.rb +73 -0
- data/app/controllers/binda/components_controller.rb +18 -44
- data/app/controllers/binda/field_groups_controller.rb +36 -24
- data/app/controllers/binda/field_settings_controller.rb +5 -5
- data/app/controllers/binda/manage/users_controller.rb +2 -9
- data/app/controllers/binda/structures_controller.rb +6 -13
- data/app/controllers/concerns/binda/default_helpers.rb +226 -0
- data/app/controllers/concerns/binda/fieldable_helpers.rb +44 -0
- data/app/helpers/binda/boards_helper.rb +13 -0
- data/app/helpers/binda/components_helper.rb +0 -5
- data/app/helpers/binda/field_settings_helper.rb +1 -1
- data/app/models/binda/asset.rb +0 -8
- data/app/models/binda/binda.rb +7 -0
- data/app/models/binda/binding.rb +4 -4
- data/app/models/binda/board.rb +41 -0
- data/app/models/binda/category.rb +7 -3
- data/app/models/binda/checkbox.rb +1 -3
- data/app/models/binda/choice.rb +31 -1
- data/app/models/binda/component.rb +7 -22
- data/app/models/binda/field_group.rb +13 -7
- data/app/models/binda/field_setting.rb +40 -29
- data/app/models/binda/gallery.rb +0 -7
- data/app/models/binda/radio.rb +1 -1
- data/app/models/binda/repeater.rb +13 -20
- data/app/models/binda/selection.rb +17 -0
- data/app/models/binda/string.rb +4 -0
- data/app/models/binda/structure.rb +65 -7
- data/app/models/concerns/binda/{component_model_helper.rb → fieldable_associations.rb} +102 -31
- data/app/views/binda/boards/edit.html.erb +7 -0
- data/app/views/binda/components/edit.html.erb +4 -1
- data/app/views/binda/components/index.html.erb +2 -0
- data/app/views/binda/components/new.html.erb +1 -1
- data/app/views/binda/field_groups/_form_body.html.erb +8 -8
- data/app/views/binda/field_groups/_form_item.html.erb +3 -3
- data/app/views/binda/field_groups/_form_item_choice.erb +11 -8
- data/app/views/binda/field_groups/_form_section.html.erb +5 -5
- data/app/views/binda/field_groups/_form_section_repeater.html.erb +3 -3
- data/app/views/binda/field_groups/edit.html.erb +1 -1
- data/app/views/binda/field_groups/new.html.erb +1 -1
- data/app/views/binda/{components → fieldable}/_form_body.html.erb +9 -9
- data/app/views/binda/{components → fieldable}/_form_item_asset.html.erb +0 -0
- data/app/views/binda/{components → fieldable}/_form_item_date.html.erb +0 -0
- data/app/views/binda/{components → fieldable}/_form_item_gallery.html.erb +0 -0
- data/app/views/binda/{components → fieldable}/_form_item_new_repeater.html.erb +5 -5
- data/app/views/binda/{components → fieldable}/_form_item_repeater.html.erb +8 -9
- data/app/views/binda/fieldable/_form_item_selections.html.erb +99 -0
- data/app/views/binda/fieldable/_form_item_string.html.erb +19 -0
- data/app/views/binda/{components → fieldable}/_form_item_text.html.erb +2 -11
- data/app/views/binda/fieldable/_form_section.html.erb +52 -0
- data/app/views/binda/fieldable/_form_section_repeater.html.erb +48 -0
- data/app/views/binda/fieldable/_form_sidebar.html.erb +35 -0
- data/app/views/binda/structures/_form_body.html.erb +6 -0
- data/app/views/binda/structures/_form_section.html.erb +1 -1
- data/app/views/binda/structures/edit.html.erb +3 -0
- data/app/views/binda/structures/index.html.erb +2 -0
- data/app/views/layouts/binda/_flash.html.erb +3 -3
- data/app/views/layouts/binda/_sidebar.html.erb +20 -15
- data/config/locales/en.yml +4 -0
- data/config/routes.rb +18 -21
- data/db/migrate/1_create_binda_tables.rb +12 -6
- data/lib/binda/engine.rb +5 -1
- data/lib/binda/version.rb +1 -1
- data/lib/generators/binda/install/install_generator.rb +9 -0
- data/lib/generators/binda/setup/setup_generator.rb +50 -7
- data/lib/tasks/binda.rake +78 -24
- metadata +100 -31
- data/app/controllers/binda/settings_controller.rb +0 -75
- data/app/controllers/concerns/binda/component_controller_helper.rb +0 -16
- data/app/helpers/binda/settings_helper.rb +0 -13
- data/app/models/binda/select.rb +0 -7
- data/app/models/binda/setting.rb +0 -42
- data/app/views/binda/components/_form_item_selectable.html.erb +0 -72
- data/app/views/binda/components/_form_section.html.erb +0 -42
- data/app/views/binda/components/_form_section_repeater.html.erb +0 -41
- data/app/views/binda/components/_form_sidebar.html.erb +0 -34
- data/app/views/binda/settings/_dashboard_form.html.erb +0 -51
- data/app/views/binda/settings/_form.html.erb +0 -52
- data/app/views/binda/settings/dashboard.html.erb +0 -9
- data/app/views/binda/settings/edit.html.erb +0 -8
- data/app/views/binda/settings/index.html.erb +0 -34
- data/app/views/binda/settings/new.html.erb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6690ffecf6e02f102a52ba0adb48e57914e6daa3
|
4
|
+
data.tar.gz: 3a29b2ed21beea482e4d4f069ee882595ab321b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 084e2b3bb8e2e52676cc381e8eb6daaceb15a2127da3fe78889bcf3d36054b2adfcb2948fd042afa12e6446f45a6709722b702eb97dbb5419e4ae06b937b599f
|
7
|
+
data.tar.gz: 29cd68ff87c402662711569bfdef44c4951e39f36a112f900ced53a5c325bbc8a2819818a27292a40212c4dcfe665b980f1ebaf9015d29d2b6db343ba2b2b50e
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Binda
|
2
|
-
A modular CMS for Ruby on Rails 5.
|
2
|
+
A modular CMS for Ruby on Rails 5.1.
|
3
3
|
|
4
4
|
[![Code Climate](https://codeclimate.com/github/lacolonia/binda/badges/gpa.svg)](https://codeclimate.com/github/lacolonia/binda)
|
5
5
|
[![Issue Count](https://codeclimate.com/github/lacolonia/binda/badges/issue_count.svg)](https://codeclimate.com/github/lacolonia/binda)
|
@@ -10,15 +10,17 @@ A modular CMS for Ruby on Rails 5.
|
|
10
10
|
Add this line to your application's Gemfile:
|
11
11
|
|
12
12
|
```ruby
|
13
|
-
gem 'binda', '~> 0.0.
|
13
|
+
gem 'binda', '~> 0.0.7'
|
14
14
|
```
|
15
15
|
|
16
16
|
Then execute:
|
17
|
+
|
17
18
|
```bash
|
18
19
|
$ bundle
|
19
20
|
```
|
20
21
|
|
21
22
|
To install Binda run the installer from terminal.
|
23
|
+
|
22
24
|
``` bash
|
23
25
|
$ rails g binda:install
|
24
26
|
```
|
data/Rakefile
CHANGED
@@ -32,6 +32,7 @@ require 'bundler/gem_tasks'
|
|
32
32
|
# t.libs << 'test'
|
33
33
|
# t.pattern = 'test/**/*_test.rb'
|
34
34
|
# t.verbose = false
|
35
|
+
# t.warning = false
|
35
36
|
# end
|
36
37
|
# task default: :test
|
37
38
|
|
@@ -40,4 +41,4 @@ require 'bundler/gem_tasks'
|
|
40
41
|
require 'rspec/core/rake_task'
|
41
42
|
RSpec::Core::RakeTask.new('spec')
|
42
43
|
# If you want to make this the default task
|
43
|
-
task :
|
44
|
+
task default: :spec
|
@@ -63,7 +63,7 @@
|
|
63
63
|
/******/ __webpack_require__.p = "";
|
64
64
|
/******/
|
65
65
|
/******/ // Load entry module and return exports
|
66
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
66
|
+
/******/ return __webpack_require__(__webpack_require__.s = 6);
|
67
67
|
/******/ })
|
68
68
|
/************************************************************************/
|
69
69
|
/******/ ([
|
@@ -71,7 +71,67 @@
|
|
71
71
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
72
72
|
|
73
73
|
"use strict";
|
74
|
-
/* harmony
|
74
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemEditor; });
|
75
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
76
|
+
|
77
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
78
|
+
|
79
|
+
///- - - - - - - - - - - - - - - - - - - -
|
80
|
+
/// FORM ITEM
|
81
|
+
///- - - - - - - - - - - - - - - - - - - -
|
82
|
+
|
83
|
+
var FormItemEditor = function () {
|
84
|
+
function FormItemEditor() {
|
85
|
+
_classCallCheck(this, FormItemEditor);
|
86
|
+
|
87
|
+
this.target = '.form-item--editor';
|
88
|
+
}
|
89
|
+
|
90
|
+
_createClass(FormItemEditor, [{
|
91
|
+
key: 'isSet',
|
92
|
+
value: function isSet() {
|
93
|
+
if ($(this.target).length > 0) {
|
94
|
+
return true;
|
95
|
+
} else {
|
96
|
+
return false;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}, {
|
100
|
+
key: 'setEvents',
|
101
|
+
value: function setEvents() {
|
102
|
+
var _this = this;
|
103
|
+
|
104
|
+
// run resize to set initial size
|
105
|
+
this.resize();
|
106
|
+
// run resize on each of these events
|
107
|
+
$(window).resize(function () {
|
108
|
+
_this.resize();
|
109
|
+
});
|
110
|
+
}
|
111
|
+
}, {
|
112
|
+
key: 'resize',
|
113
|
+
value: function resize() {
|
114
|
+
$(this.target).each(function () {
|
115
|
+
// If the form item edito is closed don't go any further
|
116
|
+
if ($(this).height() === 0) return;
|
117
|
+
// otherwise update the max-height which is needed for the CSS transition
|
118
|
+
// NOTE you need to remove the max-height (inside 'style' attribute) to get the real height
|
119
|
+
$(this).css("max-height", $(this).removeAttr('style').height());
|
120
|
+
});
|
121
|
+
}
|
122
|
+
}]);
|
123
|
+
|
124
|
+
return FormItemEditor;
|
125
|
+
}();
|
126
|
+
|
127
|
+
var _FormItemEditor = new FormItemEditor();
|
128
|
+
|
129
|
+
/***/ }),
|
130
|
+
/* 1 */
|
131
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
132
|
+
|
133
|
+
"use strict";
|
134
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(0);
|
75
135
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItem; });
|
76
136
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
77
137
|
|
@@ -148,7 +208,7 @@ function addNewItem(event) {
|
|
148
208
|
}
|
149
209
|
|
150
210
|
/***/ }),
|
151
|
-
/*
|
211
|
+
/* 2 */
|
152
212
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
153
213
|
|
154
214
|
"use strict";
|
@@ -191,11 +251,11 @@ var FormItemAsset = function () {
|
|
191
251
|
var _FormItemAsset = new FormItemAsset();
|
192
252
|
|
193
253
|
/***/ }),
|
194
|
-
/*
|
254
|
+
/* 3 */
|
195
255
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
196
256
|
|
197
257
|
"use strict";
|
198
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(
|
258
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(0);
|
199
259
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemChoice; });
|
200
260
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
201
261
|
|
@@ -266,11 +326,11 @@ var FormItemChoice = function () {
|
|
266
326
|
var _FormItemChoice = new FormItemChoice();
|
267
327
|
|
268
328
|
/***/ }),
|
269
|
-
/*
|
329
|
+
/* 4 */
|
270
330
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
271
331
|
|
272
332
|
"use strict";
|
273
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(
|
333
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(0);
|
274
334
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemRepeater; });
|
275
335
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
276
336
|
|
@@ -355,7 +415,7 @@ function addNewItem(event) {
|
|
355
415
|
}
|
356
416
|
|
357
417
|
/***/ }),
|
358
|
-
/*
|
418
|
+
/* 5 */
|
359
419
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
360
420
|
|
361
421
|
"use strict";
|
@@ -398,17 +458,17 @@ function addNewItem(event) {
|
|
398
458
|
};
|
399
459
|
|
400
460
|
/***/ }),
|
401
|
-
/*
|
461
|
+
/* 6 */
|
402
462
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
403
463
|
|
404
464
|
"use strict";
|
405
465
|
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
406
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_form_item__ = __webpack_require__(
|
407
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__ = __webpack_require__(
|
408
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__components_form_item_asset__ = __webpack_require__(
|
409
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__components_form_item_choice__ = __webpack_require__(
|
410
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__ = __webpack_require__(
|
411
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__components_sortable__ = __webpack_require__(
|
466
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_form_item__ = __webpack_require__(1);
|
467
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__ = __webpack_require__(4);
|
468
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__components_form_item_asset__ = __webpack_require__(2);
|
469
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__components_form_item_choice__ = __webpack_require__(3);
|
470
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__ = __webpack_require__(0);
|
471
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__components_sortable__ = __webpack_require__(5);
|
412
472
|
///- - - - - - - - - - - - - - - - - - - -
|
413
473
|
/// INDEX OF BINDA'S SCRIPTS
|
414
474
|
///- - - - - - - - - - - - - - - - - - - -
|
@@ -439,65 +499,5 @@ $(document).ready(function () {
|
|
439
499
|
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_5__components_sortable__["a" /* default */])();
|
440
500
|
});
|
441
501
|
|
442
|
-
/***/ }),
|
443
|
-
/* 6 */
|
444
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
445
|
-
|
446
|
-
"use strict";
|
447
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemEditor; });
|
448
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
449
|
-
|
450
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
451
|
-
|
452
|
-
///- - - - - - - - - - - - - - - - - - - -
|
453
|
-
/// FORM ITEM
|
454
|
-
///- - - - - - - - - - - - - - - - - - - -
|
455
|
-
|
456
|
-
var FormItemEditor = function () {
|
457
|
-
function FormItemEditor() {
|
458
|
-
_classCallCheck(this, FormItemEditor);
|
459
|
-
|
460
|
-
this.target = '.form-item--editor';
|
461
|
-
}
|
462
|
-
|
463
|
-
_createClass(FormItemEditor, [{
|
464
|
-
key: 'isSet',
|
465
|
-
value: function isSet() {
|
466
|
-
if ($(this.target).length > 0) {
|
467
|
-
return true;
|
468
|
-
} else {
|
469
|
-
return false;
|
470
|
-
}
|
471
|
-
}
|
472
|
-
}, {
|
473
|
-
key: 'setEvents',
|
474
|
-
value: function setEvents() {
|
475
|
-
var _this = this;
|
476
|
-
|
477
|
-
// run resize to set initial size
|
478
|
-
this.resize();
|
479
|
-
// run resize on each of these events
|
480
|
-
$(window).resize(function () {
|
481
|
-
_this.resize();
|
482
|
-
});
|
483
|
-
}
|
484
|
-
}, {
|
485
|
-
key: 'resize',
|
486
|
-
value: function resize() {
|
487
|
-
$(this.target).each(function () {
|
488
|
-
// If the form item edito is closed don't go any further
|
489
|
-
if ($(this).height() === 0) return;
|
490
|
-
// otherwise update the max-height which is needed for the CSS transition
|
491
|
-
// NOTE you need to remove the max-height (inside 'style' attribute) to get the real height
|
492
|
-
$(this).css("max-height", $(this).removeAttr('style').height());
|
493
|
-
});
|
494
|
-
}
|
495
|
-
}]);
|
496
|
-
|
497
|
-
return FormItemEditor;
|
498
|
-
}();
|
499
|
-
|
500
|
-
var _FormItemEditor = new FormItemEditor();
|
501
|
-
|
502
502
|
/***/ })
|
503
503
|
/******/ ]);
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require_dependency "binda/application_controller"
|
2
|
+
|
3
|
+
module Binda
|
4
|
+
class BoardsController < ApplicationController
|
5
|
+
before_action :set_board, only: [:edit, :update, :destroy, :new_repeater ]
|
6
|
+
before_action :set_structure, only: [:edit, :update, :destroy, :new_repeater ]
|
7
|
+
|
8
|
+
include FieldableHelpers
|
9
|
+
|
10
|
+
def show
|
11
|
+
redirect_to action: :edit
|
12
|
+
end
|
13
|
+
|
14
|
+
def edit
|
15
|
+
end
|
16
|
+
|
17
|
+
def update
|
18
|
+
if @board.update(board_params)
|
19
|
+
redirect_to structure_board_path( @structure.slug, @board.slug ), notice: 'Setting was successfully updated.'
|
20
|
+
else
|
21
|
+
redirect_to edit_structure_board_path( @structure.slug, @board.slug ), flash: { alert: @board.errors }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def destroy
|
26
|
+
@board.destroy
|
27
|
+
redirect_to root_url, notice: 'Setting was successfully destroyed.'
|
28
|
+
end
|
29
|
+
|
30
|
+
def new_repeater
|
31
|
+
@repeater_setting = FieldSetting.find( params[:repeater_setting_id] )
|
32
|
+
position = @instance.repeaters.find_all{|r| r.field_setting_id = @repeater_setting.id }.length + 1
|
33
|
+
@repeater = @instance.repeaters.create( field_setting: @repeater_setting, position: position )
|
34
|
+
render 'binda/fieldable/_form_item_new_repeater', layout: false
|
35
|
+
end
|
36
|
+
|
37
|
+
def sort_repeaters
|
38
|
+
params[:repeater].each_with_index do |id, i|
|
39
|
+
Repeater.find( id ).update({ position: i + 1 })
|
40
|
+
end
|
41
|
+
head :ok
|
42
|
+
end
|
43
|
+
|
44
|
+
def dashboard
|
45
|
+
@structure = Structure.friendly.find('dashboard')
|
46
|
+
@board = Board.friendly.find('dashboard')
|
47
|
+
@instance = @board
|
48
|
+
render action: :edit
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
# Use callbacks to share common setup or constraints between actions.
|
53
|
+
def set_board
|
54
|
+
id ||= params[:id]
|
55
|
+
id ||= params[:board_id]
|
56
|
+
@board = Board.friendly.find(id)
|
57
|
+
# The following variable will be used as wildcard by fieldable views
|
58
|
+
@instance = @board
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_structure
|
62
|
+
@structure = Structure.friendly.find(params[:structure_id])
|
63
|
+
end
|
64
|
+
|
65
|
+
# Only allow a trusted parameter "white list" through.
|
66
|
+
def board_params
|
67
|
+
default_params = params.require(:board).permit(
|
68
|
+
:name, :slug, :position, :structure_id,
|
69
|
+
{ structure_attributes: [ :id ] },
|
70
|
+
*fieldable_params )
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -6,8 +6,10 @@ module Binda
|
|
6
6
|
before_action :set_component, only: [:show, :edit, :update, :destroy, :new_repeater]
|
7
7
|
before_action :set_position, only: [:create]
|
8
8
|
|
9
|
+
include FieldableHelpers
|
10
|
+
|
9
11
|
def index
|
10
|
-
@components = @structure.components.order('position').all
|
12
|
+
@components = @structure.components.order('position').all.page params[:page]
|
11
13
|
end
|
12
14
|
|
13
15
|
def show
|
@@ -16,6 +18,8 @@ module Binda
|
|
16
18
|
|
17
19
|
def new
|
18
20
|
@component = @structure.components.build()
|
21
|
+
# The following variable will be used as wildcard by fieldable views
|
22
|
+
@instance = @component
|
19
23
|
end
|
20
24
|
|
21
25
|
def edit
|
@@ -33,7 +37,7 @@ module Binda
|
|
33
37
|
|
34
38
|
def update
|
35
39
|
if @component.update(component_params)
|
36
|
-
redirect_to structure_component_path( @structure.slug, @component.slug ), notice: "
|
40
|
+
redirect_to structure_component_path( @structure.slug, @component.slug ), notice: "#{ @component.name.capitalize } was successfully updated."
|
37
41
|
else
|
38
42
|
redirect_to edit_structure_component_path( @structure.slug, @component.slug ), flash: { alert: @component.errors }
|
39
43
|
end
|
@@ -41,14 +45,14 @@ module Binda
|
|
41
45
|
|
42
46
|
def destroy
|
43
47
|
@component.destroy
|
44
|
-
redirect_to structure_components_url( @structure.slug ), notice: "
|
48
|
+
redirect_to structure_components_url( @structure.slug ), notice: "#{ @component.name.capitalize } was successfully destroyed."
|
45
49
|
end
|
46
50
|
|
47
51
|
def new_repeater
|
48
52
|
@repeater_setting = FieldSetting.find( params[:repeater_setting_id] )
|
49
|
-
position = @
|
50
|
-
@repeater = @
|
51
|
-
render 'binda/
|
53
|
+
position = @instance.repeaters.find_all{|r| r.field_setting_id=@repeater_setting.id }.length + 1
|
54
|
+
@repeater = @instance.repeaters.create( field_setting: @repeater_setting, position: position )
|
55
|
+
render 'binda/fieldable/_form_item_new_repeater', layout: false
|
52
56
|
end
|
53
57
|
|
54
58
|
def sort_repeaters
|
@@ -57,6 +61,7 @@ module Binda
|
|
57
61
|
end
|
58
62
|
head :ok
|
59
63
|
end
|
64
|
+
|
60
65
|
|
61
66
|
def sort
|
62
67
|
params[:component].each_with_index do |id, i|
|
@@ -72,50 +77,19 @@ module Binda
|
|
72
77
|
end
|
73
78
|
|
74
79
|
def set_component
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
+
id ||= params[:id]
|
81
|
+
id ||= params[:component_id]
|
82
|
+
@component = Component.friendly.find(id)
|
83
|
+
# The following variable will be used as wildcard by fieldable views
|
84
|
+
@instance = @component
|
80
85
|
end
|
81
86
|
|
82
87
|
# Only allow a trusted parameter "white list" through.
|
83
88
|
def component_params
|
84
89
|
params.require(:component).permit(
|
85
90
|
:name, :slug, :position, :publish_state, :structure_id, :category_ids,
|
86
|
-
structure_attributes: [ :id ],
|
87
|
-
categories_attributes: [ :id, :category_id ],
|
88
|
-
texts_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :content ],
|
89
|
-
assets_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :image ],
|
90
|
-
dates_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :date ],
|
91
|
-
galleries_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id ],
|
92
|
-
radios_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :choice_ids ],
|
93
|
-
selects_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
94
|
-
checkboxes_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
95
|
-
repeaters_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :field_group_id,
|
96
|
-
texts_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
97
|
-
assets_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
98
|
-
dates_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
99
|
-
galleries_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id ],
|
100
|
-
repeaters_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :field_group_id ],
|
101
|
-
radios_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :choice_ids ],
|
102
|
-
selects_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
103
|
-
checkboxes_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ]
|
104
|
-
])
|
105
|
-
end
|
106
|
-
|
107
|
-
def repeater_params
|
108
|
-
params.require(:repeater).permit(
|
109
|
-
new_repeaters_attributes: [ :id, :field_setting_id, :field_group_id, :fieldable_type, :fieldable_id,
|
110
|
-
texts_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :content ],
|
111
|
-
assets_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :image ],
|
112
|
-
dates_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :date ],
|
113
|
-
galleries_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id ],
|
114
|
-
repeaters_attributes: [ :id, :field_setting_id, :field_group_id, :fieldable_type, :fieldable_id ],
|
115
|
-
radios_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, :choice_ids ],
|
116
|
-
selects_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ],
|
117
|
-
checkboxes_attributes: [ :id, :field_setting_id, :fieldable_type, :fieldable_id, choice_ids: [] ]
|
118
|
-
])
|
91
|
+
{structure_attributes: [ :id ]},
|
92
|
+
{categories_attributes: [ :id, :category_id ]}, *fieldable_params )
|
119
93
|
end
|
120
94
|
|
121
95
|
def set_position
|