Skip to content

Commit

Permalink
Updated Type Categories on Types Screen and converted Data Type label…
Browse files Browse the repository at this point in the history
… to Item Type on Concepts Screen (SunSpecOrangeButton#40)
  • Loading branch information
joelebwf committed Jan 17, 2020
1 parent 0961495 commit 92c862f
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 34 deletions.
11 changes: 11 additions & 0 deletions viewer/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,14 @@
"LEI": "Value must be a 20 character LEI string"
}


TYPE_MAPPINGS = {
"dei": "DEI",
"num-us": "Numeric",
"num": "Numeric",
"solar-types": "Solar",
"nonnum": "Basic",
"us-types": "Basic",
"xbrli": "Basic"
}

2 changes: 1 addition & 1 deletion viewer/tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_concepts(self):
self.assertEqual(3404, len(data))
self.assertTrue("name" in data[0])
self.assertTrue("taxonomy" in data[0])
self.assertTrue("datatype" in data[0])
self.assertTrue("itemtype" in data[0])
self.assertTrue("period" in data[0])

def test_types(self):
Expand Down
12 changes: 6 additions & 6 deletions viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import re

import werkzeug
from oblib import taxonomy, data_model, parser
from flask import Flask, request, render_template, make_response, jsonify
from oblib import taxonomy
from flask import Flask, make_response, jsonify
from flask_cors import CORS

RETURN_INDEX = "<h2><a href='/html'>Return to search page</a></h2>"
Expand Down Expand Up @@ -103,7 +103,7 @@ def concepts():
data.append({
"name": details.name,
"taxonomy": t,
"datatype": details.type_name.split(":")[1].replace("ItemType", ""),
"itemtype": details.type_name.split(":")[1].replace("ItemType", ""),
"period": details.period_type.value
})

Expand Down Expand Up @@ -150,21 +150,21 @@ def types():
values += e
data.append({
"code": name.replace("solar-types:", "").replace("ItemType", ""),
"type": "Non numeric",
"type": reference.TYPE_MAPPINGS[name.split(":")[0]],
"values": values,
"definition": ""
})
elif name in numeric_types:
data.append({
"code": name.replace("num-us:", ""),
"type": "Numeric",
"type": reference.TYPE_MAPPINGS[name.split(":")[0]],
"values": "N/A",
"definition": ""
})
else:
data.append({
"code": name.split(":")[1].replace("ItemType", ""),
"type": "Other",
"type": reference.TYPE_MAPPINGS[name.split(":")[0]],
"values": "N/A",
"definition": ""
})
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/ConceptList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export default {
thStyle: { width: "87px" }
},
{
key: "datatype",
label: "Data Type",
key: "itemtype",
label: "Item Type",
thClass: ".col-field-styling",
thStyle: { width: "87px" }
},
Expand Down
14 changes: 8 additions & 6 deletions web/src/components/TypeFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@

<h1>Type</h1>
<div class="form-group">
<label for="nonnumeric">
<input type="checkbox" id="nonnumeric" value="NonNumeric" v-model="$store.state.chkNonnumeric"/> Non
Numeric
<label for="solar">
<input type="checkbox" id="Solar" value="Solar" v-model="$store.state.chkSolarType"/> Solar
</label>
<label for="numeric">
<input type="checkbox" id="numeric" value="Numeric" v-model="$store.state.chkNumeric"/> 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 for="basic">
<input type="checkbox" id="Basic" value="Basic" v-model="$store.state.chkBasic"/> Basic
</label>
<label for="dei">
<input type="checkbox" id="DEI" value="DEI" v-model="$store.state.chkDeiType"/> DEI
</label>
</div>
<div class="button-group">
Expand Down
25 changes: 17 additions & 8 deletions web/src/components/TypeList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ export default {
searchFilter() {
let tableData = this.$store.state.apiData.filter( node => {
return node.code.toLowerCase().includes(this.$store.state.searchTerm.toLowerCase()) &&
((node.type.toLowerCase()=="non numeric" && this.$store.state.chkNonnumeric) ||
((node.type.toLowerCase()=="solar" && this.$store.state.chkSolarType) ||
(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()=="basic" && this.$store.state.chkBasic) ||
(node.type.toLowerCase()=="dei" && this.$store.state.chkDeiType) ||
(node.type.toLowerCase()=="solar" && !this.$store.state.actvChk) ||
(node.type.toLowerCase()=="numeric" && !this.$store.state.actvChk) ||
(node.type.toLowerCase()=="other" && !this.$store.state.actvChk))
(node.type.toLowerCase()=="basic" && !this.$store.state.actvChk) ||
(node.type.toLowerCase()=="dei" && !this.$store.state.actvChk))
})
this.numOfElem = 100
this.showLoadMore = true
Expand Down Expand Up @@ -127,8 +129,8 @@ export default {
this.showLoadMore = false
}
},
"$store.state.chkNonnumeric"() {
if (this.$store.state.chkNonnumeric) {
"$store.state.chkSolarType"() {
if (this.$store.state.chkSolarType) {
this.$store.state.actvChk = true
} else {
this.$store.state.actvChk = false
Expand All @@ -141,8 +143,15 @@ export default {
this.$store.state.actvChk = false
}
},
"$store.state.chkOther"() {
if (this.$store.state.chkOther) {
"$store.state.chkBasic"() {
if (this.$store.state.chkBasic) {
this.$store.state.actvChk = true
} else {
this.$store.state.actvChk = false
}
},
"$store.state.chkDeiType"() {
if (this.$store.state.chkDeiType) {
this.$store.state.actvChk = true
} else {
this.$store.state.actvChk = false
Expand Down
10 changes: 6 additions & 4 deletions web/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ export default new Vuex.Store({
chkUSGaap: false,
chkDEI: false,

chkNonnumeric: false,
chkSolarType: false,
chkNumeric: false,
chkOther: false,
chkBasic: false,
chkDeiType: false,

chkAcronym: true,
chkAbbreviation: true,
Expand Down Expand Up @@ -141,9 +142,10 @@ export default new Vuex.Store({
state.chkDEI = false;
},
clearTypesChks(state) {
state.chkNonnumeric = false;
state.chkSolarType = false;
state.chkNumeric = false;
state.chkOther = false;
state.chkBasic = false;
state.chkDeiType = false;
},
clearUnitsChks(state) {
state.chkCustomary = false;
Expand Down
6 changes: 3 additions & 3 deletions web/tests/unit/concepts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const localVue = createLocalVue();
localVue.use(Vuex);

process.env.TEST_JSON = `[
{"name": "Curtailment", "taxonomy": "SOLAR", "datatype": "energy", "period": "duration"},
{"name": "AccruedLiabilitiesCurrent", "taxonomy": "US-GAAP", "datatype": "monetary", "period": "instant"}
{"name": "Curtailment", "taxonomy": "SOLAR", "itemtype": "energy", "period": "duration"},
{"name": "AccruedLiabilitiesCurrent", "taxonomy": "US-GAAP", "itemtype": "monetary", "period": "instant"}
]`;

describe('ConceptsPage', () => {
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('ConceptList', () => {
expect(wrapper.vm.$store.state.returnItemsCount).toBe(2);
expect(wrapper.vm.$store.state.apiData[0]["name"]).toBe("Curtailment");
expect(wrapper.vm.$store.state.apiData[0]["taxonomy"]).toBe("SOLAR");
expect(wrapper.vm.$store.state.apiData[1]["datatype"]).toBe("monetary");
expect(wrapper.vm.$store.state.apiData[1]["itemtype"]).toBe("monetary");
expect(wrapper.vm.$store.state.apiData[1]["period"]).toBe("instant");
expect(wrapper.vm.$store.state.apiLoading).toBe(false);
expect(wrapper.vm.$store.state.dataReady).toBe(true);
Expand Down
9 changes: 5 additions & 4 deletions web/tests/unit/types.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const localVue = createLocalVue();
localVue.use(Vuex);

process.env.TEST_JSON = `[
{"code": "fundStatus", "type": "Non numeric", "values": "Closed, Open, Committed"},
{"code": "force", "type": "Numeric", "values": "N/A"}
{"code": "fundStatus", "type": "solar", "values": "Closed, Open, Committed"},
{"code": "force", "type": "numeric", "values": "N/A"}
]`;

describe('TypesPage', () => {
Expand Down Expand Up @@ -55,7 +55,8 @@ describe('TypeFilter', () => {
it('clears all filters on clearFilters()', () => {
const wrapper = shallowMount(TypeFilter, {store, localVue});
wrapper.vm.clearFilters();
let result = wrapper.vm.$store.state.chkNumeric || wrapper.vm.$store.state.chkNonNumeric ||
let result = wrapper.vm.$store.state.chkNumeric || wrapper.vm.$store.state.chkBasic ||
wrapper.vm.$store.state.chkSolarType || wrapper.vm.$store.state.chkDeiType ||
wrapper.vm.$store.state.searchTerm != "";
expect(result).toBe(false);
});
Expand All @@ -72,7 +73,7 @@ describe('TypeList', () => {
const wrapper = shallowMount(TypeList, {store, localVue});
expect(wrapper.vm.$store.state.returnItemsCount).toBe(2);
expect(wrapper.vm.$store.state.apiData[0]["code"]).toBe("fundStatus");
expect(wrapper.vm.$store.state.apiData[1]["type"]).toBe("Numeric");
expect(wrapper.vm.$store.state.apiData[1]["type"]).toBe("numeric");
expect(wrapper.vm.$store.state.apiData[0]["values"]).toBe("Closed, Open, Committed");
expect(wrapper.vm.$store.state.apiLoading).toBe(false);
expect(wrapper.vm.$store.state.dataReady).toBe(true);
Expand Down

0 comments on commit 92c862f

Please sign in to comment.