biovision-base 0.9.171227 → 0.11.180127

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 (124) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/biovision/base/biovision-sliders.js +3 -17
  3. data/app/assets/javascripts/biovision/base/biovision.js +17 -5
  4. data/app/assets/stylesheets/biovision/base/admin.scss +0 -12
  5. data/app/assets/stylesheets/biovision/base/biovision.scss +2 -179
  6. data/app/assets/stylesheets/biovision/base/default_admin.scss +0 -1
  7. data/app/controllers/admin/privileges_controller.rb +0 -6
  8. data/app/controllers/admin/users_controller.rb +2 -2
  9. data/app/models/editable_page.rb +41 -3
  10. data/app/models/feedback_request.rb +1 -0
  11. data/app/models/language.rb +49 -0
  12. data/app/models/privilege.rb +16 -16
  13. data/app/models/user.rb +3 -2
  14. data/app/models/user_language.rb +6 -0
  15. data/app/models/user_privilege.rb +3 -14
  16. data/app/views/admin/agents/entity/_in_list.html.erb +1 -1
  17. data/app/views/admin/agents/index.html.erb +1 -1
  18. data/app/views/admin/agents/show.html.erb +2 -2
  19. data/app/views/admin/browsers/entity/_in_list.html.erb +2 -1
  20. data/app/views/admin/browsers/index.html.erb +1 -1
  21. data/app/views/admin/browsers/show.html.erb +2 -2
  22. data/app/views/admin/codes/index.html.erb +1 -1
  23. data/app/views/admin/codes/show.html.erb +1 -1
  24. data/app/views/admin/editable_pages/index.html.erb +1 -1
  25. data/app/views/admin/editable_pages/show.html.erb +1 -1
  26. data/app/views/admin/index/_biovision_base.html.erb +2 -1
  27. data/app/views/admin/media_files/show.html.erb +0 -1
  28. data/app/views/admin/metrics/index.html.erb +1 -1
  29. data/app/views/admin/metrics/show.html.erb +1 -1
  30. data/app/views/admin/privilege_groups/index.html.erb +1 -1
  31. data/app/views/admin/privilege_groups/show.html.erb +1 -1
  32. data/app/views/admin/privileges/entity/_in_list.html.erb +1 -1
  33. data/app/views/admin/privileges/index.html.erb +1 -1
  34. data/app/views/admin/privileges/show.html.erb +2 -2
  35. data/app/views/admin/privileges/users.html.erb +1 -1
  36. data/app/views/admin/stored_values/index.html.erb +1 -1
  37. data/app/views/admin/tokens/entity/_in_list.html.erb +1 -1
  38. data/app/views/admin/tokens/index.html.erb +1 -1
  39. data/app/views/admin/tokens/show.html.erb +2 -2
  40. data/app/views/admin/users/codes.html.erb +1 -1
  41. data/app/views/admin/users/entity/_in_list.html.erb +2 -1
  42. data/app/views/admin/users/entity/_privilege.html.erb +1 -1
  43. data/app/views/admin/users/index.html.erb +1 -1
  44. data/app/views/admin/users/show.html.erb +4 -4
  45. data/app/views/admin/users/tokens.html.erb +1 -1
  46. data/app/views/agents/edit.html.erb +1 -1
  47. data/app/views/agents/new.html.erb +1 -1
  48. data/app/views/application/error.html.erb +1 -1
  49. data/app/views/browsers/edit.html.erb +1 -1
  50. data/app/views/browsers/new.html.erb +1 -1
  51. data/app/views/codes/edit.html.erb +1 -1
  52. data/app/views/codes/new.html.erb +1 -1
  53. data/app/views/editable_pages/edit.html.erb +1 -1
  54. data/app/views/editable_pages/new.html.erb +1 -1
  55. data/app/views/errors/error.html.erb +1 -1
  56. data/app/views/feedback_requests/_form.html.erb +1 -3
  57. data/app/views/feedback_requests/create.js.erb +2 -2
  58. data/app/views/layouts/admin/_footer.html.erb +1 -1
  59. data/app/views/layouts/admin/_header.html.erb +3 -3
  60. data/app/views/metrics/edit.html.erb +1 -1
  61. data/app/views/privilege_groups/edit.html.erb +1 -1
  62. data/app/views/privilege_groups/new.html.erb +1 -1
  63. data/app/views/privileges/edit.html.erb +1 -1
  64. data/app/views/privileges/new.html.erb +1 -1
  65. data/app/views/shared/forms/_default_ajax_handler.html.erb +2 -0
  66. data/app/views/stored_values/edit.html.erb +1 -1
  67. data/app/views/stored_values/new.html.erb +1 -1
  68. data/app/views/tokens/edit.html.erb +1 -1
  69. data/app/views/tokens/new.html.erb +1 -1
  70. data/app/views/users/edit.html.erb +1 -1
  71. data/config/locales/common-en.yml +10 -2
  72. data/config/locales/common-ru.yml +10 -2
  73. data/config/locales/editable-pages-en.yml +76 -0
  74. data/config/locales/editable-pages-ru.yml +1 -0
  75. data/config/locales/feedback-en.yml +1 -0
  76. data/config/locales/feedback-ru.yml +1 -0
  77. data/config/locales/media-en.yml +92 -0
  78. data/config/locales/users-ru.yml +1 -0
  79. data/config/routes.rb +0 -10
  80. data/db/migrate/20170228000000_create_languages.rb +22 -0
  81. data/db/migrate/20170302000001_create_users.rb +2 -1
  82. data/db/migrate/20170302000101_create_privileges.rb +7 -6
  83. data/db/migrate/20170302000102_create_user_privileges.rb +1 -1
  84. data/db/migrate/20170302000103_create_privilege_groups.rb +0 -1
  85. data/db/migrate/20170302000104_create_privilege_group_privileges.rb +0 -4
  86. data/db/migrate/20170320000000_create_editable_pages.rb +12 -3
  87. data/db/migrate/20171025222222_add_new_fields_171026.rb +0 -8
  88. data/db/migrate/20171211000000_create_feedback_requests.rb +1 -0
  89. data/db/migrate/20171223333333_amend_foreign_keys.rb +1 -3
  90. data/db/migrate/20180117151515_add_language_to_models.rb +25 -0
  91. data/db/migrate/20180117160000_create_user_languages.rb +17 -0
  92. data/lib/biovision/base/base_methods.rb +1 -1
  93. data/lib/biovision/base/engine.rb +0 -1
  94. data/lib/biovision/base/privilege_methods.rb +3 -21
  95. data/lib/biovision/base/version.rb +1 -1
  96. metadata +13 -34
  97. data/app/assets/images/biovision/base/placeholders/region_image.svg +0 -1
  98. data/app/assets/stylesheets/biovision/base/regions.scss +0 -9
  99. data/app/controllers/admin/regions_controller.rb +0 -28
  100. data/app/controllers/regions_controller.rb +0 -73
  101. data/app/helpers/biovision_regions_helper.rb +0 -22
  102. data/app/models/central_region.rb +0 -53
  103. data/app/models/region.rb +0 -110
  104. data/app/uploaders/header_image_uploader.rb +0 -50
  105. data/app/uploaders/region_image_uploader.rb +0 -53
  106. data/app/views/admin/agents/_toggleable.html.erb +0 -7
  107. data/app/views/admin/browsers/_toggleable.html.erb +0 -7
  108. data/app/views/admin/index/dashboard/_biovision_region.html.erb +0 -8
  109. data/app/views/admin/privileges/_toggleable.html.erb +0 -7
  110. data/app/views/admin/privileges/entity/_region.html.erb +0 -12
  111. data/app/views/admin/privileges/regions.jbuilder +0 -10
  112. data/app/views/admin/regions/_nav_item.html.erb +0 -2
  113. data/app/views/admin/regions/_toggleable.html.erb +0 -7
  114. data/app/views/admin/regions/entity/_in_list.html.erb +0 -32
  115. data/app/views/admin/regions/index.html.erb +0 -22
  116. data/app/views/admin/regions/show.html.erb +0 -95
  117. data/app/views/admin/tokens/_toggleable.html.erb +0 -7
  118. data/app/views/admin/users/_toggleable.html.erb +0 -7
  119. data/app/views/regions/_form.html.erb +0 -73
  120. data/app/views/regions/edit.html.erb +0 -20
  121. data/app/views/regions/new.html.erb +0 -17
  122. data/config/locales/regions-ru.yml +0 -62
  123. data/db/migrate/20170301000201_create_regions.rb +0 -35
  124. data/lib/tasks/regions.rake +0 -105
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bb51fe50abffa84bf05497d98302f8024cb97c8174dd1107c209405cdb36bd8
4
- data.tar.gz: 18998efeae8acc7888f2a4942117a233c346e66d3591f845938976ee94f3231e
3
+ metadata.gz: 8f9fa1898ab0825170025cc1c9d2c4409672fae0124dfd8eb292fa20b5d5efb0
4
+ data.tar.gz: f9e2d769bd9ed60b43021af0c8f315a21ec381b2e258e650a26b638367a61005
5
5
  SHA512:
6
- metadata.gz: 14e334effd38045f5a5b0f69f08587d8910ad9b5d64a409b802005ebcaa814e98b35153ce36e74c289463d5f6e4bd383d525063ec6e87cc0dd0c3aafcf71c939
7
- data.tar.gz: a00cbf51d51d0fbb5dc51028daab2909bc93ce74ec2a57ca6b633d7ef336b2d7a518b8afadfdfd5e09a3126f2d95e90e5502e7717e76498befafad15074ee393
6
+ metadata.gz: 193adfd352a265199c0d5376068279a47640b8bc5c1e43f197b251e6bea7c7d3a809a0003946d2a9b693c6c37efb13c26f558e9aa094aabebb14b84ff1021f80
7
+ data.tar.gz: 0c97feb7d31796b88bb95c92ac634adf37d9ac57e3aecd76797bcbb685f58fdfce60126dd4c0e489752147c38bfa142b1456ba7e1fc11bec32f0aadc61e58790
@@ -1,10 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  document.addEventListener('DOMContentLoaded', function () {
4
- const sliders = document.querySelectorAll('.biovision-slider');
5
4
  const sliding = {
6
5
  opacity: {
7
- left: function(list, delay) {
6
+ left: function (list, delay) {
8
7
  const li = list.querySelector('li:last-of-type');
9
8
  const restore_opacity = function () {
10
9
  li.style.opacity = '';
@@ -14,7 +13,7 @@ document.addEventListener('DOMContentLoaded', function () {
14
13
  list.prepend(li);
15
14
  setTimeout(restore_opacity, delay);
16
15
  },
17
- right: function(list, delay) {
16
+ right: function (list, delay) {
18
17
  const li = list.querySelector('li:first-of-type');
19
18
  const move = function () {
20
19
  list.append(li);
@@ -27,7 +26,7 @@ document.addEventListener('DOMContentLoaded', function () {
27
26
  }
28
27
  };
29
28
 
30
- Array.prototype.slice.call(sliders).forEach(function(slider) {
29
+ document.querySelectorAll('.biovision-slider').forEach(function (slider) {
31
30
  const delay = slider.getAttribute('data-delay') || 125;
32
31
  const list = slider.querySelector('ul');
33
32
  let type = slider.getAttribute('data-type') || 'opacity';
@@ -49,16 +48,3 @@ document.addEventListener('DOMContentLoaded', function () {
49
48
  slider.querySelector('button.next').addEventListener('click', slide_right);
50
49
  });
51
50
  });
52
-
53
- /*
54
-
55
- <script>
56
- 'use strict';
57
-
58
- document.addEventListener('DOMContentLoaded', function () {
59
- const slider = document.getElementById('crew-slider');
60
- });
61
- </script>
62
-
63
-
64
- */
@@ -107,7 +107,7 @@ const Biovision = {
107
107
  console.log(response);
108
108
  }
109
109
  },
110
- transliterate: function(input) {
110
+ transliterate: function (input) {
111
111
  const char_map = {
112
112
  'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd',
113
113
  'е': 'e', 'ё': 'yo', 'ж': 'zh', 'з': 'z', 'и': 'i',
@@ -205,7 +205,7 @@ document.addEventListener('DOMContentLoaded', function () {
205
205
  const url = element.parentNode.getAttribute('data-url');
206
206
  const parameter = element.getAttribute('data-flag');
207
207
 
208
- const on_success = function() {
208
+ const on_success = function () {
209
209
  const response = JSON.parse(this.responseText);
210
210
 
211
211
  if (response.hasOwnProperty('data')) {
@@ -224,7 +224,7 @@ document.addEventListener('DOMContentLoaded', function () {
224
224
  }
225
225
  };
226
226
 
227
- const on_failure = function() {
227
+ const on_failure = function () {
228
228
  element.className = 'unknown';
229
229
  Biovision.handle_ajax_failure.call(this);
230
230
  };
@@ -246,7 +246,7 @@ document.addEventListener('DOMContentLoaded', function () {
246
246
  let item = element.closest('li[data-number]');
247
247
 
248
248
  if (parseInt(item.getAttribute('data-number')) + delta > 0) {
249
- const on_success = function() {
249
+ const on_success = function () {
250
250
  const response = JSON.parse(this.responseText);
251
251
 
252
252
  if (response.hasOwnProperty('data')) {
@@ -276,7 +276,7 @@ document.addEventListener('DOMContentLoaded', function () {
276
276
  } else {
277
277
  return 0;
278
278
  }
279
- }).forEach(function(item) {
279
+ }).forEach(function (item) {
280
280
  container.appendChild(item);
281
281
  });
282
282
  }
@@ -337,6 +337,18 @@ document.addEventListener('DOMContentLoaded', function () {
337
337
  });
338
338
  });
339
339
 
340
+ document.querySelectorAll('form[data-remote]').forEach(function (form) {
341
+ const button = form.querySelector('button[type=submit]');
342
+
343
+ form.addEventListener('ajax:before', function () {
344
+ button.disabled = true;
345
+ });
346
+
347
+ form.addEventListener('ajax:complete', function () {
348
+ button.disabled = false;
349
+ });
350
+ });
351
+
340
352
  if (typeof jQuery !== 'undefined') {
341
353
  jQuery.ajaxSetup({
342
354
  headers: {
@@ -204,18 +204,6 @@ nav.admin-breadcrumbs {
204
204
  ul {
205
205
  border-left: $border-primary;
206
206
  margin: .8rem 0 0 2.4rem;
207
-
208
- &.regions {
209
- margin: 0 0 0 1.2rem;
210
- padding: 0;
211
- border: none;
212
-
213
- > li {
214
- list-style: none;
215
- margin: 0;
216
- padding: 0;
217
- }
218
- }
219
207
  }
220
208
  }
221
209
 
@@ -8,183 +8,6 @@ textarea {
8
8
  font-size: $font-size-normal;
9
9
  }
10
10
 
11
- article.entity-page {
12
- position: relative;
13
-
14
- > nav {
15
- ul {
16
- margin: 1.6rem 0;
17
- padding: 0;
18
-
19
- li {
20
- list-style: none;
21
- display: inline-block;
22
- margin: 0 1.6rem;
23
-
24
- a {
25
- @include button-nav;
26
- }
27
- }
28
- }
29
- }
30
-
31
- table {
32
- border-spacing: 0;
33
- margin: 1.6rem;
34
-
35
- figure {
36
- margin: 0;
37
- padding: 0;
38
- text-align: center;
39
-
40
- img {
41
- max-height: 32rem;
42
- max-width: 32rem;
43
- }
44
- }
45
-
46
- tbody {
47
- tr:nth-of-type(even) {
48
- background: $row-background-even;
49
- }
50
-
51
- tr:nth-of-type(odd) {
52
- background: $row-background-odd;
53
- }
54
-
55
- th {
56
- padding: .4rem .8rem;
57
- text-align: right;
58
- }
59
-
60
- td {
61
- padding: .4rem .8rem;
62
-
63
- &[colspan]:first-letter {
64
- text-transform: capitalize;
65
- }
66
-
67
- figure {
68
- text-align: center;
69
- }
70
- }
71
- }
72
- }
73
-
74
- form {
75
- table {
76
- th {
77
- font-weight: normal;
78
- line-height: 2.8rem;
79
- text-align: right;
80
- vertical-align: top;
81
-
82
- &[colspan] {
83
- border-top: .1rem solid $text-color-secondary;
84
- font-weight: bold;
85
- padding-top: 1.6rem;
86
- text-align: center;
87
- }
88
- }
89
-
90
- input[type=text]:not([size]), input[type=url], textarea {
91
- width: calc(100% - 1rem);
92
- }
93
-
94
- tfoot {
95
- td {
96
- padding: .8rem 0;
97
- text-align: center;
98
- }
99
- }
100
-
101
- .flags {
102
- text-align: left;
103
-
104
- ul {
105
- margin: 0;
106
- padding: 0;
107
-
108
- > li {
109
- list-style: none;
110
- margin: 0;
111
- padding: 0;
112
- }
113
- }
114
-
115
- label {
116
- font-weight: normal;
117
- }
118
- }
119
-
120
- .tree {
121
- text-align: left;
122
-
123
- > ul {
124
- margin: 0;
125
- padding: 0;
126
-
127
- li {
128
- list-style: none;
129
- margin: 0;
130
- padding: 0;
131
-
132
- label {
133
- font-weight: normal;
134
- }
135
-
136
- ul {
137
- margin: 0 0 0 2rem;
138
- padding: 0;
139
- }
140
- }
141
- }
142
- }
143
- }
144
-
145
- .fields {
146
- figure {
147
- margin: 0 auto;
148
- padding: 0;
149
- max-width: 32rem;
150
- text-align: center;
151
-
152
- img {
153
- max-width: 100%;
154
- }
155
- }
156
-
157
- > div {
158
- background: $row_background_odd;
159
- padding: .4rem 0;
160
-
161
- &:nth-of-type(even) {
162
- background: $row_background_even;
163
- }
164
-
165
- > div {
166
- padding: 0 .4rem;
167
- }
168
- }
169
-
170
- ul.flags {
171
- margin: 0;
172
- padding: 0;
173
-
174
- li {
175
- list-style: none;
176
- margin: 0;
177
- padding: .4rem;
178
- }
179
- }
180
-
181
- input:not([type=checkbox]):not([size]), textarea {
182
- width: calc(100% - 1rem);
183
- }
184
- }
185
- }
186
- }
187
-
188
11
  ul.actions {
189
12
  align-items: center;
190
13
  background: #fff;
@@ -268,9 +91,10 @@ ul.actions {
268
91
  }
269
92
 
270
93
  .image {
271
- flex-basis: 8rem;
94
+ flex: none;
272
95
  margin: 0 .8rem 0 0;
273
96
  text-align: center;
97
+ width: 8rem;
274
98
 
275
99
  img {
276
100
  max-height: 8rem;
@@ -284,7 +108,6 @@ ul.actions {
284
108
 
285
109
  .data {
286
110
  flex: 1;
287
- max-width: 100%;
288
111
  position: relative;
289
112
 
290
113
  .info {
@@ -32,7 +32,6 @@ $link-color-hover: rgb(255, 77, 20) !default;
32
32
  @import "biovision/base/buttons";
33
33
  @import "biovision/base/biovision";
34
34
  @import "biovision/base/admin";
35
- @import "biovision/base/regions";
36
35
  @import "biovision/base/tootik";
37
36
  @import "biovision/base/message-box";
38
37
  @import "biovision/base/pagination";
@@ -20,12 +20,6 @@ class Admin::PrivilegesController < AdminController
20
20
  @collection = @entity.users.page_for_administration(current_page)
21
21
  end
22
22
 
23
- # get /admin/privileges/:id/regions
24
- def regions
25
- @user = User.find_by(id: params[:user_id])
26
- @collection = Region.visible.for_tree(params[:parent_id]).reject { |r| @entity.has_user?(@user, r) }
27
- end
28
-
29
23
  protected
30
24
 
31
25
  def restrict_access
@@ -31,14 +31,14 @@ class Admin::UsersController < AdminController
31
31
 
32
32
  # put /admin/users/:id/privileges/:privilege_id
33
33
  def grant_privilege
34
- @privilege.grant(@entity, Region.find_by(id: params[:region_id]))
34
+ @privilege.grant(@entity, params[:region_id])
35
35
 
36
36
  render json: { data: { user_privilege_ids: @entity.user_privilege_ids } }
37
37
  end
38
38
 
39
39
  # delete /admin/users/:id/privileges/:privilege_id
40
40
  def revoke_privilege
41
- @privilege.revoke(@entity, Region.find_by(id: params[:region_id]))
41
+ @privilege.revoke(@entity, params[:region_id])
42
42
 
43
43
  render json: { data: { user_privilege_ids: @entity.user_privilege_ids } }
44
44
  end
@@ -1,23 +1,36 @@
1
1
  class EditablePage < ApplicationRecord
2
2
  include RequiredUniqueName
3
- include RequiredUniqueSlug
4
3
 
5
4
  NAME_LIMIT = 100
6
5
  SLUG_LIMIT = 100
7
6
  META_LIMIT = 250
8
7
  BODY_LIMIT = 65535
9
8
 
9
+ PRIORITY_RANGE = (1..999)
10
+
10
11
  mount_uploader :image, EditablePageImageUploader
11
12
 
13
+ belongs_to :language, optional: true
14
+
15
+ before_validation { self.slug = slug.strip unless slug.nil? }
16
+ before_validation :normalize_priority
17
+
18
+ validates_presence_of :slug
12
19
  validates_length_of :name, maximum: NAME_LIMIT
13
20
  validates_length_of :slug, maximum: SLUG_LIMIT
14
21
  validates_length_of :title, maximum: META_LIMIT
15
22
  validates_length_of :keywords, maximum: META_LIMIT
16
23
  validates_length_of :description, maximum: META_LIMIT
17
- # validates_length_of :body, maximum: BODY_LIMIT
24
+ validates_length_of :body, maximum: BODY_LIMIT
25
+ validates_uniqueness_of :slug, scope: [:language_id]
26
+
27
+ scope :ordered_by_slug, -> { order('slug asc') }
28
+ scope :with_slug_like, ->(slug) { where('slug ilike ?', "%#{slug}%") unless slug.blank? }
29
+ scope :with_slug, ->(slug) { where('lower(slug) = lower(?)', slug) unless slug.blank? }
30
+ scope :siblings, ->(s) { where(language: s.language, nav_group: s.nav_group) }
18
31
 
19
32
  def self.page_for_administration
20
- ordered_by_name
33
+ ordered_by_slug
21
34
  end
22
35
 
23
36
  def self.entity_parameters
@@ -27,4 +40,29 @@ class EditablePage < ApplicationRecord
27
40
  def self.creation_parameters
28
41
  entity_parameters + %i(slug)
29
42
  end
43
+
44
+ # @param [Integer] delta
45
+ def change_priority(delta)
46
+ new_priority = priority + delta
47
+ adjacent = self.class.siblings(self).find_by(priority: new_priority)
48
+ if adjacent.is_a?(self.class) && (adjacent.id != id)
49
+ adjacent.update!(priority: priority)
50
+ end
51
+ update(priority: new_priority)
52
+
53
+ self.class.siblings(self).map { |e| [e.id, e.priority] }.to_h
54
+ end
55
+
56
+ private
57
+
58
+ def set_next_priority
59
+ if id.nil? && priority == 1
60
+ self.priority = self.class.siblings(self).maximum(:priority).to_i + 1
61
+ end
62
+ end
63
+
64
+ def normalize_priority
65
+ self.priority = PRIORITY_RANGE.first if priority < PRIORITY_RANGE.first
66
+ self.priority = PRIORITY_RANGE.last if priority > PRIORITY_RANGE.last
67
+ end
30
68
  end