biovision-base 0.37.190607.0 → 0.39.190804.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/biovision/base/icons/components/content.svg +20 -0
- data/app/assets/images/biovision/base/icons/components/users.svg +21 -0
- data/app/assets/javascripts/biovision/base/biovision.js +68 -108
- data/app/assets/stylesheets/biovision/base/admin/components.scss +85 -95
- data/app/assets/stylesheets/biovision/base/admin.scss +0 -36
- data/app/assets/stylesheets/biovision/base/biovision.scss +49 -0
- data/app/assets/stylesheets/biovision/base/default.scss +1 -0
- data/app/assets/stylesheets/biovision/base/default_admin.scss +1 -0
- data/app/controllers/admin/components_controller.rb +60 -0
- data/app/controllers/feedback_requests_controller.rb +1 -1
- data/app/helpers/biovision_components_helper.rb +11 -0
- data/app/mailers/feedback_mailer.rb +1 -1
- data/app/models/biovision_component.rb +21 -4
- data/app/models/biovision_component_user.rb +17 -0
- data/app/models/feedback_request.rb +25 -4
- data/app/models/metric.rb +39 -4
- data/app/models/metric_value.rb +12 -5
- data/app/models/user.rb +1 -2
- data/app/services/biovision/components/base_component.rb +65 -11
- data/app/services/biovision/components/contact_component.rb +24 -0
- data/app/services/biovision/components/content_component.rb +12 -0
- data/app/services/biovision/components/registration_component.rb +12 -6
- data/app/services/biovision/components/users_component.rb +12 -0
- data/app/views/admin/components/entity/_links.html.erb +20 -0
- data/app/views/admin/{settings → components}/index.html.erb +5 -5
- data/app/views/admin/components/links/_contact.html.erb +1 -0
- data/app/views/admin/components/links/_content.html.erb +2 -0
- data/app/views/admin/components/links/_users.html.erb +7 -0
- data/app/views/admin/components/settings/_new_parameter.html.erb +46 -0
- data/app/views/admin/components/settings/_parameters.html.erb +20 -0
- data/app/views/admin/{settings/component → components/settings}/_setting.html.erb +0 -0
- data/app/views/admin/{settings/component → components/settings}/_settings.html.erb +2 -2
- data/app/views/admin/components/settings.html.erb +44 -0
- data/app/views/admin/components/show.html.erb +22 -0
- data/app/views/admin/feedback_requests/entity/_in_list.html.erb +12 -1
- data/app/views/admin/index/_components.html.erb +17 -8
- data/app/views/admin/index/index.html.erb +8 -2
- data/app/views/admin/users/entity/_in_list.html.erb +8 -0
- data/app/views/admin/users/entity/in_list/_additional_data.html.erb +0 -0
- data/app/views/admin/users/show.html.erb +9 -1
- data/app/views/authentication/_form.html.erb +4 -1
- data/app/views/editable_pages/entity/_content.html.erb +1 -0
- data/app/views/feedback_requests/_form.html.erb +19 -8
- data/app/views/layouts/admin/_footer.html.erb +2 -2
- data/app/views/shared/entity/_metadata.html.erb +1 -1
- data/app/views/users/_form.html.erb +9 -1
- data/config/locales/common-en.yml +1 -1
- data/config/locales/common-ru.yml +1 -1
- data/config/locales/common-sv.yml +1 -1
- data/config/locales/components-en.yml +36 -0
- data/config/locales/components-ru.yml +19 -16
- data/config/locales/components-sv.yml +36 -0
- data/config/routes.rb +8 -6
- data/db/migrate/20181217000000_create_biovision_components.rb +15 -3
- data/db/migrate/20181217000200_create_feedback_requests.rb +1 -0
- data/db/migrate/20190326120000_create_simple_blocks.rb +3 -1
- data/db/migrate/20190610141414_add_user_to_feedback_requests.rb +14 -0
- data/db/migrate/20190730000000_create_biovision_component_users.rb +24 -0
- data/db/migrate/20190731222222_add_biovision_component_to_metrics.rb +14 -0
- data/db/migrate/20190801111111_add_components.rb +27 -0
- data/db/{migrate → obsolete_migrations}/20181217121211_add_uuid_to_users.rb +0 -0
- data/db/{migrate → obsolete_migrations}/20181217121212_update_fields181217.rb +0 -0
- data/db/{migrate → obsolete_migrations}/20190311121212_convert_json_columns.rb +0 -0
- data/lib/biovision/base/version.rb +1 -1
- metadata +42 -24
- data/app/controllers/admin/settings_controller.rb +0 -47
- data/app/views/admin/index/_biovision_base.html.erb +0 -9
- data/app/views/admin/index/dashboard/_biovision_feedback.html.erb +0 -9
- data/app/views/admin/index/dashboard/_biovision_links.html.erb +0 -11
- data/app/views/admin/index/dashboard/_biovision_track.html.erb +0 -8
- data/app/views/admin/index/dashboard/_biovision_user.html.erb +0 -14
- data/app/views/admin/index/dashboard/_editorial.html.erb +0 -11
- data/app/views/admin/index/dashboard/_settings.html.erb +0 -9
- data/app/views/admin/settings/component/_new_parameter.html.erb +0 -54
- data/app/views/admin/settings/component/_parameters.html.erb +0 -37
- data/app/views/admin/settings/show.html.erb +0 -42
@@ -4,26 +4,36 @@ module Biovision
|
|
4
4
|
module Components
|
5
5
|
# Base biovision component
|
6
6
|
class BaseComponent
|
7
|
-
attr_reader :component, :slug, :name
|
7
|
+
attr_reader :component, :slug, :name, :user
|
8
8
|
|
9
9
|
# @param [BiovisionComponent] component
|
10
|
-
|
10
|
+
# @param [User] user
|
11
|
+
def initialize(component, user = nil)
|
11
12
|
@component = component
|
12
|
-
@slug
|
13
|
+
@slug = component&.slug || 'base'
|
14
|
+
self.user = user
|
13
15
|
|
14
16
|
@name = I18n.t("biovision.components.#{@slug}.name", default: @slug)
|
15
17
|
end
|
16
18
|
|
17
19
|
# Receive component-specific handler by component slug
|
18
20
|
#
|
19
|
-
# @param [String]
|
21
|
+
# @param [String|BiovisionComponent] input
|
22
|
+
# @param [User] user
|
20
23
|
# @return [BaseComponent]
|
21
|
-
def self.handler(
|
22
|
-
|
24
|
+
def self.handler(input, user = nil)
|
25
|
+
if input.is_a?(BiovisionComponent)
|
26
|
+
handler_class(input.slug).new(input, user)
|
27
|
+
else
|
28
|
+
entity = BiovisionComponent.find_by!(slug: input)
|
29
|
+
handler_class(input).new(entity, user)
|
30
|
+
end
|
31
|
+
end
|
23
32
|
|
24
|
-
|
25
|
-
|
26
|
-
|
33
|
+
# @param [String] slug
|
34
|
+
def self.handler_class(slug)
|
35
|
+
handler_name = "biovision/components/#{slug}_component".classify
|
36
|
+
handler_name.safe_constantize || BaseComponent
|
27
37
|
end
|
28
38
|
|
29
39
|
def self.default_privilege_name
|
@@ -40,6 +50,34 @@ module Biovision
|
|
40
50
|
UserPrivilege.user_has_privilege?(user, privilege)
|
41
51
|
end
|
42
52
|
|
53
|
+
# @param [User] user
|
54
|
+
def user=(user)
|
55
|
+
@user = user
|
56
|
+
|
57
|
+
criteria = {
|
58
|
+
biovision_component: @component,
|
59
|
+
user: user
|
60
|
+
}
|
61
|
+
|
62
|
+
@role = BiovisionComponentUser.find_by(criteria)
|
63
|
+
end
|
64
|
+
|
65
|
+
def use_parameters?
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
69
|
+
# @param [Hash] options
|
70
|
+
def allow?(options = {})
|
71
|
+
return false if user.nil?
|
72
|
+
return true if user.super_user? || @role&.administrator?
|
73
|
+
|
74
|
+
if options.key?(:action)
|
75
|
+
@role.data[options[:action].to_s]
|
76
|
+
else
|
77
|
+
!@role.nil?
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
43
81
|
# @param [Hash] data
|
44
82
|
def settings=(data)
|
45
83
|
@component.settings.merge!(normalize_settings(data))
|
@@ -52,7 +90,7 @@ module Biovision
|
|
52
90
|
|
53
91
|
# Receive parameter value with default
|
54
92
|
#
|
55
|
-
# Returns value of component's parameter or default value
|
93
|
+
# Returns value of component's parameter or default value
|
56
94
|
# when it's not found
|
57
95
|
#
|
58
96
|
# @param [String] key
|
@@ -77,7 +115,23 @@ module Biovision
|
|
77
115
|
# @param [String] key
|
78
116
|
# @param [String] value
|
79
117
|
def []=(key, value)
|
80
|
-
@component[key] = value
|
118
|
+
@component[key] = value unless key.blank?
|
119
|
+
end
|
120
|
+
|
121
|
+
# @param [String] name
|
122
|
+
# @param [Integer] quantity
|
123
|
+
def register_metric(name, quantity = 1)
|
124
|
+
metric = Metric.find_by(name: name)
|
125
|
+
if metric.nil?
|
126
|
+
attributes = {
|
127
|
+
biovision_component: @component,
|
128
|
+
name: name,
|
129
|
+
incremental: !name.end_with?('.hit')
|
130
|
+
}
|
131
|
+
metric = Metric.create(attributes)
|
132
|
+
end
|
133
|
+
|
134
|
+
metric << quantity
|
81
135
|
end
|
82
136
|
|
83
137
|
protected
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Biovision
|
4
|
+
module Components
|
5
|
+
# Component for feedback
|
6
|
+
class ContactComponent < BaseComponent
|
7
|
+
def allow?(options = {})
|
8
|
+
UserPrivilege.user_has_privilege?(user, :feedback_manager)
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
# @param [Hash] data
|
14
|
+
# @return [Hash]
|
15
|
+
def normalize_settings(data)
|
16
|
+
result = {}
|
17
|
+
allowed = %w[feedback_receiver]
|
18
|
+
allowed.each { |f| result[f] = data[f].to_s }
|
19
|
+
|
20
|
+
result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -4,6 +4,8 @@ module Biovision
|
|
4
4
|
module Components
|
5
5
|
# Handler for registration component
|
6
6
|
class RegistrationComponent < BaseComponent
|
7
|
+
METRIC_NEW_USER = 'registration.new_user.hit'
|
8
|
+
|
7
9
|
# @param [Hash] parameters
|
8
10
|
# @param [Code] code
|
9
11
|
def handle(parameters, code)
|
@@ -40,6 +42,10 @@ module Biovision
|
|
40
42
|
@component.settings['require_email'] || email_as_login?
|
41
43
|
end
|
42
44
|
|
45
|
+
def use_parameters?
|
46
|
+
false
|
47
|
+
end
|
48
|
+
|
43
49
|
protected
|
44
50
|
|
45
51
|
# @param [Hash] data
|
@@ -60,7 +66,7 @@ module Biovision
|
|
60
66
|
def persist_user
|
61
67
|
return unless @user.save
|
62
68
|
|
63
|
-
|
69
|
+
register_metric(METRIC_NEW_USER)
|
64
70
|
|
65
71
|
handle_codes
|
66
72
|
end
|
@@ -84,10 +90,10 @@ module Biovision
|
|
84
90
|
CodeSender.email(code.id).deliver_later
|
85
91
|
end
|
86
92
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
93
|
+
return unless use_invites?
|
94
|
+
|
95
|
+
@manager.activate(@user) if @manager.code_is_valid?
|
96
|
+
create_invitations(settings['invite_count'].to_i)
|
91
97
|
end
|
92
98
|
|
93
99
|
# @param [Integer] quantity
|
@@ -97,7 +103,7 @@ module Biovision
|
|
97
103
|
parameters = {
|
98
104
|
code_type: CodeManager::Invitation.code_type,
|
99
105
|
user: @user,
|
100
|
-
quantity: quantity
|
106
|
+
quantity: quantity
|
101
107
|
}
|
102
108
|
Code.create(parameters)
|
103
109
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<nav class="biovision-component-nav">
|
2
|
+
<% if handler.allow?(action: 'settings') %>
|
3
|
+
<% if handler.use_parameters? || handler.component.settings.any? %>
|
4
|
+
<%=
|
5
|
+
link_to(
|
6
|
+
t('admin.components.settings.nav_text'),
|
7
|
+
admin_component_settings_path(slug: handler.slug),
|
8
|
+
class: 'settings'
|
9
|
+
)
|
10
|
+
%>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<% prefix = 'admin/components/links/' %>
|
15
|
+
<% if lookup_context.exists?("#{prefix}_#{handler.slug}") %>
|
16
|
+
<ul class="biovision-component-links">
|
17
|
+
<%= render "#{prefix}#{handler.slug}" %>
|
18
|
+
</ul>
|
19
|
+
<% end %>
|
20
|
+
</nav>
|
@@ -11,14 +11,14 @@
|
|
11
11
|
</ul>
|
12
12
|
|
13
13
|
<ul class="biovision-components-list">
|
14
|
-
<% @collection.each do |
|
14
|
+
<% @collection.each do |component| %>
|
15
15
|
<li>
|
16
|
-
<% name = t("biovision.components.#{slug}.name", default: slug) %>
|
16
|
+
<% name = t("biovision.components.#{component.slug}.name", default: component.slug) %>
|
17
17
|
<%=
|
18
18
|
link_to(
|
19
|
-
"#{slug}: #{name}",
|
20
|
-
admin_component_path(slug: slug),
|
21
|
-
class: slug
|
19
|
+
"#{component.slug}: #{name}",
|
20
|
+
admin_component_path(slug: component.slug),
|
21
|
+
class: component.slug
|
22
22
|
)
|
23
23
|
%>
|
24
24
|
</li>
|
@@ -0,0 +1 @@
|
|
1
|
+
<li><%= render 'admin/feedback_requests/nav_item' %></li>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<li><%= render 'admin/users/nav_item' %></li>
|
2
|
+
<li><%= render 'admin/foreign_users/nav_item' %></li>
|
3
|
+
<li><%= render 'admin/privileges/nav_item' %></li>
|
4
|
+
<li><%= render 'admin/privilege_groups/nav_item' %></li>
|
5
|
+
<li><%= render 'admin/login_attempts/nav_item' %></li>
|
6
|
+
<li><%= render 'admin/tokens/nav_item' %></li>
|
7
|
+
<li><%= render 'admin/codes/nav_item' %></li>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<section
|
2
|
+
id="biovision-component-new-parameter"
|
3
|
+
data-url="<%= admin_component_parameters_path(slug: handler.slug) %>"
|
4
|
+
>
|
5
|
+
<h2><%= t('.heading') %></h2>
|
6
|
+
|
7
|
+
<dl>
|
8
|
+
<div>
|
9
|
+
<dt><%= label_tag(:new_parameter_slug, t('.parameter_slug')) %></dt>
|
10
|
+
<dd>
|
11
|
+
<%=
|
12
|
+
text_field_tag(
|
13
|
+
:slug,
|
14
|
+
'',
|
15
|
+
autocomplete: :off,
|
16
|
+
id: :new_parameter_slug,
|
17
|
+
maxlength: 50,
|
18
|
+
pattern: BiovisionComponent::SLUG_PATTERN_HTML,
|
19
|
+
required: true,
|
20
|
+
size: nil
|
21
|
+
)
|
22
|
+
%>
|
23
|
+
<div class="guideline"><%= t('.guidelines.slug') %></div>
|
24
|
+
</dd>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div>
|
28
|
+
<dt><%= label_tag(:new_parameter_value, t('.parameter_value')) %></dt>
|
29
|
+
<dd>
|
30
|
+
<%=
|
31
|
+
text_field_tag(
|
32
|
+
:value,
|
33
|
+
'',
|
34
|
+
autocomplete: :off,
|
35
|
+
id: :new_parameter_value,
|
36
|
+
maxlength: 255,
|
37
|
+
size: nil
|
38
|
+
)
|
39
|
+
%>
|
40
|
+
<div class="guideline"><%= t('.guidelines.value') %></div>
|
41
|
+
</dd>
|
42
|
+
</div>
|
43
|
+
</dl>
|
44
|
+
|
45
|
+
<%= button_tag(t(:save), class: 'button-save', type: :button) %>
|
46
|
+
</section>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<section
|
2
|
+
id="biovision-component-parameters"
|
3
|
+
data-url="<%= admin_component_parameters_path(slug: handler.slug) %>"
|
4
|
+
>
|
5
|
+
<h2><%= t('.heading') %></h2>
|
6
|
+
|
7
|
+
<dl>
|
8
|
+
<% parameters.each do |parameter, value| %>
|
9
|
+
<% element_id = "parameter-#{parameter}" %>
|
10
|
+
<div>
|
11
|
+
<dt><%= label_tag(element_id, parameter) %></dt>
|
12
|
+
<dd>
|
13
|
+
<%=
|
14
|
+
text_field_tag(parameter, value, autocomplete: :off, id: element_id)
|
15
|
+
%>
|
16
|
+
</dd>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
</dl>
|
20
|
+
</section>
|
File without changes
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<%=
|
6
6
|
form_with(
|
7
|
-
url:
|
7
|
+
url: admin_component_settings_path(slug: handler.slug),
|
8
8
|
method: :patch,
|
9
9
|
local: true
|
10
10
|
) do
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<% settings.each do |key, value| %>
|
14
14
|
<%=
|
15
15
|
render(
|
16
|
-
partial: 'admin/settings/
|
16
|
+
partial: 'admin/components/settings/setting',
|
17
17
|
locals: {
|
18
18
|
slug: handler.slug,
|
19
19
|
key: key,
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<% content_for :meta_title, t('.title', slug: @handler.slug) %>
|
2
|
+
<% content_for :breadcrumbs do %>
|
3
|
+
<%= link_to(t('admin.components.index.nav_text'), admin_components_path) %>
|
4
|
+
<%= admin_biovision_component_link(@handler.component, @handler.name) %>
|
5
|
+
<span><%= t('.nav_text') %></span>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<article>
|
9
|
+
<h1><%= @handler.name %></h1>
|
10
|
+
|
11
|
+
<ul class="actions">
|
12
|
+
<li><%= back_icon(admin_components_path) %></li>
|
13
|
+
<li><%= return_icon(admin_component_path(slug: @handler.slug)) %></li>
|
14
|
+
</ul>
|
15
|
+
|
16
|
+
<%=
|
17
|
+
render(
|
18
|
+
partial: 'admin/components/settings/settings',
|
19
|
+
locals: {
|
20
|
+
handler: @handler,
|
21
|
+
settings: @handler.component.settings
|
22
|
+
}
|
23
|
+
)
|
24
|
+
%>
|
25
|
+
|
26
|
+
<% if @handler.use_parameters? %>
|
27
|
+
<%=
|
28
|
+
render(
|
29
|
+
partial: 'admin/components/settings/parameters',
|
30
|
+
locals: {
|
31
|
+
handler: @handler,
|
32
|
+
parameters: @handler.component.parameters
|
33
|
+
}
|
34
|
+
)
|
35
|
+
%>
|
36
|
+
|
37
|
+
<%=
|
38
|
+
render(
|
39
|
+
partial: 'admin/components/settings/new_parameter',
|
40
|
+
locals: { handler: @handler }
|
41
|
+
)
|
42
|
+
%>
|
43
|
+
<% end %>
|
44
|
+
</article>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<% content_for :meta_title, t('.title', slug: @handler.slug) %>
|
2
|
+
<% content_for :breadcrumbs do %>
|
3
|
+
<%= link_to(t('admin.components.index.nav_text'), admin_components_path) %>
|
4
|
+
<span><%= @handler.name %></span>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<article>
|
8
|
+
<h1><%= @handler.name %></h1>
|
9
|
+
|
10
|
+
<ul class="actions">
|
11
|
+
<li><%= return_icon(admin_components_path) %></li>
|
12
|
+
</ul>
|
13
|
+
|
14
|
+
<%=
|
15
|
+
render(
|
16
|
+
partial: 'admin/components/entity/links',
|
17
|
+
locals: {
|
18
|
+
handler: @handler
|
19
|
+
}
|
20
|
+
)
|
21
|
+
%>
|
22
|
+
</article>
|
@@ -1,6 +1,9 @@
|
|
1
1
|
<div class="data">
|
2
2
|
<div><%= entity.name %></div>
|
3
3
|
<div class="info">
|
4
|
+
<% unless entity.user.blank? %>
|
5
|
+
<%= admin_user_link(entity.user) %><br/>
|
6
|
+
<% end %>
|
4
7
|
<%= entity.phone %><br/>
|
5
8
|
<%= entity.email %>
|
6
9
|
</div>
|
@@ -22,5 +25,13 @@
|
|
22
25
|
</div>
|
23
26
|
<% end %>
|
24
27
|
|
25
|
-
<%=
|
28
|
+
<%=
|
29
|
+
render(
|
30
|
+
partial: 'shared/admin/toggleable',
|
31
|
+
locals: {
|
32
|
+
entity: entity,
|
33
|
+
url: toggle_admin_feedback_request_path(id: entity.id)
|
34
|
+
}
|
35
|
+
)
|
36
|
+
%>
|
26
37
|
</div>
|