bootbox_crud 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +31 -0
  3. data/MIT.license +20 -0
  4. data/README.md +301 -0
  5. data/app/views/layouts/_bb_alert.html.haml +2 -0
  6. data/app/views/layouts/_show_link_to.html.haml +5 -0
  7. data/app/views/layouts/_show_link_to_array.html.haml +6 -0
  8. data/app/views/layouts/_show_value.html.haml +4 -0
  9. data/app/views/modals/_alert.js.erb +5 -0
  10. data/app/views/modals/_create.js.erb +1 -0
  11. data/app/views/modals/_destroy.js.erb +1 -0
  12. data/app/views/modals/_form.js.erb +16 -0
  13. data/app/views/modals/_update.js.erb +1 -0
  14. data/bootbox_crud.gemspec +28 -0
  15. data/lib/bootbox_crud.rb +7 -0
  16. data/lib/bootbox_crud/action_view/helpers.rb +37 -0
  17. data/lib/bootbox_crud/engine.rb +23 -0
  18. data/lib/bootbox_crud/version.rb +5 -0
  19. data/lib/generators/bootbox_crud/install_generator.rb +16 -0
  20. data/lib/generators/bootbox_crud/templates/README +6 -0
  21. data/lib/generators/bootbox_crud/templates/app/assets/javascripts/models.js +7 -0
  22. data/lib/generators/bootbox_crud/templates/config/initializers/simple_form.rb +142 -0
  23. data/lib/generators/bootbox_crud/templates/config/initializers/simple_form_bootstrap.rb +163 -0
  24. data/lib/generators/rails/haml_modal_crud/USAGE +15 -0
  25. data/lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb +30 -0
  26. data/lib/generators/rails/haml_modal_crud/templates/create.js.erb +2 -0
  27. data/lib/generators/rails/haml_modal_crud/templates/destroy.js.erb +1 -0
  28. data/lib/generators/rails/haml_modal_crud/templates/update.js.erb +1 -0
  29. data/lib/generators/rails/modal_crud_route/USAGE +9 -0
  30. data/lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb +21 -0
  31. data/lib/generators/rails/modal_crud_route/templates/models.js +7 -0
  32. data/lib/templates/haml/scaffold/_form.html.haml +12 -0
  33. data/lib/templates/haml/scaffold/edit.html.haml +2 -0
  34. data/lib/templates/haml/scaffold/index.html.haml +51 -0
  35. data/lib/templates/haml/scaffold/new.html.haml +2 -0
  36. data/lib/templates/haml/scaffold/show.html.haml +7 -0
  37. data/lib/templates/rails/scaffold_controller/controller.rb +102 -0
  38. data/vendor/assets/javascripts/bootbox_crud_main.js +6 -0
  39. data/vendor/assets/javascripts/bootbox_crud_modals.js +206 -0
  40. data/vendor/assets/javascripts/sortable.js +177 -0
  41. data/vendor/assets/stylesheets/bootbox_crud.css.scss +25 -0
  42. data/vendor/assets/stylesheets/bootbox_crud_main.css.scss +2 -0
  43. data/vendor/assets/stylesheets/sortable-theme-minimal.css +47 -0
  44. metadata +255 -0
@@ -0,0 +1,177 @@
1
+ (function() {
2
+ var SELECTOR, addEventListener, clickEvent, numberRegExp, sortable, touchDevice, trimRegExp;
3
+
4
+ SELECTOR = 'table[data-sortable]';
5
+
6
+ numberRegExp = /^-?[£$¤]?[\d,.]+%?$/;
7
+
8
+ trimRegExp = /^\s+|\s+$/g;
9
+
10
+ //touchDevice = 'ontouchstart' in document.documentElement;
11
+
12
+ clickEvent = 'click';//touchDevice ? 'touchstart' : 'click';
13
+
14
+ addEventListener = function(el, event, handler) {
15
+ if (el.addEventListener != null) {
16
+ return el.addEventListener(event, handler, false);
17
+ } else {
18
+ return el.attachEvent("on" + event, handler);
19
+ }
20
+ };
21
+
22
+ sortable = {
23
+ init: function(options) {
24
+ var table, tables, _i, _len, _results;
25
+ if (options == null) {
26
+ options = {};
27
+ }
28
+ if (options.selector == null) {
29
+ options.selector = SELECTOR;
30
+ }
31
+ tables = document.querySelectorAll(options.selector);
32
+ _results = [];
33
+ for (_i = 0, _len = tables.length; _i < _len; _i++) {
34
+ table = tables[_i];
35
+ _results.push(sortable.initTable(table));
36
+ }
37
+ return _results;
38
+ },
39
+ initTable: function(table) {
40
+ var i, th, ths, _i, _len, _ref;
41
+ if (((_ref = table.tHead) != null ? _ref.rows.length : void 0) !== 1) {
42
+ return;
43
+ }
44
+ if (table.getAttribute('data-sortable-initialized') === 'true') {
45
+ return;
46
+ }
47
+ table.setAttribute('data-sortable-initialized', 'true');
48
+ ths = table.querySelectorAll('th');
49
+ for (i = _i = 0, _len = ths.length; _i < _len; i = ++_i) {
50
+ th = ths[i];
51
+ if (th.getAttribute('data-sortable') !== 'false') {
52
+ sortable.setupClickableTH(table, th, i);
53
+ }
54
+ }
55
+ return table;
56
+ },
57
+ setupClickableTH: function(table, th, i) {
58
+ var type;
59
+ type = sortable.getColumnType(table, i);
60
+ return addEventListener(th, clickEvent, function(e) {
61
+ console.log(e.type);
62
+
63
+ var newSortedDirection, row, rowArray, rowArrayObject, sorted, sortedDirection, tBody, ths, _i, _j, _k, _len, _len1, _len2, _ref, _results;
64
+ sorted = this.getAttribute('data-sorted') === 'true';
65
+ sortedDirection = this.getAttribute('data-sorted-direction');
66
+ if (sorted) {
67
+ newSortedDirection = sortedDirection === 'ascending' ? 'descending' : 'ascending';
68
+ } else {
69
+ newSortedDirection = type.defaultSortDirection;
70
+ }
71
+ ths = this.parentNode.querySelectorAll('th');
72
+ for (_i = 0, _len = ths.length; _i < _len; _i++) {
73
+ th = ths[_i];
74
+ th.setAttribute('data-sorted', 'false');
75
+ th.removeAttribute('data-sorted-direction');
76
+ }
77
+ this.setAttribute('data-sorted', 'true');
78
+ this.setAttribute('data-sorted-direction', newSortedDirection);
79
+ tBody = table.tBodies[0];
80
+ rowArray = [];
81
+ _ref = tBody.rows;
82
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
83
+ row = _ref[_j];
84
+ rowArray.push([sortable.getNodeValue(row.cells[i]), row]);
85
+ }
86
+ if (sorted) {
87
+ rowArray.reverse();
88
+ } else {
89
+ rowArray.sort(type.compare);
90
+ }
91
+ _results = [];
92
+ for (_k = 0, _len2 = rowArray.length; _k < _len2; _k++) {
93
+ rowArrayObject = rowArray[_k];
94
+ _results.push(tBody.appendChild(rowArrayObject[1]));
95
+ }
96
+ return _results;
97
+ });
98
+ },
99
+ getColumnType: function(table, i) {
100
+ if (table.tBodies.length > 0) {
101
+ var row, text, _i, _len, _ref;
102
+ _ref = table.tBodies[0].rows;
103
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
104
+ row = _ref[_i];
105
+ text = sortable.getNodeValue(row.cells[i]);
106
+ if (text !== '') {
107
+ if (text.match(numberRegExp)) {
108
+ return sortable.types.numeric;
109
+ }
110
+ if (!isNaN(Date.parse(text))) {
111
+ return sortable.types.date;
112
+ }
113
+ }
114
+ }
115
+ return sortable.types.alpha;
116
+ }
117
+ return false;
118
+ },
119
+ getNodeValue: function(node) {
120
+ if (!node) {
121
+ return '';
122
+ }
123
+ if (node.getAttribute('data-value') !== null) {
124
+ return node.getAttribute('data-value');
125
+ }
126
+ if (typeof node.innerText !== 'undefined') {
127
+ return node.innerText.replace(trimRegExp, '');
128
+ }
129
+ return node.textContent.replace(trimRegExp, '');
130
+ },
131
+ types: {
132
+ numeric: {
133
+ defaultSortDirection: 'descending',
134
+ compare: function(a, b) {
135
+ var aa, bb;
136
+ aa = parseFloat(a[0].replace(/[^0-9.-]/g, ''), 10);
137
+ bb = parseFloat(b[0].replace(/[^0-9.-]/g, ''), 10);
138
+ if (isNaN(aa)) {
139
+ aa = 0;
140
+ }
141
+ if (isNaN(bb)) {
142
+ bb = 0;
143
+ }
144
+ return bb - aa;
145
+ }
146
+ },
147
+ alpha: {
148
+ defaultSortDirection: 'ascending',
149
+ compare: function(a, b) {
150
+ return a[0].localeCompare(b[0]);
151
+ }
152
+ },
153
+ date: {
154
+ defaultSortDirection: 'ascending',
155
+ compare: function(a, b) {
156
+ var aa, bb;
157
+ aa = Date.parse(a[0]);
158
+ bb = Date.parse(b[0]);
159
+ if (isNaN(aa)) {
160
+ aa = 0;
161
+ }
162
+ if (isNaN(bb)) {
163
+ bb = 0;
164
+ }
165
+ return aa - bb;
166
+ }
167
+ }
168
+ }
169
+ };
170
+
171
+ window.Sortable = sortable;
172
+
173
+ }).call(this);
174
+
175
+ $(function() {
176
+ window.Sortable.init();
177
+ });
@@ -0,0 +1,25 @@
1
+ @import 'bootstrap/mixins';
2
+
3
+ // show modal not looking like input form
4
+ #content.show {
5
+ .form-control {
6
+ border: none;
7
+ @include box-shadow(none);
8
+ }
9
+ }
10
+
11
+ // nested form inputs looking the same as root form inputs
12
+ .form-group .form-group {
13
+ margin-left: 0px;
14
+ margin-right: 0px;
15
+ }
16
+
17
+ .bb-alert {
18
+ position: fixed;
19
+ top: 65px;
20
+ right: 15px;
21
+ margin-bottom: 0;
22
+ font-size: 1.2em;
23
+ padding: 1em 1.3em;
24
+ z-index: 9999;
25
+ }
@@ -0,0 +1,2 @@
1
+ @import 'bootbox_crud';
2
+ @import 'sortable-theme-minimal';
@@ -0,0 +1,47 @@
1
+ table[data-sortable] {
2
+ border-collapse: collapse;
3
+ border-spacing: 0;
4
+ }
5
+ table[data-sortable] th {
6
+ vertical-align: bottom;
7
+ font-weight: bold;
8
+ }
9
+ table[data-sortable] th, table[data-sortable] td {
10
+ text-align: left;
11
+ padding: 10px;
12
+ }
13
+ table[data-sortable] th:not([data-sortable="false"]) {
14
+ -webkit-user-select: none;
15
+ -moz-user-select: none;
16
+ -ms-user-select: none;
17
+ -o-user-select: none;
18
+ user-select: none;
19
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
20
+ -webkit-touch-callout: none;
21
+ cursor: pointer;
22
+ }
23
+ table[data-sortable] th:after {
24
+ content: "";
25
+ visibility: hidden;
26
+ display: inline-block;
27
+ vertical-align: inherit;
28
+ height: 0;
29
+ width: 0;
30
+ border-width: 5px;
31
+ border-style: solid;
32
+ border-color: transparent;
33
+ margin-right: 1px;
34
+ margin-left: 10px;
35
+ float: right;
36
+ }
37
+ table[data-sortable] th[data-sorted="true"]:after {
38
+ visibility: visible;
39
+ }
40
+ table[data-sortable] th[data-sorted-direction="descending"]:after {
41
+ border-top-color: inherit;
42
+ margin-top: 8px;
43
+ }
44
+ table[data-sortable] th[data-sorted-direction="ascending"]:after {
45
+ border-bottom-color: inherit;
46
+ margin-top: 3px;
47
+ }
metadata ADDED
@@ -0,0 +1,255 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bootbox_crud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jiri Kaipr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sass-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bootstrap-sass
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: haml
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: haml-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simple_form
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bootbox-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.5'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: jquery-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: turbolinks
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.5'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.5'
139
+ - !ruby/object:Gem::Dependency
140
+ name: jquery-turbolinks
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.1'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: remotipart
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.2'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.2'
167
+ - !ruby/object:Gem::Dependency
168
+ name: bundler
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '1.0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '1.0'
181
+ description: Provides Rails modal CRUD scaffolding powered by bootstrap & bootbox
182
+ & simple_form. Built for use with Turbolinks, jQuery and Twitter Bootstrap 3.
183
+ email:
184
+ - jiri.kaipr@gmail.com
185
+ executables: []
186
+ extensions: []
187
+ extra_rdoc_files: []
188
+ files:
189
+ - ".gitignore"
190
+ - MIT.license
191
+ - README.md
192
+ - app/views/layouts/_bb_alert.html.haml
193
+ - app/views/layouts/_show_link_to.html.haml
194
+ - app/views/layouts/_show_link_to_array.html.haml
195
+ - app/views/layouts/_show_value.html.haml
196
+ - app/views/modals/_alert.js.erb
197
+ - app/views/modals/_create.js.erb
198
+ - app/views/modals/_destroy.js.erb
199
+ - app/views/modals/_form.js.erb
200
+ - app/views/modals/_update.js.erb
201
+ - bootbox_crud.gemspec
202
+ - lib/bootbox_crud.rb
203
+ - lib/bootbox_crud/action_view/helpers.rb
204
+ - lib/bootbox_crud/engine.rb
205
+ - lib/bootbox_crud/version.rb
206
+ - lib/generators/bootbox_crud/install_generator.rb
207
+ - lib/generators/bootbox_crud/templates/README
208
+ - lib/generators/bootbox_crud/templates/app/assets/javascripts/models.js
209
+ - lib/generators/bootbox_crud/templates/config/initializers/simple_form.rb
210
+ - lib/generators/bootbox_crud/templates/config/initializers/simple_form_bootstrap.rb
211
+ - lib/generators/rails/haml_modal_crud/USAGE
212
+ - lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb
213
+ - lib/generators/rails/haml_modal_crud/templates/create.js.erb
214
+ - lib/generators/rails/haml_modal_crud/templates/destroy.js.erb
215
+ - lib/generators/rails/haml_modal_crud/templates/update.js.erb
216
+ - lib/generators/rails/modal_crud_route/USAGE
217
+ - lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb
218
+ - lib/generators/rails/modal_crud_route/templates/models.js
219
+ - lib/templates/haml/scaffold/_form.html.haml
220
+ - lib/templates/haml/scaffold/edit.html.haml
221
+ - lib/templates/haml/scaffold/index.html.haml
222
+ - lib/templates/haml/scaffold/new.html.haml
223
+ - lib/templates/haml/scaffold/show.html.haml
224
+ - lib/templates/rails/scaffold_controller/controller.rb
225
+ - vendor/assets/javascripts/bootbox_crud_main.js
226
+ - vendor/assets/javascripts/bootbox_crud_modals.js
227
+ - vendor/assets/javascripts/sortable.js
228
+ - vendor/assets/stylesheets/bootbox_crud.css.scss
229
+ - vendor/assets/stylesheets/bootbox_crud_main.css.scss
230
+ - vendor/assets/stylesheets/sortable-theme-minimal.css
231
+ homepage: https://github.com/Virtualmaster/bootbox_crud
232
+ licenses: []
233
+ metadata: {}
234
+ post_install_message:
235
+ rdoc_options: []
236
+ require_paths:
237
+ - lib
238
+ required_ruby_version: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: '0'
243
+ required_rubygems_version: !ruby/object:Gem::Requirement
244
+ requirements:
245
+ - - ">="
246
+ - !ruby/object:Gem::Version
247
+ version: '0'
248
+ requirements: []
249
+ rubyforge_project:
250
+ rubygems_version: 2.4.6
251
+ signing_key:
252
+ specification_version: 4
253
+ summary: Rails CRUD scaffold with bootbox modals.
254
+ test_files: []
255
+ has_rdoc: