Skip to content

Commit

Permalink
Completed writing test cases for all methods and calculated propertie…
Browse files Browse the repository at this point in the history
…s. (#10)

* Added Mock-Mock API JSON support and test case for Pages parent vue file

* Added test cases for List components

* Removed unused code

* Reformatted code
  • Loading branch information
joelebwf authored and shelcrow committed Nov 25, 2019
1 parent baf1bf2 commit 80e7e8c
Show file tree
Hide file tree
Showing 25 changed files with 611 additions and 680 deletions.
12 changes: 7 additions & 5 deletions web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
-->

<template>
<div id="app">
<Navbar id="navbar"></Navbar>
<router-view id="router-v" />
<Footer id="footer"></Footer>
</div>
<div id="app">
<Navbar id="navbar"></Navbar>
<router-view id="router-v"/>
<Footer id="footer"></Footer>
</div>
</template>

<script>
Expand All @@ -29,6 +29,7 @@ export default {
Footer
}
};

</script>

<style>
Expand Down Expand Up @@ -60,6 +61,7 @@ html {
#navbar {
grid-row: 1 / 2;
}

</style>


Expand Down
121 changes: 39 additions & 82 deletions web/src/components/ConceptFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,103 +13,59 @@
-->

<template>
<div class="public-filter">
<form @submit.prevent>
<h1>Keyword</h1>
<div class="form-group">
<input
type="text"
class="form-control"
id="keyword_search"
v-model="$store.state.searchTerm"
@keyup.enter="updateQuery"
/>
</div>

<h1>Concept Type</h1>
<div class="form-group">
<label for="data">
<input type="checkbox" id="solar" value="Solar" v-model="$store.state.chkSolar" /> Solar
</label>
<label for="documents">
<input type="checkbox" id="usgaap" value="USGaap" v-model="$store.state.chkUSGaap" /> US-Gaap
</label>
<label for="process">
<input type="checkbox" id="dei" value="DEI" v-model="$store.state.chkDEI" /> DEI
</label>
</div>
<div class="button-group">
<button type="button" class="btn btn-primary" @click="updateQuery">
<v-icon name="search" class="search-icon" />&nbsp; Search
</button>
<button type="button" class="btn btn-primary" @click="clearFilters">
<v-icon name="times" class="clear-icon" />&nbsp;&nbsp;Clear filters
</button>
</div>
</form>
</div>
<div class="public-filter">
<form @submit.prevent>
<h1>Keyword</h1>
<div class="form-group">
<input
type="text"
class="form-control"
id="keyword_search"
v-model="$store.state.searchTerm"
@keyup.enter="updateQuery"
/>
</div>

<h1>Concept Type</h1>
<div class="form-group">
<label for="data">
<input type="checkbox" id="solar" value="Solar" v-model="$store.state.chkSolar"/> Solar
</label>
<label for="documents">
<input type="checkbox" id="usgaap" value="USGaap" v-model="$store.state.chkUSGaap"/> US-Gaap
</label>
<label for="process">
<input type="checkbox" id="dei" value="DEI" v-model="$store.state.chkDEI"/> DEI
</label>
</div>
<div class="button-group">
<button type="button" class="btn btn-primary" @click="updateQuery">
<v-icon name="search" class="search-icon"/>&nbsp; Search
</button>
<button type="button" class="btn btn-primary" @click="clearFilters">
<v-icon name="times" class="clear-icon"/>&nbsp;&nbsp;Clear filters
</button>
</div>
</form>
</div>
</template>

<script>
export default {
data() {
return {
query_data: {
ConceptType: [],
ConceptRegion: [],
ConceptCertificationType: []
},
search_string: ""
};
},
methods: {
updateQuery() {
this.$store.commit("toggleAPILoading");
// console.log(this.query_data);
let query_search_string = "";
if (this.search_string) {
query_search_string = "search=" + this.search_string;
}

let query_string = "?";
Object.keys(this.query_data).forEach(key => {
if (this.query_data[key].length != 0) {
if (query_string == "?") {
query_string += key + "__in=";
} else {
query_string += "&" + key + "__in=";
}
for (let i in this.query_data[key]) {
query_string += this.query_data[key][i] + ",";
}
query_string = query_string.slice(0, -1);
}
});

if (query_string == "?") {
query_string = query_string + query_search_string;
} else {
query_string = query_string + "&" + query_search_string;
}
// console.log(query_string);
this.$store.commit("callAPI", query_string);
// TODO: Remove - currently referenced in other code.
},
clearFilters() {
this.$store.commit("toggleAPILoading");
this.search_string = "";
this.$store.commit("clearQueryString");
this.$store.commit("clearConceptsChks")
this.$store.commit("clearConceptsChks");
this.$store.commit("callAPI", "concepts");
},
updateSearch() {
this.$store.commit("toggleAPILoading");

let query_search_string = "?search=" + this.search_string;
// console.log(query_search_string);
this.$store.commit("callAPI", query_search_string);
}
}
};

</script>

<style scoped>
Expand Down Expand Up @@ -180,4 +136,5 @@ label {
#keyword_search {
width: 214px;
}

</style>
53 changes: 26 additions & 27 deletions web/src/components/ConceptList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@
-->

<template>
<div class="concept-public-list-container">
<div class="concept-public-list">
<b-table
class="concept-table"
primary-key="name"
striped
hover
outlined
small
:fields="fields"
:items="searchFilter"
:busy="apiLoading"
>
<!-- :items="json" -->
<!-- :items="apiData.results" -->

<template v-slot:table-busy>
<div class="text-center text-primary my-2">
<b-spinner class="align-middle"></b-spinner>
<strong>&nbsp; Loading...</strong>
</div>
</template>
</b-table>
<div class="concept-public-list-container">
<div class="concept-public-list">
<b-table
class="concept-table"
primary-key="name"
striped
hover
outlined
small
:fields="fields"
:items="searchFilter"
:busy="apiLoading"
>
<!-- :items="json" -->
<!-- :items="apiData.results" -->

<template v-slot:table-busy>
<div class="text-center text-primary my-2">
<b-spinner class="align-middle"></b-spinner>
<strong>&nbsp; Loading...</strong>
</div>
</template>
</b-table>
</div>
</div>
</div>
</template>

<script>
Expand Down Expand Up @@ -89,9 +89,6 @@ export default {
return this.$store.state.dataReady;
},
searchFilter() {

//return this.$store.state.apiData;

return this.$store.state.apiData.filter( node => {
return node.name.toLowerCase().includes(this.$store.state.searchTerm.toLowerCase()) &&
((node.taxonomy.toLowerCase()=="solar" && this.$store.state.chkSolar) ||
Expand All @@ -106,6 +103,7 @@ export default {
components: {
}
};

</script>

<style>
Expand Down Expand Up @@ -246,4 +244,5 @@ a {
.table {
margin-bottom: 0px !important;
}

</style>
Loading

0 comments on commit 80e7e8c

Please sign in to comment.