the_role_management_panel 3.0.1

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 (33) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +71 -0
  6. data/Rakefile +1 -0
  7. data/app/assets/javascripts/the_role_editinplace.js.coffee +38 -0
  8. data/app/assets/javascripts/the_role_management_panel.js +10 -0
  9. data/app/assets/javascripts/the_role_management_panel_initializer.js.coffee +4 -0
  10. data/app/assets/stylesheets/the_role_management_panel.css.scss +4 -0
  11. data/app/controllers/admin/role_sections_controller.rb +95 -0
  12. data/app/controllers/admin/roles_controller.rb +139 -0
  13. data/app/views/admin/roles/_role.html.haml +97 -0
  14. data/app/views/admin/roles/_sidebar.html.haml +41 -0
  15. data/app/views/admin/roles/edit.html.haml +2 -0
  16. data/app/views/admin/roles/index.haml +2 -0
  17. data/app/views/admin/roles/new.html.haml +28 -0
  18. data/app/views/layouts/the_role_management_panel.html.haml +47 -0
  19. data/config/locales/en.the_role.gui.yml +49 -0
  20. data/config/locales/es.the_role.gui.yml +46 -0
  21. data/config/locales/nl.the_role.gui.yml +47 -0
  22. data/config/locales/pl.the_role.gui.yml +46 -0
  23. data/config/locales/pt_BR.the_role.gui.yml +47 -0
  24. data/config/locales/ru.the_role.gui.yml +49 -0
  25. data/config/locales/zh_CN.the_role.gui.yml +46 -0
  26. data/config/routes.rb +52 -0
  27. data/gem_version.rb +3 -0
  28. data/lib/generators/the_role_management_panel/USAGE +32 -0
  29. data/lib/generators/the_role_management_panel/the_role_management_panel_generator.rb +56 -0
  30. data/lib/the_role_management_panel/version.rb +1 -0
  31. data/lib/the_role_management_panel.rb +12 -0
  32. data/the_role_management_panel.gemspec +31 -0
  33. metadata +199 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 180dbaf4d903a8db92e07375d1f7a53a1c3e0c26
4
+ data.tar.gz: a1f21218eef2dcf6c90d4b523570336074b876a0
5
+ SHA512:
6
+ metadata.gz: a2604a0e186fa3ac55cf80feafd7ff4ab7784bf4e6eb2c1290974476aae4c53e855ff6bb836ded60d14cff213593e9dd8f9c310fb9e2eb50bf8b2762c0286a7a
7
+ data.tar.gz: 302226afab0c0efac4d3518df5a1b0bbf3701395f647e7616d9db775653fecf990371e0e2fb00f86280c5f7fc23d2c1d5f04c95bff68b32d769884d1aeefde8b
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
19
+ .idea
20
+
21
+ # find . -name ".DS_Store" -delete
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in the_role_bootstrap3_ui.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Ilya N. Zykin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ <h2 align="center" class='center' style="text-align:center">
2
+ TheRole. Management Panel on Bootstrap 3
3
+ </h2>
4
+
5
+ <p align="center" class='center' style="text-align:center">
6
+ <b>Authorization gem for Ruby on Rails</b><br>
7
+ <i>with Management Panel</i>
8
+ </p>
9
+
10
+ <p align="center" class='center' style="text-align:center">
11
+ <img src="https://raw.githubusercontent.com/TheRole/docs/master/images/the_role.png" alt="TheRole. Authorization gem for Ruby on Rails with Administrative interface">
12
+ </p>
13
+
14
+ <p align="center" class='center' style="text-align:center">
15
+ <b>Semantic. Flexible. Lightweigh</b>
16
+ </p>
17
+
18
+ <div align="center" class='center' style="text-align:center">
19
+
20
+ <a href="http://badge.fury.io/rb/the_role"><img src="https://badge.fury.io/rb/the_role.svg" alt="Gem Version" height="18"></a>
21
+ &nbsp;
22
+ <a href="https://travis-ci.org/TheRole/DummyApp"><img src="https://travis-ci.org/TheRole/DummyApp.svg?branch=master" alt="Build Status" height="18"></a>
23
+ &nbsp;
24
+ <a href="https://codeclimate.com/github/TheRole/TheRoleManagementPanelBootstrap3"><img src="https://codeclimate.com/github/TheRole/TheRoleManagementPanelBootstrap3/badges/gpa.svg" /></a>
25
+ &nbsp;
26
+ <a href="https://www.ruby-toolbox.com/categories/rails_authorization">ruby-toolbox</a>
27
+ </div>
28
+
29
+ <hr>
30
+
31
+ <table>
32
+ <tr>
33
+ <td>
34
+ <b>http://localhost:3000/admin/roles</b>
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td>
39
+ <img src="https://raw.githubusercontent.com/TheRole/docs/master/images/gui.png?2" alt="TheRole GUI">
40
+ </td>
41
+ </tr>
42
+ </table>
43
+
44
+ <div align="center" class='center' style="text-align:center">
45
+ <a href="https://github.com/TheRole/docs/blob/master/TheRoleGuiInstallation.md">
46
+ <img src="https://raw.githubusercontent.com/TheRole/docs/master/images/install_gui.png" alt="TheRole GUI. Installation">
47
+ </a>
48
+ </div>
49
+
50
+ <div align="center" class='center' style="text-align:center">
51
+ <a href="https://github.com/the-teacher/the_role">
52
+ <img src="https://raw.githubusercontent.com/TheRole/docs/master/images/main.png" alt="gem TheRole">
53
+ </a>
54
+ </div>
55
+
56
+ <hr>
57
+
58
+ ### MIT License
59
+
60
+ [MIT License](https://github.com/TheRole/docs/blob/master/LICENSE.md)
61
+ Copyright (c) 2012-2015 [Ilya N.Zykin](https://github.com/the-teacher)
62
+
63
+ #### Maintainers
64
+
65
+ [@the-teacher](https://github.com/the-teacher),
66
+ [@sedx](https://github.com/sedx),
67
+ [@seuros](https://github.com/seuros)
68
+
69
+ #### Contributors
70
+
71
+ @igmarin, @doabit, @linjunpop, @egb3
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,38 @@
1
+ @TheRoleEditInPlace = do ->
2
+ showForm: (item) ->
3
+ holder = item.parents('.holder')
4
+ a_item = holder.children('span.a')
5
+ b_item = holder.children('span.b')
6
+
7
+ a_item.hide().off 'click'
8
+ b_item.css('visibility', 'visible')
9
+
10
+ holder.find('.btn-warning').click (e) =>
11
+ item = $ e.currentTarget
12
+ @hideForm item
13
+ item.parents('form')[0].reset()
14
+
15
+ holder.find('.btn-success').click ->
16
+ $(@).parents('form')[0].submit()
17
+
18
+ b_item.find('input').keypress (event) ->
19
+ ENTER = 13
20
+ form = $(event.target).parents('form')
21
+ form.submit() if event.which is ENTER
22
+
23
+ hideForm: (item) ->
24
+ holder = item.parents('.holder')
25
+ a_item = holder.children('span.a')
26
+ b_item = holder.children('span.b')
27
+
28
+ a_item.show()
29
+ b_item.css('visibility', 'hidden')
30
+ holder.find('.btn').off('click')
31
+
32
+ a_item.click =>
33
+ @showForm item
34
+
35
+ init: ->
36
+ $('span.a', 'h3, h5').click (e) =>
37
+ item = $ e.currentTarget
38
+ @showForm item
@@ -0,0 +1,10 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+
4
+ //= require bootstrap
5
+ //= require the_role_editinplace
6
+
7
+ //= require the_notification/vendors/toastr
8
+ //= require the_notification
9
+
10
+ //= require the_role_management_panel_initializer
@@ -0,0 +1,4 @@
1
+ $ ->
2
+ TheNotification.show_notifications()
3
+ TheRoleEditInPlace.init()
4
+
@@ -0,0 +1,4 @@
1
+ //= require the_notification/vendors/toastr
2
+
3
+ @import "bootstrap-sprockets";
4
+ @import "bootstrap";
@@ -0,0 +1,95 @@
1
+ class Admin::RoleSectionsController < ApplicationController
2
+ include TheRole::Controller
3
+ layout TheRole.config.layout.to_s
4
+
5
+ before_filter :login_required
6
+ before_filter :role_required
7
+
8
+ before_filter :section_rule_names, only: [:rule_on, :rule_off, :destroy_rule]
9
+ before_filter :role_find, only: [:create, :create_rule, :rule_on, :rule_off, :destroy, :destroy_rule]
10
+ before_filter :owner_required, only: [:create, :create_rule, :rule_on, :rule_off, :destroy, :destroy_rule]
11
+
12
+ def create
13
+ if @role.create_section params[:section_name]
14
+ flash[:notice] = t(:section_created, scope: t_scope)
15
+ else
16
+ flash[:error] = t(:section_not_created, scope: t_scope)
17
+ end
18
+
19
+ redirect_to_edit
20
+ end
21
+
22
+ def create_rule
23
+ if @role.create_rule params[:section_name], params[:rule_name]
24
+ flash[:notice] = t(:section_rule_created, scope: t_scope)
25
+ else
26
+ flash[:error] = t(:section_rule_not_created, scope: t_scope)
27
+ end
28
+
29
+ redirect_to_edit
30
+ end
31
+
32
+ def rule_on
33
+ if @role.rule_on @section_name, @rule_name
34
+ flash[:notice] = t(:section_rule_on, scope: t_scope)
35
+ else
36
+ flash[:error] = t(:state_not_changed, scope: t_scope)
37
+ end
38
+
39
+ redirect_to_edit
40
+ end
41
+
42
+ def rule_off
43
+ if @role.rule_off @section_name, @rule_name
44
+ flash[:notice] = t(:section_rule_off, scope: t_scope)
45
+ else
46
+ flash[:error] = t(:state_not_changed, scope: t_scope)
47
+ end
48
+
49
+ redirect_to_edit
50
+ end
51
+
52
+ def destroy_rule
53
+ if @role.delete_rule @section_name, @rule_name
54
+ flash[:notice] = t(:section_rule_deleted, scope: t_scope)
55
+ else
56
+ flash[:error] = t(:section_rule_not_deleted, scope: t_scope)
57
+ end
58
+
59
+ redirect_to_edit
60
+ end
61
+
62
+ def destroy
63
+ section_name = params[:id]
64
+
65
+ if @role.delete_section section_name
66
+ flash[:notice] = t(:section_deleted, scope: t_scope)
67
+ else
68
+ flash[:error] = t(:section_not_deleted, scope: t_scope)
69
+ end
70
+
71
+ redirect_to_edit
72
+ end
73
+
74
+ protected
75
+
76
+ def t_scope
77
+ [:the_role_gui]
78
+ end
79
+
80
+ def section_rule_names
81
+ @section_name = params[:id]
82
+ @rule_name = params[:name]
83
+ end
84
+
85
+ def role_find
86
+ @role = Role.find params[:role_id]
87
+
88
+ # TheRole: You have to define object for ownership check
89
+ for_ownership_check(@role)
90
+ end
91
+
92
+ def redirect_to_edit
93
+ redirect_to edit_admin_role_path @role
94
+ end
95
+ end
@@ -0,0 +1,139 @@
1
+ class Admin::RolesController < ApplicationController
2
+ include TheRole::Controller
3
+ layout TheRole.config.layout.to_s
4
+
5
+ before_filter :login_required
6
+ before_filter :role_required
7
+
8
+ before_filter :role_find, only: [:edit, :update, :destroy, :change, :role_export]
9
+ before_filter :owner_required, only: [:edit, :update, :destroy, :change]
10
+
11
+ def index
12
+ @roles = Role.order('created_at ASC')
13
+ end
14
+
15
+ def new
16
+ @role = Role.new
17
+ end
18
+
19
+ def edit; end
20
+
21
+ def role_export
22
+ role_for_export = {
23
+ @role.name => {
24
+ title: @role.title,
25
+ description: @role.description,
26
+ role_hash: @role.to_hash
27
+ }
28
+ }
29
+
30
+ role_for_export[:export_comment] = "EXPORT Role with name: *#{ @role.name }*"
31
+ send_data role_for_export.to_json, filename: "TheRole_#{ @role.name }.json"
32
+ end
33
+
34
+ def export
35
+ roles = Role.all
36
+
37
+ role_for_exports = roles.inject({}) do |hash, role|
38
+ hash[role.name] = {
39
+ title: role.title,
40
+ description: role.description,
41
+ role_hash: role.to_hash
42
+ }
43
+ hash
44
+ end
45
+
46
+ role_for_exports[:export_comment] = "EXPORT Roles: *#{ roles.map(&:name).join(', ') }*"
47
+ send_data role_for_exports.to_json, filename: "TheRole_#{ roles.map(&:name).join('-') }.json"
48
+ end
49
+
50
+ def import
51
+ roles_hash = params[:roles].try(:read)
52
+ roles_hash = begin; JSON.parse roles_hash; rescue; {}; end
53
+ roles_hash.except!('export_comment')
54
+
55
+ flash = if roles_hash.keys.empty?
56
+ { error: t(:cant_be_imported, scope: t_scope) }
57
+ else
58
+ roles_list = roles_hash.keys.join(', ')
59
+ update_roles(roles_hash)
60
+ { notice: t(:imported_roles, scope: t_scope, roles_list: roles_list) }
61
+ end
62
+
63
+ redirect_to admin_roles_url, flash: flash
64
+ end
65
+
66
+ def create
67
+ @role = Role.new role_params
68
+
69
+ if @role.save
70
+ flash = { notice: t(:role_created, scope: t_scope) }
71
+ redirect_to_edit flash
72
+ else
73
+ render action: :new
74
+ end
75
+ end
76
+
77
+ def update
78
+ if @role.update_role params[:role][:the_role]
79
+ flash = { notice: t(:role_updated, scope: t_scope) }
80
+ redirect_to_edit flash
81
+ else
82
+ render action: :edit
83
+ end
84
+ end
85
+
86
+ def change
87
+ if @role.update_attributes!(role_params)
88
+ flash = { notice: t(:role_updated, scope: t_scope) }
89
+ redirect_to_edit flash
90
+ else
91
+ render action: :edit
92
+ end
93
+ end
94
+
95
+ def destroy
96
+ @role.destroy
97
+ flash = { alert: t(:role_deleted, scope: t_scope) }
98
+ redirect_to admin_roles_url, flash
99
+ end
100
+
101
+ protected
102
+
103
+ def t_scope
104
+ [:the_role_gui]
105
+ end
106
+
107
+ def update_roles roles_hash
108
+ roles_hash.except('export_comment').each_pair do |role_name, role_data|
109
+ title = role_data['title']
110
+ descr = role_data['description']
111
+ role_hash = role_data['role_hash']
112
+
113
+ role = Role.where(name: role_name).first_or_create(title: title, description: descr)
114
+ role.update_role role_hash = role_hash
115
+ end
116
+ end
117
+
118
+ def role_params
119
+ params.require(:role).permit(*%w[
120
+ name
121
+ title
122
+ description
123
+ the_role
124
+ based_on_role
125
+ ])
126
+ end
127
+
128
+ def role_find
129
+ @role = Role.find params[:id]
130
+
131
+ # TheRole: You have to define object for ownership check
132
+ for_ownership_check(@role)
133
+ end
134
+
135
+ def redirect_to_edit flash = {}
136
+ redirect_to edit_admin_role_path(@role), flash
137
+ end
138
+
139
+ end
@@ -0,0 +1,97 @@
1
+ - t_scope = [ :the_role_gui, :roles, :role ]
2
+
3
+ - content_for :role_update_btn_set do
4
+ .btn-group
5
+ %a.btn.btn-warning
6
+ %i.icon-repeat.glyphicon.glyphicon-repeat
7
+ %a.btn.btn-success
8
+ %i.icon-ok.glyphicon.glyphicon-ok
9
+
10
+ - content_for :role_main do
11
+ - hidden = 'visibility:hidden'
12
+ .panel.panel-primary
13
+ .panel-heading
14
+ Role Info (edit in place)
15
+ = link_to t(:role_export, scope: t_scope), role_export_admin_role_path(role), class: "btn btn-xs btn-warning pull-right"
16
+ .panel-body
17
+ = form_for(role, url: change_admin_role_path(role), html: { class: "form-inline" } ) do |f|
18
+ .row
19
+ .col-md-12
20
+ %h3.holder{ style: 'margin: 3px' }
21
+ = t(:role_name, scope: t_scope) + ':'
22
+ %span.a= role.name
23
+ %span.b{ style: hidden }
24
+ .form-group= f.text_field :name, class: "form-control"
25
+ = yield(:role_update_btn_set)
26
+
27
+ %h5.holder{ style: 'margin: 3px' }
28
+ = t(:title, scope: t_scope) + ':'
29
+ %span.a= role.title
30
+ %span.b{ style: hidden }
31
+ .form-group= f.text_field :title, class: "form-control"
32
+ = yield(:role_update_btn_set)
33
+
34
+ %h5.holder{ style: 'margin: 3px' }
35
+ = t(:role_description, scope: t_scope) + ':'
36
+ %span.a= role.description
37
+ %span.b{ style: hidden }
38
+ .form-group= f.text_field :description, class: "form-control"
39
+ = yield(:role_update_btn_set)
40
+
41
+ .panel.panel-primary
42
+ .panel-heading Role rules
43
+ .panel-body
44
+ - role.to_hash.each_pair do |section, rules|
45
+ .panel.panel-info
46
+ .panel-heading
47
+ .row
48
+ .col-md-9
49
+ %h5= section
50
+ .col-md-3
51
+ .delete
52
+ .btn-group
53
+ = button_to t(:delete_section, scope: t_scope), admin_role_section_path(role, section), method: :delete, class: 'btn btn-danger', data: { confirm: t(:section_delete_confirm, scope: t_scope) }
54
+
55
+ .panel-body
56
+ .rules
57
+ - rules.each_pair do |rule, value|
58
+ .row
59
+ .col-md-9
60
+ %h4
61
+ &rarr;
62
+ = rule
63
+ .col-md-3
64
+ .controls
65
+ .btn-group
66
+ - klass = value ? :success : :info
67
+ - state = value ? t(:enable, scope: t_scope) : t(:disable, scope: t_scope)
68
+ %button{ class: "btn btn-#{klass}" }= state
69
+ %button{ class: "btn btn-#{klass} dropdown-toggle", 'data-toggle' => :dropdown }
70
+ %span.caret
71
+ %ul.dropdown-menu
72
+ %li.success= link_to t(:enable, scope: t_scope), rule_on_admin_role_section_path(role, section, :name => rule), :method => :put
73
+ %li.info= link_to t(:disable, scope: t_scope), rule_off_admin_role_section_path(role, section, :name => rule), :method => :put
74
+ %li.divider
75
+ %li.error= link_to t(:delete_rule, scope: t_scope), destroy_rule_admin_role_section_path(role, section, :name => rule), method: :delete, data: { confirm: t(:rule_delete_confirm, scope: t_scope) }
76
+
77
+ .panel.panel-success
78
+ .panel-heading
79
+ = t(:create_section, scope: t_scope)
80
+ .panel-body
81
+ = form_tag admin_role_sections_path(role), class: "form-inline"do |f|
82
+ .form-group
83
+ = text_field_tag :section_name, '', class: "form-control", placeholder: t(:new_section_placeholder, scope: t_scope)
84
+ = submit_tag t(:create_section, scope: t_scope), class: "btn btn-success"
85
+
86
+ .panel.panel-success
87
+ .panel-heading
88
+ = t(:create_rule, scope: t_scope)
89
+ .panel-body
90
+ = form_tag create_rule_admin_role_sections_path(role), role: :form, class: "form-inline" do |f|
91
+ .form-group
92
+ %select.form-control{ name: :section_name }
93
+ - role.to_hash.each_pair do |section, rules|
94
+ %option{ value: section }= section
95
+ .form-group
96
+ = text_field_tag :rule_name, '', class: "form-control", placeholder: t(:new_rule_placeholder, scope: t_scope)
97
+ = submit_tag t(:create_rule, scope: t_scope), class: "btn btn-success"
@@ -0,0 +1,41 @@
1
+ - t_scope = [ :the_role_gui, :roles, :sidebar ]
2
+
3
+ - content_for :role_sidebar do
4
+ .panel.panel-primary
5
+ .panel-heading Role Nav
6
+ .panel-body
7
+ %h4= link_to raw('&larr; Home'), root_path
8
+
9
+ .panel.panel-primary
10
+ .panel-heading
11
+ = t '.roles_list'
12
+ .panel-body
13
+
14
+ - (@roles || Role.all).each do |role|
15
+ %p
16
+ = link_to role.title, edit_admin_role_url(role)
17
+ (#{role.users.count})
18
+ = link_to admin_role_url(role), method: :delete, title: role.title, data: { confirm: t(:delete_role_confirm, scope: t_scope) }, class: :delete do
19
+ %i.icon-remove.glyphicon.glyphicon-remove
20
+
21
+ %hr
22
+
23
+ %p.new= link_to t(:new_role, scope: t_scope), new_admin_role_path, class: 'btn btn-xs btn-success'
24
+
25
+ %hr
26
+
27
+ .panel.panel-default
28
+ .panel-heading
29
+ = t(:roles_export, scope: t_scope)
30
+ .panel-body
31
+ = link_to t(:roles_export, scope: t_scope), export_admin_roles_path, class: "btn btn-xs btn-warning"
32
+
33
+ .panel.panel-default
34
+ .panel-heading
35
+ =t(:roles_import, scope: t_scope)
36
+ .panel-body
37
+ = form_tag import_admin_roles_path, multipart: true, method: :put do
38
+ .form-group
39
+ = file_field_tag :roles
40
+ .form-group
41
+ = submit_tag t(:roles_import, scope: t_scope), class: "btn btn-xs btn-warning", data: { confirm: t(:roles_import_confirm, scope: t_scope) }
@@ -0,0 +1,2 @@
1
+ = render partial: 'sidebar'
2
+ = render partial: 'role', locals: { role: @role }
@@ -0,0 +1,2 @@
1
+ = render partial: 'sidebar'
2
+ = render partial: 'role', locals: { role: @roles.first }
@@ -0,0 +1,28 @@
1
+ - t_scope = [ :the_role_gui, :roles, :new ]
2
+
3
+ = render partial: 'sidebar'
4
+
5
+ - content_for :role_main do
6
+ .panel.panel-success
7
+ .panel-heading= raw t(:create, scope: t_scope)
8
+
9
+ = render partial: 'the_notification/form', locals: { object: @role }
10
+
11
+ .panel-body
12
+ = form_for(@role, url: admin_roles_path, role: :form) do |f|
13
+ %label= t(:name, scope: t_scope)
14
+ %p= f.text_field :name, class: "form-control"
15
+
16
+ %label= t(:title, scope: t_scope)
17
+ %p= f.text_field :title, class: "form-control"
18
+
19
+ %label= t(:description, scope: t_scope)
20
+ %p= f.text_field :description, class: "form-control"
21
+
22
+ - opts = options_for_select Role.all.map{|role| [ role.name, role.id ] }
23
+ - unless opts.empty?
24
+ .form-group
25
+ %label= t(:based_on_role, scope: t_scope)
26
+ = f.select :based_on_role, opts, { include_blank: true }, class: "form-control"
27
+
28
+ = f.submit t(:create, scope: t_scope), class: "btn btn-success"
@@ -0,0 +1,47 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title TheRoleTestcase
5
+ = stylesheet_link_tag :the_role_management_panel
6
+ = javascript_include_tag :the_role_management_panel
7
+ = stylesheet_link_tag "http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css"
8
+
9
+ = csrf_meta_tags
10
+ %body
11
+ .container
12
+ .row
13
+ .col-md-12.header
14
+ %p{ style: "text-align:center" }
15
+ Authorization gem for Ruby on Rails with Management Panel
16
+
17
+ %p{ style: "text-align:center" }
18
+ = link_to "https://github.com/the-teacher/the_role" do
19
+ = image_tag "https://raw.githubusercontent.com/TheRole/docs/master/images/the_role.png", alt: 'TheRole 3.0', width: 150
20
+
21
+ %p{ style: "text-align:center" }
22
+ Semantic. Flexible. Lightweigh
23
+ .row
24
+ .col-md-3.manage_panel
25
+ = yield :role_sidebar
26
+ .col-md-9.main_content
27
+ = render partial: 'the_notification/flash', locals: { format: :json }
28
+ = yield
29
+ = yield :role_main
30
+
31
+ .row
32
+ .col-md-12.center
33
+ %p{ style: "text-align:center" }
34
+ = link_to 'en', '/?locale=en'
35
+ \|
36
+ = link_to 'ru', '/?locale=ru'
37
+ \|
38
+ = link_to 'es', '/?locale=es'
39
+ \|
40
+ = link_to 'zh_CN', '/?locale=zh_CN'
41
+ \|
42
+ = link_to 'pl', '/?locale=pl'
43
+ \|
44
+ %b
45
+ = t '.current_locale'
46
+ = "[#{ I18n.locale }]"
47
+