-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #820 from kanselarij-vlaanderen/feature/KAS-261-re…
…factor-publications-index-route Feature/kas 261 refactor publications index route
- Loading branch information
Showing
6 changed files
with
125 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,2 @@ | ||
{{ page-title | ||
(t "publications") | ||
}} | ||
{{#if shouldShowPublicationHeader}} | ||
{{!-- TODO auk-panel-layout gebruiken, component ? --}} | ||
<div class="vlc-panel-layout__main-content"> | ||
<WebComponents::AuNavbar class="vlc-publication-overview-navbar" @border="bottom" @skin="gray-100" @auto="true"> | ||
<WebComponents::AuToolbar> | ||
<WebComponents::AuToolbar::Group @position="left"> | ||
<WebComponents::AuToolbar::Item> | ||
<div class="auk-u-flex auk-u-flex--vertical auk-u-mt-2"> | ||
<h4 class="auk-toolbar-complex__title">{{t "publications" }}</h4> | ||
</div> | ||
</WebComponents::AuToolbar::Item> | ||
</WebComponents::AuToolbar::Group> | ||
<WebComponents::AuToolbar::Group @position="right"> | ||
<WebComponents::AuToolbar::Item> | ||
<WebComponents::AuDropdown> | ||
<Publications::PublicationCaseSearch /> | ||
</WebComponents::AuDropdown> | ||
</WebComponents::AuToolbar::Item> | ||
<WebComponents::AuToolbar::Item> | ||
<WebComponents::AuButton @skin="secondary" @icon="filter" {{on "click" (fn this.showFilterModal)}}> | ||
{{t "filter-content"}} | ||
</WebComponents::AuButton> | ||
</WebComponents::AuToolbar::Item> | ||
|
||
<WebComponents::AuToolbar::Item> | ||
<WebComponents::AuButton data-test-publication-header-button-new @icon="add" @skin="primary" {{on "click" | ||
(fn this.showPublicationModal)}}> | ||
{{t "publications-new"}} | ||
</WebComponents::AuButton> | ||
</WebComponents::AuToolbar::Item> | ||
</WebComponents::AuToolbar::Group> | ||
</WebComponents::AuToolbar> | ||
</WebComponents::AuNavbar> | ||
<div class="vlc-u-box-model-maximize-height vlc-scroll-wrapper"> | ||
{{#if this.isShowPublicationModal}} | ||
<Publications::NewPublicationModal | ||
@onCancel={{this.closePublicationModal}} | ||
@onSave={{this.saveNewPublication}} /> | ||
{{/if}} | ||
{{#if this.isShowPublicationFilterModal}} | ||
<Publications::PublicationsFilterModal | ||
@filter={{this.publicationFilter}} | ||
@onCancel={{this.cancelPublicationsFilter}} | ||
@onSave={{this.savePublicationsFilter}} /> | ||
{{/if}} | ||
{{outlet}} | ||
</div> | ||
</div> | ||
{{else}} | ||
{{outlet}} | ||
{{/if}} | ||
{{!-- LOADER --}} | ||
{{#if this.showLoader}} | ||
<WebComponents::AuLoadingOverlay /> | ||
{{/if}} | ||
{{ page-title (t "publications") }} | ||
{{outlet}} |