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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/biovision/base/icons/components/content.svg +20 -0
  3. data/app/assets/images/biovision/base/icons/components/users.svg +21 -0
  4. data/app/assets/javascripts/biovision/base/biovision.js +68 -108
  5. data/app/assets/stylesheets/biovision/base/admin/components.scss +85 -95
  6. data/app/assets/stylesheets/biovision/base/admin.scss +0 -36
  7. data/app/assets/stylesheets/biovision/base/biovision.scss +49 -0
  8. data/app/assets/stylesheets/biovision/base/default.scss +1 -0
  9. data/app/assets/stylesheets/biovision/base/default_admin.scss +1 -0
  10. data/app/controllers/admin/components_controller.rb +60 -0
  11. data/app/controllers/feedback_requests_controller.rb +1 -1
  12. data/app/helpers/biovision_components_helper.rb +11 -0
  13. data/app/mailers/feedback_mailer.rb +1 -1
  14. data/app/models/biovision_component.rb +21 -4
  15. data/app/models/biovision_component_user.rb +17 -0
  16. data/app/models/feedback_request.rb +25 -4
  17. data/app/models/metric.rb +39 -4
  18. data/app/models/metric_value.rb +12 -5
  19. data/app/models/user.rb +1 -2
  20. data/app/services/biovision/components/base_component.rb +65 -11
  21. data/app/services/biovision/components/contact_component.rb +24 -0
  22. data/app/services/biovision/components/content_component.rb +12 -0
  23. data/app/services/biovision/components/registration_component.rb +12 -6
  24. data/app/services/biovision/components/users_component.rb +12 -0
  25. data/app/views/admin/components/entity/_links.html.erb +20 -0
  26. data/app/views/admin/{settings → components}/index.html.erb +5 -5
  27. data/app/views/admin/components/links/_contact.html.erb +1 -0
  28. data/app/views/admin/components/links/_content.html.erb +2 -0
  29. data/app/views/admin/components/links/_users.html.erb +7 -0
  30. data/app/views/admin/components/settings/_new_parameter.html.erb +46 -0
  31. data/app/views/admin/components/settings/_parameters.html.erb +20 -0
  32. data/app/views/admin/{settings/component → components/settings}/_setting.html.erb +0 -0
  33. data/app/views/admin/{settings/component → components/settings}/_settings.html.erb +2 -2
  34. data/app/views/admin/components/settings.html.erb +44 -0
  35. data/app/views/admin/components/show.html.erb +22 -0
  36. data/app/views/admin/feedback_requests/entity/_in_list.html.erb +12 -1
  37. data/app/views/admin/index/_components.html.erb +17 -8
  38. data/app/views/admin/index/index.html.erb +8 -2
  39. data/app/views/admin/users/entity/_in_list.html.erb +8 -0
  40. data/app/views/admin/users/entity/in_list/_additional_data.html.erb +0 -0
  41. data/app/views/admin/users/show.html.erb +9 -1
  42. data/app/views/authentication/_form.html.erb +4 -1
  43. data/app/views/editable_pages/entity/_content.html.erb +1 -0
  44. data/app/views/feedback_requests/_form.html.erb +19 -8
  45. data/app/views/layouts/admin/_footer.html.erb +2 -2
  46. data/app/views/shared/entity/_metadata.html.erb +1 -1
  47. data/app/views/users/_form.html.erb +9 -1
  48. data/config/locales/common-en.yml +1 -1
  49. data/config/locales/common-ru.yml +1 -1
  50. data/config/locales/common-sv.yml +1 -1
  51. data/config/locales/components-en.yml +36 -0
  52. data/config/locales/components-ru.yml +19 -16
  53. data/config/locales/components-sv.yml +36 -0
  54. data/config/routes.rb +8 -6
  55. data/db/migrate/20181217000000_create_biovision_components.rb +15 -3
  56. data/db/migrate/20181217000200_create_feedback_requests.rb +1 -0
  57. data/db/migrate/20190326120000_create_simple_blocks.rb +3 -1
  58. data/db/migrate/20190610141414_add_user_to_feedback_requests.rb +14 -0
  59. data/db/migrate/20190730000000_create_biovision_component_users.rb +24 -0
  60. data/db/migrate/20190731222222_add_biovision_component_to_metrics.rb +14 -0
  61. data/db/migrate/20190801111111_add_components.rb +27 -0
  62. data/db/{migrate → obsolete_migrations}/20181217121211_add_uuid_to_users.rb +0 -0
  63. data/db/{migrate → obsolete_migrations}/20181217121212_update_fields181217.rb +0 -0
  64. data/db/{migrate → obsolete_migrations}/20190311121212_convert_json_columns.rb +0 -0
  65. data/lib/biovision/base/version.rb +1 -1
  66. metadata +42 -24
  67. data/app/controllers/admin/settings_controller.rb +0 -47
  68. data/app/views/admin/index/_biovision_base.html.erb +0 -9
  69. data/app/views/admin/index/dashboard/_biovision_feedback.html.erb +0 -9
  70. data/app/views/admin/index/dashboard/_biovision_links.html.erb +0 -11
  71. data/app/views/admin/index/dashboard/_biovision_track.html.erb +0 -8
  72. data/app/views/admin/index/dashboard/_biovision_user.html.erb +0 -14
  73. data/app/views/admin/index/dashboard/_editorial.html.erb +0 -11
  74. data/app/views/admin/index/dashboard/_settings.html.erb +0 -9
  75. data/app/views/admin/settings/component/_new_parameter.html.erb +0 -54
  76. data/app/views/admin/settings/component/_parameters.html.erb +0 -37
  77. data/app/views/admin/settings/show.html.erb +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53f6745ccdb17530c51d58bc412f980bb9ec1e47e54a858a5aa207b117c9f6c1
4
- data.tar.gz: 4fb31a1e0780d1984c30225c05f74c24934d706350009a007bb24f8ded0f43e6
3
+ metadata.gz: 9d5f8617a8dff7ad9626d48a7f1e22cc8f08c2593b217c6c27841ab5aa921d6c
4
+ data.tar.gz: 01c40c0839b5f499a4230ff5c66ca3b0eda1e5366004f9191d019788eb33262a
5
5
  SHA512:
6
- metadata.gz: 7b812126a16490736dda1d3af3b38fec3de5bbcaf674c603f571bee8db5274131c77ea6c6420593e1dc9d19a335d0197eb91daa210735935a45d06b075eaf929
7
- data.tar.gz: 8d2efd4a4972f0e2a17a0f8fac8b4f403b5d495ef0c94c700914bd1bf5706bad0b901092c1ff591c8e04373f48c741288c731203812320c0bfb82420f787b8d8
6
+ metadata.gz: bf4038b7bddff5695f12bbe5a98f146a3f2ac6ebbabfa34c35a4f1b3cd66d2b575a04c2b47806638cd6d85110ce0d38f90fecb4ea3bfaa46cc94244edf25b7a1
7
+ data.tar.gz: 5f506ea490fb45a7e3eb072d9494e66360370b037cdd8605f570108def672749ff4f462946b0e9f9363b889d103edd22ff76e9d207cb75c445a2dbb7ea40d861
@@ -0,0 +1,20 @@
1
+ <svg version="1.1" viewBox="0 0 24 24" width="24px" height="24px" xmlns="http://www.w3.org/2000/svg">
2
+ <title>Content</title>
3
+ <defs>
4
+ <style type="text/css">
5
+ rect { stroke-width: 1; stroke: #aaa }
6
+ line { stroke-width: 1 }
7
+ </style>
8
+ </defs>
9
+ <rect x="5" y="2" width="10" height="16" fill="#ddd"/>
10
+ <rect x="7" y="4" width="10" height="16" fill="#eee"/>
11
+ <g>
12
+ <rect x="9" y="6" width="10" height="16" fill="#fff"/>
13
+ <line x1="11" y1="9" x2="14" y2="9" stroke="#111"/>
14
+ <line x1="11" y1="11" x2="17" y2="11" stroke="#555"/>
15
+ <line x1="11" y1="13" x2="17" y2="13" stroke="#555"/>
16
+ <line x1="11" y1="15" x2="16" y2="15" stroke="#555"/>
17
+ <line x1="11" y1="18" x2="17" y2="18" stroke="#555"/>
18
+ <line x1="11" y1="20" x2="17" y2="20" stroke="#555"/>
19
+ </g>
20
+ </svg>
@@ -0,0 +1,21 @@
1
+ <svg version="1.1" viewBox="0 0 24 24" width="24px" height="24px" xmlns="http://www.w3.org/2000/svg">
2
+ <title>Users</title>
3
+ <defs>
4
+ <style type="text/css">
5
+ .a { stroke-width: 1; stroke: #aaa; fill: #eee; }
6
+ .b { stroke-width: 1.5; stroke: #333; fill: #777; }
7
+ </style>
8
+ </defs>
9
+ <g class="a">
10
+ <ellipse cx="6.5" cy="7" rx="2" ry="3.2"/>
11
+ <path d="M1,16 Q6.5,8 12,16 z" stroke-linejoin="round"/>
12
+ </g>
13
+ <g class="a">
14
+ <ellipse cx="18.5" cy="7" rx="2" ry="3.2"/>
15
+ <path d="M13,16 Q18.5,8 23,16 z" stroke-linejoin="round"/>
16
+ </g>
17
+ <g class="b">
18
+ <ellipse cx="12.5" cy="10" rx="3.5" ry="4.5"/>
19
+ <path d="M3,22 Q12,11 22,22 z" stroke-linejoin="round"/>
20
+ </g>
21
+ </svg>
@@ -841,151 +841,111 @@ Biovision.components.hidingPopups = {
841
841
  }
842
842
  };
843
843
 
844
- Biovision.components.componentEditor = {
844
+ Biovision.components.componentParameters = {
845
845
  initialized: false,
846
- /**
847
- * @type {HTMLElement}
848
- */
849
- list: undefined,
846
+ container: undefined,
850
847
  url: undefined,
848
+ list: undefined,
851
849
  elements: [],
852
- values: {},
853
850
  init: function () {
854
- this.list = document.getElementById('biovision-component-parameters');
855
- if (this.list) {
856
- const component = this;
857
- this.url = this.list.getAttribute('data-url');
858
- this.list.querySelectorAll('input[type="text"]').forEach(component.apply);
859
-
851
+ this.container = document.getElementById("biovision-component-parameters");
852
+ if (this.container) {
853
+ this.url = this.container.getAttribute("data-url");
854
+ this.list = this.container.querySelector("dl");
855
+ this.list.querySelectorAll("input").forEach(this.apply);
860
856
  this.initialized = true;
861
857
  }
862
858
  },
863
859
  /**
864
860
  *
865
- * @param element
861
+ * @param {HTMLElement} element
866
862
  * @type {Function}
867
863
  */
868
864
  apply: function (element) {
869
- const component = Biovision.components.componentEditor;
870
- const button = element.parentNode.querySelector('button');
871
-
872
- component.values[element.getAttribute('id')] = element.value;
873
-
865
+ const component = Biovision.components.componentParameters;
874
866
  component.elements.push(element);
875
- element.addEventListener('change', component.handleChange);
876
- element.addEventListener('keyup', component.keyUp);
877
- button.addEventListener('click', component.handleClick);
867
+ element.addEventListener("change", component.change);
878
868
  },
879
- handleChange: function (event) {
869
+ change: function (event) {
870
+ const component = Biovision.components.componentParameters;
880
871
  const element = event.target;
881
- const button = element.parentNode.querySelector('button');
882
-
883
- button.disabled = false;
884
- },
885
- keyUp: function (event) {
886
- const component = Biovision.components.componentEditor;
887
- const element = event.target;
888
- const button = element.parentNode.querySelector('button');
889
-
890
- if (component.values[element.getAttribute('id')] !== element.value) {
891
- button.disabled = false;
892
- }
893
- },
894
- /**
895
- *
896
- * @param {MouseEvent} event
897
- * @type {Function}
898
- */
899
- handleClick: function (event) {
900
- const component = Biovision.components.componentEditor;
901
- /**
902
- *
903
- * @type {HTMLButtonElement}
904
- */
905
- const button = event.target;
906
- const li = button.closest('li');
907
- const input = li.querySelector('input');
908
872
  const data = {
909
873
  "key": {
910
- "slug": button.getAttribute('data-slug'),
911
- "value": input.value
874
+ "slug": element.name,
875
+ "value": element.value
912
876
  }
913
877
  };
914
-
915
- const request = Biovision.jsonAjaxRequest('put', component.url, function () {
916
- component.values[input.getAttribute('id')] = input.value;
878
+ const request = Biovision.jsonAjaxRequest("patch", component.url, function () {
879
+ element.disabled = false;
880
+ element.classList.add("updated");
881
+ }, function () {
882
+ element.disabled = false;
883
+ element.classList.add("failed");
917
884
  });
918
885
 
919
- button.disabled = true;
886
+ element.classList.remove("updated", "failed");
887
+ element.disabled = true;
920
888
  request.send(JSON.stringify(data));
921
889
  },
922
890
  add: function (data) {
923
- if (this.initialized) {
924
- const li = document.createElement('li');
925
- const name = document.createElement('div');
926
- const value = document.createElement('div');
927
- const input = document.createElement('input');
928
-
929
- name.classList.add('name');
930
- name.innerHTML = "<label>" + data["slug"] + "</label>\n<span>(" + data["name"] + ")</span>";
931
-
932
- value.classList.add('value');
933
- input.value = data["value"];
934
- value.appendChild(input);
935
-
936
- li.appendChild(name);
937
- li.appendChild(value);
938
-
939
- if (data["description"]) {
940
- const desc = document.createElement('div');
941
- desc.classList.add('description');
942
- desc.innerHTML = data["description"];
943
-
944
- li.appendChild(desc);
945
- }
946
-
947
- this.list.appendChild(li);
948
- } else {
949
- console.log('componentEditor is not initialized');
950
- }
891
+ const div = document.createElement("div");
892
+ const dt = document.createElement("dt");
893
+ const label = document.createElement("label");
894
+ const elementId = "parameter-" + data["slug"];
895
+ label.setAttribute("for", elementId);
896
+ label.innerHTML = data["slug"];
897
+ dt.append(label);
898
+ const dd = document.createElement("dd");
899
+ const input = document.createElement("input");
900
+ input.setAttribute("id", elementId);
901
+ input.setAttribute("name", data["slug"]);
902
+ input.value = data["value"];
903
+ dd.append(input);
904
+ this.apply(input);
905
+ div.append(dt);
906
+ div.append(dd);
907
+ this.list.append(div);
951
908
  }
952
909
  };
953
910
 
954
- Biovision.components.newParameterForm = {
911
+ Biovision.components.newComponentParameter = {
955
912
  initialized: false,
956
- element: undefined,
913
+ container: undefined,
914
+ url: undefined,
915
+ button: undefined,
957
916
  init: function () {
958
- this.element = document.getElementById('new-biovision-parameter-form');
959
- if (this.element) {
917
+ this.container = document.getElementById("biovision-component-new-parameter");
918
+ if (this.container) {
960
919
  const component = this;
961
-
962
- this.element.addEventListener('submit', component.handler);
920
+ this.url = this.container.getAttribute("data-url");
921
+ this.button = this.container.querySelector("button");
922
+ this.button.addEventListener("click", component.click);
963
923
  this.initialized = true;
964
924
  }
965
925
  },
966
- handler: function (event) {
967
- event.preventDefault();
968
-
969
- const form = event.target;
970
- const url = form.getAttribute('action');
926
+ click: function () {
927
+ const component = Biovision.components.newComponentParameter;
971
928
  const data = {"key": {}};
972
- form.querySelectorAll('input[data-field]').forEach(function (input) {
973
- data["key"][input.getAttribute('data-field')] = input.value;
929
+ let dataPresent = true;
930
+ component.container.querySelectorAll("input").forEach(function (input) {
931
+ dataPresent &= input.value.length > 0;
932
+ data.key[input.name] = input.value;
974
933
  });
975
934
 
976
- const request = Biovision.jsonAjaxRequest('put', url, function () {
977
- Biovision.components.newParameterForm.clear();
978
- Biovision.components.componentEditor.add(data["key"]);
979
- });
980
-
981
- request.send(JSON.stringify(data));
982
- },
983
- clear: function () {
984
- const component = Biovision.components.newParameterForm;
935
+ if (dataPresent) {
936
+ const request = Biovision.jsonAjaxRequest("patch", component.url, function () {
937
+ component.container.querySelectorAll("input").forEach(function (input) {
938
+ input.value = '';
939
+ });
940
+ Biovision.components.componentParameters.add(data["key"]);
941
+ component.button.disabled = false;
942
+ }, function () {
943
+ component.button.disabled = false;
944
+ });
985
945
 
986
- component.element.querySelectorAll('input').forEach(function (input) {
987
- input.value = '';
988
- });
946
+ component.button.disabled = true;
947
+ request.send(JSON.stringify(data));
948
+ }
989
949
  }
990
950
  };
991
951
 
@@ -1,141 +1,131 @@
1
1
  $text-color-secondary: #777 !default;
2
+ $block-shadow: .2rem .2rem .4rem .2rem rgba(0, 0, 0, .125) !default;
3
+ $row-background-even: hsl(0, 0%, 95%) !default;
4
+ $row-background-odd: hsl(0, 0%, 98%) !default;
2
5
 
3
6
  #biovision-component-parameters {
4
7
  margin: var(--spacer-s) 0;
5
8
  padding: 0;
6
9
 
7
- li {
8
- list-style: none;
9
- margin: 0 0 var(--spacer-m);
10
- }
11
-
12
10
  label {
13
11
  font-size: var(--font-size-increased);
14
12
  font-weight: 400;
15
-
16
- + span {
17
- color: $text-color-secondary;
18
- }
19
13
  }
20
14
 
21
- .name {
22
- input {
23
- width: 100%;
24
- }
15
+ input {
16
+ border: .1rem solid #aaa;
17
+ margin: 0;
18
+ padding: var(--spacer-xxs);
19
+ transition: .125s;
25
20
  }
26
21
 
27
- .value {
28
- align-items: center;
29
- display: flex;
30
- margin: var(--spacer-xxs) 0;
31
-
32
- input {
33
- flex: 1;
34
- }
35
-
36
- button {
37
- --shadow-color: rgba(0, 0, 0, .25);
38
-
39
- background: no-repeat center / contain;
40
- border: none;
41
- border-radius: .2rem;
42
- box-shadow: 0 0 .4rem var(--shadow-color);
43
- cursor: pointer;
44
- display: inline-block;
45
- flex: none;
46
- height: 2.4rem;
47
- margin: 0 var(--spacer-xxs);
48
- transition: .25s;
49
- width: 2.4rem;
50
-
51
- &:active,
52
- &:hover {
53
- --shadow-color: rgba(0, 0, 0, .75);
54
- }
55
-
56
- &:disabled {
57
- cursor: default;
58
- filter: grayscale(1);
59
- }
60
- }
61
-
62
- .apply {
63
- background-color: rgba(97, 228, 64, .125);
64
- background-image: image_url('biovision/base/icons/apply.svg');
65
- }
22
+ :disabled {
23
+ background-color: transparent;
24
+ border-color: transparent;
25
+ }
66
26
 
67
- .delete {
68
- background-color: rgba(228, 97, 64, .125);
69
- background-image: image_url('biovision/base/icons/destroy.svg');
70
- }
27
+ .updated {
28
+ background-color: rgba(0, 127, 0, .125);
29
+ border-color: rgb(0, 127, 0);
71
30
  }
72
31
 
73
- .description {
74
- font-size: var(--font-size-decreased);
75
- margin: var(--spacer-xxs) 0 0;
32
+ .failed {
33
+ background-color: rgba(127, 0, 0, .125);
34
+ border-color: rgb(127, 0, 0);
76
35
  }
77
36
  }
78
37
 
79
- .biovision-components {
80
- align-items: center;
81
- display: flex;
82
- flex-wrap: wrap;
38
+ .biovision-components-list {
83
39
  margin: 0;
84
40
  padding: 0;
85
41
 
86
42
  li {
87
43
  list-style: none;
88
- margin: var(--spacer-xs);
89
- padding: 0;
44
+ margin: var(--spacer-xs) 0;
90
45
  }
91
46
 
92
47
  a {
93
- --shadow-color: rgba(0, 0, 0, .25);
48
+ --image-size: calc(var(--font-size-normal) + var(--spacer-xs));
94
49
 
95
- background: no-repeat center top var(--spacer-s);
96
- border-radius: .4rem;
97
- box-shadow: 0 0 .4rem var(--shadow-color);
50
+ background: no-repeat center left / var(--image-size) var(--image-size);
98
51
  display: inline-block;
99
- padding: calc(var(--spacer-m) + 16rem) 0 var(--spacer-s);
100
- text-align: center;
101
- width: calc(var(--spacer-s) + 16rem);
102
-
103
- &:active,
104
- &:focus,
105
- &:hover {
106
- --shadow-color: rgba(0, 0, 0, .75);
52
+ padding: var(--spacer-xxs) 0 var(--spacer-xxs) calc(var(--image-size) + var(--spacer-xxs));
53
+ }
54
+
55
+ .contact {
56
+ background-image: image_url('biovision/base/icons/components/contact.svg');
57
+ }
58
+
59
+ .registration {
60
+ background-image: image_url('biovision/base/icons/components/registration.svg');
61
+ }
62
+
63
+ .users {
64
+ background-image: image_url('biovision/base/icons/components/users.svg');
65
+ }
66
+
67
+ .content {
68
+ background-image: image_url('biovision/base/icons/components/content.svg');
69
+ }
70
+ }
71
+
72
+ .biovision-components-index {
73
+ h2 {
74
+ background: no-repeat center left / 2.4rem 2.4rem;
75
+ padding-left: 3rem;
76
+ }
77
+
78
+ .contact {
79
+ h2 {
80
+ background-image: image_url('biovision/base/icons/components/contact.svg');
107
81
  }
108
82
  }
109
83
 
110
- .settings-general {
111
- a {
112
- background-image: image_url('biovision/base/icons/settings.svg');
84
+ .registration {
85
+ h2 {
86
+ background-image: image_url('biovision/base/icons/components/registration.svg');
113
87
  }
114
88
  }
115
- }
116
89
 
117
- .biovision-components-list {
118
- margin: 0;
119
- padding: 0;
90
+ .users {
91
+ h2 {
92
+ background-image: image_url('biovision/base/icons/components/users.svg');
93
+ }
94
+ }
120
95
 
121
- li {
122
- list-style: none;
123
- margin: var(--spacer-xs) 0;
96
+ .content {
97
+ h2 {
98
+ background-image: image_url('biovision/base/icons/components/content.svg');
99
+ }
124
100
  }
101
+ }
125
102
 
126
- a {
127
- --image-size: calc(var(--font-size-normal) + var(--spacer-xs));
103
+ .biovision-component-nav {
104
+ margin: var(--spacer-s);
128
105
 
129
- background: no-repeat center left / var(--image-size) var(--image-size);
106
+ .settings {
107
+ background: image_url('biovision/base/icons/settings.svg') no-repeat center left / 2rem 2rem;
130
108
  display: inline-block;
131
- padding: var(--spacer-xxs) 0 var(--spacer-xxs) calc(var(--image-size) + var(--spacer-xxs));
109
+ margin: 0 0 var(--spacer-xs);
110
+ padding-left: 2.4rem;
132
111
  }
133
112
 
134
- .contact {
135
- background-image: image_url('biovision/base/icons/components/contact.svg');
113
+ ul {
114
+ box-shadow: $block-shadow;
115
+ margin: var(--spacer-xxs);
116
+ max-width: 64rem;
117
+ padding: 0;
136
118
  }
137
119
 
138
- .registration {
139
- background-image: image_url('biovision/base/icons/components/registration.svg');
120
+ li {
121
+ background: $row-background-odd;
122
+ list-style: none;
123
+ margin: 0;
124
+ padding: var(--spacer-xs);
125
+ position: relative;
126
+
127
+ &:nth-last-of-type(even) {
128
+ background: $row-background-even;
129
+ }
140
130
  }
141
131
  }