From a296e51538e8bc3e6744f1cd624c25d02754b636 Mon Sep 17 00:00:00 2001 From: Annelies-P Date: Fri, 9 Apr 2021 10:50:48 +0200 Subject: [PATCH 1/4] KAS-2405 refactor publications index route --- app/pods/publications/controller.js | 59 ---------------------- app/pods/publications/index/controller.js | 60 +++++++++++++++++++++-- app/pods/publications/index/route.js | 32 +++++------- app/pods/publications/index/template.hbs | 51 +++++++++++++++++++ app/pods/publications/route.js | 9 ---- app/pods/publications/template.hbs | 60 +---------------------- 6 files changed, 122 insertions(+), 149 deletions(-) diff --git a/app/pods/publications/controller.js b/app/pods/publications/controller.js index 9747afdcad..dde8c841f8 100644 --- a/app/pods/publications/controller.js +++ b/app/pods/publications/controller.js @@ -1,64 +1,5 @@ import Controller from '@ember/controller'; -import { inject as service } from '@ember/service'; -import { action } from '@ember/object'; -import { tracked } from '@glimmer/tracking'; -import PublicationFilter from 'frontend-kaleidos/utils/publication-filter'; export default class PublicationsController extends Controller { - @service publicationService; - @service('-routing') routing; - @tracked isShowPublicationModal = false; - @tracked showLoader = false; - @tracked isShowPublicationFilterModal = false; - @tracked publicationFilter = new PublicationFilter(JSON.parse(localStorage.getItem('publicationFilter')) || {}); - - @action - async startPublicationFromCaseId(_caseId) { - this.showLoader = true; - const newPublicationNumber = await this.publicationService.getNewPublicationNextNumber(); - const newPublication = await this.publicationService.createNewPublication(newPublicationNumber, '', _caseId); - this.showLoader = false; - - this.transitionToRoute('publications.publication.case', newPublication.get('id')); - } - - @action - showPublicationModal() { - this.isShowPublicationModal = true; - } - - @action - closePublicationModal() { - this.isShowPublicationModal = false; - } - - @action - async saveNewPublication(publication) { - const newPublication = await this.publicationService.createNewPublication(publication.number, publication.suffix, false, publication.longTitle, publication.shortTitle); - this.closePublicationModal(); - this.transitionToRoute('publications.publication', newPublication.get('id')); - } - - @action - showFilterModal() { - this.isShowPublicationFilterModal = true; - } - - @action - cancelPublicationsFilter() { - this.isShowPublicationFilterModal = false; - } - - @action - savePublicationsFilter(publicationFilter) { - this.publicationFilter = publicationFilter; - localStorage.setItem('publicationFilter', this.publicationFilter.toString()); - this.isShowPublicationFilterModal = false; - this.send('refreshModel'); - } - - get shouldShowPublicationHeader() { - return this.routing.currentRouteName.startsWith('publications.index'); - } } diff --git a/app/pods/publications/index/controller.js b/app/pods/publications/index/controller.js index 86f2060540..b300a476de 100644 --- a/app/pods/publications/index/controller.js +++ b/app/pods/publications/index/controller.js @@ -1,7 +1,9 @@ import Controller from '@ember/controller'; import { action } from '@ember/object'; +import { inject as service } from '@ember/service'; import { tracked } from '@glimmer/tracking'; import tableColumns from 'frontend-kaleidos/config/publications/overview-table-columns'; +import PublicationFilter from 'frontend-kaleidos/utils/publication-filter'; export default class PublicationsIndexController extends Controller { queryParams = { @@ -16,6 +18,11 @@ export default class PublicationsIndexController extends Controller { }, }; + @service publicationService; + + page = 0; + size = 25; + sort = '-created'; sizeOptions = Object.freeze([5, 10, 25, 50, 100, 200]); @tracked tableColumnDisplayOptions = JSON.parse(localStorage.getItem('tableColumnDisplayOptions')) @@ -26,9 +33,11 @@ export default class PublicationsIndexController extends Controller { tableColumns = tableColumns; @tracked showTableDisplayOptions = false; - @tracked page = 0; - @tracked size = 25; - @tracked sort = '-created'; + @tracked isShowPublicationModal = false; + @tracked showLoader = false; + @tracked isShowPublicationFilterModal = false; + + @tracked publicationFilter = new PublicationFilter(JSON.parse(localStorage.getItem('publicationFilter')) || {}); @action navigateToPublication(publicationFlowRow) { @@ -56,4 +65,49 @@ export default class PublicationsIndexController extends Controller { closeColumnDisplayOptionsModal() { this.showTableDisplayOptions = false; } + + @action + async startPublicationFromCaseId(_caseId) { + this.showLoader = true; + const newPublicationNumber = await this.publicationService.getNewPublicationNextNumber(); + const newPublication = await this.publicationService.createNewPublication(newPublicationNumber, '', _caseId); + this.showLoader = false; + + this.transitionToRoute('publications.publication.case', newPublication.get('id')); + } + + @action + showPublicationModal() { + this.isShowPublicationModal = true; + } + + @action + closePublicationModal() { + this.isShowPublicationModal = false; + } + + @action + async saveNewPublication(publication) { + const newPublication = await this.publicationService.createNewPublication(publication.number, publication.suffix, false, publication.longTitle, publication.shortTitle); + this.closePublicationModal(); + this.transitionToRoute('publications.publication', newPublication.get('id')); + } + + @action + showFilterModal() { + this.isShowPublicationFilterModal = true; + } + + @action + cancelPublicationsFilter() { + this.isShowPublicationFilterModal = false; + } + + @action + savePublicationsFilter(publicationFilter) { + this.publicationFilter = publicationFilter; + localStorage.setItem('publicationFilter', this.publicationFilter.toString()); + this.isShowPublicationFilterModal = false; + this.send('refreshModel'); + } } diff --git a/app/pods/publications/index/route.js b/app/pods/publications/index/route.js index b723408fa3..db723bb54e 100644 --- a/app/pods/publications/index/route.js +++ b/app/pods/publications/index/route.js @@ -21,30 +21,33 @@ export default class PublicationsIndexRoute extends Route.extend(AuthenticatedRo }, } + beforeModel() { + this.publicationFilter = new PublicationFilter(JSON.parse(localStorage.getItem('publicationFilter')) || {}); + } + async model(params) { - const publicationFilter = new PublicationFilter(JSON.parse(localStorage.getItem('publicationFilter')) || {}); const ids = []; let ministerFilter = {}; - if (publicationFilter.publishedFilterOption) { + if (this.publicationFilter.publishedFilterOption) { ids.push(CONFIG.publicationStatusPublished.id); } - if (publicationFilter.pausedFilterOption) { + if (this.publicationFilter.pausedFilterOption) { ids.push(CONFIG.publicationStatusPauzed.id); } - if (publicationFilter.withdrawnFilterOption) { + if (this.publicationFilter.withdrawnFilterOption) { ids.push(CONFIG.publicationStatusWithdrawn.id); } - if (publicationFilter.toPublishFilterOption) { + if (this.publicationFilter.toPublishFilterOption) { ids.push(CONFIG.publicationStatusToPublish.id); } - if (!(publicationFilter.ministerFilterOption && publicationFilter.notMinisterFilterOption)) { - if (publicationFilter.ministerFilterOption) { + if (!(this.publicationFilter.ministerFilterOption && this.publicationFilter.notMinisterFilterOption)) { + if (this.publicationFilter.ministerFilterOption) { ministerFilter = { ':has:subcases': 'yes', }; } - if (publicationFilter.notMinisterFilterOption) { + if (this.publicationFilter.notMinisterFilterOption) { ministerFilter = { ':has-no:subcases': 'yes', }; @@ -77,7 +80,7 @@ export default class PublicationsIndexRoute extends Route.extend(AuthenticatedRo } // note that the "dasherize" here is used in order to keep the original column keyName's if (qpSort === dasherize('publicationNumber')) { - // Specifically requested by Johan, because Suffix needs to be string and Quater... + // show the most recent publication first if publication-number is the same apiSort = 'publication-number,-created'; } else if (qpSort === dasherize('regulationType')) { apiSort = 'regulation-type.position'; @@ -108,15 +111,4 @@ export default class PublicationsIndexRoute extends Route.extend(AuthenticatedRo refreshModel() { this.refresh(); } - - @action - refresh() { - super.refresh(); - } - - setupController(controller, model) { - super.setupController(controller, model); - const params = this.paramsFor('publications.index'); - controller.page = params.page; - } } diff --git a/app/pods/publications/index/template.hbs b/app/pods/publications/index/template.hbs index 726fb3b977..d80fe3eb79 100644 --- a/app/pods/publications/index/template.hbs +++ b/app/pods/publications/index/template.hbs @@ -1,3 +1,50 @@ +{{!-- TODO auk-panel-layout gebruiken, component ? --}} +
+ + + + +
+

{{t "publications" }}

+
+
+
+ + + + + + + + + {{t "filter-content"}} + + + + + + {{t "publications-new"}} + + + +
+
+
+ {{#if this.isShowPublicationModal}} + + {{/if}} + {{#if this.isShowPublicationFilterModal}} + + {{/if}} + {{outlet}} +
+
{{/if}} +{{!-- LOADER --}} +{{#if this.showLoader}} + +{{/if}} \ No newline at end of file diff --git a/app/pods/publications/route.js b/app/pods/publications/route.js index 815be446fa..b2fc88a715 100644 --- a/app/pods/publications/route.js +++ b/app/pods/publications/route.js @@ -1,15 +1,6 @@ import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; import Route from '@ember/routing/route'; -import { action } from '@ember/object'; export default class PublicationsRoute extends Route.extend(AuthenticatedRouteMixin) { - @action - refreshModel() { - this.refresh(); - } - @action - refresh() { - super.refresh(); - } } diff --git a/app/pods/publications/template.hbs b/app/pods/publications/template.hbs index 5f0f7fcdb3..bcb64548e4 100644 --- a/app/pods/publications/template.hbs +++ b/app/pods/publications/template.hbs @@ -1,58 +1,2 @@ -{{ page-title - (t "publications") -}} -{{#if shouldShowPublicationHeader}} - {{!-- TODO auk-panel-layout gebruiken, component ? --}} -
- - - - -
-

{{t "publications" }}

-
-
-
- - - - - - - - - {{t "filter-content"}} - - - - - - {{t "publications-new"}} - - - -
-
-
- {{#if this.isShowPublicationModal}} - - {{/if}} - {{#if this.isShowPublicationFilterModal}} - - {{/if}} - {{outlet}} -
-
-{{else}} - {{outlet}} -{{/if}} -{{!-- LOADER --}} -{{#if this.showLoader}} - -{{/if}} \ No newline at end of file +{{ page-title (t "publications") }} +{{outlet}} From 73233bbeb4510d164ed04a3b3e6958e18c848710 Mon Sep 17 00:00:00 2001 From: Annelies-P Date: Fri, 9 Apr 2021 11:57:09 +0200 Subject: [PATCH 2/4] merge from development --- app/pods/publications/index/template.hbs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/pods/publications/index/template.hbs b/app/pods/publications/index/template.hbs index f03e568cf5..e114b04318 100644 --- a/app/pods/publications/index/template.hbs +++ b/app/pods/publications/index/template.hbs @@ -292,11 +292,11 @@
{{#if this.showTableDisplayOptions}} - + {{/if}} {{!-- LOADER --}} From 5d383dfc7050bba68a3dca6aa322df24ad56305e Mon Sep 17 00:00:00 2001 From: Annelies-P Date: Fri, 9 Apr 2021 12:33:36 +0200 Subject: [PATCH 3/4] remove AuthenticatedRouteMixin from index route --- app/pods/publications/index/route.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/pods/publications/index/route.js b/app/pods/publications/index/route.js index db723bb54e..2cb82dcbab 100644 --- a/app/pods/publications/index/route.js +++ b/app/pods/publications/index/route.js @@ -1,11 +1,10 @@ -import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; import Route from '@ember/routing/route'; import { action } from '@ember/object'; import CONFIG from 'frontend-kaleidos/utils/config'; import { dasherize } from '@ember/string'; import PublicationFilter from 'frontend-kaleidos/utils/publication-filter'; -export default class PublicationsIndexRoute extends Route.extend(AuthenticatedRouteMixin) { +export default class PublicationsIndexRoute extends Route { queryParams = { page: { refreshModel: true, From 57a64c7064b17995cf61636116b898d9c40a5fa9 Mon Sep 17 00:00:00 2001 From: Annelies-P Date: Fri, 9 Apr 2021 16:26:37 +0200 Subject: [PATCH 4/4] fix merge issue --- app/pods/publications/index/template.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pods/publications/index/template.hbs b/app/pods/publications/index/template.hbs index 3eac00bcca..0cf5d05d05 100644 --- a/app/pods/publications/index/template.hbs +++ b/app/pods/publications/index/template.hbs @@ -86,7 +86,7 @@   - + {{#if this.tableColumnDisplayOptions.caseName}} {{!-- There is legacy data were case does not have a shortTitle, we have to fall back to title --}}