biovision-base 0.5.170614 → 0.7.170709
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/app/assets/images/biovision/base/placeholders/image.svg +1 -1
- data/app/assets/images/biovision/base/placeholders/region_image.svg +1 -0
- data/app/assets/stylesheets/biovision/base/admin.scss +226 -31
- data/app/assets/stylesheets/biovision/base/biovision.scss +45 -104
- data/app/assets/stylesheets/biovision/base/buttons.scss +3 -2
- data/app/assets/stylesheets/biovision/base/default.scss +66 -45
- data/app/assets/stylesheets/biovision/base/default_admin.scss +10 -0
- data/app/assets/stylesheets/biovision/base/default_application.scss +8 -0
- data/app/assets/stylesheets/biovision/base/filters.scss +4 -4
- data/app/assets/stylesheets/biovision/base/layout.scss +113 -0
- data/app/assets/stylesheets/biovision/base/message-box.scss +3 -3
- data/app/assets/stylesheets/biovision/base/regions.scss +9 -0
- data/app/assets/stylesheets/biovision/base/tootik.scss +6 -6
- data/app/assets/stylesheets/biovision/base/track.scss +7 -6
- data/app/assets/stylesheets/biovision/base/users.scss +64 -0
- data/app/controllers/admin/login_attempts_controller.rb +6 -0
- data/app/controllers/admin/privileges_controller.rb +37 -1
- data/app/controllers/admin/regions_controller.rb +37 -0
- data/app/controllers/admin/users_controller.rb +2 -2
- data/app/controllers/authentication_controller.rb +27 -26
- data/app/controllers/concerns/authentication.rb +20 -0
- data/app/controllers/my/confirmations_controller.rb +8 -3
- data/app/controllers/my/login_attempts_controller.rb +9 -0
- data/app/controllers/my/profiles_controller.rb +10 -2
- data/app/controllers/my/tokens_controller.rb +20 -0
- data/app/controllers/regions_controller.rb +73 -0
- data/app/helpers/biovision_regions_helper.rb +22 -0
- data/app/mailers/application_mailer.rb +5 -0
- data/app/mailers/user_mailer.rb +8 -0
- data/app/models/central_region.rb +49 -0
- data/app/models/concerns/required_unique_name.rb +1 -1
- data/app/models/concerns/required_unique_slug.rb +1 -1
- data/app/models/login_attempt.rb +24 -0
- data/app/models/privilege.rb +176 -1
- data/app/models/region.rb +100 -0
- data/app/models/user.rb +118 -1
- data/app/models/user_privilege.rb +52 -1
- data/app/services/code_manager/confirmation.rb +1 -1
- data/app/services/user_bouncer.rb +37 -0
- data/app/uploaders/header_image_uploader.rb +50 -0
- data/app/uploaders/region_image_uploader.rb +53 -0
- data/app/views/admin/agents/entity/_preview.jbuilder +8 -0
- data/app/views/admin/codes/index.html.erb +1 -1
- data/app/views/admin/editable_pages/index.html.erb +1 -1
- data/app/views/admin/index/index.html.erb +4 -0
- data/app/views/admin/login_attempts/_nav_item.html.erb +6 -0
- data/app/views/admin/login_attempts/entity/_in_list.html.erb +16 -0
- data/app/views/admin/login_attempts/included/_agents.jbuilder +3 -0
- data/app/views/admin/login_attempts/included/_users.jbuilder +3 -0
- data/app/views/admin/login_attempts/index.html.erb +16 -0
- data/app/views/admin/login_attempts/index.jbuilder +28 -0
- data/app/views/admin/privilege_groups/index.html.erb +1 -1
- data/app/views/admin/privileges/_toggleable.html.erb +7 -0
- data/app/views/admin/privileges/entity/_in_list.html.erb +1 -0
- data/app/views/admin/privileges/entity/_region.html.erb +12 -0
- data/app/views/admin/privileges/regions.jbuilder +10 -0
- data/app/views/admin/privileges/show.html.erb +2 -0
- data/app/views/admin/regions/_nav_item.html.erb +2 -0
- data/app/views/admin/regions/_toggleable.html.erb +7 -0
- data/app/views/admin/regions/entity/_in_list.html.erb +32 -0
- data/app/views/admin/regions/index.html.erb +22 -0
- data/app/views/admin/regions/show.html.erb +95 -0
- data/app/views/admin/tokens/index.html.erb +1 -1
- data/app/views/admin/users/_search.html.erb +1 -1
- data/app/views/admin/users/entity/_preview.jbuilder +12 -0
- data/app/views/admin/users/entity/_privilege.html.erb +23 -7
- data/app/views/admin/users/entity/_privilege_tree.html.erb +2 -2
- data/app/views/admin/users/privileges.html.erb +47 -12
- data/app/views/admin/users/show.html.erb +17 -1
- data/app/views/admin/users/tokens.html.erb +1 -1
- data/app/views/authentication/new.html.erb +1 -2
- data/app/views/layouts/admin/_footer.html.erb +8 -0
- data/app/views/layouts/application/_footer.html.erb +5 -0
- data/app/views/layouts/application/_header.html.erb +9 -0
- data/app/views/layouts/application/header/_authentication.html.erb +7 -0
- data/app/views/layouts/application/header/_logo.html.erb +3 -0
- data/app/views/layouts/application/header/_navigation.html.erb +0 -0
- data/app/views/layouts/application/header/authentication/_links.html.erb +4 -0
- data/app/views/layouts/application/header/authentication/_plate.html.erb +4 -0
- data/app/views/layouts/mailer.html.erb +13 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/app/views/my/confirmations/show.html.erb +11 -1
- data/app/views/my/index/index.html.erb +6 -4
- data/app/views/{admin/tokens → my/login_attempts}/_list.html.erb +1 -1
- data/app/views/my/login_attempts/_nav_item.html.erb +6 -0
- data/app/views/my/login_attempts/entity/_in_list.html.erb +13 -0
- data/app/views/my/login_attempts/included/_agents.jbuilder +7 -0
- data/app/views/my/login_attempts/index.html.erb +13 -0
- data/app/views/my/login_attempts/index.jbuilder +22 -0
- data/app/views/my/profiles/_nav_item.html.erb +6 -0
- data/app/views/my/profiles/new/_form.html.erb +49 -23
- data/app/views/my/profiles/new.html.erb +2 -2
- data/app/views/{admin/codes → my/tokens}/_list.html.erb +1 -1
- data/app/views/my/tokens/_nav_item.html.erb +6 -0
- data/app/views/my/tokens/_toggleable.html.erb +7 -0
- data/app/views/my/tokens/entity/_in_list.html.erb +18 -0
- data/app/views/my/tokens/index.html.erb +13 -0
- data/app/views/privileges/_form.html.erb +7 -0
- data/app/views/regions/_form.html.erb +73 -0
- data/app/views/regions/edit.html.erb +20 -0
- data/app/views/regions/new.html.erb +17 -0
- data/app/views/shared/_counters.html.erb +0 -0
- data/app/views/shared/_pagination.jbuilder +9 -0
- data/app/views/{admin/editable_pages → shared/admin}/_list.html.erb +2 -2
- data/app/views/user_mailer/login_attempt.html.erb +7 -0
- data/config/locales/common-ru.yml +5 -0
- data/config/locales/editable-pages-ru.yml +1 -1
- data/config/locales/regions-ru.yml +62 -0
- data/config/locales/users-ru.yml +48 -6
- data/config/routes.rb +19 -2
- data/db/migrate/20170301000201_create_regions.rb +32 -0
- data/db/migrate/20170302000001_create_users.rb +1 -0
- data/db/migrate/20170302000101_create_privileges.rb +2 -0
- data/db/migrate/20170302000102_create_user_privileges.rb +1 -0
- data/db/migrate/20170302000103_create_privilege_groups.rb +1 -0
- data/db/migrate/20170302000104_create_privilege_group_privileges.rb +4 -0
- data/db/migrate/20170629120000_create_login_attempts.rb +19 -0
- data/lib/biovision/base/engine.rb +6 -0
- data/lib/biovision/base/privilege_methods.rb +21 -3
- data/lib/biovision/base/version.rb +1 -1
- data/lib/tasks/{biovision/agents.rake → agents.rake} +0 -0
- data/lib/tasks/{biovision/browsers.rake → browsers.rake} +0 -0
- data/lib/tasks/{biovision/codes.rake → codes.rake} +0 -0
- data/lib/tasks/regions.rake +70 -0
- data/lib/tasks/{biovision/tokens.rake → tokens.rake} +0 -0
- data/lib/tasks/{biovision/users.rake → users.rake} +0 -0
- metadata +75 -17
- data/app/assets/stylesheets/biovision/base/fonts.scss +0 -9
- data/app/controllers/concerns/biovision/admin/privileges.rb +0 -34
- data/app/models/concerns/biovision/privilege_base.rb +0 -143
- data/app/models/concerns/biovision/user_base.rb +0 -124
- data/app/models/concerns/biovision/user_privilege_base.rb +0 -46
- data/app/views/admin/privilege_groups/_list.html.erb +0 -11
- data/app/views/authentication/_info.html.erb +0 -8
@@ -0,0 +1,53 @@
|
|
1
|
+
class RegionImageUploader < CarrierWave::Uploader::Base
|
2
|
+
include CarrierWave::MiniMagick
|
3
|
+
include CarrierWave::BombShelter
|
4
|
+
|
5
|
+
def max_pixel_dimensions
|
6
|
+
[2000, 2000]
|
7
|
+
end
|
8
|
+
|
9
|
+
storage :file
|
10
|
+
|
11
|
+
# Override the directory where uploaded files will be stored.
|
12
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
13
|
+
def store_dir
|
14
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
15
|
+
end
|
16
|
+
|
17
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
18
|
+
# def default_url
|
19
|
+
# # For Rails 3.1+ asset pipeline compatibility:
|
20
|
+
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
21
|
+
#
|
22
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
23
|
+
# end
|
24
|
+
|
25
|
+
version :header_2x do
|
26
|
+
resize_to_fit 220, 220
|
27
|
+
end
|
28
|
+
|
29
|
+
version :header, from_version: :header_2x do
|
30
|
+
resize_to_fit 110, 110
|
31
|
+
end
|
32
|
+
|
33
|
+
version :preview_2x, from_version: :header_2x do
|
34
|
+
resize_to_fit 160, 160
|
35
|
+
end
|
36
|
+
|
37
|
+
version :preview, from_version: :preview_2x do
|
38
|
+
resize_to_fit 80, 80
|
39
|
+
end
|
40
|
+
|
41
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
42
|
+
# For images you might use something like this:
|
43
|
+
def extension_whitelist
|
44
|
+
%w(jpg jpeg png)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Override the filename of the uploaded files:
|
48
|
+
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
49
|
+
# def filename
|
50
|
+
# "something.jpg" if original_filename
|
51
|
+
# end
|
52
|
+
|
53
|
+
end
|
@@ -8,11 +8,15 @@
|
|
8
8
|
<ul>
|
9
9
|
<% if current_user_has_privilege?(:administrator) %>
|
10
10
|
<li><%= render 'admin/users/nav_item' %></li>
|
11
|
+
<li><%= render 'admin/login_attempts/nav_item' %></li>
|
11
12
|
<li><%= render 'admin/tokens/nav_item' %></li>
|
12
13
|
<li><%= render 'admin/codes/nav_item' %></li>
|
13
14
|
<li><%= render 'admin/privileges/nav_item' %></li>
|
14
15
|
<li><%= render 'admin/privilege_groups/nav_item' %></li>
|
15
16
|
<% end %>
|
17
|
+
<% if current_user_in_group?(:region_managers) %>
|
18
|
+
<li><%= render 'admin/regions/nav_item' %></li>
|
19
|
+
<% end %>
|
16
20
|
<% if current_user_has_privilege?(:metrics_manager) %>
|
17
21
|
<li><%= render 'admin/metrics/nav_item' %></li>
|
18
22
|
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="image">
|
2
|
+
<%= profile_avatar(entity.user) unless entity.user.nil? %>
|
3
|
+
</div>
|
4
|
+
<div class="data">
|
5
|
+
<div><%= admin_user_link(entity.user) %></div>
|
6
|
+
<div class="info"><%= time_tag(entity.created_at) %></div>
|
7
|
+
<div class="secondary info">
|
8
|
+
<div><%= entity.password %></div>
|
9
|
+
<% unless entity.ip.nil? %>
|
10
|
+
<div><%= entity.ip %></div>
|
11
|
+
<% end %>
|
12
|
+
<% unless entity.agent.nil? %>
|
13
|
+
<div class="truncate"><%= entity.agent.name %></div>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% content_for :meta_title, t('.title', page: current_page) %>
|
2
|
+
<% content_for :breadcrumbs do %>
|
3
|
+
<span><%= t('admin.login_attempts.nav_item.text') %></span>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<article>
|
7
|
+
<h1><%= t('.heading') %></h1>
|
8
|
+
|
9
|
+
<ul class="actions">
|
10
|
+
<li><%= back_icon(admin_path) %></li>
|
11
|
+
</ul>
|
12
|
+
|
13
|
+
<%= paginate @collection %>
|
14
|
+
<%= render partial: 'shared/admin/list', locals: { collection: @collection } %>
|
15
|
+
<%= paginate @collection %>
|
16
|
+
</article>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
json.data @collection do |entity|
|
2
|
+
json.id entity.id
|
3
|
+
json.type entity.class.table_name
|
4
|
+
json.attributes do
|
5
|
+
json.(entity, :created_at, :password, :ip)
|
6
|
+
end
|
7
|
+
json.relationships do
|
8
|
+
json.user do
|
9
|
+
json.data do
|
10
|
+
json.id entity.user_id
|
11
|
+
json.type entity.user.class.table_name
|
12
|
+
end
|
13
|
+
end
|
14
|
+
unless entity.agent.nil?
|
15
|
+
json.agent do
|
16
|
+
json.data do
|
17
|
+
json.id entity.agent_id
|
18
|
+
json.type entity.agent.class.table_name
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
json.included do
|
25
|
+
json.partial! 'admin/login_attempts/included/users', locals: { collection: User.where(id: @collection.pluck(:user_id).uniq) }
|
26
|
+
json.partial! 'admin/login_attempts/included/agents', locals: { collection: Agent.where(id: @collection.pluck(:agent_id).uniq) }
|
27
|
+
end
|
28
|
+
json.partial! 'shared/pagination', locals: { collection: @collection }
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<div class="toggleable" data-url="<%= toggle_admin_privilege_path(entity) %>">
|
2
|
+
<% Privilege.toggleable_attributes.each do |flag| %>
|
3
|
+
<span class="<%= entity.attributes[flag.to_s] ? 'active' : 'inactive' %>" data-flag="<%= flag %>">
|
4
|
+
<%= t("activerecord.attributes.privilege.#{flag}") %>
|
5
|
+
</span>
|
6
|
+
<% end %>
|
7
|
+
</div>
|
@@ -8,6 +8,7 @@
|
|
8
8
|
<div><%= entity.privilege_groups.map(&:name).join(', ') %></div>
|
9
9
|
<div><%= link_to t(:user_count, count: entity.users_count), users_admin_privilege_path(entity.id) %></div>
|
10
10
|
</div>
|
11
|
+
<%= render partial: 'admin/privileges/toggleable', locals: { entity: entity } %>
|
11
12
|
|
12
13
|
<ul class="actions">
|
13
14
|
<li class="lockable <%= entity.locked? ? 'hidden' : '' %>">
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div>
|
2
|
+
<% element_id = "user_privilege_#{privilege.id}_#{region.id}" %>
|
3
|
+
<%= check_box_tag element_id, region.id, false, class: 'privilege-adder' %>
|
4
|
+
<%= label_tag element_id, region.name %>
|
5
|
+
</div>
|
6
|
+
<% if region.children_cache.any? %>
|
7
|
+
<ul class="regions" data-url="<%= regions_admin_privilege_path(privilege.id, parent_id: region.id, user_id: user.id) %>">
|
8
|
+
<li>
|
9
|
+
<button class="add_regions" type="button"><%= t('.deeper_level') %></button>
|
10
|
+
</li>
|
11
|
+
</ul>
|
12
|
+
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
json.data @collection do |entity|
|
2
|
+
json.id entity.id
|
3
|
+
json.type entity.class.table_name
|
4
|
+
json.attributes do
|
5
|
+
json.(entity, :name, :long_slug, :children_cache)
|
6
|
+
end
|
7
|
+
json.meta do
|
8
|
+
json.html_chunk render(partial: 'admin/privileges/entity/region', formats: [:html], locals: { privilege: @entity, region: entity, user: @user })
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<div class="toggleable" data-url="<%= toggle_admin_region_path(entity) %>">
|
2
|
+
<% Region.toggleable_attributes.each do |flag| %>
|
3
|
+
<span class="<%= entity.attributes[flag.to_s] ? 'active' : 'inactive' %>" data-flag="<%= flag %>">
|
4
|
+
<%= t("activerecord.attributes.region.#{flag}") %>
|
5
|
+
</span>
|
6
|
+
<% end %>
|
7
|
+
</div>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<div class="image">
|
2
|
+
<%= region_image_preview(entity) %>
|
3
|
+
</div>
|
4
|
+
<div class="data">
|
5
|
+
<div><%= admin_region_link(entity) %></div>
|
6
|
+
<div class="info">
|
7
|
+
<div><%= entity.long_slug %></div>
|
8
|
+
<% unless entity.parents_cache.blank? %>
|
9
|
+
<div>
|
10
|
+
<%= t('activerecord.attributes.region.parents_cache') %>:
|
11
|
+
<%= entity.parents_cache %>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
<% unless entity.children_cache.blank? %>
|
15
|
+
<div>
|
16
|
+
<%= t('activerecord.attributes.region.children_cache') %>:
|
17
|
+
<%= entity.children_cache.join(', ') %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
<div class="secondary info">
|
22
|
+
<%= t(:user_count, count: entity.users_count) %>
|
23
|
+
</div>
|
24
|
+
<%= render partial: 'admin/regions/toggleable', locals: { entity: entity } %>
|
25
|
+
|
26
|
+
<ul class="actions">
|
27
|
+
<li class="lockable <%= entity.editable_by?(current_user) ? '' : 'hidden' %>">
|
28
|
+
<%= edit_icon edit_region_path(entity) %>
|
29
|
+
</li>
|
30
|
+
<%= render partial: 'shared/actions/locks', locals: { entity: entity, path: lock_admin_region_path(entity) } %>
|
31
|
+
</ul>
|
32
|
+
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<% content_for :meta_title, t('.title') %>
|
2
|
+
<% content_for :breadcrumbs do %>
|
3
|
+
<span><%= t('admin.regions.nav_item.text') %></span>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<article class="entity-page">
|
7
|
+
<h1><%= t('.heading') %></h1>
|
8
|
+
|
9
|
+
<ul class="actions">
|
10
|
+
<li><%= back_icon(admin_path) %></li>
|
11
|
+
</ul>
|
12
|
+
|
13
|
+
<%= render partial: 'shared/admin/list', locals: { collection: @collection } %>
|
14
|
+
|
15
|
+
<% if current_user_has_privilege?(:administrator) %>
|
16
|
+
<section>
|
17
|
+
<h2><%= t('regions.new.heading') %></h2>
|
18
|
+
|
19
|
+
<%= render partial: 'regions/form', locals: { entity: Region.new } %>
|
20
|
+
</section>
|
21
|
+
<% end %>
|
22
|
+
</article>
|
@@ -0,0 +1,95 @@
|
|
1
|
+
<% content_for :meta_title, t('.title', name: @entity.name) %>
|
2
|
+
<% content_for :breadcrumbs do %>
|
3
|
+
<%= link_to(t('admin.regions.nav_item.text'), admin_regions_path) %>
|
4
|
+
<% @entity.parents.each do |parent| %>
|
5
|
+
<%= admin_region_link(parent) %>
|
6
|
+
<% end %>
|
7
|
+
<span><%= @entity.name %></span>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<article class="entity-page">
|
11
|
+
<h1><%= @entity.name %></h1>
|
12
|
+
|
13
|
+
<ul class="actions">
|
14
|
+
<li><%= back_icon(admin_regions_path) %></li>
|
15
|
+
<% if @entity.editable_by?(current_user) %>
|
16
|
+
<li><%= edit_icon edit_region_path(@entity.id) %></li>
|
17
|
+
<% end %>
|
18
|
+
</ul>
|
19
|
+
|
20
|
+
<% unless @entity.header_image.blank? %>
|
21
|
+
<figure>
|
22
|
+
<%= image_tag(@entity.header_image.medium.url) %>
|
23
|
+
<figcaption>
|
24
|
+
<%= t('activerecord.attributes.region.header_image') %>
|
25
|
+
</figcaption>
|
26
|
+
</figure>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% unless @entity.image.blank? %>
|
30
|
+
<figure>
|
31
|
+
<%= image_tag(@entity.image.header.url) %>
|
32
|
+
<figcaption>
|
33
|
+
<%= t('activerecord.attributes.region.image') %>
|
34
|
+
</figcaption>
|
35
|
+
</figure>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<dl>
|
39
|
+
<dt><%= t('activerecord.attributes.region.long_slug') %></dt>
|
40
|
+
<dd>
|
41
|
+
<%= @entity.long_slug %>
|
42
|
+
</dd>
|
43
|
+
|
44
|
+
<% unless @entity.short_name.blank? %>
|
45
|
+
<dt><%= t('activerecord.attributes.region.short_name') %></dt>
|
46
|
+
<dd>
|
47
|
+
<%= @entity.short_name %>
|
48
|
+
</dd>
|
49
|
+
<% end %>
|
50
|
+
|
51
|
+
<% unless @entity.locative.blank? %>
|
52
|
+
<dt><%= t('activerecord.attributes.region.locative') %></dt>
|
53
|
+
<dd>
|
54
|
+
<%= @entity.locative %>
|
55
|
+
</dd>
|
56
|
+
<% end %>
|
57
|
+
|
58
|
+
<% unless @entity.parent.nil? %>
|
59
|
+
<dt><%= t('activerecord.attributes.region.parent_id') %></dt>
|
60
|
+
<dd>
|
61
|
+
<%= admin_region_link(@entity.parent) %>
|
62
|
+
</dd>
|
63
|
+
<% end %>
|
64
|
+
|
65
|
+
<% unless @entity.parents_cache.blank? %>
|
66
|
+
<dt><%= t('activerecord.attributes.region.parents_cache') %></dt>
|
67
|
+
<dd>
|
68
|
+
<%= @entity.parents_cache %>
|
69
|
+
</dd>
|
70
|
+
<% end %>
|
71
|
+
|
72
|
+
<% unless @entity.children_cache.blank? %>
|
73
|
+
<dt><%= t('activerecord.attributes.region.children_cache') %></dt>
|
74
|
+
<dd>
|
75
|
+
<%= @entity.children_cache.join(', ') %>
|
76
|
+
</dd>
|
77
|
+
<% end %>
|
78
|
+
</dl>
|
79
|
+
|
80
|
+
<% if @entity.child_regions.any? %>
|
81
|
+
<section>
|
82
|
+
<h2><%= t('.children') %></h2>
|
83
|
+
|
84
|
+
<%= render partial: 'shared/admin/list', locals: { collection: Region.for_tree(@entity.id) } %>
|
85
|
+
</section>
|
86
|
+
<% end %>
|
87
|
+
|
88
|
+
<% if @entity.editable_by?(current_user) %>
|
89
|
+
<section>
|
90
|
+
<h2><%= t('regions.new.heading') %></h2>
|
91
|
+
|
92
|
+
<%= render partial: 'regions/form', locals: { entity: Region.new(parent: @entity) } %>
|
93
|
+
</section>
|
94
|
+
<% end %>
|
95
|
+
</article>
|
@@ -14,6 +14,6 @@
|
|
14
14
|
<%= render partial: 'admin/tokens/filter', locals: { filter: @filter } %>
|
15
15
|
|
16
16
|
<%= paginate @collection %>
|
17
|
-
<%= render partial: 'list', locals: { collection: @collection } %>
|
17
|
+
<%= render partial: 'shared/admin/list', locals: { collection: @collection } %>
|
18
18
|
<%= paginate @collection %>
|
19
19
|
</article>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div class="user-search" data-target="<%= target_id %>" data-url="<%= search_admin_users_path %>">
|
2
|
-
<%= search_field_tag 'user_search', param_from_request(:user_search), id: "#{target_id}_user_search" %>
|
2
|
+
<%= search_field_tag 'user_search', param_from_request(:user_search), id: "#{target_id}_user_search", size: 24 %>
|
3
3
|
<%= button_tag t(:find), type: :button %>
|
4
4
|
<div class="results"></div>
|
5
5
|
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
json.id entity.id
|
2
|
+
json.type entity.class.table_name
|
3
|
+
json.attributes do
|
4
|
+
json.(entity, :screen_name)
|
5
|
+
end
|
6
|
+
json.meta do
|
7
|
+
json.image_2x_url entity.image.preview_2x.url
|
8
|
+
json.image_url entity.image.preview.url
|
9
|
+
end
|
10
|
+
json.links do
|
11
|
+
json.self admin_user_url(entity.id)
|
12
|
+
end
|
@@ -1,10 +1,26 @@
|
|
1
1
|
<div class="data">
|
2
|
-
<div>
|
3
|
-
<%
|
4
|
-
|
5
|
-
|
2
|
+
<div data-url="<%= privilege_admin_user_path(id: user.id, privilege_id: privilege.id) %>" class="entity">
|
3
|
+
<% if privilege.regional? %>
|
4
|
+
<span><%= privilege.name %></span>
|
5
|
+
<ul data-url="<%= regions_admin_privilege_path(privilege.id, user_id: user.id) %>" class="regions">
|
6
|
+
<% user.user_privileges.where(privilege: privilege).order('region_id asc').each do |link| %>
|
7
|
+
<li>
|
8
|
+
<% element_id = "user_privilege_#{privilege.id}_#{link.region_id}" %>
|
9
|
+
<%= check_box_tag element_id, 1, true, data: { region_id: link.region_id } %>
|
10
|
+
<%= label_tag element_id, link.region.long_name %>
|
11
|
+
</li>
|
12
|
+
<% end %>
|
13
|
+
<li>
|
14
|
+
<button class="add_regions" type="button"><%= t('.select_regions') %></button>
|
15
|
+
</li>
|
16
|
+
</ul>
|
17
|
+
<% else %>
|
18
|
+
<% element_id = "user_privilege_#{privilege.id}" %>
|
19
|
+
<%= check_box_tag element_id, 1, privilege.has_user?(user) %>
|
20
|
+
<%= label_tag element_id, privilege.name %>
|
21
|
+
<% end %>
|
22
|
+
<% if privilege.children.any? %>
|
23
|
+
<%= render partial: 'admin/users/entity/privilege_tree', locals: { privileges: Privilege.for_tree(privilege.id), user: user } %>
|
24
|
+
<% end %>
|
6
25
|
</div>
|
7
|
-
<% if privilege.children.any? %>
|
8
|
-
<%= render partial: 'admin/users/entity/privilege_tree', locals: { privileges: Privilege.for_tree(privilege.id), user: user } %>
|
9
|
-
<% end %>
|
10
26
|
</div>
|
@@ -2,11 +2,11 @@
|
|
2
2
|
<ul class="list-of-entities privileges">
|
3
3
|
<% privileges.each do |privilege| %>
|
4
4
|
<% if privilege.deleted? %>
|
5
|
-
<li class="deleted">
|
5
|
+
<li class="deleted" data-id="<%= privilege.id %>">
|
6
6
|
<%= t(:deleted_entity) %>, id: <%= privilege.id %> [<%= privilege.name %>]
|
7
7
|
</li>
|
8
8
|
<% else %>
|
9
|
-
<li>
|
9
|
+
<li data-id="<%= privilege.id %>">
|
10
10
|
<%= render partial: 'admin/users/entity/privilege', locals: { privilege: privilege, user: user } %>
|
11
11
|
</li>
|
12
12
|
<% end %>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<span><%= t('.heading') %></span>
|
6
6
|
<% end %>
|
7
7
|
|
8
|
-
<article
|
8
|
+
<article>
|
9
9
|
<h1><%= @entity.profile_name %></h1>
|
10
10
|
|
11
11
|
<ul class="actions">
|
@@ -16,20 +16,55 @@
|
|
16
16
|
<h2><%= t('.heading') %></h2>
|
17
17
|
|
18
18
|
<%= render partial: 'admin/users/entity/privilege_tree', locals: { privileges: Privilege.for_tree, user: @entity } %>
|
19
|
+
</section>
|
20
|
+
</article>
|
21
|
+
|
22
|
+
<script>
|
23
|
+
'use strict';
|
19
24
|
|
20
|
-
|
21
|
-
$(function() {
|
22
|
-
$(
|
23
|
-
let url = $(this).data('url');
|
25
|
+
$(function () {
|
26
|
+
$('ul.privileges input[type=checkbox]').on('click', function () {
|
27
|
+
if ($(this).is(':visible')) {
|
28
|
+
let url = $(this).closest('div.entity').data('url');
|
24
29
|
let method = $(this).is(':checked') ? 'put' : 'delete';
|
30
|
+
let region_id = $(this).data('region-id');
|
31
|
+
let data = region_id > 0 ? { region_id: region_id } : {};
|
32
|
+
|
25
33
|
$.ajax(url, {
|
26
34
|
method: method,
|
27
|
-
|
28
|
-
console.log(response);
|
29
|
-
}
|
35
|
+
data: data,
|
30
36
|
}).fail(handle_ajax_failure);
|
31
|
-
}
|
37
|
+
}
|
32
38
|
});
|
33
|
-
|
34
|
-
|
35
|
-
|
39
|
+
|
40
|
+
$(document).on('click', 'button.add_regions', function () {
|
41
|
+
let $button = $(this);
|
42
|
+
let $container = $(this).closest('ul');
|
43
|
+
|
44
|
+
$.get($container.data('url'), function (response) {
|
45
|
+
if (response.hasOwnProperty('data')) {
|
46
|
+
$(response['data']).each(function(i, data) {
|
47
|
+
if (data.hasOwnProperty('meta')) {
|
48
|
+
$container.append('<li>' + data['meta']['html_chunk'] + '</li>');
|
49
|
+
}
|
50
|
+
});
|
51
|
+
}
|
52
|
+
$button.closest('li').remove();
|
53
|
+
}).fail(handle_ajax_failure);
|
54
|
+
});
|
55
|
+
|
56
|
+
$(document).on('click', 'input[type=checkbox].privilege-adder', function () {
|
57
|
+
let url = $(this).closest('div.entity').data('url');
|
58
|
+
let $li = $(this).closest('li');
|
59
|
+
let data = {region_id: $(this).val()};
|
60
|
+
|
61
|
+
$.ajax(url, {
|
62
|
+
method: 'put',
|
63
|
+
data: data,
|
64
|
+
success: function(response) {
|
65
|
+
$li.find('ul.regions').remove();
|
66
|
+
}
|
67
|
+
}).fail(handle_ajax_failure);
|
68
|
+
});
|
69
|
+
});
|
70
|
+
</script>
|
@@ -21,7 +21,7 @@
|
|
21
21
|
<li><%= link_to t('.privileges'), privileges_admin_user_path(@entity.id) %></li>
|
22
22
|
<li><%= link_to t('admin.tokens.index.heading'), tokens_admin_user_path(@entity) %></li>
|
23
23
|
<li><%= link_to t('admin.codes.index.heading'), codes_admin_user_path(@entity) %></li>
|
24
|
-
<% unless @entity ==
|
24
|
+
<% unless @entity == current_user %>
|
25
25
|
<li><%= link_to t('.authenticate'), authenticate_admin_user_path(@entity.id), method: :post %></li>
|
26
26
|
<% end %>
|
27
27
|
</ul>
|
@@ -86,6 +86,22 @@
|
|
86
86
|
<dt><%= t('activerecord.attributes.user.last_seen') %></dt>
|
87
87
|
<dd><%= time_tag @entity.last_seen %></dd>
|
88
88
|
<% end %>
|
89
|
+
|
90
|
+
<% if @entity.user_privileges.any? %>
|
91
|
+
<dt><%= t('.privileges') %></dt>
|
92
|
+
<dd>
|
93
|
+
<ol>
|
94
|
+
<% @entity.user_privileges.order('privilege_id, region_id asc nulls first').each do |link| %>
|
95
|
+
<li>
|
96
|
+
<%= link.privilege.name %>
|
97
|
+
<% unless link.region.nil? %>
|
98
|
+
(<%= link.region.long_name %>)
|
99
|
+
<% end %>
|
100
|
+
</li>
|
101
|
+
<% end %>
|
102
|
+
</ol>
|
103
|
+
</dd>
|
104
|
+
<% end %>
|
89
105
|
</dl>
|
90
106
|
|
91
107
|
<% unless @entity.deleted? %>
|
@@ -5,6 +5,5 @@
|
|
5
5
|
|
6
6
|
<%= render 'form' %>
|
7
7
|
|
8
|
-
<p><%= link_to t('my.
|
9
|
-
<p><%= link_to t('my.recoveries.show.title'), my_recovery_path %></p>
|
8
|
+
<p><%= link_to t('my.recoveries.show.title'), my_recovery_path, class: 'nav-button' %></p>
|
10
9
|
</article>
|