From 1446a2e8fc4134924913804047c7f74647da75e9 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Tue, 25 Oct 2022 19:07:42 -0500 Subject: [PATCH 1/9] add status filter sidebar --- app/components/filter-sidebar.js | 43 +++++++++++++++++++++ app/templates/components/filter-sidebar.hbs | 23 +++++++++++ 2 files changed, 66 insertions(+) create mode 100644 app/components/filter-sidebar.js create mode 100644 app/templates/components/filter-sidebar.hbs diff --git a/app/components/filter-sidebar.js b/app/components/filter-sidebar.js new file mode 100644 index 00000000..631f1c9c --- /dev/null +++ b/app/components/filter-sidebar.js @@ -0,0 +1,43 @@ +import Component from '@ember/component'; +import { inject as service } from '@ember/service'; + +export default Component.extend({ + router: service(), + activeStatus: true, + inactiveStatus: false, + withdrawnStatus: false, + filterValue: '', + + actions: { + applyFilter() { + this.filterValue = '' + console.log("apply filter") + if (this.activeStatus == true){ + this.filterValue += "status:active," + } + if (this.inactiveStatus == true){ + this.filterValue += "status:inactive," + } + if (this.withdrawnStatus == true){ + this.filterValue += "status:withdrawn," + } + this.filterValue = this.filterValue.slice(0, -1) + this.set('model.query.filter', this.filterValue) + //this.get('globalSearch').doSearch(this.query, this.allStatus) + console.log("model is") + console.log(this.model) + this.get('router').transitionTo('organizations.index', { queryParams: { query: this.model.query.query, page: this.model.query.page, all_status: this.model.query.allStatus, filter: this.model.query.filter}}); + }, + clearFilter() { + this.filterValue = '' + console.log("clear filters") + this.set('activeStatus', true); + this.set('inactiveStatus', false); + this.set('withdrawnStatus', false); + this.filterValue = "status:active" + this.set('model.query.filter', this.filterValue) + this.get('router').transitionTo('organizations.index', { queryParams: { query: this.model.query.query, page: this.model.query.page, all_status: this.model.query.allStatus, filter: this.model.query.filter}}); + } + } + +}); diff --git a/app/templates/components/filter-sidebar.hbs b/app/templates/components/filter-sidebar.hbs new file mode 100644 index 00000000..c8b55323 --- /dev/null +++ b/app/templates/components/filter-sidebar.hbs @@ -0,0 +1,23 @@ +
+ +
+
+

Record status

+
+
+ {{input class="filters-list-input" type="checkbox" id="active-status" name="activeStatus" checked=activeStatus}} + +
+
+ {{input class="filters-list-input" type="checkbox" id="inactive-status" name="inactiveStatus" checked=inactiveStatus}} + +
+
+ {{input class="filters-list-input" type="checkbox" id="withdrawn-status" name="withdrawnStatus" checked=withdrawnStatus}} + +
+
+ + +
+
\ No newline at end of file From ef63745be32c8db35c935743e5d9976b3d1e9e76 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Tue, 25 Oct 2022 19:08:38 -0500 Subject: [PATCH 2/9] update search functionality to support filters and remove unused files --- app/components/application-footer.js | 4 -- app/components/application-header.js | 6 +- app/components/application-subscribe.js | 4 -- app/components/controllers/.gitkeep | 0 .../controllers/organizations/index.js | 25 -------- .../controllers/organizations/show.js | 4 -- app/helpers/.gitkeep | 0 app/routes/organizations/index.js | 10 +++- app/services/global-search.js | 4 +- app/styles/app.scss | 60 +++++++++++++++++++ .../components/application-header.hbs | 42 +++++++++---- .../components/organization-item.hbs | 2 +- app/templates/organizations/index.hbs | 26 +++++--- 13 files changed, 125 insertions(+), 62 deletions(-) delete mode 100644 app/components/application-footer.js delete mode 100644 app/components/application-subscribe.js delete mode 100644 app/components/controllers/.gitkeep delete mode 100644 app/components/controllers/organizations/index.js delete mode 100644 app/components/controllers/organizations/show.js delete mode 100644 app/helpers/.gitkeep diff --git a/app/components/application-footer.js b/app/components/application-footer.js deleted file mode 100644 index bb93d73f..00000000 --- a/app/components/application-footer.js +++ /dev/null @@ -1,4 +0,0 @@ -import Component from '@ember/component'; - -export default Component.extend({ -}); diff --git a/app/components/application-header.js b/app/components/application-header.js index 0d8778e7..e54c1564 100644 --- a/app/components/application-header.js +++ b/app/components/application-header.js @@ -3,10 +3,12 @@ import { inject as service } from '@ember/service'; export default Component.extend({ globalSearch: service(), + allStatus: false, + showAdvanced: false, actions: { - search(query) { - this.get('globalSearch').doSearch(query); + search() { + this.get('globalSearch').doSearch(this.query); }, clear() { this.get('globalSearch').doSearch(null); diff --git a/app/components/application-subscribe.js b/app/components/application-subscribe.js deleted file mode 100644 index bb93d73f..00000000 --- a/app/components/application-subscribe.js +++ /dev/null @@ -1,4 +0,0 @@ -import Component from '@ember/component'; - -export default Component.extend({ -}); diff --git a/app/components/controllers/.gitkeep b/app/components/controllers/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/components/controllers/organizations/index.js b/app/components/controllers/organizations/index.js deleted file mode 100644 index ccaa3648..00000000 --- a/app/components/controllers/organizations/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import Controller from '@ember/controller'; -export default Controller.extend({ - queryParams: ['sort', 'page', 'query'], - query: null, - sort: null, - page: 1, - - actions: { - doSearch(query) { - if (query) { - this.set('sort', 'relevance'); - } else if (this.sort === 'relevance') { - this.set('sort', null); - } - - this.set('query', query); - this.search(); - }, - clear() { - this.set('query', null); - this.set('sort', null); - this.search(); - } - } -}); \ No newline at end of file diff --git a/app/components/controllers/organizations/show.js b/app/components/controllers/organizations/show.js deleted file mode 100644 index 3ad17932..00000000 --- a/app/components/controllers/organizations/show.js +++ /dev/null @@ -1,4 +0,0 @@ -import Controller from '@ember/controller'; - -export default Controller.extend({ -}); \ No newline at end of file diff --git a/app/helpers/.gitkeep b/app/helpers/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/routes/organizations/index.js b/app/routes/organizations/index.js index 4d5eaf4b..aed21c09 100644 --- a/app/routes/organizations/index.js +++ b/app/routes/organizations/index.js @@ -2,12 +2,14 @@ import Route from '@ember/routing/route'; export default Route.extend({ model(params) { + console.log(params) /*Escape Elasticsearch reserved chars https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters*/ if(params.query){ // eslint-disable-next-line - params.query = params.query.replace(/([\+\-\=\&\|\>\<\!\(\)\{\}\\\[\]\^\"\~\*\?\:\/])/g, "\\$1"); + params.query = params.query.replace(/([\+\-\=\&\|\>\<\!\(\)\{\}\\\[\]\^\~\*\?\:\/])/g, "\\$1"); } + console.log(params) return this.store.query('organization', params).then(function(model) { return model; }).catch(function (reason) { @@ -22,6 +24,12 @@ export default Route.extend({ }, page: { refreshModel: true + }, + all_status: { + refreshModel: true + }, + filter: { + refreshModel: true } } }); diff --git a/app/services/global-search.js b/app/services/global-search.js index 68360d76..aecb2e98 100644 --- a/app/services/global-search.js +++ b/app/services/global-search.js @@ -10,9 +10,11 @@ export default Service.extend({ }, doSearch(query) { + console.log("do search") + console.log(this.model) //let params = assign(this.model.get('query'), { query: this.query, sort: this.sort }); // this.router.transitionTo({ queryParams: params }); - this.get('router').transitionTo('organizations.index', { queryParams: { query: query, page: 1 } }); + this.get('router').transitionTo('organizations.index', { queryParams: { query: query, page: 1}}); } }); diff --git a/app/styles/app.scss b/app/styles/app.scss index e7e2b003..64643c23 100644 --- a/app/styles/app.scss +++ b/app/styles/app.scss @@ -48,3 +48,63 @@ $desktop-width: 1024px; display: none; } } + +.filters-list { + position: relative; + display: block; + padding-left: 1.25rem; +} + +.filters-list input[type=checkbox] { + box-sizing: border-box; + padding: 0; +} + +.filters-list-input { + position: absolute; + margin-top: 0.4rem; + margin-left: -1.25rem; +} + +.filters-list-label { + display: inline-block; + margin: 0; +} + +#filters{ + line-height: 1.5rem; + h2 { + font-size: 1.5rem; + margin: 0; + line-height: normal; + } + h3 { + font-size: 1rem; + margin: 0; + line-height: normal; + } + p { + margin-bottom: 0; + } + hr { + margin: .5rem 0; + } + .filter-group{ + margin-bottom: 1rem; + } + + a { + line-height: normal; + font-size: 1rem; + font-style: italic; + } + i { + margin-right: .3rem; + } + .btn-round { + padding: 6px 9px; + float: left; + margin-right: .3rem; + } + +} diff --git a/app/templates/components/application-header.hbs b/app/templates/components/application-header.hbs index e0a6d788..f1031fb5 100755 --- a/app/templates/components/application-header.hbs +++ b/app/templates/components/application-header.hbs @@ -5,11 +5,12 @@ onCollapse=(action (mut collapsed) true) onExpand=(action (mut collapsed) false) Research Organization Registry logo

ROR

- - + {{navbar.toggle}} @@ -21,32 +22,51 @@ onCollapse=(action (mut collapsed) true) onExpand=(action (mut collapsed) false)

About

{{/nav.item}} - + {{#nav.item}}

Registry

{{/nav.item}} - + {{#nav.item}}

Community

{{/nav.item}} - + {{#nav.item}}

Blog

{{/nav.item}} - + {{#nav.item}}

Support

{{/nav.item}} - + {{/navbar.nav}} {{/navbar.content}} -{{/bs-navbar}} \ No newline at end of file +{{/bs-navbar}} +{{#if showAdvanced}} +
+
+
+

Show records with status:

+ +
+
+
+ {{/if}} \ No newline at end of file diff --git a/app/templates/components/organization-item.hbs b/app/templates/components/organization-item.hbs index 22ef56c3..ab0d316f 100644 --- a/app/templates/components/organization-item.hbs +++ b/app/templates/components/organization-item.hbs @@ -1,5 +1,5 @@
-
+
{{#if notFound}} diff --git a/app/templates/organizations/index.hbs b/app/templates/organizations/index.hbs index 02176813..09207909 100644 --- a/app/templates/organizations/index.hbs +++ b/app/templates/organizations/index.hbs @@ -5,17 +5,25 @@

{{format-number model.meta.total}} Organizations

Are we missing an organization you're looking for? Submit a request to add it

{{/if}} - - {{#each model as |organization|}} - {{organization-item model=organization}} - {{/each}} - - {{#if (gt model.meta.totalPages 1)}} - {{page-numbers model=model link="organizations.index"}} - {{/if}} +
+
+ {{filter-sidebar model=model}} +
+
+ {{#each model as |organization|}} + {{organization-item model=organization}} + {{/each}} +
+ {{#if (gt model.meta.totalPages 1)}} + {{page-numbers model=model link="organizations.index"}} + {{/if}} +
{{else}}
-
+
+ {{filter-sidebar model=model}} +
+
{{#bs-alert dismissible=false type="warning"}} No Organizations found. {{/bs-alert}} From 1f0b3bf09923ed506a4db3a133d003e47323430a Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Wed, 26 Oct 2022 07:30:45 -0500 Subject: [PATCH 3/9] fix no restuls behavior --- app/routes/organizations/index.js | 8 ++++++-- app/services/global-search.js | 5 +++-- app/templates/organizations/index.hbs | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/routes/organizations/index.js b/app/routes/organizations/index.js index aed21c09..aceb2a1c 100644 --- a/app/routes/organizations/index.js +++ b/app/routes/organizations/index.js @@ -2,14 +2,18 @@ import Route from '@ember/routing/route'; export default Route.extend({ model(params) { - console.log(params) + console.log(this.model.queryParams) /*Escape Elasticsearch reserved chars https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters*/ if(params.query){ + console.log("params exist") // eslint-disable-next-line params.query = params.query.replace(/([\+\-\=\&\|\>\<\!\(\)\{\}\\\[\]\^\~\*\?\:\/])/g, "\\$1"); } - console.log(params) + if(params.query === ""){ + console.log("empty query") + params.query = undefined + } return this.store.query('organization', params).then(function(model) { return model; }).catch(function (reason) { diff --git a/app/services/global-search.js b/app/services/global-search.js index aecb2e98..3bb6395a 100644 --- a/app/services/global-search.js +++ b/app/services/global-search.js @@ -10,8 +10,9 @@ export default Service.extend({ }, doSearch(query) { - console.log("do search") - console.log(this.model) + if (query.trim() === ''){ + query = undefined + } //let params = assign(this.model.get('query'), { query: this.query, sort: this.sort }); // this.router.transitionTo({ queryParams: params }); diff --git a/app/templates/organizations/index.hbs b/app/templates/organizations/index.hbs index 09207909..0bcbca9d 100644 --- a/app/templates/organizations/index.hbs +++ b/app/templates/organizations/index.hbs @@ -25,7 +25,8 @@
{{#bs-alert dismissible=false type="warning"}} - No Organizations found. + No Organizations found. {{#link-to "organizations.index" (query-params + query=undefined page=undefined) }}Return to organizations list{{/link-to}}. {{/bs-alert}}
From 72c088aaf80dd93ce7bd31b25ea1debf25799c80 Mon Sep 17 00:00:00 2001 From: lizkrznarich Date: Wed, 26 Oct 2022 08:03:51 -0500 Subject: [PATCH 4/9] add popover --- app/styles/app.scss | 12 ++++++ .../components/application-header.hbs | 1 - app/templates/components/filter-sidebar.hbs | 37 +++++++++---------- app/templates/organizations/index.hbs | 2 +- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/app/styles/app.scss b/app/styles/app.scss index 64643c23..8bffbfee 100644 --- a/app/styles/app.scss +++ b/app/styles/app.scss @@ -27,6 +27,14 @@ $desktop-width: 1024px; } } +.fa-question-circle { + font-size: 1.1rem; + &:hover{ + color: #53BAA1; + } + +} + .badge { padding: 8px 12px; font-size: .8em; @@ -49,6 +57,10 @@ $desktop-width: 1024px; } } +.popover { + font-size: .8rem; +} + .filters-list { position: relative; display: block; diff --git a/app/templates/components/application-header.hbs b/app/templates/components/application-header.hbs index f1031fb5..1dc1a35e 100755 --- a/app/templates/components/application-header.hbs +++ b/app/templates/components/application-header.hbs @@ -3,7 +3,6 @@ onCollapse=(action (mut collapsed) true) onExpand=(action (mut collapsed) false)
Research Organization Registry logo -

ROR