Skip to content

Commit

Permalink
Merge branch 'development' into DES/enhancement/#732-vlc-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
brenner-company committed Apr 15, 2021
2 parents 3e395d5 + f8ef8e1 commit 008a2f2
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 185 deletions.
45 changes: 0 additions & 45 deletions app/components/agenda/agenda-overview/agenda-overview-item.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,51 +45,6 @@
{{/if}}

</div>

{{!-- TODO: Commented out section triggers many requests that slow down agenda overview
<div class="vlc-u-flex-float-right">
{{#if currentSessionService.isOvrb}}
PUBLICATION FLOW CALL TO ACTION
<div class="vlc-u-flex-float-right">
PUBLICATION FLOW CALL TO ACTION
{{#if (not @isEditingFormallyOkStatus)}}
<div class="auk-button-toolbar">
{{#if (await @agendaitem.publicationFlow)}}
<LinkTo
class=""
@route="publications.publication"
@model={{ await @agendaitem.publicationFlowId }}
>
{{t "publications-to" }}
</LinkTo>
{{else}}
{{#if (await @agendaitem.case)}}
<WebComponents::AuButton
@skin="tertiary"
@layout="icon-only"
@disabled={{this.startPublication.isRunning}}
data-test-start-publication
{{on "click" (perform this.startPublication)}}>
{{t "start-publication"}}
</WebComponents::AuButton>
{{/if}}
{{/if}}
</div>
{{/if}}
END PUBLICATION FLOW CALL TO ACTION
</div>
{{/if}}
END PUBLICATION FLOW CALL TO ACTION
</div>
--}}
</div>

<div class="auk-u-flex auk-u-flex--justify-between">
Expand Down
11 changes: 0 additions & 11 deletions app/components/agenda/agenda-overview/agenda-overview-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default class AgendaOverviewItem extends AgendaSidebarItem {
@service toaster;
@service sessionService;
@service agendaService;
@service publicationService;
@service router;
@service('current-session') currentSessionService;

Expand Down Expand Up @@ -60,16 +59,6 @@ export default class AgendaOverviewItem extends AgendaSidebarItem {
return this.agendaitemDocuments.length > this.documentListSize;
}

@action
async startPublication() {
this.showLoader = true;
const _case = await this.subcase.get('case');
const newPublicationNumber = await this.publicationService.getNewPublicationNextNumber();
const newPublication = await this.publicationService.createNewPublication(newPublicationNumber, '', _case.id);
this.showLoader = false;
this.router.transitionTo('publications.publication.case', newPublication.id);
}

@task
*setFormallyOkStatus(status) {
yield this.args.setFormallyOkAction(status.uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,29 @@
</WebComponents::AuToolbar::Item>
</WebComponents::AuToolbar::Group>
<WebComponents::AuToolbar::Group @position="right">
{{#if @subcase.case.id}}
{{!-- TODO: for now the link-button is hidden while loading.
A disabled state would be better to avoid flashing a new button in view once loaded. --}}
{{#if (and @subcase this.loadCase.isIdle)}}
<WebComponents::AuToolbar::Item>
<WebComponents::AuButton
data-test-agendaitem-titles-to-subcase
{{on "click" this.redirectToSubcase}}
@skin="tertiary"
@layout="icon-right"
@icon="chevron-right"
<LinkTo
class="auk-button auk-button--tertiary"
data-test-agendaitem-titles-to-subcase={{true}}
@route="cases.case.subcases.subcase.overview"
@models={{array this.case.id @subcase.id}}
>
{{t "to-subcase"}}
</WebComponents::AuButton>
<span class="auk-button__content">
<span class="auk-button__label">{{t "to-subcase"}}</span>
<div class="auk-icon auk-icon--default auk-icon--chevron-right">
<i class="ki ki-chevron-right"></i>
</div>
</span>
</LinkTo>
</WebComponents::AuToolbar::Item>
{{/if}}
<WebComponents::AuToolbar::Item>
<WebComponents::AuButton
data-test-agendaitem-titles-edit
{{on "click" this.toggleIsEditingAction}}
{{on "click" this.startEditing}}
@skin="tertiary"
@icon="edit"
@layout="icon-only"
Expand Down Expand Up @@ -82,7 +88,7 @@
{{/if}}
{{#if
(and @agendaitem.isDesignAgenda
(and currentSession.isEditor @agendaitem.formallyOkToShow))
(and this.currentSession.isEditor @agendaitem.formallyOkToShow))
}}
<WebComponents::AuPill
@skin={{@agendaitem.formallyOkToShow.svg.color}}
Expand All @@ -108,4 +114,4 @@
</WebComponents::AuModal::Footer>
{{/if}}
</WebComponents::AuPanel>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,33 @@ import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { alias } from '@ember/object/computed';
import {
task,
lastValue
} from 'ember-concurrency-decorators';

export default class AgendaitemTitles extends Component {
@alias('args.agendaitem.agendaActivity.subcase') subcase;

@tracked showLoader = false;

@service currentSession;

@service publicationService;

@service router;

@action
toggleIsEditingAction() {
this.args.toggleIsEditing();
@lastValue('loadCase') case;

@tracked showLoader = false;

constructor() {
super(...arguments);
this.loadCase.perform();
}

@action
async redirectToSubcase() {
const subcase = this.args.subcase;
const _case = await subcase.get('case');
const subcaseId = subcase.id;
this.router.transitionTo('cases.case.subcases.subcase.overview', _case.id, subcaseId);
@task
*loadCase() {
const _case = yield this.args.subcase.case;
return _case;
}

@action
async startPublication() {
this.showLoader = true;
const _case = await this.subcase.get('case');
const newPublicationNumber = await this.publicationService.getNewPublicationNextNumber();
const newPublication = await this.publicationService.createNewPublication(newPublicationNumber, '', _case.id);
this.showLoader = false;
this.router.transitionTo('publications.publication.case', newPublication.id);
startEditing() {
this.args.toggleIsEditing();
}
}
12 changes: 11 additions & 1 deletion app/components/publications/new-publication-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { tracked } from '@glimmer/tracking';

export default class NewPublicationModal extends Component {
@service publicationService;
@service store;

@tracked number = null;
@tracked suffix = null;
Expand Down Expand Up @@ -38,7 +39,16 @@ export default class NewPublicationModal extends Component {

@task
*initPublicationNumber() {
this.number = yield this.publicationService.getNewPublicationNextNumber();
// Deze query possibly breaks if publication-flows without number exist
const latestPublication = yield this.store.queryOne('publication-flow', {
sort: '-publication-number',
});
if (latestPublication) {
this.number = latestPublication.publicationNumber + 1;
} else {
// This should only be a "no-data" issue, in that case we have to default to number 1
this.number = 1;
}
}

@task
Expand Down
8 changes: 8 additions & 0 deletions app/components/publications/urgency-level-checkbox.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="auk-form-group">
{{#unless this.loadData.isRunning}}
<WebComponents::VlCheckbox
@value={{@urgencyLevel.isUrgent}}
@toggle={{this.toggleUrgency}}
@label={{t "priority-procedure"}}/>
{{/unless}}
</div>
29 changes: 29 additions & 0 deletions app/components/publications/urgency-level-checkbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';
import CONFIG from 'frontend-kaleidos/utils/config';
import { inject as service } from '@ember/service';
import { task } from 'ember-concurrency-decorators';
import { tracked } from '@glimmer/tracking';

export default class UrgencyLevelCheckboxComponent extends Component {
@service store;

@tracked urgencyLevels = null;

constructor() {
super(...arguments);
this.loadData.perform();
}

@task
*loadData() {
this.urgencyLevels = yield this.store.query('urgency-level', {});
}

@action
toggleUrgency(value) {
const uri = value ? CONFIG.URGENCY_LEVELS.spoedprocedure : CONFIG.URGENCY_LEVELS.standaard;
const urgencyLevel = this.urgencyLevels.find((level) => level.uri === uri);
this.args.onChange(urgencyLevel);
}
}
4 changes: 1 addition & 3 deletions app/models/case.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export default Model.extend({
isArchived: attr('boolean'),
confidential: attr('boolean'),

publicationFlow: belongsTo('publication-flow', {
inverse: null,
}),
publicationFlow: belongsTo('publication-flow'),

subcases: hasMany('subcase'),
pieces: hasMany('piece'),
Expand Down
7 changes: 1 addition & 6 deletions app/models/publication-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default class PublicationFlow extends Model {
@attr('datetime') publishDateRequested;
@attr('datetime') publishedAt;
@attr('string') remark;
@attr('number') priority;
@attr('datetime') created;
@attr('datetime') modified;

Expand All @@ -30,6 +29,7 @@ export default class PublicationFlow extends Model {

@belongsTo('publication-type') type;
@belongsTo('regulation-type') regulationType;
@belongsTo('urgency-level') urgencyLevel;

// Has many .
@hasMany('numac-number', {
Expand All @@ -39,11 +39,6 @@ export default class PublicationFlow extends Model {
@hasMany('contact-person') contactPersons;
@hasMany('mandatee') mandatees;

@computed('priority')
get hasPriority() {
return this.priority > 0;
}

@computed('publicationNumber,publicationSuffix')
get publicationNumberToDisplay() {
if (this.publicationSuffix && this.publicationSuffix !== '') {
Expand Down
13 changes: 13 additions & 0 deletions app/models/urgency-level.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Model, {
attr, hasMany
} from '@ember-data/model';
import CONFIG from 'frontend-kaleidos/utils/config';
export default class UrgencyLevel extends Model {
@attr('string') uri;
@attr('string') label;
@attr('number') position;
@hasMany('publication-flow') publications;
get isUrgent() {
return this.uri === CONFIG.URGENCY_LEVELS.spoedprocedure;
}
}
39 changes: 28 additions & 11 deletions app/pods/publications/index/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import CONFIG from 'frontend-kaleidos/utils/config';
import tableColumns from 'frontend-kaleidos/config/publications/overview-table-columns';
import PublicationFilter from 'frontend-kaleidos/utils/publication-filter';

Expand All @@ -24,6 +25,7 @@ export default class PublicationsIndexController extends Controller {
size = 25;
sort = '-created';
sizeOptions = Object.freeze([5, 10, 25, 50, 100, 200]);
urgencyLevels = CONFIG.URGENCY_LEVELS;

@tracked tableColumnDisplayOptions = JSON.parse(localStorage.getItem('tableColumnDisplayOptions'))
|| tableColumns.reduce((accumulator, currentValue) => {
Expand Down Expand Up @@ -66,16 +68,6 @@ export default class PublicationsIndexController extends Controller {
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;
Expand All @@ -88,7 +80,7 @@ export default class PublicationsIndexController extends Controller {

@action
async saveNewPublication(publication) {
const newPublication = await this.publicationService.createNewPublication(publication.number, publication.suffix, false, publication.longTitle, publication.shortTitle);
const newPublication = await this.createNewPublication(publication.number, publication.suffix, publication.longTitle, publication.shortTitle);
this.closePublicationModal();
this.transitionToRoute('publications.publication', newPublication.get('id'));
}
Expand All @@ -110,4 +102,29 @@ export default class PublicationsIndexController extends Controller {
this.isShowPublicationFilterModal = false;
this.send('refreshModel');
}

async createNewPublication(publicationNumber, publicationSuffix, title, shortTitle) {
const creationDatetime = new Date();
const caze = this.store.createRecord('case', {
title,
shortTitle,
created: creationDatetime,
});
await caze.save();

const toPublishStatus = (await this.store.queryOne('publication-status', {
'filter[:id:]': CONFIG.publicationStatusToPublish.id,
}));

const publicationFlow = this.store.createRecord('publication-flow', {
publicationNumber,
publicationSuffix,
case: caze,
created: creationDatetime,
status: toPublishStatus,
modified: creationDatetime,
});
await publicationFlow.save();
return publicationFlow;
}
}
2 changes: 1 addition & 1 deletion app/pods/publications/index/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@

{{#if this.tableColumnDisplayOptions.speedProcedure}}
<td class="auk-u-text-align--center">
{{#if row.hasPriority}}
{{#if row.urgencyLevel.isUrgent}}
<WebComponents::AuIcon @iconSkinColor="warning" @name="alert-triangle"/>
<EmberTooltip @tooltipClass="auk-tooltip" @side="bottom">
<p>
Expand Down
Loading

0 comments on commit 008a2f2

Please sign in to comment.