@abi-software/flatmapvuer 0.3.14 → 0.4.0-beta-0

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.
@@ -1,150 +1,150 @@
1
- <template>
2
- <div class="pubmed-container">
3
- <!-- To view old pubmed display go to: https://github.com/Tehsurfer/flatmapvuer/commit/eca131f8d32cdcac4d136d1722d7fe4df25f6c3a -->
4
- </div>
5
- </template>
6
-
7
-
8
- <script>
9
- /* eslint-disable no-alert, no-console */
10
-
11
- export default {
12
- name: "Tooltip",
13
- props: {
14
- entry: {
15
- type: Object,
16
- default: () => {}
17
- },
18
- },
19
- watch: {
20
- 'entry.featureIds': {
21
- handler: function(ids) {
22
- this.pubmedQueryOnIds(ids)
23
- }
24
- }
25
- },
26
- inject: ['flatmapAPI'],
27
- data: function() {
28
- return {
29
- pubmeds: [],
30
- pubmedIds: [],
31
- };
32
- },
33
- mounted: function() {
34
- if (this.entry.featureIds)
35
- this.pubmedQueryOnIds(this.entry.featureIds)
36
- },
37
- methods: {
38
- stripPMIDPrefix: function (pubmedId){
39
- return pubmedId.split(':')[1]
40
- },
41
- buildPubmedSqlStatement: function(keastIds) {
42
- let sql = 'select distinct publication from publications where entity in ('
43
- if (keastIds.length === 1) {
44
- sql += `'${keastIds[0]}')`
45
- } else if (keastIds.length > 1) {
46
- for (let i in keastIds) {
47
- sql += `'${keastIds[i]}'${i >= keastIds.length - 1 ? ')' : ','} `
48
- }
49
- }
50
- return sql
51
- },
52
- buildPubmedSqlStatementForModels: function(model) {
53
- return `select distinct publication from publications where entity = '${model}'`
54
- },
55
- flatmapQuery: function(sql){
56
- const data = { sql: sql}
57
- return fetch(`${this.flatmapAPI}knowledge/query/`, {
58
- method: 'POST',
59
- headers: {
60
- 'Content-Type': 'application/json',
61
- },
62
- body: JSON.stringify(data),
63
- })
64
- .then(response => response.json())
65
- .catch((error) => {
66
- console.error('Error:', error)
67
- })
68
- },
69
- pubmedQueryOnIds: function(keastIds){
70
- if(!keastIds || keastIds.length === 0) return
71
- const sql = this.buildPubmedSqlStatement(keastIds)
72
- this.flatmapQuery(sql).then(data=>{
73
- this.responseData = data
74
- // Create pubmed url on paths if we have them
75
- if (data.values.length > 0){
76
- this.$emit('pubmedSearchUrl', this.pubmedSearchUrl(data.values.map(id=>this.stripPMIDPrefix(id[0]))))
77
- } else { // Create pubmed url on models
78
- this.pubmedQueryOnModels(this.entry.source)
79
- }
80
- })
81
- },
82
- pubmedQueryOnModels(source){
83
- this.flatmapQuery(this.buildPubmedSqlStatementForModels(source)).then(data=>{
84
- if (Array.isArray(data.values) && data.values.length > 0){
85
- this.$emit('pubmedSearchUrl', this.pubmedSearchUrl(data.values.map(id=>this.stripPMIDPrefix(id[0]))))
86
- } else {
87
- this.$emit('pubmedSearchUrl', '') // Clears the pubmed search button
88
- }
89
- })
90
- },
91
- pubmedSearchUrl: function(ids) {
92
- let url = 'https://pubmed.ncbi.nlm.nih.gov/?'
93
- let params = new URLSearchParams()
94
- params.append('term', ids)
95
- return url + params.toString()
96
- }
97
- }
98
- };
99
- </script>
100
-
101
- <style scoped lang="scss">
102
- @import "~element-ui/packages/theme-chalk/src/link";
103
- @import "~element-ui/packages/theme-chalk/src/carousel";
104
- @import "~element-ui/packages/theme-chalk/src/carousel-item";
105
-
106
- .attribute-title{
107
- font-size: 16px;
108
- font-weight: 600;
109
- /* font-weight: bold; */
110
- text-transform: uppercase;
111
- }
112
-
113
- .attribute-content{
114
- font-size: 14px;
115
- font-weight: 400;
116
- }
117
-
118
- .el-link {
119
- color: $app-primary-color;
120
- text-decoration: none;
121
- word-wrap: break-word;
122
- &:hover, &:focus{
123
- color: $app-primary-color;
124
- text-decoration: underline;
125
- }
126
- }
127
-
128
- ::v-deep .el-carousel__button {
129
- background-color: $app-primary-color;
130
- }
131
-
132
- .button {
133
- margin-left: 0px !important;
134
- margin-top: 0px !important;
135
- font-size: 14px !important;
136
- background-color: $app-primary-color;
137
- color: #fff;
138
- &:hover{
139
- color: #fff !important;
140
- background: #ac76c5 !important;
141
- border: 1px solid #ac76c5 !important;
142
- }
143
- &+.button {
144
- margin-top: 10px !important;
145
- background-color: $app-primary-color;
146
- color: #fff;
147
- }
148
- }
149
-
1
+ <template>
2
+ <div class="pubmed-container">
3
+ <!-- To view old pubmed display go to: https://github.com/Tehsurfer/flatmapvuer/commit/eca131f8d32cdcac4d136d1722d7fe4df25f6c3a -->
4
+ </div>
5
+ </template>
6
+
7
+
8
+ <script>
9
+ /* eslint-disable no-alert, no-console */
10
+
11
+ export default {
12
+ name: "Tooltip",
13
+ props: {
14
+ entry: {
15
+ type: Object,
16
+ default: () => {}
17
+ },
18
+ },
19
+ watch: {
20
+ 'entry.featureIds': {
21
+ handler: function(ids) {
22
+ this.pubmedQueryOnIds(ids)
23
+ }
24
+ }
25
+ },
26
+ inject: ['flatmapAPI'],
27
+ data: function() {
28
+ return {
29
+ pubmeds: [],
30
+ pubmedIds: [],
31
+ };
32
+ },
33
+ mounted: function() {
34
+ if (this.entry.featureIds)
35
+ this.pubmedQueryOnIds(this.entry.featureIds)
36
+ },
37
+ methods: {
38
+ stripPMIDPrefix: function (pubmedId){
39
+ return pubmedId.split(':')[1]
40
+ },
41
+ buildPubmedSqlStatement: function(keastIds) {
42
+ let sql = 'select distinct publication from publications where entity in ('
43
+ if (keastIds.length === 1) {
44
+ sql += `'${keastIds[0]}')`
45
+ } else if (keastIds.length > 1) {
46
+ for (let i in keastIds) {
47
+ sql += `'${keastIds[i]}'${i >= keastIds.length - 1 ? ')' : ','} `
48
+ }
49
+ }
50
+ return sql
51
+ },
52
+ buildPubmedSqlStatementForModels: function(model) {
53
+ return `select distinct publication from publications where entity = '${model}'`
54
+ },
55
+ flatmapQuery: function(sql){
56
+ const data = { sql: sql}
57
+ return fetch(`${this.flatmapAPI}knowledge/query/`, {
58
+ method: 'POST',
59
+ headers: {
60
+ 'Content-Type': 'application/json',
61
+ },
62
+ body: JSON.stringify(data),
63
+ })
64
+ .then(response => response.json())
65
+ .catch((error) => {
66
+ console.error('Error:', error)
67
+ })
68
+ },
69
+ pubmedQueryOnIds: function(keastIds){
70
+ if(!keastIds || keastIds.length === 0) return
71
+ const sql = this.buildPubmedSqlStatement(keastIds)
72
+ this.flatmapQuery(sql).then(data=>{
73
+ this.responseData = data
74
+ // Create pubmed url on paths if we have them
75
+ if (data.values.length > 0){
76
+ this.$emit('pubmedSearchUrl', this.pubmedSearchUrl(data.values.map(id=>this.stripPMIDPrefix(id[0]))))
77
+ } else { // Create pubmed url on models
78
+ this.pubmedQueryOnModels(this.entry.source)
79
+ }
80
+ })
81
+ },
82
+ pubmedQueryOnModels(source){
83
+ this.flatmapQuery(this.buildPubmedSqlStatementForModels(source)).then(data=>{
84
+ if (Array.isArray(data.values) && data.values.length > 0){
85
+ this.$emit('pubmedSearchUrl', this.pubmedSearchUrl(data.values.map(id=>this.stripPMIDPrefix(id[0]))))
86
+ } else {
87
+ this.$emit('pubmedSearchUrl', '') // Clears the pubmed search button
88
+ }
89
+ })
90
+ },
91
+ pubmedSearchUrl: function(ids) {
92
+ let url = 'https://pubmed.ncbi.nlm.nih.gov/?'
93
+ let params = new URLSearchParams()
94
+ params.append('term', ids)
95
+ return url + params.toString()
96
+ }
97
+ }
98
+ };
99
+ </script>
100
+
101
+ <style scoped lang="scss">
102
+ @import "~element-ui/packages/theme-chalk/src/link";
103
+ @import "~element-ui/packages/theme-chalk/src/carousel";
104
+ @import "~element-ui/packages/theme-chalk/src/carousel-item";
105
+
106
+ .attribute-title{
107
+ font-size: 16px;
108
+ font-weight: 600;
109
+ /* font-weight: bold; */
110
+ text-transform: uppercase;
111
+ }
112
+
113
+ .attribute-content{
114
+ font-size: 14px;
115
+ font-weight: 400;
116
+ }
117
+
118
+ .el-link {
119
+ color: $app-primary-color;
120
+ text-decoration: none;
121
+ word-wrap: break-word;
122
+ &:hover, &:focus{
123
+ color: $app-primary-color;
124
+ text-decoration: underline;
125
+ }
126
+ }
127
+
128
+ ::v-deep .el-carousel__button {
129
+ background-color: $app-primary-color;
130
+ }
131
+
132
+ .button {
133
+ margin-left: 0px !important;
134
+ margin-top: 0px !important;
135
+ font-size: 14px !important;
136
+ background-color: $app-primary-color;
137
+ color: #fff;
138
+ &:hover{
139
+ color: #fff !important;
140
+ background: #ac76c5 !important;
141
+ border: 1px solid #ac76c5 !important;
142
+ }
143
+ &+.button {
144
+ margin-top: 10px !important;
145
+ background-color: $app-primary-color;
146
+ color: #fff;
147
+ }
148
+ }
149
+
150
150
  </style>
@@ -0,0 +1,225 @@
1
+ <template>
2
+ <div class="selections-container">
3
+ <el-row>
4
+ <el-col :span="12">
5
+ <div class="checkall-display-text">{{title}}</div>
6
+ </el-col>
7
+ <el-col :span="12">
8
+ <el-checkbox
9
+ v-if="selections && selections.length > 1"
10
+ class="all-checkbox"
11
+ :indeterminate="isIndeterminate"
12
+ v-model="checkAll"
13
+ @change="handleCheckAllChange"
14
+ >Display all</el-checkbox>
15
+ </el-col>
16
+ </el-row>
17
+ <el-checkbox-group
18
+ v-model="checkedItems"
19
+ size="small"
20
+ class="checkbox-group"
21
+ @change="handleCheckedItemsChange"
22
+ >
23
+ <div class="checkbox-group-inner">
24
+ <el-row v-for="item in selections" :key="item[identifierKey]" :label="item[identifierKey]">
25
+ <div class="checkbox-container">
26
+ <el-checkbox
27
+ class="my-checkbox"
28
+ :label="item[identifierKey]"
29
+ @change="visibilityToggle(item[identifierKey], $event)"
30
+ :checked="!(('enable' in item) && item.enable === false)">
31
+ <div class="path-visual" :style="getVisualStyles(item)"></div>
32
+ {{item[labelKey]}}
33
+ </el-checkbox>
34
+ </div>
35
+ </el-row>
36
+ </div>
37
+ </el-checkbox-group>
38
+ </div>
39
+ </template>
40
+
41
+ <script>
42
+ /* eslint-disable no-alert, no-console */
43
+ import Vue from "vue";
44
+ import {
45
+ Checkbox,
46
+ CheckboxGroup,
47
+ Col,
48
+ Row
49
+ } from "element-ui";
50
+ import lang from "element-ui/lib/locale/lang/en";
51
+ import locale from "element-ui/lib/locale";
52
+
53
+ locale.use(lang);
54
+ Vue.use(Checkbox);
55
+ Vue.use(CheckboxGroup);
56
+ Vue.use(Col);
57
+ Vue.use(Row);
58
+
59
+
60
+ export default {
61
+ name: "SelectionsGroup",
62
+ methods: {
63
+ /**
64
+ * Function to toggle paths to default.
65
+ * Also called when the associated button is pressed.
66
+ */
67
+ reset: function() {
68
+ this.checkAll = true;
69
+ this.checkedItems = [];
70
+ this.selections.forEach(item => {
71
+ if (!(('enable' in item) && item.enable === false)) {
72
+ this.checkedItems.push(item[this.identifierKey]);
73
+ } else {
74
+ this.checkAll = false;
75
+ }
76
+ });
77
+ },
78
+ visibilityToggle: function(key, value) {
79
+ this.$emit("changed", {key, value});
80
+ },
81
+ handleCheckedItemsChange: function(value) {
82
+ let checkedCount = value.length;
83
+ this.checkAll = checkedCount === this.selections.length;
84
+ },
85
+ handleCheckAllChange(val) {
86
+ this.checkedItems = val ? this.selections.map(a => a[this.identifierKey]) : [];
87
+ this.$emit("checkAll",
88
+ {
89
+ keys: this.selections.map(a => a[this.identifierKey]),
90
+ value: val
91
+ });
92
+ },
93
+ getVisualStyles(item) {
94
+ if ('colour' in item) {
95
+ if (('dashed' in item) && (item.dashed === true)) {
96
+ const background = `repeating-linear-gradient(90deg,${item.colour},${item.colour} 6px,transparent 0,transparent 9px)`;
97
+ return {'background':background};
98
+ }
99
+ else {
100
+ const background = item.colour;
101
+ return {background};
102
+ }
103
+ }
104
+ return {};
105
+ }
106
+ },
107
+ props: {
108
+ identifierKey: {
109
+ type: String,
110
+ default: "id"
111
+ },
112
+ labelKey: {
113
+ type: String,
114
+ default: "label"
115
+ },
116
+ title: {
117
+ type: String,
118
+ default: ""
119
+ },
120
+ selections: {
121
+ type: Array,
122
+ default: function() {
123
+ return [];
124
+ },
125
+ },
126
+ },
127
+ computed: {
128
+ isIndeterminate: function() {
129
+ const count = this.checkedItems.length;
130
+ if ((count === 0) || this.checkAll){
131
+ return false;
132
+ }
133
+ return true;
134
+ }
135
+ },
136
+ data: function() {
137
+ return {
138
+ checkedItems: [],
139
+ checkAll: true,
140
+ };
141
+ },
142
+ mounted: function() {
143
+ this.reset();
144
+ }
145
+ };
146
+ </script>
147
+
148
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
149
+ <style scoped lang="scss">
150
+ @import "~element-ui/packages/theme-chalk/src/checkbox";
151
+ @import "~element-ui/packages/theme-chalk/src/checkbox-group";
152
+ @import "~element-ui/packages/theme-chalk/src/row";
153
+
154
+ .selection-container {
155
+ margin-top:5px;
156
+ }
157
+
158
+ .path-visual {
159
+ margin: 3px 0;
160
+ height: 3px;
161
+ width: 25px;
162
+ margin-right: 5px;
163
+ display: inline-block;
164
+ }
165
+
166
+ .checkall-display-text {
167
+ width: 59px;
168
+ height: 20px;
169
+ color: rgb(48, 49, 51);
170
+ font-size: 14px;
171
+ font-weight: normal;
172
+ line-height: 20px;
173
+ margin-left: 8px;
174
+ }
175
+
176
+ .all-checkbox {
177
+ float: right;
178
+ }
179
+
180
+ .checkbox-container {
181
+ display: flex;
182
+ cursor: pointer;
183
+ }
184
+
185
+ .checkbox-group {
186
+ width: 260px;
187
+ border: 1px solid rgb(144, 147, 153);
188
+ border-radius: 4px;
189
+ background: #ffffff;
190
+ }
191
+
192
+ .my-checkbox {
193
+ background-color: #fff;
194
+ width: 100%;
195
+ }
196
+
197
+ .checkbox-group-inner {
198
+ padding: 18px;
199
+ }
200
+
201
+ ::v-deep .el-checkbox__label {
202
+ padding-left: 5px;
203
+ color: $app-primary-color;
204
+ font-size: 12px;
205
+ font-weight: 500;
206
+ letter-spacing: 0px;
207
+ line-height: 14px;
208
+ }
209
+
210
+ ::v-deep .el-checkbox__input {
211
+ &.is-indeterminate,
212
+ &.is-checked {
213
+ .el-checkbox__inner {
214
+ background-color: $app-primary-color;
215
+ border-color: $app-primary-color;
216
+ }
217
+ }
218
+ }
219
+
220
+ ::v-deep .el-checkbox__label {
221
+ color: $app-primary-color !important;
222
+ }
223
+
224
+ </style>
225
+