the_role 1.5.1 → 1.6.0

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 (45) hide show
  1. data/Bye_bye_CanCan_I_got_the_Role.png +0 -0
  2. data/README.md +82 -92
  3. data/app/assets/javascripts/admin_the_role.js +3 -0
  4. data/app/assets/javascripts/bootstrap-dropdown.js +100 -0
  5. data/app/assets/stylesheets/admin_the_role.css +7 -0
  6. data/app/assets/stylesheets/alerts.less +58 -0
  7. data/app/assets/stylesheets/button-groups.less +191 -0
  8. data/app/assets/stylesheets/buttons.less +191 -0
  9. data/app/assets/stylesheets/custom.scss +3 -0
  10. data/app/assets/stylesheets/dropdowns.less +143 -0
  11. data/app/assets/stylesheets/forms.less +583 -0
  12. data/app/assets/stylesheets/grid.less +5 -0
  13. data/app/assets/stylesheets/headers.scss +15 -0
  14. data/app/assets/stylesheets/layouts.less +17 -0
  15. data/app/assets/stylesheets/mix.scss +41 -0
  16. data/app/assets/stylesheets/mixins.less +646 -0
  17. data/app/assets/stylesheets/reset.css +117 -0
  18. data/app/assets/stylesheets/role_set.less +136 -0
  19. data/app/assets/stylesheets/scaffolding.less +29 -0
  20. data/app/assets/stylesheets/variables.less +206 -0
  21. data/app/assets/stylesheets/wells.less +27 -0
  22. data/app/controllers/admin/role_sections_controller.rb +40 -17
  23. data/app/controllers/admin/roles_controller.rb +8 -6
  24. data/app/views/admin/roles/_role.html.haml +53 -0
  25. data/app/views/admin/roles/_sidebar.html.haml +8 -0
  26. data/app/views/admin/roles/edit.html.haml +2 -42
  27. data/app/views/admin/roles/index.haml +2 -15
  28. data/app/views/admin/roles/new.html.haml +5 -4
  29. data/app/views/layouts/the_role.html.haml +24 -0
  30. data/config/routes.rb +5 -1
  31. data/lib/the_role/engine.rb +2 -2
  32. data/lib/the_role/hash.rb +50 -14
  33. data/lib/the_role/modules/base.rb +4 -4
  34. data/lib/the_role/modules/controller_requires.rb +4 -15
  35. data/lib/the_role/modules/role_model.rb +14 -13
  36. data/lib/the_role/param_helper.rb +15 -0
  37. data/lib/the_role/version.rb +1 -1
  38. data/lib/the_role.rb +13 -11
  39. data/pic.png +0 -0
  40. data/the_role.gemspec +5 -2
  41. metadata +58 -16
  42. data/app/assets/stylesheets/the_role/form.css +0 -57
  43. data/app/assets/stylesheets/the_role/headers.css.scss +0 -15
  44. data/app/assets/stylesheets/the_role/style.css.scss +0 -75
  45. data/lib/the_role/modules/param_helper.rb +0 -7
@@ -0,0 +1,583 @@
1
+ // Forms.less
2
+ // Base styles for various input types, form layouts, and states
3
+ // -------------------------------------------------------------
4
+
5
+
6
+ // GENERAL STYLES
7
+ // --------------
8
+
9
+ // Make all forms have space below them
10
+ form {
11
+ margin: 0 0 @baseLineHeight;
12
+ }
13
+
14
+ fieldset {
15
+ padding: 0;
16
+ margin: 0;
17
+ border: 0;
18
+ }
19
+
20
+ // Groups of fields with labels on top (legends)
21
+ legend {
22
+ display: block;
23
+ width: 100%;
24
+ padding: 0;
25
+ margin-bottom: @baseLineHeight * 1.5;
26
+ font-size: @baseFontSize * 1.5;
27
+ line-height: @baseLineHeight * 2;
28
+ color: @grayDark;
29
+ border: 0;
30
+ border-bottom: 1px solid #e5e5e5;
31
+
32
+ // Small
33
+ small {
34
+ font-size: @baseLineHeight * .75;
35
+ color: @grayLight;
36
+ }
37
+ }
38
+
39
+ // Set font for forms
40
+ label,
41
+ input,
42
+ button,
43
+ select,
44
+ textarea {
45
+ #font > .shorthand(@baseFontSize,normal,@baseLineHeight); // Set size, weight, line-height here
46
+ }
47
+ input,
48
+ button,
49
+ select,
50
+ textarea {
51
+ font-family: @baseFontFamily; // And only set font-family here for those that need it (note the missing label element)
52
+ }
53
+
54
+ // Identify controls by their labels
55
+ label {
56
+ display: block;
57
+ margin-bottom: 5px;
58
+ }
59
+
60
+ // Form controls
61
+ // -------------------------
62
+
63
+ // Shared size and type resets
64
+ select,
65
+ textarea,
66
+ input[type="text"],
67
+ input[type="password"],
68
+ input[type="datetime"],
69
+ input[type="datetime-local"],
70
+ input[type="date"],
71
+ input[type="month"],
72
+ input[type="time"],
73
+ input[type="week"],
74
+ input[type="number"],
75
+ input[type="email"],
76
+ input[type="url"],
77
+ input[type="search"],
78
+ input[type="tel"],
79
+ input[type="color"],
80
+ .uneditable-input {
81
+ display: inline-block;
82
+ height: @baseLineHeight;
83
+ padding: 4px;
84
+ margin-bottom: 9px;
85
+ font-size: @baseFontSize;
86
+ line-height: @baseLineHeight;
87
+ color: @gray;
88
+ }
89
+
90
+ // Reset appearance properties for textual inputs and textarea
91
+ // Declare width for legacy (can't be on input[type=*] selectors or it's too specific)
92
+ input,
93
+ textarea {
94
+ width: 210px;
95
+ }
96
+ // Reset height since textareas have rows
97
+ textarea {
98
+ height: auto;
99
+ }
100
+ // Everything else
101
+ textarea,
102
+ input[type="text"],
103
+ input[type="password"],
104
+ input[type="datetime"],
105
+ input[type="datetime-local"],
106
+ input[type="date"],
107
+ input[type="month"],
108
+ input[type="time"],
109
+ input[type="week"],
110
+ input[type="number"],
111
+ input[type="email"],
112
+ input[type="url"],
113
+ input[type="search"],
114
+ input[type="tel"],
115
+ input[type="color"],
116
+ .uneditable-input {
117
+ background-color: @inputBackground;
118
+ border: 1px solid @inputBorder;
119
+ .border-radius(@inputBorderRadius);
120
+ .box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
121
+ @transition: border linear .2s, box-shadow linear .2s;
122
+ .transition(@transition);
123
+
124
+ // Focus state
125
+ &:focus {
126
+ border-color: rgba(82,168,236,.8);
127
+ outline: 0;
128
+ outline: thin dotted \9; /* IE6-9 */
129
+ .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6)");
130
+ }
131
+ }
132
+
133
+ // Position radios and checkboxes better
134
+ input[type="radio"],
135
+ input[type="checkbox"] {
136
+ margin: 3px 0;
137
+ *margin-top: 0; /* IE7 */
138
+ line-height: normal;
139
+ cursor: pointer;
140
+ }
141
+
142
+ // Reset width of input buttons, radios, checkboxes
143
+ input[type="submit"],
144
+ input[type="reset"],
145
+ input[type="button"],
146
+ input[type="radio"],
147
+ input[type="checkbox"] {
148
+ width: auto; // Override of generic input selector
149
+ }
150
+
151
+ // Make uneditable textareas behave like a textarea
152
+ .uneditable-textarea {
153
+ width: auto;
154
+ height: auto;
155
+ }
156
+
157
+ // Set the height of select and file controls to match text inputs
158
+ select,
159
+ input[type="file"] {
160
+ height: 28px; /* In IE7, the height of the select element cannot be changed by height, only font-size */
161
+ *margin-top: 4px; /* For IE7, add top margin to align select with labels */
162
+ line-height: 28px;
163
+ }
164
+
165
+ // Make select elements obey height by applying a border
166
+ select {
167
+ width: 220px; // default input width + 10px of padding that doesn't get applied
168
+ border: 1px solid #bbb;
169
+ }
170
+
171
+ // Make multiple select elements height not fixed
172
+ select[multiple],
173
+ select[size] {
174
+ height: auto;
175
+ }
176
+
177
+ // Focus for select, file, radio, and checkbox
178
+ select:focus,
179
+ input[type="file"]:focus,
180
+ input[type="radio"]:focus,
181
+ input[type="checkbox"]:focus {
182
+ .tab-focus();
183
+ }
184
+
185
+
186
+
187
+ // CHECKBOXES & RADIOS
188
+ // -------------------
189
+
190
+ // Indent the labels to position radios/checkboxes as hanging
191
+ .radio,
192
+ .checkbox {
193
+ min-height: 18px; // clear the floating input if there is no label text
194
+ padding-left: 18px;
195
+ }
196
+ .radio input[type="radio"],
197
+ .checkbox input[type="checkbox"] {
198
+ float: left;
199
+ margin-left: -18px;
200
+ }
201
+
202
+ // Move the options list down to align with labels
203
+ .controls > .radio:first-child,
204
+ .controls > .checkbox:first-child {
205
+ padding-top: 5px; // has to be padding because margin collaspes
206
+ }
207
+
208
+ // Radios and checkboxes on same line
209
+ // TODO v3: Convert .inline to .control-inline
210
+ .radio.inline,
211
+ .checkbox.inline {
212
+ display: inline-block;
213
+ padding-top: 5px;
214
+ margin-bottom: 0;
215
+ vertical-align: middle;
216
+ }
217
+ .radio.inline + .radio.inline,
218
+ .checkbox.inline + .checkbox.inline {
219
+ margin-left: 10px; // space out consecutive inline controls
220
+ }
221
+
222
+
223
+
224
+ // INPUT SIZES
225
+ // -----------
226
+
227
+ // General classes for quick sizes
228
+ .input-mini { width: 60px; }
229
+ .input-small { width: 90px; }
230
+ .input-medium { width: 150px; }
231
+ .input-large { width: 210px; }
232
+ .input-xlarge { width: 270px; }
233
+ .input-xxlarge { width: 530px; }
234
+
235
+ // Grid style input sizes
236
+ input[class*="span"],
237
+ select[class*="span"],
238
+ textarea[class*="span"],
239
+ .uneditable-input[class*="span"],
240
+ // Redeclare since the fluid row class is more specific
241
+ .row-fluid input[class*="span"],
242
+ .row-fluid select[class*="span"],
243
+ .row-fluid textarea[class*="span"],
244
+ .row-fluid .uneditable-input[class*="span"] {
245
+ float: none;
246
+ margin-left: 0;
247
+ }
248
+ // Ensure input-prepend/append never wraps
249
+ .input-append input[class*="span"],
250
+ .input-append .uneditable-input[class*="span"],
251
+ .input-prepend input[class*="span"],
252
+ .input-prepend .uneditable-input[class*="span"],
253
+ .row-fluid .input-prepend [class*="span"],
254
+ .row-fluid .input-append [class*="span"] {
255
+ display: inline-block;
256
+ }
257
+
258
+
259
+
260
+ // GRID SIZING FOR INPUTS
261
+ // ----------------------
262
+
263
+ #grid > .input(@gridColumnWidth, @gridGutterWidth);
264
+
265
+
266
+
267
+ // DISABLED STATE
268
+ // --------------
269
+
270
+ // Disabled and read-only inputs
271
+ input[disabled],
272
+ select[disabled],
273
+ textarea[disabled],
274
+ input[readonly],
275
+ select[readonly],
276
+ textarea[readonly] {
277
+ cursor: not-allowed;
278
+ background-color: @inputDisabledBackground;
279
+ border-color: #ddd;
280
+ }
281
+ // Explicitly reset the colors here
282
+ input[type="radio"][disabled],
283
+ input[type="checkbox"][disabled],
284
+ input[type="radio"][readonly],
285
+ input[type="checkbox"][readonly] {
286
+ background-color: transparent;
287
+ }
288
+
289
+
290
+
291
+
292
+ // FORM FIELD FEEDBACK STATES
293
+ // --------------------------
294
+
295
+ // Warning
296
+ .control-group.warning {
297
+ .formFieldState(@warningText, @warningText, @warningBackground);
298
+ }
299
+ // Error
300
+ .control-group.error {
301
+ .formFieldState(@errorText, @errorText, @errorBackground);
302
+ }
303
+ // Success
304
+ .control-group.success {
305
+ .formFieldState(@successText, @successText, @successBackground);
306
+ }
307
+
308
+ // HTML5 invalid states
309
+ // Shares styles with the .control-group.error above
310
+ input:focus:required:invalid,
311
+ textarea:focus:required:invalid,
312
+ select:focus:required:invalid {
313
+ color: #b94a48;
314
+ border-color: #ee5f5b;
315
+ &:focus {
316
+ border-color: darken(#ee5f5b, 10%);
317
+ .box-shadow(0 0 6px lighten(#ee5f5b, 20%));
318
+ }
319
+ }
320
+
321
+
322
+
323
+ // FORM ACTIONS
324
+ // ------------
325
+
326
+ .form-actions {
327
+ padding: (@baseLineHeight - 1) 20px @baseLineHeight;
328
+ margin-top: @baseLineHeight;
329
+ margin-bottom: @baseLineHeight;
330
+ background-color: @formActionsBackground;
331
+ border-top: 1px solid #e5e5e5;
332
+ .clearfix(); // Adding clearfix to allow for .pull-right button containers
333
+ }
334
+
335
+ // For text that needs to appear as an input but should not be an input
336
+ .uneditable-input {
337
+ overflow: hidden; // prevent text from wrapping, but still cut it off like an input does
338
+ white-space: nowrap;
339
+ cursor: not-allowed;
340
+ background-color: @inputBackground;
341
+ border-color: #eee;
342
+ .box-shadow(inset 0 1px 2px rgba(0,0,0,.025));
343
+ }
344
+
345
+ // Placeholder text gets special styles; can't be bundled together though for some reason
346
+ .placeholder();
347
+
348
+
349
+
350
+ // HELP TEXT
351
+ // ---------
352
+
353
+ .help-block,
354
+ .help-inline {
355
+ color: @gray; // lighten the text some for contrast
356
+ }
357
+
358
+ .help-block {
359
+ display: block; // account for any element using help-block
360
+ margin-bottom: @baseLineHeight / 2;
361
+ }
362
+
363
+ .help-inline {
364
+ display: inline-block;
365
+ .ie7-inline-block();
366
+ vertical-align: middle;
367
+ padding-left: 5px;
368
+ }
369
+
370
+
371
+
372
+ // INPUT GROUPS
373
+ // ------------
374
+
375
+ // Allow us to put symbols and text within the input field for a cleaner look
376
+ .input-prepend,
377
+ .input-append {
378
+ margin-bottom: 5px;
379
+ input,
380
+ select,
381
+ .uneditable-input {
382
+ position: relative; // placed here by default so that on :focus we can place the input above the .add-on for full border and box-shadow goodness
383
+ margin-bottom: 0; // prevent bottom margin from screwing up alignment in stacked forms
384
+ *margin-left: 0;
385
+ vertical-align: middle;
386
+ .border-radius(0 @inputBorderRadius @inputBorderRadius 0);
387
+ // Make input on top when focused so blue border and shadow always show
388
+ &:focus {
389
+ z-index: 2;
390
+ }
391
+ }
392
+ .uneditable-input {
393
+ border-left-color: #ccc;
394
+ }
395
+ .add-on {
396
+ display: inline-block;
397
+ width: auto;
398
+ height: @baseLineHeight;
399
+ min-width: 16px;
400
+ padding: 4px 5px;
401
+ font-weight: normal;
402
+ line-height: @baseLineHeight;
403
+ text-align: center;
404
+ text-shadow: 0 1px 0 @white;
405
+ vertical-align: middle;
406
+ background-color: @grayLighter;
407
+ border: 1px solid #ccc;
408
+ }
409
+ .add-on,
410
+ .btn {
411
+ margin-left: -1px;
412
+ .border-radius(0);
413
+ }
414
+ .active {
415
+ background-color: lighten(@green, 30);
416
+ border-color: @green;
417
+ }
418
+ }
419
+ .input-prepend {
420
+ .add-on,
421
+ .btn {
422
+ margin-right: -1px;
423
+ }
424
+ .add-on:first-child,
425
+ .btn:first-child {
426
+ .border-radius(@inputBorderRadius 0 0 @inputBorderRadius);
427
+ }
428
+ }
429
+ .input-append {
430
+ input,
431
+ select,
432
+ .uneditable-input {
433
+ .border-radius(@inputBorderRadius 0 0 @inputBorderRadius);
434
+ }
435
+ .uneditable-input {
436
+ border-right-color: #ccc;
437
+ border-left-color: #eee;
438
+ }
439
+ .add-on:last-child,
440
+ .btn:last-child {
441
+ .border-radius(0 @inputBorderRadius @inputBorderRadius 0);
442
+ }
443
+ }
444
+ // Remove all border-radius for inputs with both prepend and append
445
+ .input-prepend.input-append {
446
+ input,
447
+ select,
448
+ .uneditable-input {
449
+ .border-radius(0);
450
+ }
451
+ .add-on:first-child,
452
+ .btn:first-child {
453
+ margin-right: -1px;
454
+ .border-radius(@inputBorderRadius 0 0 @inputBorderRadius);
455
+ }
456
+ .add-on:last-child,
457
+ .btn:last-child {
458
+ margin-left: -1px;
459
+ .border-radius(0 @inputBorderRadius @inputBorderRadius 0);
460
+ }
461
+ }
462
+
463
+
464
+
465
+ // SEARCH FORM
466
+ // -----------
467
+
468
+ .search-query {
469
+ padding-right: 14px;
470
+ padding-right: 4px \9;
471
+ padding-left: 14px;
472
+ padding-left: 4px \9; /* IE7-8 doesn't have border-radius, so don't indent the padding */
473
+ margin-bottom: 0; // remove the default margin on all inputs
474
+ .border-radius(14px);
475
+ }
476
+
477
+
478
+
479
+ // HORIZONTAL & VERTICAL FORMS
480
+ // ---------------------------
481
+
482
+ // Common properties
483
+ // -----------------
484
+
485
+ .form-search,
486
+ .form-inline,
487
+ .form-horizontal {
488
+ input,
489
+ textarea,
490
+ select,
491
+ .help-inline,
492
+ .uneditable-input,
493
+ .input-prepend,
494
+ .input-append {
495
+ display: inline-block;
496
+ .ie7-inline-block();
497
+ margin-bottom: 0;
498
+ }
499
+ // Re-hide hidden elements due to specifity
500
+ .hide {
501
+ display: none;
502
+ }
503
+ }
504
+ .form-search label,
505
+ .form-inline label {
506
+ display: inline-block;
507
+ }
508
+ // Remove margin for input-prepend/-append
509
+ .form-search .input-append,
510
+ .form-inline .input-append,
511
+ .form-search .input-prepend,
512
+ .form-inline .input-prepend {
513
+ margin-bottom: 0;
514
+ }
515
+ // Inline checkbox/radio labels (remove padding on left)
516
+ .form-search .radio,
517
+ .form-search .checkbox,
518
+ .form-inline .radio,
519
+ .form-inline .checkbox {
520
+ padding-left: 0;
521
+ margin-bottom: 0;
522
+ vertical-align: middle;
523
+ }
524
+ // Remove float and margin, set to inline-block
525
+ .form-search .radio input[type="radio"],
526
+ .form-search .checkbox input[type="checkbox"],
527
+ .form-inline .radio input[type="radio"],
528
+ .form-inline .checkbox input[type="checkbox"] {
529
+ float: left;
530
+ margin-right: 3px;
531
+ margin-left: 0;
532
+ }
533
+
534
+
535
+ // Margin to space out fieldsets
536
+ .control-group {
537
+ margin-bottom: @baseLineHeight / 2;
538
+ }
539
+
540
+ // Legend collapses margin, so next element is responsible for spacing
541
+ legend + .control-group {
542
+ margin-top: @baseLineHeight;
543
+ -webkit-margin-top-collapse: separate;
544
+ }
545
+
546
+ // Horizontal-specific styles
547
+ // --------------------------
548
+
549
+ .form-horizontal {
550
+ // Increase spacing between groups
551
+ .control-group {
552
+ margin-bottom: @baseLineHeight;
553
+ .clearfix();
554
+ }
555
+ // Float the labels left
556
+ .control-label {
557
+ float: left;
558
+ width: 140px;
559
+ padding-top: 5px;
560
+ text-align: right;
561
+ }
562
+ // Move over all input controls and content
563
+ .controls {
564
+ // Super jank IE7 fix to ensure the inputs in .input-append and input-prepend
565
+ // don't inherit the margin of the parent, in this case .controls
566
+ *display: inline-block;
567
+ *padding-left: 20px;
568
+ margin-left: 160px;
569
+ *margin-left: 0;
570
+ &:first-child {
571
+ *padding-left: 160px;
572
+ }
573
+ }
574
+ // Remove bottom margin on block level help text since that's accounted for on .control-group
575
+ .help-block {
576
+ margin-top: @baseLineHeight / 2;
577
+ margin-bottom: 0;
578
+ }
579
+ // Move over buttons in .form-actions to align with .controls
580
+ .form-actions {
581
+ padding-left: 160px;
582
+ }
583
+ }
@@ -0,0 +1,5 @@
1
+ // Fixed (940px)
2
+ #grid > .core(@gridColumnWidth, @gridGutterWidth);
3
+
4
+ // Fluid (940px)
5
+ #grid > .fluid(@fluidGridColumnWidth, @fluidGridGutterWidth);
@@ -0,0 +1,15 @@
1
+ @import "mix";
2
+
3
+ h1,h2,h3,h4,h5,h6{
4
+ @include arial;
5
+ color: #333;
6
+ font-weight: normal;
7
+ line-height: 100%;
8
+ margin-bottom: 15px
9
+ }
10
+ h1{ font-size:2.3em }
11
+ h2{ font-size:2.7em }
12
+ h3{ font-size:2.3em }
13
+ h4{ font-size:1.9em }
14
+ h5{ font-size:1.5em }
15
+ h6{ font-size:1.1em }
@@ -0,0 +1,17 @@
1
+ //
2
+ // Layouts
3
+ // Fixed-width and fluid (with sidebar) layouts
4
+ // --------------------------------------------
5
+
6
+
7
+ // Container (centered, fixed-width layouts)
8
+ .container {
9
+ .container-fixed();
10
+ }
11
+
12
+ // Fluid layouts (left aligned, with sidebar, min- & max-width content)
13
+ .container-fluid {
14
+ padding-right: @gridGutterWidth;
15
+ padding-left: @gridGutterWidth;
16
+ .clearfix();
17
+ }
@@ -0,0 +1,41 @@
1
+ @mixin corp_font { font-family: AnyCorpFont, Arial, sans-serif }
2
+ @mixin treb_ms { font-family: 'Trebuchet MS', Helvetica, sans-serif }
3
+ @mixin arial { font-family: Arial, Helvetica, sans-serif }
4
+ @mixin times { font-family: 'Times New Roman', Times, serif }
5
+
6
+ @mixin overblock{ overflow: hidden; zoom: 1 }
7
+
8
+ @mixin inline-block{
9
+ display: inline-block;
10
+ *display: inline;
11
+ zoom: 1
12
+ }
13
+
14
+ /* for sliders building */
15
+ @mixin nobr{ white-space: nowrap }
16
+
17
+ @mixin nobr_item{
18
+ @include inline-block;
19
+ vertical-align: top
20
+ }
21
+
22
+ /* no text elements select */
23
+ @mixin no_text_select{
24
+ -webkit-touch-callout: none;
25
+ -webkit-user-select: none;
26
+ -khtml-user-select: none;
27
+ -moz-user-select: none;
28
+ -ms-user-select: none;
29
+ -o-user-select: none;
30
+ user-select: none;
31
+ }
32
+
33
+ /*
34
+ @media screen and (-webkit-min-device-pixel-ratio:0){
35
+ .class{
36
+ .element{
37
+ display: inline-table;
38
+ }
39
+ }
40
+ }
41
+ */