biovision 0.0.200518.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +214 -0
  4. data/Rakefile +22 -0
  5. data/app/assets/config/biovision_manifest.js +1 -0
  6. data/app/assets/images/biovision/components/carousel/arrow-left.svg +4 -0
  7. data/app/assets/images/biovision/components/carousel/arrow-right.svg +4 -0
  8. data/app/assets/images/biovision/icons/breadcrumb-hover.svg +1 -0
  9. data/app/assets/images/biovision/icons/breadcrumb.svg +1 -0
  10. data/app/assets/images/biovision/icons/components/contact.svg +26 -0
  11. data/app/assets/images/biovision/icons/components/content.svg +20 -0
  12. data/app/assets/images/biovision/icons/components/users.svg +21 -0
  13. data/app/assets/images/biovision/icons/key.svg +16 -0
  14. data/app/assets/images/biovision/icons/log_in.svg +15 -0
  15. data/app/assets/images/biovision/icons/log_out.svg +15 -0
  16. data/app/assets/images/biovision/icons/messages/error.svg +14 -0
  17. data/app/assets/images/biovision/icons/messages/info.svg +8 -0
  18. data/app/assets/images/biovision/icons/messages/success.svg +12 -0
  19. data/app/assets/images/biovision/icons/messages/warning.svg +13 -0
  20. data/app/assets/images/biovision/icons/settings.svg +41 -0
  21. data/app/assets/images/biovision/placeholders/16x9.svg +11 -0
  22. data/app/assets/images/biovision/placeholders/1x1.svg +11 -0
  23. data/app/assets/images/biovision/placeholders/3x2.svg +11 -0
  24. data/app/assets/images/biovision/placeholders/user.svg +15 -0
  25. data/app/assets/stylesheets/biovision/admin.scss +6 -0
  26. data/app/assets/stylesheets/biovision/admin/components.scss +59 -0
  27. data/app/assets/stylesheets/biovision/admin/default.scss +57 -0
  28. data/app/assets/stylesheets/biovision/admin/layout.scss +95 -0
  29. data/app/assets/stylesheets/biovision/admin/vars.scss +56 -0
  30. data/app/assets/stylesheets/biovision/biovision.scss +134 -0
  31. data/app/assets/stylesheets/biovision/biovision/messages.scss +41 -0
  32. data/app/assets/stylesheets/biovision/components/carousel.scss +53 -0
  33. data/app/assets/stylesheets/biovision/components/forms.scss +85 -0
  34. data/app/assets/stylesheets/biovision/components/hamburger.scss +56 -0
  35. data/app/assets/stylesheets/biovision/components/lists.scss +91 -0
  36. data/app/assets/stylesheets/biovision/default.scss +57 -0
  37. data/app/assets/stylesheets/biovision/themes/default_theme.scss +2 -0
  38. data/app/assets/stylesheets/biovision/themes/default_theme/components.scss +3 -0
  39. data/app/assets/stylesheets/biovision/themes/default_theme/layout.scss +44 -0
  40. data/app/assets/stylesheets/biovision/themes/default_theme/layout/footer.scss +0 -0
  41. data/app/assets/stylesheets/biovision/themes/default_theme/layout/header.scss +39 -0
  42. data/app/assets/stylesheets/biovision/vars.scss +53 -0
  43. data/app/controllers/admin/agents_controller.rb +15 -0
  44. data/app/controllers/admin/components_controller.rb +174 -0
  45. data/app/controllers/admin/index_controller.rb +11 -0
  46. data/app/controllers/admin/ip_addresses_controller.rb +15 -0
  47. data/app/controllers/admin_controller.rb +14 -0
  48. data/app/controllers/authentication_controller.rb +79 -0
  49. data/app/controllers/concerns/authentication.rb +45 -0
  50. data/app/controllers/index_controller.rb +8 -0
  51. data/app/controllers/my/confirmations_controller.rb +2 -0
  52. data/app/controllers/my/index_controller.rb +8 -0
  53. data/app/controllers/my/profiles_controller.rb +128 -0
  54. data/app/controllers/my/recoveries_controller.rb +2 -0
  55. data/app/helpers/biovision_components_helper.rb +14 -0
  56. data/app/helpers/users_helper.rb +11 -0
  57. data/app/lib/biovision/components/base_component.rb +177 -0
  58. data/app/lib/biovision/components/component_settings.rb +30 -0
  59. data/app/lib/biovision/components/privilege_handler.rb +77 -0
  60. data/app/lib/biovision/components/track_component.rb +9 -0
  61. data/app/lib/biovision/components/users/authentication.rb +47 -0
  62. data/app/lib/biovision/components/users/code_handler.rb +23 -0
  63. data/app/lib/biovision/components/users/profile_handler.rb +12 -0
  64. data/app/lib/biovision/components/users/registration_handler.rb +99 -0
  65. data/app/lib/biovision/components/users_component.rb +47 -0
  66. data/app/lib/biovision/notifiers/base_notifier.rb +69 -0
  67. data/app/lib/biovision/notifiers/socialization_notifier.rb +31 -0
  68. data/app/lib/biovision/notifiers/users_notifier.rb +15 -0
  69. data/app/models/agent.rb +35 -0
  70. data/app/models/biovision_component.rb +45 -0
  71. data/app/models/biovision_component_user.rb +21 -0
  72. data/app/models/browser.rb +34 -0
  73. data/app/models/code.rb +71 -0
  74. data/app/models/concerns/checkable.rb +22 -0
  75. data/app/models/concerns/flat_priority.rb +50 -0
  76. data/app/models/concerns/has_language.rb +10 -0
  77. data/app/models/concerns/has_owner.rb +22 -0
  78. data/app/models/concerns/has_simple_image.rb +18 -0
  79. data/app/models/concerns/has_track.rb +10 -0
  80. data/app/models/concerns/has_uuid.rb +12 -0
  81. data/app/models/concerns/meta_texts.rb +16 -0
  82. data/app/models/concerns/nested_priority.rb +58 -0
  83. data/app/models/concerns/required_unique_name.rb +16 -0
  84. data/app/models/concerns/required_unique_slug.rb +15 -0
  85. data/app/models/concerns/toggleable.rb +33 -0
  86. data/app/models/foreign_site.rb +34 -0
  87. data/app/models/foreign_user.rb +21 -0
  88. data/app/models/ip_address.rb +31 -0
  89. data/app/models/language.rb +31 -0
  90. data/app/models/login_attempt.rb +35 -0
  91. data/app/models/metric.rb +48 -0
  92. data/app/models/metric_value.rb +11 -0
  93. data/app/models/notification.rb +37 -0
  94. data/app/models/simple_image.rb +47 -0
  95. data/app/models/simple_image_tag.rb +30 -0
  96. data/app/models/simple_image_tag_image.rb +13 -0
  97. data/app/models/token.rb +96 -0
  98. data/app/models/user.rb +136 -0
  99. data/app/models/user_language.rb +15 -0
  100. data/app/uploaders/simple_image_uploader.rb +96 -0
  101. data/app/uploaders/user_image_uploader.rb +58 -0
  102. data/app/views/admin/agents/_nav_item.html.erb +6 -0
  103. data/app/views/admin/agents/entity/_in_list.html.erb +6 -0
  104. data/app/views/admin/agents/index.html.erb +13 -0
  105. data/app/views/admin/components/_list.html.erb +12 -0
  106. data/app/views/admin/components/entity/_links.html.erb +35 -0
  107. data/app/views/admin/components/entity/_section.html.erb +12 -0
  108. data/app/views/admin/components/index.html.erb +12 -0
  109. data/app/views/admin/components/links/_track.html.erb +2 -0
  110. data/app/views/admin/components/links/_users.html.erb +11 -0
  111. data/app/views/admin/components/privileges.html.erb +20 -0
  112. data/app/views/admin/components/privileges/_component_user.html.erb +17 -0
  113. data/app/views/admin/components/privileges/_links.html.erb +35 -0
  114. data/app/views/admin/components/privileges/_privilege_flag.html.erb +28 -0
  115. data/app/views/admin/components/privileges/_users.html.erb +23 -0
  116. data/app/views/admin/components/settings.html.erb +39 -0
  117. data/app/views/admin/components/settings/_new_parameter.html.erb +46 -0
  118. data/app/views/admin/components/settings/_parameters.html.erb +20 -0
  119. data/app/views/admin/components/settings/_setting.html.erb +18 -0
  120. data/app/views/admin/components/settings/_settings.html.erb +31 -0
  121. data/app/views/admin/components/show.html.erb +14 -0
  122. data/app/views/admin/index/index.html.erb +14 -0
  123. data/app/views/admin/ip_addresses/_nav_item.html.erb +6 -0
  124. data/app/views/admin/ip_addresses/entity/_in_list.html.erb +6 -0
  125. data/app/views/admin/ip_addresses/index.html.erb +13 -0
  126. data/app/views/admin/unauthorized.html.erb +19 -0
  127. data/app/views/authentication/_form.html.erb +40 -0
  128. data/app/views/authentication/failed.js.erb +3 -0
  129. data/app/views/authentication/new.html.erb +21 -0
  130. data/app/views/index/index.html.erb +0 -0
  131. data/app/views/layouts/admin.html.erb +23 -0
  132. data/app/views/layouts/admin/_breadcrumbs.html.erb +8 -0
  133. data/app/views/layouts/admin/_footer.html.erb +10 -0
  134. data/app/views/layouts/admin/_header.html.erb +18 -0
  135. data/app/views/layouts/admin/header/_logo.html.erb +3 -0
  136. data/app/views/layouts/application/_footer.html.erb +8 -0
  137. data/app/views/layouts/application/_header.html.erb +9 -0
  138. data/app/views/layouts/application/header/_authentication.html.erb +13 -0
  139. data/app/views/my/index/index.html.erb +0 -0
  140. data/app/views/my/profiles/closed.html.erb +12 -0
  141. data/app/views/my/profiles/new.html.erb +17 -0
  142. data/app/views/my/profiles/new/_form.html.erb +147 -0
  143. data/app/views/shared/_breadcrumbs.html.erb +8 -0
  144. data/app/views/shared/_cookie_notification.html.erb +4 -0
  145. data/app/views/shared/_flash_messages.html.erb +7 -0
  146. data/app/views/shared/_meta_texts.html.erb +31 -0
  147. data/app/views/shared/_nothing_found.html.erb +1 -0
  148. data/app/views/shared/_pagination.jbuilder +15 -0
  149. data/app/views/shared/admin/_list.html.erb +19 -0
  150. data/app/views/shared/admin/_list_with_priority.html.erb +19 -0
  151. data/app/views/shared/admin/_toggleable.html.erb +8 -0
  152. data/app/views/shared/entity/_list_of_errors.html.erb +7 -0
  153. data/app/views/shared/forms/errors.js.erb +5 -0
  154. data/config/initializers/carrierwave.rb +27 -0
  155. data/config/initializers/pluralization.rb +2 -0
  156. data/config/locales/biovision-ru.yml +90 -0
  157. data/config/locales/components-ru.yml +81 -0
  158. data/config/locales/track-ru.yml +40 -0
  159. data/config/locales/users-ru.yml +130 -0
  160. data/config/routes.rb +75 -0
  161. data/db/migrate/20191228000000_create_biovision_components.rb +72 -0
  162. data/db/migrate/20200224000000_create_track_component.rb +59 -0
  163. data/db/migrate/20200224000010_create_users_component.rb +189 -0
  164. data/db/migrate/20200404000000_create_simple_images.rb +54 -0
  165. data/lib/biovision.rb +9 -0
  166. data/lib/biovision/base_methods.rb +167 -0
  167. data/lib/biovision/engine.rb +40 -0
  168. data/lib/biovision/version.rb +5 -0
  169. data/lib/tasks/biovision_tasks.rake +4 -0
  170. metadata +392 -0
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Uploader for user images
4
+ class UserImageUploader < CarrierWave::Uploader::Base
5
+ include CarrierWave::MiniMagick
6
+ include CarrierWave::BombShelter
7
+
8
+ storage :file
9
+
10
+ def max_pixel_dimensions
11
+ [4000, 4000]
12
+ end
13
+
14
+ # Override the directory where uploaded files will be stored.
15
+ # This is a sensible default for uploaders that are meant to be mounted:
16
+ def store_dir
17
+ uuid = model&.uuid.to_s
18
+ slug = "#{uuid[0..2]}/#{uuid[3..5]}/#{uuid[6..7]}/#{uuid}"
19
+
20
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{slug}"
21
+ end
22
+
23
+ def default_url(*)
24
+ ActionController::Base.helpers.asset_path('biovision/placeholders/user.svg')
25
+ end
26
+
27
+ process :auto_orient
28
+
29
+ def auto_orient
30
+ manipulate! do |image|
31
+ image.tap(&:auto_orient)
32
+ end
33
+ end
34
+
35
+ version :hd do
36
+ resize_to_fit(1280, 1280)
37
+ end
38
+
39
+ version :large, from_version: :hd do
40
+ resize_to_fit(640, 640)
41
+ end
42
+
43
+ version :profile, from_version: :large do
44
+ resize_to_fit(320, 320)
45
+ end
46
+
47
+ version :preview, from_version: :profile do
48
+ resize_to_fit(160, 160)
49
+ end
50
+
51
+ version :tiny, from_version: :preview do
52
+ resize_to_fit(48, 48)
53
+ end
54
+
55
+ def extension_whitelist
56
+ %w[jpg jpeg png]
57
+ end
58
+ end
@@ -0,0 +1,6 @@
1
+ <div>
2
+ <%= link_to t('.text'), admin_agents_path %>
3
+ </div>
4
+ <div class="description">
5
+ <%= t('.description') %>
6
+ </div>
@@ -0,0 +1,6 @@
1
+ <div class="data">
2
+ <div class="truncate"><%= entity.name %></div>
3
+ <div class="secondary info">
4
+ <%= t(:object_count, count: entity.object_count) %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,13 @@
1
+ <% content_for :meta_title, t('.title', page: current_page) %>
2
+ <% content_for :breadcrumbs do %>
3
+ <%= admin_biovision_component_link(component_handler.component) %>
4
+ <span><%= t('admin.agents.nav_item.text') %></span>
5
+ <% end %>
6
+
7
+ <article>
8
+ <h1><%= t('.heading') %></h1>
9
+
10
+ <%= paginate @collection %>
11
+ <%= render partial: 'shared/admin/list', locals: { collection: @collection } %>
12
+ <%= paginate @collection %>
13
+ </article>
@@ -0,0 +1,12 @@
1
+ <% collection.each do |component| %>
2
+ <%
3
+ handler = Biovision::Components::BaseComponent.handler(component, current_user)
4
+ next if handler.component.nil? || !handler.allow?
5
+ %>
6
+ <%=
7
+ render(
8
+ partial: 'admin/components/entity/section',
9
+ locals: { component: component, handler: handler }
10
+ )
11
+ %>
12
+ <% end %>
@@ -0,0 +1,35 @@
1
+ <nav class="biovision-component-nav">
2
+ <% if handler.allow?('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
+ <% if handler.administrator? %>
15
+ <%=
16
+ link_to(
17
+ t('admin.components.privileges.nav_text'),
18
+ admin_component_privileges_path(slug: handler.slug),
19
+ class: 'privileges'
20
+ )
21
+ %>
22
+ <% end %>
23
+
24
+ <% prefix = 'admin/components/links/' %>
25
+ <% if lookup_context.exists?("#{prefix}_#{handler.slug}") %>
26
+ <ul class="biovision-component-links">
27
+ <%=
28
+ render(
29
+ partial: "#{prefix}#{handler.slug}",
30
+ locals: { handler: handler }
31
+ )
32
+ %>
33
+ </ul>
34
+ <% end %>
35
+ </nav>
@@ -0,0 +1,12 @@
1
+ <section class="biovision-component <%= component.slug %>">
2
+ <header>
3
+ <h2><%= handler.name %></h2>
4
+ </header>
5
+
6
+ <%=
7
+ render(
8
+ partial: 'admin/components/entity/links',
9
+ locals: { handler: handler }
10
+ )
11
+ %>
12
+ </section>
@@ -0,0 +1,12 @@
1
+ <% content_for :meta_title, t('.title') %>
2
+ <% content_for :breadcrumbs do %>
3
+ <span><%= t('.nav_text') %></span>
4
+ <% end %>
5
+
6
+ <article>
7
+ <h1><%= t('.heading') %></h1>
8
+
9
+ <%=
10
+ render partial: 'admin/components/list', locals: { collection: @collection }
11
+ %>
12
+ </article>
@@ -0,0 +1,2 @@
1
+ <li><%= render 'admin/agents/nav_item' %></li>
2
+ <li><%= render 'admin/ip_addresses/nav_item' %></li>
@@ -0,0 +1,11 @@
1
+ <% if handler.allow?('view', 'edit') %>
2
+ <!-- <li><%#= render 'admin/users/nav_item' %></li>-->
3
+ <!-- <li><%#= render 'admin/foreign_users/nav_item' %></li>-->
4
+ <% end %>
5
+ <% if handler.administrator? %>
6
+ <!-- <li><%#= render 'admin/login_attempts/nav_item' %></li>-->
7
+ <!-- <li><%#= render 'admin/tokens/nav_item' %></li>-->
8
+ <% end %>
9
+ <% if handler.allow?('manage_codes') %>
10
+ <!-- <li><%#= render 'admin/codes/nav_item' %></li>-->
11
+ <% end %>
@@ -0,0 +1,20 @@
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
+ <%=
12
+ render(
13
+ partial: 'admin/components/privileges/users',
14
+ locals: {
15
+ collection: @handler.component.privileges,
16
+ handler: @handler
17
+ }
18
+ )
19
+ %>
20
+ </article>
@@ -0,0 +1,17 @@
1
+ <figure class="image">
2
+ <%= user_image_small(entity.user) %>
3
+ </figure>
4
+ <div class="data">
5
+ <div><%= admin_user_link(entity.user) %></div>
6
+ <div>
7
+ <%=
8
+ render(
9
+ partial: 'admin/components/privileges/links',
10
+ locals: {
11
+ handler: handler,
12
+ entity: entity
13
+ }
14
+ )
15
+ %>
16
+ </div>
17
+ </div>
@@ -0,0 +1,35 @@
1
+ <ul class="entity-links">
2
+ <li>
3
+ <% element_id = "component_administrator_#{handler.slug}_#{entity.user_id}" %>
4
+ <%=
5
+ check_box_tag(
6
+ 'user_id',
7
+ entity.user_id,
8
+ entity.administrator?,
9
+ data: {
10
+ url: admin_component_administrators_path(slug: handler.slug, user_id: entity.user_id)
11
+ },
12
+ id: element_id
13
+ )
14
+ %>
15
+ <%= label_tag(element_id, t('activerecord.attributes.biovision_component_user.administrator')) %>
16
+ </li>
17
+ <%
18
+ privilege_names = handler.class.privilege_names
19
+ privilege_names.unshift('settings') if handler.use_settings?
20
+ %>
21
+ <% privilege_names.each do |privilege_slug| %>
22
+ <li>
23
+ <%=
24
+ render(
25
+ partial: 'admin/components/privileges/privilege_flag',
26
+ locals: {
27
+ entity: entity,
28
+ handler: handler,
29
+ slug: privilege_slug
30
+ }
31
+ )
32
+ %>
33
+ </li>
34
+ <% end %>
35
+ </ul>
@@ -0,0 +1,28 @@
1
+ <% element_id = "component_privilege_#{slug}_#{entity.user_id}" %>
2
+ <%=
3
+ check_box_tag(
4
+ 'user_id',
5
+ entity.user_id,
6
+ Array(entity.data['privileges']).include?(slug),
7
+ data: {
8
+ url: admin_component_privilege_path(
9
+ privilege_slug: slug,
10
+ slug: handler.slug,
11
+ user_id: entity.user_id
12
+ )
13
+ },
14
+ id: element_id
15
+ )
16
+ %>
17
+ <%=
18
+ label_tag(
19
+ element_id,
20
+ t(
21
+ "biovision.components.#{handler.slug}.privileges.#{slug}",
22
+ default: [
23
+ "biovision.components.common.privileges.#{slug}".to_sym,
24
+ slug
25
+ ]
26
+ )
27
+ )
28
+ %>
@@ -0,0 +1,23 @@
1
+ <section>
2
+ <h2><%= t('.heading') %></h2>
3
+
4
+ <% if collection.any? %>
5
+ <ul class="list-of-entities">
6
+ <% collection.each do |entity| %>
7
+ <li data-id="<%= entity.id %>">
8
+ <%=
9
+ render(
10
+ partial: 'admin/components/privileges/component_user',
11
+ locals: {
12
+ handler: handler,
13
+ entity: entity
14
+ }
15
+ )
16
+ %>
17
+ </li>
18
+ <% end %>
19
+ </ul>
20
+ <% else %>
21
+ <%= render 'shared/nothing_found' %>
22
+ <% end %>
23
+ </section>
@@ -0,0 +1,39 @@
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
+ <%=
12
+ render(
13
+ partial: 'admin/components/settings/settings',
14
+ locals: {
15
+ handler: @handler,
16
+ settings: @handler.component.settings
17
+ }
18
+ )
19
+ %>
20
+
21
+ <% if @handler.use_parameters? %>
22
+ <%=
23
+ render(
24
+ partial: 'admin/components/settings/parameters',
25
+ locals: {
26
+ handler: @handler,
27
+ parameters: @handler.component.parameters
28
+ }
29
+ )
30
+ %>
31
+
32
+ <%=
33
+ render(
34
+ partial: 'admin/components/settings/new_parameter',
35
+ locals: { handler: @handler }
36
+ )
37
+ %>
38
+ <% end %>
39
+ </article>
@@ -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>
@@ -0,0 +1,18 @@
1
+ <%
2
+ element_id = "setting-#{key}"
3
+ element_name = "component[settings][#{key}]"
4
+ key_name = t("biovision.components.#{slug}.settings.#{key}", default: key)
5
+ %>
6
+ <div>
7
+ <% if value.is_a?(Numeric) %>
8
+ <%= label_tag(element_id, key_name) %>
9
+ <%= number_field_tag(element_name, value, class: 'input-text', id: element_id) %>
10
+ <% elsif [true, false].include?(value) %>
11
+ <%= hidden_field_tag(element_name, '0', id: nil) %>
12
+ <%= check_box_tag(element_name, '1', value, id: element_id) %>
13
+ <%= label_tag(element_id, key_name) %>
14
+ <% else %>
15
+ <%= label_tag(element_id, key_name) %>
16
+ <%= text_field_tag(element_name, value, class: 'input-text', id: element_id) %>
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,31 @@
1
+ <% if settings.any? %>
2
+ <section class="biovision-component-settings">
3
+ <h2><%= t('.heading') %></h2>
4
+
5
+ <%=
6
+ form_with(
7
+ url: admin_component_settings_path(slug: handler.slug),
8
+ method: :patch,
9
+ local: true
10
+ ) do
11
+ %>
12
+ <div class="fields">
13
+ <% settings.each do |key, value| %>
14
+ <%=
15
+ render(
16
+ partial: 'admin/components/settings/setting',
17
+ locals: {
18
+ slug: handler.slug,
19
+ key: key,
20
+ value: value
21
+ }
22
+ )
23
+ %>
24
+ <% end %>
25
+ </div>
26
+ <div class="buttons">
27
+ <%= button_tag(t(:update), type: :submit, class: 'button-save') %>
28
+ </div>
29
+ <% end %>
30
+ </section>
31
+ <% end %>