biovision-base 0.8.170916 → 0.8.171029

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/biovision/base/placeholders/image.svg +3 -18
  3. data/app/assets/javascripts/biovision/base/biovision.js +228 -124
  4. data/app/assets/stylesheets/biovision/base/admin.scss +8 -7
  5. data/app/assets/stylesheets/biovision/base/biovision.scss +1 -1
  6. data/app/assets/stylesheets/biovision/base/default.scss +6 -3
  7. data/app/assets/stylesheets/biovision/base/default_admin.scss +30 -0
  8. data/app/assets/stylesheets/biovision/base/layout.scss +22 -14
  9. data/app/assets/stylesheets/biovision/base/message-box.scss +8 -1
  10. data/app/controllers/admin/regions_controller.rb +0 -9
  11. data/app/controllers/admin/users_controller.rb +2 -2
  12. data/app/controllers/authentication_controller.rb +4 -1
  13. data/app/controllers/concerns/toggleable_entity.rb +12 -3
  14. data/app/controllers/regions_controller.rb +1 -1
  15. data/app/helpers/biovision_users_helper.rb +18 -8
  16. data/app/models/region.rb +6 -1
  17. data/app/models/user.rb +3 -3
  18. data/app/models/user_profile.rb +8 -0
  19. data/app/services/canonizer.rb +9 -8
  20. data/app/views/admin/metrics/show.html.erb +20 -12
  21. data/app/views/admin/privileges/entity/_groups.html.erb +12 -10
  22. data/app/views/admin/regions/entity/_in_list.html.erb +1 -1
  23. data/app/views/admin/regions/show.html.erb +1 -1
  24. data/app/views/admin/users/_filter.html.erb +2 -14
  25. data/app/views/admin/users/index.html.erb +1 -1
  26. data/app/views/admin/users/privileges.html.erb +53 -38
  27. data/app/views/agents/_filter.html.erb +28 -28
  28. data/app/views/authentication/new.jbuilder +6 -0
  29. data/app/views/editable_pages/_editable_page.html.erb +6 -0
  30. data/app/views/editable_pages/form/_ckeditor.html.erb +3 -3
  31. data/app/views/layouts/admin.html.erb +1 -1
  32. data/app/views/my/recoveries/show.html.erb +1 -1
  33. data/app/views/shared/_breadcrumbs.html.erb +6 -0
  34. data/app/views/shared/_list_of_errors.html.erb +5 -9
  35. data/config/locales/common-ru.yml +22 -22
  36. data/config/locales/users-ru.yml +9 -0
  37. data/config/routes.rb +1 -1
  38. data/db/migrate/20170301000001_create_metrics.rb +1 -1
  39. data/db/migrate/20170301000002_create_metric_values.rb +1 -1
  40. data/db/migrate/20170301000101_create_browsers.rb +1 -1
  41. data/db/migrate/20170301000102_create_agents.rb +1 -1
  42. data/db/migrate/20170301000201_create_regions.rb +4 -1
  43. data/db/migrate/20170302000001_create_users.rb +2 -1
  44. data/db/migrate/20170302000003_create_tokens.rb +1 -1
  45. data/db/migrate/20170302000005_create_codes.rb +1 -1
  46. data/db/migrate/20170302000101_create_privileges.rb +1 -1
  47. data/db/migrate/20170302000102_create_user_privileges.rb +1 -1
  48. data/db/migrate/20170302000103_create_privilege_groups.rb +1 -1
  49. data/db/migrate/20170302000104_create_privilege_group_privileges.rb +1 -1
  50. data/db/migrate/20170320000000_create_editable_pages.rb +4 -1
  51. data/db/migrate/20170425000001_create_foreign_sites.rb +1 -1
  52. data/db/migrate/20170425000002_create_foreign_users.rb +1 -1
  53. data/db/migrate/20171025222222_add_new_fields_171026.rb +29 -0
  54. data/lib/biovision/base/engine.rb +5 -0
  55. data/lib/biovision/base/version.rb +1 -1
  56. metadata +8 -4
@@ -17,22 +17,28 @@
17
17
  <canvas id="metric-chart" width="640" height="480" data-source="<%= data_admin_metric_path(@entity.id) %>"></canvas>
18
18
  </article>
19
19
 
20
- <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.bundle.min.js"></script>
20
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.0/Chart.bundle.min.js"></script>
21
21
  <script>
22
22
  'use strict';
23
- $(function () {
24
- let $canvas = $('#metric-chart');
25
- $.get($canvas.data('source'), function (response) {
23
+
24
+ document.addEventListener('DOMContentLoaded', function () {
25
+ const canvas = document.getElementById('metric-chart');
26
+ const url = canvas.getAttribute('data-source');
27
+ const request = Biovision.new_ajax_request('GET', url, function () {
28
+ const response = JSON.parse(this.responseText);
29
+
26
30
  if (response.hasOwnProperty('data')) {
27
- let metric = response['data'];
28
- let labels = Object.keys(metric['graph_data']);
29
- let myChart = new Chart($canvas[0], {
31
+ const metric = response.data;
32
+ const labels = Object.keys(metric.graph_data);
33
+ const myChart = new Chart(canvas, {
30
34
  type: 'line',
31
35
  data: {
32
36
  labels: labels,
33
37
  datasets: [{
34
- label: metric['name'],
35
- data: labels.map(function(k) { return metric['graph_data'][k]; } ),
38
+ label: metric.name,
39
+ data: labels.map(function (k) {
40
+ return metric.graph_data.k;
41
+ }),
36
42
  borderWidth: 1
37
43
  }]
38
44
  },
@@ -40,13 +46,15 @@
40
46
  scales: {
41
47
  yAxes: [{
42
48
  ticks: {
43
- beginAtZero: metric['start_with_zero']
49
+ beginAtZero: metric.start_with_zero
44
50
  }
45
51
  }]
46
52
  }
47
53
  }
48
54
  });
49
55
  }
50
- }).fail(handle_ajax_failure);
56
+ });
57
+
58
+ request.send();
51
59
  });
52
- </script>
60
+ </script>
@@ -14,17 +14,19 @@
14
14
 
15
15
  <script>
16
16
  'use strict';
17
- $(function () {
18
- $('ul.privilege-groups input[type=checkbox]').on('click', function () {
19
- var url = $(this).closest('li').data('url');
20
- var method = $(this).is(':checked') ? 'put' : 'delete';
21
17
 
22
- $.ajax(url, {
23
- method: method,
24
- success: function (response) {
25
- console.log(response);
26
- }
27
- }).fail(handle_ajax_failure);
18
+ document.addEventListener('DOMContentLoaded', function () {
19
+ document.querySelectorAll('ul.privilege-groups input[type=checkbox]').forEach(function(element) {
20
+ element.addEventListener('click', function () {
21
+ const url = this.closest('li').getAttribute('data-url');
22
+ const method = this.checked ? 'put' : 'delete';
23
+ const request = Biovision.new_ajax_request(method, url, function() {
24
+ console.log(JSON.parse(this.responseText));
25
+ });
26
+
27
+ request.send();
28
+ });
29
+
28
30
  });
29
31
  });
30
32
  </script>
@@ -24,7 +24,7 @@
24
24
  <%= render partial: 'admin/regions/toggleable', locals: { entity: entity } %>
25
25
 
26
26
  <ul class="actions">
27
- <li class="lockable <%= entity.editable_by?(current_user) ? '' : 'hidden' %>">
27
+ <li class="lockable <%= (entity.editable_by?(current_user) && !entity.locked?) ? '' : 'hidden' %>">
28
28
  <%= edit_icon edit_region_path(entity) %>
29
29
  </li>
30
30
  <%= render partial: 'shared/actions/locks', locals: { entity: entity, path: lock_admin_region_path(entity) } %>
@@ -12,7 +12,7 @@
12
12
 
13
13
  <ul class="actions">
14
14
  <li><%= back_icon(admin_regions_path) %></li>
15
- <% if @entity.editable_by?(current_user) %>
15
+ <% if @entity.editable_by?(current_user) && !@entity.locked? %>
16
16
  <li><%= edit_icon edit_region_path(@entity.id) %></li>
17
17
  <% end %>
18
18
  </ul>
@@ -3,20 +3,8 @@
3
3
  <legend><%= t(:filter) %></legend>
4
4
 
5
5
  <div>
6
- <div><%= label_tag 'filter_screen_name', t('activerecord.attributes.user.screen_name') %></div>
7
- <div><%= search_field_tag 'filter[screen_name]', filter[:screen_name], size: 30, results: 5, autosave: 'screen_name' %></div>
8
- </div>
9
-
10
- <!--
11
- <div>
12
- <div><%= label_tag 'filter_name', t('activerecord.attributes.user.name') %></div>
13
- <div><%= search_field_tag 'filter[name]', filter[:name], size: 30, results: 5, autosave: 'name' %></div>
14
- </div>
15
- -->
16
-
17
- <div>
18
- <div><%= label_tag 'filter_email', t('activerecord.attributes.user.email') %></div>
19
- <div><%= search_field_tag 'filter[email]', filter[:email], size: 30, results: 5, autosave: 'email' %></div>
6
+ <div><%= label_tag 'q', t('.search') %></div>
7
+ <div><%= search_field_tag 'q', param_from_request(:q), size: 30, results: 5, autosave: 'user_search' %></div>
20
8
  </div>
21
9
 
22
10
  <div class="button"><%= button_tag t(:submit), type: :submit, name: '' %></div>
@@ -11,7 +11,7 @@
11
11
  <li><%= create_icon(new_user_path) %></li>
12
12
  </ul>
13
13
 
14
- <%= render partial: 'filter', locals: { filter: @filter } %>
14
+ <%= render partial: 'filter' %>
15
15
 
16
16
  <%= paginate @collection %>
17
17
  <%= render partial: 'list', locals: { collection: @collection } %>
@@ -22,49 +22,64 @@
22
22
  <script>
23
23
  'use strict';
24
24
 
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');
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
-
33
- $.ajax(url, {
34
- method: method,
35
- data: data,
36
- }).fail(handle_ajax_failure);
37
- }
38
- });
25
+ document.addEventListener('DOMContentLoaded', function () {
26
+ document.querySelectorAll('ul.privileges input[type=checkbox]').forEach(function (element) {
27
+ element.addEventListener('click', function () {
28
+ if (this.offsetParent !== null) {
29
+ const url = this.closest('div.entity').getAttribute('data-url');
30
+ const method = this.checked ? 'put' : 'delete';
31
+ const region_id = this.getAttribute('data-region-id');
32
+ const data = region_id > 0 ? {region_id: region_id} : {};
33
+ const request = Biovision.new_ajax_request(method, url);
39
34
 
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
- });
35
+ request.setRequestHeader("Content-Type", "application/json");
36
+ request.send(JSON.stringify(data));
51
37
  }
52
- $button.closest('li').remove();
53
- }).fail(handle_ajax_failure);
38
+ });
54
39
  });
55
40
 
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()};
41
+ document.addEventListener('click', function (event) {
42
+ const element = event.target;
60
43
 
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);
44
+ if (element.matches('button.add_regions')) {
45
+ const container = element.closest('ul');
46
+ const url = container.getAttribute('data-url');
47
+ const request = Biovision.new_ajax_request('GET', url, function () {
48
+ const response = JSON.parse(this.responseText);
49
+ const li = element.closest('li');
50
+
51
+ if (response.hasOwnProperty('data')) {
52
+ response.data.forEach(function (data) {
53
+ if (data.hasOwnProperty('meta')) {
54
+ const item = document.createElement('li');
55
+
56
+ item.innerHTML = data.meta.html_chunk;
57
+
58
+ container.appendChild(item);
59
+ }
60
+ });
61
+ }
62
+ li.parentNode.removeChild(li);
63
+ });
64
+
65
+ request.send();
66
+ }
67
+
68
+ if (element.matches('input[type=checkbox].privilege-adder')) {
69
+ const url = element.closest('div.entity').getAttribute('data-url');
70
+ const li = element.closest('li');
71
+ const data = {region_id: element.value};
72
+ const list = li.querySelector('ul.regions');
73
+
74
+ const request = Biovision.new_ajax_request('put', url, function() {
75
+ if (list) {
76
+ list.parentNode.removeChild(list);
77
+ }
78
+ });
79
+
80
+ request.setRequestHeader("Content-Type", "application/json");
81
+ request.send(JSON.stringify(data));
82
+ }
68
83
  });
69
84
  });
70
85
  </script>
@@ -23,31 +23,31 @@
23
23
  </fieldset>
24
24
  <% end %>
25
25
 
26
- <script>/*<![CDATA[*/
27
- "use strict";
28
-
29
- $(function() {
30
- var $pagination = $('#agents-filter').find('div.pages');
31
-
32
- function change_page(delta) {
33
- var $field = $('#agent-filter-page');
34
- var value = parseInt($field.val());
35
-
36
- value += delta;
37
- if (value < 1) {
38
- value = 1;
39
- }
40
-
41
- $field.val(value);
42
- $field.closest('form').submit();
43
- }
44
-
45
- $pagination.find('.previous-page').on('click', function() {
46
- change_page(-1);
47
- });
48
-
49
- $pagination.find('.next-page').on('click', function () {
50
- change_page(1);
51
- });
52
- });
53
- /*]]>*/</script>
26
+ <script>
27
+ "use strict";
28
+
29
+ document.addEventListener('DOMContentLoaded', function () {
30
+ const pagination = document.querySelector('#agents-filter div.pages');
31
+ const field = document.getElementById('agent-filter-page');
32
+
33
+ function change_page(delta) {
34
+ let value = parseInt(field.value);
35
+
36
+ value += delta;
37
+ if (value < 1) {
38
+ value = 1;
39
+ }
40
+
41
+ field.value = value;
42
+ field.closest('form').submit();
43
+ }
44
+
45
+ pagination.querySelector('.previous-page').addEventListener('click', function () {
46
+ change_page(-1);
47
+ });
48
+
49
+ pagination.querySelector('.next-page').addEventListener('click', function () {
50
+ change_page(1);
51
+ });
52
+ });
53
+ </script>
@@ -0,0 +1,6 @@
1
+ json.meta do
2
+ json.fields do
3
+ json.login t('activerecord.attributes.user.screen_name')
4
+ json.password t('activerecord.attributes.user.password')
5
+ end
6
+ end
@@ -6,3 +6,9 @@
6
6
  <meta name="twitter:card" content="summary_large_image" />
7
7
  <meta name="twitter:description" content="<%= entity.description %>" />
8
8
  <% end %>
9
+
10
+ <article>
11
+ <h1><%= entity.title %></h1>
12
+
13
+ <%= raw entity.body %>
14
+ </article>
@@ -1,7 +1,7 @@
1
- <script src="//cdn.ckeditor.com/4.7.0/standard/ckeditor.js"></script>
1
+ <script src="//cdn.ckeditor.com/4.7.3/standard/ckeditor.js"></script>
2
2
  <script>
3
- $(function () {
4
- var editor = document.getElementById('editable_page_body');
3
+ document.addEventListener('DOMContentLoaded', function () {
4
+ const editor = document.getElementById('editable_page_body');
5
5
 
6
6
  CKEDITOR.replace(editor, {
7
7
  // filebrowserUploadUrl: '/illustrations',
@@ -11,7 +11,7 @@
11
11
  <body>
12
12
  <%= render 'layouts/admin/header' %>
13
13
 
14
- <main id="main" role="main">
14
+ <main id="main">
15
15
  <%= render 'shared/flash_messages' %>
16
16
  <%= render 'shared/admin/breadcrumbs' %>
17
17
 
@@ -43,7 +43,7 @@
43
43
  <dd><%= email_field_tag :email, param_from_request(:email), required: true %></dd>
44
44
  </dl>
45
45
  <div>
46
- <%= button_tag t('.send_code'), type: :submit %>
46
+ <%= button_tag t('.receive_code'), type: :submit %>
47
47
  </div>
48
48
  <% end %>
49
49
  </section>
@@ -0,0 +1,6 @@
1
+ <% if content_for? :breadcrumbs %>
2
+ <nav class="breadcrumbs">
3
+ <%= link_to(t(:home), root_path) %>
4
+ <%= yield :breadcrumbs %>
5
+ </nav>
6
+ <% end %>
@@ -1,11 +1,7 @@
1
1
  <% if entity.errors.any? %>
2
- <section class="errors">
3
- <h2><%= t(:error_count, count: entity.errors.count) %></h2>
4
-
5
- <ol>
6
- <% entity.errors.full_messages.each do |message| %>
7
- <li><%= message %></li>
8
- <% end %>
9
- </ol>
10
- </section>
2
+ <ol class="errors">
3
+ <% entity.errors.full_messages.each do |message| %>
4
+ <li><%= message %></li>
5
+ <% end %>
6
+ </ol>
11
7
  <% end %>
@@ -25,36 +25,37 @@ ru:
25
25
  - "декабрь"
26
26
  archive_year: " за %{year} год"
27
27
  archive_month: " за %{month} %{year} года"
28
- nothing_found: "Ничего не нашлось"
28
+ are_you_sure: "Вы уверены?"
29
+ back: "Назад"
30
+ copyright: "2017"
29
31
  create: "Создать"
30
- view: "В просмотр"
31
- list: "К списку"
32
- edit: "Редактировать"
33
- update: "Обновить"
32
+ created_at: "Время создания"
33
+ current_image: "Текущая картинка"
34
34
  delete: "Удалить"
35
- submit: "Отправить"
36
- save: "Сохранить"
37
- back: "Назад"
35
+ deleted_entity: "Удалённый объект"
36
+ edit: "Редактировать"
37
+ filter: "Фильтр"
38
38
  find: "Найти"
39
- are_you_sure: "Вы уверены?"
40
- created_at: "Время создания"
41
- updated_at: "Время обновления"
39
+ flags: "Флаги"
40
+ hide: "Скрыть"
41
+ home: "Главная"
42
+ list: "К списку"
43
+ locked: "Редактирование зарещено"
44
+ "no": "Нет"
42
45
  not_selected: "Не выбрано"
43
46
  not_set: "Не задано"
44
- filter: "Фильтр"
45
- "yes": "Да"
46
- "no": "Нет"
47
+ nothing_found: "Ничего не нашлось"
47
48
  page: "Страница"
48
- current_image: "Текущая картинка"
49
- deleted_entity: "Удалённый объект"
50
- locked: "Редактирование зарещено"
49
+ save: "Сохранить"
50
+ submit: "Отправить"
51
51
  unlocked: "Редактирование разрешено"
52
- home: "Главная"
53
52
  untitled: "Без названия"
54
- hide: "Скрыть"
55
- copyright: "2017"
56
- view_as_visitor: "Посмотреть на странице"
53
+ update: "Обновить"
54
+ updated_at: "Время обновления"
55
+ view: "В просмотр"
57
56
  view_as_administrator: "Посмотреть в админке"
57
+ view_as_visitor: "Посмотреть на странице"
58
+ "yes": "Да"
58
59
  views:
59
60
  pagination:
60
61
  first: "⇤"
@@ -108,4 +109,3 @@ ru:
108
109
  title: "Раздел в разработке"
109
110
  heading: "Раздел наполняется"
110
111
  message: "Информация ещё не готова, зайдите позже"
111
- flags: "Флаги"