Skip to content

Commit

Permalink
Added minor enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
joelebwf committed Dec 31, 2019
1 parent 70721f4 commit 9aa1f48
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 45 deletions.
36 changes: 17 additions & 19 deletions viewer/relationships.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Builds JSON relationships which can be returned by the viewer to OBTV.
"""

from oblib import taxonomy
from dataclasses import dataclass
from typing import List
Expand Down Expand Up @@ -207,22 +223,4 @@ def subprocess(a, level, j):
if c is not None:
jj = {}
subprocess(c, level+1, jj)
j["children"].append(jj)

# if a.tables:
# for t in a.tables:
# TreeVRepresentation.start_table(out, t.name, level)
# data = []
# for pk in t.pks:
# data.append(pk + " (PK)")
# for member in t.members:
# data.append(member)
# TreeVRepresentation.end_table(out, data, t.pk_values_enum)
# if t.children:
# for c in t.children:
# TreeVRepresentation.subprocess(c, level+1, out)
# if a.children:
# for c in a.children:
# if c is not None:
# TreeVRepresentation.subprocess(c, level+1, out)
# TreeVRepresentation.end_list(out)
j["children"].append(jj)
2 changes: 1 addition & 1 deletion viewer/tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_concepts(self):

def test_types(self):
data = json.loads(viewer.types())
self.assertEqual(80, len(data))
self.assertEqual(92, len(data))
self.assertTrue("code" in data[0])
self.assertTrue("type" in data[0])
self.assertTrue("values" in data[0])
Expand Down
55 changes: 32 additions & 23 deletions viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,30 +213,39 @@ def types():

try:
data = []
for type in tax.types.get_all_types():

values = ""
first = True
for e in tax.types.get_type_enum(type):
if not first:
values += ", "
first = False
values += e

data.append({
"code": type.replace("solar-types:", "").replace("ItemType", ""),
"type": "Non numeric",
"values": values,
"definition": ""
})

for numeric_type in tax.numeric_types.get_all_numeric_types():
data.append({
"code": numeric_type.replace("num-us:", ""),
"type": "Numeric",
"values": "N/A",
"definition": ""
})
types = tax.types.get_all_types()
numeric_types = tax.numeric_types.get_all_numeric_types()

for name in tax.semantic.get_all_type_names():
if name in types:
values = ""
first = True
for e in tax.types.get_type_enum(name):
if not first:
values += ", "
first = False
values += e
data.append({
"code": name.replace("solar-types:", "").replace("ItemType", ""),
"type": "Non numeric",
"values": values,
"definition": ""
})
elif name in numeric_types:
data.append({
"code": name.replace("num-us:", ""),
"type": "Numeric",
"values": "N/A",
"definition": ""
})
else:
data.append({
"code": name.split(":")[1].replace("ItemType", ""),
"type": "Other",
"values": "N/A",
"definition": ""
})
s = json.dumps(data)
return s
except Exception as e:
Expand Down
Binary file modified web/src/assets/ob.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion web/src/components/TypeFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/>
</div>

<h1>Type Type</h1>
<h1>Type</h1>
<div class="form-group">
<label for="nonnumeric">
<input type="checkbox" id="nonnumeric" value="NonNumeric" v-model="$store.state.chkNonnumeric"/> Non
Expand All @@ -35,6 +35,9 @@
<label for="numeric">
<input type="checkbox" id="numeric" value="Numeric" v-model="$store.state.chkNumeric"/> Numeric
</label>
<label for="other">
<input type="checkbox" id="other" value="Other" v-model="$store.state.chkOther"/> Other
</label>
</div>
<div class="button-group">
<button type="button" class="btn btn-primary" @click="updateQuery">
Expand Down
11 changes: 10 additions & 1 deletion web/src/components/TypeList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ export default {
return node.code.toLowerCase().includes(this.$store.state.searchTerm.toLowerCase()) &&
((node.type.toLowerCase()=="non numeric" && this.$store.state.chkNonnumeric) ||
(node.type.toLowerCase()=="numeric" && this.$store.state.chkNumeric) ||
(node.type.toLowerCase()=="other" && this.$store.state.chkOther) ||
(node.type.toLowerCase()=="non numeric" && !this.$store.state.actvChk) ||
(node.type.toLowerCase()=="numeric" && !this.$store.state.actvChk))
(node.type.toLowerCase()=="numeric" && !this.$store.state.actvChk) ||
(node.type.toLowerCase()=="other" && !this.$store.state.actvChk))
})
this.numOfElem = 100
this.showLoadMore = true
Expand Down Expand Up @@ -138,6 +140,13 @@ export default {
} else {
this.$store.state.actvChk = false
}
},
"$store.state.chkOther"() {
if (this.$store.state.chkOther) {
this.$store.state.actvChk = true
} else {
this.$store.state.actvChk = false
}
}
}
};
Expand Down
2 changes: 2 additions & 0 deletions web/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default new Vuex.Store({

chkNonnumeric: false,
chkNumeric: false,
chkOther: false,

chkAcronym: true,
chkAbbreviation: true,
Expand Down Expand Up @@ -142,6 +143,7 @@ export default new Vuex.Store({
clearTypesChks(state) {
state.chkNonnumeric = false;
state.chkNumeric = false;
state.chkOther = false;
},
clearUnitsChks(state) {
state.chkCustomary = false;
Expand Down

0 comments on commit 9aa1f48

Please sign in to comment.