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,117 @@
1
+ /*
2
+ zykin-ilya@ya.ru
3
+ github.com/the-teacher
4
+ Last modified: 19 mar 2012
5
+
6
+ GLOBAL font-size: 10px; (aka 62.5%)
7
+ provide identity of:
8
+ 10px => 1em => 100%
9
+ 15px => 1.5em => 150%
10
+ 18px => 1.8em => 180%
11
+ */
12
+
13
+ *{ margin: 0; padding: 0 }
14
+
15
+ /* all block elements */
16
+ article, aside, details, figcaption, figure, footer, header, hgroup,
17
+ menu, nav, section, html, head, body, address, blockquote, center, dir,
18
+ div, dl, fieldset, form, h1, h2, h3, h4, h5, h6, hr, isindex, menu, noframes, noscript,
19
+ ol, p, pre, table, ul{
20
+ border: 0;
21
+ outline: 0;
22
+ font-size: 10px;
23
+ line-height: 100%;
24
+ background: transparent;
25
+ vertical-align: baseline;
26
+ }
27
+
28
+ html{ background: white }
29
+
30
+ /* HTML5 INIT (experimental section) */
31
+ article, aside, details, figcaption, figure, footer,
32
+ header, hgroup, menu, nav, section{
33
+ display: block
34
+ }
35
+ canvas, video, audio[controls]{
36
+ display: inline-block;
37
+ *display: inline;
38
+ zoom: 1
39
+ }
40
+ audio{ display: none }
41
+ [hidden]{ display: none }
42
+ mark{ background: yellow; padding: 0 5px }
43
+ /* HTML5 INIT */
44
+
45
+ /* TABLES */
46
+ table, tr, th, td{
47
+ border-collapse: collapse;
48
+ vertical-align: top;
49
+ border-spacing: 0
50
+ }
51
+ th{ font-weight: bold }
52
+ /* TABLES */
53
+
54
+ /* LIST */
55
+ ol, ul{ list-style: none; margin: 0 }
56
+ li{ list-style-position: outside }
57
+ /* LIST */
58
+
59
+ img{ vertical-align: top }
60
+
61
+ a{ text-decoration: underline }
62
+ a:hover{ text-decoration: none }
63
+ a:hover, a:active { outline: 0 }
64
+
65
+ sup, sub{ font-size: 85%; zoom: 1 }
66
+ sup{ vertical-align: 40% }
67
+ sub{ vertical-align: -40% }
68
+
69
+ noscript{
70
+ background: red;
71
+ font-size: 2em;
72
+ padding: 5px;
73
+ color: white
74
+ }
75
+
76
+ /* CUSTOM */
77
+ p{ line-height: 1.35em }
78
+ label{ display: block }
79
+
80
+ .numered_list, .marked_list{ margin-left: 20px }
81
+ .numered_list li, .marked_list li{
82
+ list-style-position: outside;
83
+ margin-left: 15px;
84
+ padding-left: 5px
85
+ }
86
+ .numered_list li{ list-style-type: decimal }
87
+ .marked_list li{ list-style-type: disc }
88
+
89
+ .hidden { display: none }
90
+ .invisible{ visibility: hidden; height: 0 }
91
+ .visible { visibility: visible; height: auto }
92
+
93
+ /* Unbreakable */
94
+ .nobr{ white-space: nowrap }
95
+
96
+ /* For sliders building */
97
+ .nobr_item{
98
+ display: inline-block;
99
+ vertical-align: top;
100
+ *display: inline;
101
+ zoom: 1
102
+ }
103
+
104
+ :focus{ outline: 0 }
105
+ .u{ text-decoration: underline }
106
+ .overblock{ overflow: hidden; zoom: 1 }
107
+ .indicator, .stop_indicator{
108
+ position: absolute;
109
+ top: 0; left: 0;
110
+ z-index: 1000;
111
+ display: none
112
+ }
113
+
114
+ /* WebKit fixes */
115
+ @media screen and (-webkit-min-device-pixel-ratio:0){
116
+ /* display: inline-table; */
117
+ }
@@ -0,0 +1,136 @@
1
+ @import 'mixins';
2
+ @import 'variables';
3
+
4
+ @import 'buttons';
5
+ @import 'button-groups';
6
+ @import 'dropdowns';
7
+
8
+ @import "scaffolding.less";
9
+ @import "grid.less";
10
+ @import "layouts.less";
11
+
12
+ @import "forms.less";
13
+ @import "wells.less";
14
+
15
+ .well{
16
+ input{
17
+ margin-top: -4px;
18
+ }
19
+ }
20
+
21
+ .the_role{
22
+ width: 910px;
23
+ margin: auto;
24
+ margin-top: 10px;
25
+ h3{
26
+ margin-botoom: 0;
27
+ }
28
+ }
29
+ .sidebar, .content{
30
+ padding: 15px;
31
+ }
32
+
33
+ .sidebar{
34
+ p{
35
+ font-size: 1.5em;
36
+ margin-bottom: 10px;
37
+ .delete{
38
+ color: red;
39
+ margin-left: 10px;
40
+ }
41
+ }
42
+ p.new{
43
+ padding-top: 10px;
44
+ }
45
+ p.new a{
46
+ border-radius: 3px;
47
+ color: black;
48
+ padding: 3px 10px;
49
+ background: LightGreen;
50
+ }
51
+ p.new a:hover{
52
+ color: white;
53
+ padding: 3px 10px;
54
+ background: Green;
55
+ }
56
+ }
57
+
58
+ .content{
59
+ .well{
60
+ padding: 15px;
61
+ padding-bottom: 5px;
62
+ margin-bottom: 10px;
63
+ }
64
+ .description{
65
+ font-size: 1.5em;
66
+ }
67
+ }
68
+
69
+ .btn-group{
70
+ ul.dropdown-menu{
71
+ li.alert-success{
72
+ margin-bottom: 3px;
73
+ }
74
+ li.error a{
75
+ color: @errorText;
76
+ }
77
+ li.error a:hover{
78
+ color: @white;
79
+ background: @btnDangerBackgroundHighlight;
80
+ }
81
+ }
82
+ }
83
+
84
+ .crusty{
85
+ border: 1px solid LightBlue;
86
+ margin-top: 15px;
87
+ margin-bottom: 30px;
88
+ padding: 10px;
89
+
90
+ .row [class*="span"]{
91
+ background: @white;
92
+ }
93
+ }
94
+
95
+ .dropdown-menu a{
96
+ font-size: 1.3em;
97
+ }
98
+
99
+ .section{
100
+ position: relative;
101
+ margin-bottom: 15px;
102
+ padding-bottom: 15px;
103
+ border-bottom: 1px solid Gray;
104
+
105
+ h3{
106
+ color: @grayDarker;
107
+ padding: 10px;
108
+ border-radius: 3px;
109
+ background: lighten(@btnInfoBackground, 18%);
110
+ }
111
+ .delete{
112
+ position: absolute;
113
+ top: 8px; right: 5px;
114
+ }
115
+ .rule{
116
+ background: red;
117
+ position: relative;
118
+ padding: 7px;
119
+ border-radius: 3px;
120
+ margin-bottom: 10px;
121
+ background: @tableBackgroundAccent;
122
+
123
+ h4{
124
+ margin-bottom: 0;
125
+ padding-left: 20px;
126
+ }
127
+ .controls{
128
+ position: absolute;
129
+ top: 2px; right: 0;
130
+ }
131
+ }
132
+ .rule:hover{
133
+ cursor: pointer;
134
+ background: darken(@tableBackgroundAccent, 15%);
135
+ }
136
+ }
@@ -0,0 +1,29 @@
1
+ // Scaffolding
2
+ // Basic and global styles for generating a grid system, structural layout, and page templates
3
+ // -------------------------------------------------------------------------------------------
4
+
5
+
6
+ // Body reset
7
+ // ----------
8
+
9
+ body {
10
+ margin: 0;
11
+ font-family: @baseFontFamily;
12
+ font-size: @baseFontSize;
13
+ line-height: @baseLineHeight;
14
+ color: @textColor;
15
+ background-color: @bodyBackground;
16
+ }
17
+
18
+
19
+ // Links
20
+ // -----
21
+
22
+ a {
23
+ color: @linkColor;
24
+ text-decoration: none;
25
+ }
26
+ a:hover {
27
+ color: @linkColorHover;
28
+ text-decoration: underline;
29
+ }
@@ -0,0 +1,206 @@
1
+ // Variables.less
2
+ // Variables to customize the look and feel of Bootstrap
3
+ // -----------------------------------------------------
4
+
5
+
6
+
7
+ // GLOBAL VALUES
8
+ // --------------------------------------------------
9
+
10
+
11
+ // Grays
12
+ // -------------------------
13
+ @black: #000;
14
+ @grayDarker: #222;
15
+ @grayDark: #333;
16
+ @gray: #555;
17
+ @grayLight: #999;
18
+ @grayLighter: #eee;
19
+ @white: #fff;
20
+
21
+
22
+ // Accent colors
23
+ // -------------------------
24
+ @blue: #049cdb;
25
+ @blueDark: #0064cd;
26
+ @green: #46a546;
27
+ @red: #9d261d;
28
+ @yellow: #ffc40d;
29
+ @orange: #f89406;
30
+ @pink: #c3325f;
31
+ @purple: #7a43b6;
32
+
33
+
34
+ // Scaffolding
35
+ // -------------------------
36
+ @bodyBackground: @white;
37
+ @textColor: @grayDark;
38
+
39
+
40
+ // Links
41
+ // -------------------------
42
+ @linkColor: #08c;
43
+ @linkColorHover: darken(@linkColor, 15%);
44
+
45
+
46
+ // Typography
47
+ // -------------------------
48
+ @sansFontFamily: "Helvetica Neue", Helvetica, Arial, sans-serif;
49
+ @serifFontFamily: Georgia, "Times New Roman", Times, serif;
50
+ @monoFontFamily: Menlo, Monaco, Consolas, "Courier New", monospace;
51
+
52
+ @baseFontSize: 13px;
53
+ @baseFontFamily: @sansFontFamily;
54
+ @baseLineHeight: 18px;
55
+ @altFontFamily: @serifFontFamily;
56
+
57
+ @headingsFontFamily: inherit; // empty to use BS default, @baseFontFamily
58
+ @headingsFontWeight: bold; // instead of browser default, bold
59
+ @headingsColor: inherit; // empty to use BS default, @textColor
60
+
61
+
62
+ // Tables
63
+ // -------------------------
64
+ @tableBackground: transparent; // overall background-color
65
+ @tableBackgroundAccent: #f9f9f9; // for striping
66
+ @tableBackgroundHover: #f5f5f5; // for hover
67
+ @tableBorder: #ddd; // table and cell border
68
+
69
+
70
+ // Buttons
71
+ // -------------------------
72
+ @btnBackground: @white;
73
+ @btnBackgroundHighlight: darken(@white, 10%);
74
+ @btnBorder: #ccc;
75
+
76
+ @btnPrimaryBackground: @linkColor;
77
+ @btnPrimaryBackgroundHighlight: spin(@btnPrimaryBackground, 15%);
78
+
79
+ @btnInfoBackground: #5bc0de;
80
+ @btnInfoBackgroundHighlight: #2f96b4;
81
+
82
+ @btnSuccessBackground: #62c462;
83
+ @btnSuccessBackgroundHighlight: #51a351;
84
+
85
+ @btnWarningBackground: lighten(@orange, 15%);
86
+ @btnWarningBackgroundHighlight: @orange;
87
+
88
+ @btnDangerBackground: #ee5f5b;
89
+ @btnDangerBackgroundHighlight: #bd362f;
90
+
91
+ @btnInverseBackground: @gray;
92
+ @btnInverseBackgroundHighlight: @grayDarker;
93
+
94
+
95
+ // Forms
96
+ // -------------------------
97
+ @inputBackground: @white;
98
+ @inputBorder: #ccc;
99
+ @inputBorderRadius: 3px;
100
+ @inputDisabledBackground: @grayLighter;
101
+ @formActionsBackground: #f5f5f5;
102
+
103
+ // Dropdowns
104
+ // -------------------------
105
+ @dropdownBackground: @white;
106
+ @dropdownBorder: rgba(0,0,0,.2);
107
+ @dropdownLinkColor: @grayDark;
108
+ @dropdownLinkColorHover: @white;
109
+ @dropdownLinkBackgroundHover: @linkColor;
110
+ @dropdownDividerTop: #e5e5e5;
111
+ @dropdownDividerBottom: @white;
112
+
113
+
114
+
115
+ // COMPONENT VARIABLES
116
+ // --------------------------------------------------
117
+
118
+ // Z-index master list
119
+ // -------------------------
120
+ // Used for a bird's eye view of components dependent on the z-axis
121
+ // Try to avoid customizing these :)
122
+ @zindexDropdown: 1000;
123
+ @zindexPopover: 1010;
124
+ @zindexTooltip: 1020;
125
+ @zindexFixedNavbar: 1030;
126
+ @zindexModalBackdrop: 1040;
127
+ @zindexModal: 1050;
128
+
129
+
130
+ // Sprite icons path
131
+ // -------------------------
132
+ @iconSpritePath: "../img/glyphicons-halflings.png";
133
+ @iconWhiteSpritePath: "../img/glyphicons-halflings-white.png";
134
+
135
+
136
+ // Input placeholder text color
137
+ // -------------------------
138
+ @placeholderText: @grayLight;
139
+
140
+
141
+ // Hr border color
142
+ // -------------------------
143
+ @hrBorder: @grayLighter;
144
+
145
+
146
+ // Navbar
147
+ // -------------------------
148
+ @navbarHeight: 40px;
149
+ @navbarBackground: @grayDarker;
150
+ @navbarBackgroundHighlight: @grayDark;
151
+
152
+ @navbarText: @grayLight;
153
+ @navbarLinkColor: @grayLight;
154
+ @navbarLinkColorHover: @white;
155
+ @navbarLinkColorActive: @navbarLinkColorHover;
156
+ @navbarLinkBackgroundHover: transparent;
157
+ @navbarLinkBackgroundActive: @navbarBackground;
158
+
159
+ @navbarSearchBackground: lighten(@navbarBackground, 25%);
160
+ @navbarSearchBackgroundFocus: @white;
161
+ @navbarSearchBorder: darken(@navbarSearchBackground, 30%);
162
+ @navbarSearchPlaceholderColor: #ccc;
163
+ @navbarBrandColor: @navbarLinkColor;
164
+
165
+
166
+ // Hero unit
167
+ // -------------------------
168
+ @heroUnitBackground: @grayLighter;
169
+ @heroUnitHeadingColor: inherit;
170
+ @heroUnitLeadColor: inherit;
171
+
172
+
173
+ // Form states and alerts
174
+ // -------------------------
175
+ @warningText: #c09853;
176
+ @warningBackground: #fcf8e3;
177
+ @warningBorder: darken(spin(@warningBackground, -10), 3%);
178
+
179
+ @errorText: #b94a48;
180
+ @errorBackground: #f2dede;
181
+ @errorBorder: darken(spin(@errorBackground, -10), 3%);
182
+
183
+ @successText: #468847;
184
+ @successBackground: #dff0d8;
185
+ @successBorder: darken(spin(@successBackground, -10), 5%);
186
+
187
+ @infoText: #3a87ad;
188
+ @infoBackground: #d9edf7;
189
+ @infoBorder: darken(spin(@infoBackground, -10), 7%);
190
+
191
+
192
+
193
+ // GRID
194
+ // --------------------------------------------------
195
+
196
+ // Default 940px grid
197
+ // -------------------------
198
+ @gridColumns: 12;
199
+ @gridColumnWidth: 60px;
200
+ @gridGutterWidth: 20px;
201
+ @gridRowWidth: (@gridColumns * @gridColumnWidth) + (@gridGutterWidth * (@gridColumns - 1));
202
+
203
+ // Fluid grid
204
+ // -------------------------
205
+ @fluidGridColumnWidth: 6.382978723%;
206
+ @fluidGridGutterWidth: 2.127659574%;
@@ -0,0 +1,27 @@
1
+ // WELLS
2
+ // -----
3
+
4
+ .well {
5
+ min-height: 20px;
6
+ padding: 19px;
7
+ margin-bottom: 20px;
8
+ background-color: #f5f5f5;
9
+ border: 1px solid #eee;
10
+ border: 1px solid rgba(0,0,0,.05);
11
+ .border-radius(4px);
12
+ .box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
13
+ blockquote {
14
+ border-color: #ddd;
15
+ border-color: rgba(0,0,0,.15);
16
+ }
17
+ }
18
+
19
+ // Sizes
20
+ .well-large {
21
+ padding: 24px;
22
+ .border-radius(6px);
23
+ }
24
+ .well-small {
25
+ padding: 9px;
26
+ .border-radius(3px);
27
+ }
@@ -1,24 +1,48 @@
1
1
  class Admin::RoleSectionsController < ApplicationController
2
2
  include TheRole::Requires
3
+ layout 'the_role'
3
4
 
4
- before_filter :role_login_required
5
- before_filter :role_require
6
- before_filter :role_find, :only => [:create, :create_rule, :destroy, :destroy_rule]
7
- before_filter :owner_require, :only => [:create, :create_rule, :destroy, :destroy_rule]
5
+ before_filter :login_required
6
+ before_filter :role_required
7
+
8
+ before_filter :role_find, :only => [:create, :create_rule, :rule_on, :rule_off, :destroy, :destroy_rule]
9
+ before_filter :owner_required, :only => [:create, :create_rule, :rule_on, :rule_off, :destroy, :destroy_rule]
8
10
 
9
11
  def create
10
12
  if @role.create_section params[:section_name]
11
- flash[:notice] = t('the_role.section_created')
12
- redirect_to edit_admin_role_path(@role)
13
+ flash[:notice] = t 'the_role.section_created'
14
+ redirect_to edit_admin_role_path @role
13
15
  else
14
16
  render :action => :edit
15
17
  end
16
18
  end
17
19
 
18
20
  def create_rule
19
- if @role.create_rule(params[:section_name], params[:section_rule])
20
- flash[:notice] = t('the_role.section_created')
21
- redirect_to edit_admin_role_path(@role)
21
+ if @role.create_rule params[:section_name], params[:rule_name]
22
+ flash[:notice] = t 'the_role.section_created'
23
+ redirect_to edit_admin_role_path @role
24
+ else
25
+ render :action => :edit
26
+ end
27
+ end
28
+
29
+ def rule_on
30
+ section_name = params[:id]
31
+ rule_name = params[:name]
32
+ if @role.rule_on section_name, rule_name
33
+ flash[:notice] = t 'the_role.section_rule_on'
34
+ redirect_to edit_admin_role_path @role
35
+ else
36
+ render :action => :edit
37
+ end
38
+ end
39
+
40
+ def rule_off
41
+ section_name = params[:id]
42
+ rule_name = params[:name]
43
+ if @role.rule_off section_name, rule_name
44
+ flash[:notice] = t 'the_role.section_rule_off'
45
+ redirect_to edit_admin_role_path @role
22
46
  else
23
47
  render :action => :edit
24
48
  end
@@ -26,10 +50,9 @@ class Admin::RoleSectionsController < ApplicationController
26
50
 
27
51
  def destroy
28
52
  section_name = params[:id]
29
-
30
53
  if @role.delete_section section_name
31
- flash[:notice] = t('the_role.section_deleted')
32
- redirect_to edit_admin_role_path(@role)
54
+ flash[:notice] = t 'the_role.section_deleted'
55
+ redirect_to edit_admin_role_path @role
33
56
  else
34
57
  render :action => :edit
35
58
  end
@@ -38,9 +61,9 @@ class Admin::RoleSectionsController < ApplicationController
38
61
  def destroy_rule
39
62
  section_name = params[:id]
40
63
  rule_name = params[:name]
41
- if @role.delete_rule(section_name, rule_name)
42
- flash[:notice] = t('the_role.section_rule_deleted')
43
- redirect_to edit_admin_role_path(@role)
64
+ if @role.delete_rule section_name, rule_name
65
+ flash[:notice] = t 'the_role.section_rule_deleted'
66
+ redirect_to edit_admin_role_path @role
44
67
  else
45
68
  render :action => :edit
46
69
  end
@@ -50,6 +73,6 @@ class Admin::RoleSectionsController < ApplicationController
50
73
 
51
74
  def role_find
52
75
  @role = Role.find params[:role_id]
53
- @object_for_ownership_checking = @role
76
+ @ownership_checking_object = @role
54
77
  end
55
- end
78
+ end
@@ -1,10 +1,12 @@
1
1
  class Admin::RolesController < ApplicationController
2
2
  include TheRole::Requires
3
+ layout 'the_role'
3
4
 
4
- before_filter :role_login_required
5
- before_filter :role_require
6
- before_filter :role_find, :only => [:show, :edit, :update, :destroy]
7
- before_filter :owner_require, :only => [:show, :edit, :update, :destroy]
5
+ before_filter :login_required
6
+ before_filter :role_required
7
+
8
+ before_filter :role_find, :only => [:edit, :update, :destroy]
9
+ before_filter :owner_required, :only => [:edit, :update, :destroy]
8
10
 
9
11
  def index
10
12
  @roles = Role.all(:order => "created_at ASC")
@@ -45,7 +47,7 @@ class Admin::RolesController < ApplicationController
45
47
 
46
48
  def role_find
47
49
  @role = Role.find params[:id]
48
- @object_for_ownership_checking = @role
50
+ @ownership_checking_object = @role
49
51
  end
50
52
 
51
- end
53
+ end
@@ -0,0 +1,53 @@
1
+ .well
2
+ %h3
3
+ %b Role name:
4
+ = role.name
5
+
6
+ %h5
7
+ %b Title:
8
+ = role.title
9
+
10
+ %p.description
11
+ %b Description of role:
12
+ = role.description
13
+
14
+ - role.to_hash.each_pair do |section, rules|
15
+ .section
16
+ %h3= section
17
+ .delete
18
+ .btn-group
19
+ = button_to 'Delete section', admin_role_section_path(role, section), :method => :delete, :class => 'btn btn-danger', :confirm => 'Are you sure?'
20
+
21
+ - rules.each_pair do |rule, value|
22
+ .rule
23
+ %h4
24
+ &rarr;
25
+ = rule
26
+ .controls
27
+ .btn-group
28
+ - klass = value ? :success : :info
29
+ - state = value ? :Enable : :Disable
30
+ %button{ :class => "btn btn-#{klass}" }= state
31
+ %button{ :class => "btn btn-#{klass} dropdown-toggle", 'data-toggle' => :dropdown }
32
+ %span.caret
33
+ %ul.dropdown-menu
34
+ %li.success= link_to 'Enable', rule_on_admin_role_section_path(role, section, :name => rule), :method => :put
35
+ %li.info= link_to 'Disable', rule_off_admin_role_section_path(role, section, :name => rule), :method => :put
36
+ %li.divider
37
+ %li.error= link_to 'Delete rule', destroy_rule_admin_role_section_path(role, section, :name => rule), :method => :delete, :confirm => 'Are you sure?'
38
+
39
+ %h4 Create new section
40
+
41
+ = form_tag admin_role_sections_path(role), :class => 'well form-inline' do |f|
42
+ = text_field_tag :section_name, '', :class => 'input-xlarge', :placeholder => "New Section Name"
43
+ = submit_tag 'Create Section', :class => :btn
44
+
45
+ %h4 Create new rule
46
+
47
+ = form_tag create_rule_admin_role_sections_path(role), :class => 'well form-inline' do |f|
48
+ %select.span3{ :name => :section_name }
49
+ - role.to_hash.each_pair do |section, rules|
50
+ %option{ :value => section }= section
51
+
52
+ = text_field_tag :rule_name, '', :class => 'input-large', :placeholder => "New Rule Name"
53
+ = submit_tag 'Create Rule', :class => :btn
@@ -0,0 +1,8 @@
1
+ - content_for :sidebar do
2
+ %h3= t '.roles_list'
3
+ - (@roles || Role.all).each do |role|
4
+ %p
5
+ = link_to role.title, edit_admin_role_url(role)
6
+ = link_to raw('&times;'), admin_role_url(role), :method => :delete, :title => role.title, :confirm => t('the_role.delete_role'), :class => :delete
7
+
8
+ %p.new= link_to t('.new_role'), new_admin_role_path