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
# Conflicts:
#	app/components/sessions/session-agenda-nav.hbs
  • Loading branch information
brenner-company committed Apr 27, 2021
2 parents 7090180 + 8eda40f commit ffe292b
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
data-test-agenda-overview-sub-item
@route="agenda.agendaitems.agendaitem"
@model={{@agendaitem.id}}
@query={{hash anchor=@agendaitem.id}}
>
<pre class="auk-u-text-pre-line">
{{#if @agendaitem.shortTitle}}
Expand Down
26 changes: 26 additions & 0 deletions app/components/publications/publication/publication-navigation.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<WebComponents::AuTabs @reversed="true">
<WebComponents::AuTab @isHierarchicalBack="true" @route="publications"
data-test-publication-case-nav-go-back></WebComponents::AuTab>
<WebComponents::AuTab @route="publications.publication.case" data-test-publication-case-nav-case>
{{t "agendaitem-case"}}
</WebComponents::AuTab>
{{!-- TODO adapt tab content classes to new CSS once available in CSS-package --}}
<WebComponents::AuTab @route="publications.publication.documents" data-test-publication-case-nav-documents>
<div class="auk-u-flex auk-u-flex--center">
<span class="auk-u-mr-2">{{t "documents"}}</span>
{{#unless this.loadData.isRunning}}
<p>({{this.documentsCount}})</p>
{{/unless}}
</div>
</WebComponents::AuTab>
<WebComponents::AuTab @route="publications.publication.translations" data-test-publication-case-nav-translations>
<div class="auk-u-flex auk-u-flex--center">
<span class="auk-u-mr-2">{{t "translations"}}</span>
</div>
</WebComponents::AuTab>
<WebComponents::AuTab @route="publications.publication.publishpreview" data-test-publication-case-nav-publishpreview>
<div class="auk-u-flex auk-u-flex--center">
<span class="auk-u-mr-2">{{t "publishpreview-requests"}}</span>
</div>
</WebComponents::AuTab>
</WebComponents::AuTabs>
26 changes: 26 additions & 0 deletions app/components/publications/publication/publication-navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency-decorators';
import { inject as service } from '@ember/service';

export default class PublicationNavigation extends Component {
@service store;

@tracked documentsCount = 0;

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

@task
*loadData() {
const pieces = yield this.store.query('piece',
{
'filter[cases][publication-flow][:id:]': this.args.publicationFlow.id,
'page[size]': 1,
}
);
this.documentsCount = pieces.meta.count;
}
}
1 change: 1 addition & 0 deletions app/components/sessions/session-agenda-nav.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<LinkTo
@route="agenda.agendaitems.index"
@activeClass="active"
@query={{if this.currentAgendaItemId (hash anchor=this.currentAgendaItemId)}}
>
<span class="auk-tabs__tab-inner">
{{t "overview"}}
Expand Down
16 changes: 14 additions & 2 deletions app/components/sessions/session-agenda-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class SessionsSessionAgendaNavComponent extends Component {
/**
* @argument currentAgenda
*/
@service('-routing') routing;
@service router;
@service sessionService;
@service currentSession;

Expand All @@ -14,6 +14,18 @@ export default class SessionsSessionAgendaNavComponent extends Component {
}

get isInAgendaItemDetailRoute() {
return this.routing.currentRouteName.startsWith('agenda.agendaitems.agendaitem');
return this.router.currentRouteName.startsWith('agenda.agendaitems.agendaitem');
}

get currentAgendaItemId() {
const currentRoute = this.router.currentRoute;
let agendaItemsRoute = currentRoute;
if (currentRoute && currentRoute.name.startsWith('agenda.agendaitems.agendaitem')) {
while (agendaItemsRoute.name !== 'agenda.agendaitems.agendaitem') {
agendaItemsRoute = agendaItemsRoute.parent;
}
return agendaItemsRoute.params.agendaitem_id;
}
return null;
}
}
6 changes: 2 additions & 4 deletions app/models/publication-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export default class PublicationFlow extends Model {
const openVertalingen = this.publicationService.getPublicationCountsPerTypePerStatus(totals, CONFIG.ACTIVITY_TYPES.vertalen.url, CONFIG.ACTIVITY_STATUSSES.open.url);
const closedVertalingen = this.publicationService.getPublicationCountsPerTypePerStatus(totals, CONFIG.ACTIVITY_TYPES.vertalen.url, CONFIG.ACTIVITY_STATUSSES.closed.url);
const withdrawnVertalingen = this.publicationService.getPublicationCountsPerTypePerStatus(totals, CONFIG.ACTIVITY_TYPES.vertalen.url, CONFIG.ACTIVITY_STATUSSES.withdrawn.url);
const total = openVertalingen + closedVertalingen + withdrawnVertalingen;
return total;
return openVertalingen + closedVertalingen + withdrawnVertalingen;
});
}

Expand All @@ -77,8 +76,7 @@ export default class PublicationFlow extends Model {
const openDrukproeven = this.publicationService.getPublicationCountsPerTypePerStatus(totals, CONFIG.ACTIVITY_TYPES.drukproeven.url, CONFIG.ACTIVITY_STATUSSES.open.url);
const closedDrukproeven = this.publicationService.getPublicationCountsPerTypePerStatus(totals, CONFIG.ACTIVITY_TYPES.drukproeven.url, CONFIG.ACTIVITY_STATUSSES.closed.url);
const withdrawnDrukproeven = this.publicationService.getPublicationCountsPerTypePerStatus(totals, CONFIG.ACTIVITY_TYPES.drukproeven.url, CONFIG.ACTIVITY_STATUSSES.withdrawn.url);
const total = openDrukproeven + closedDrukproeven + withdrawnDrukproeven;
return total;
return openDrukproeven + closedDrukproeven + withdrawnDrukproeven;
});
}

Expand Down
25 changes: 25 additions & 0 deletions app/pods/agenda/agendaitems/index/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ import {
AgendaitemGroup
} from 'frontend-kaleidos/utils/agendaitem-utils';
import { animationFrame } from 'ember-concurrency';
import { guidFor } from '@ember/object/internals';

export default class AgendaitemsAgendaController extends Controller {
queryParams = [{
anchor: {
type: 'string',
},
}];

@service sessionService;
@service agendaService;

// @tracked anchor; // TODO: don't do tracking on qp's before updating to Ember 3.22+ (https://github.com/emberjs/ember.js/issues/18715)
@tracked filter;
@tracked showModifiedOnly;

Expand All @@ -29,6 +37,14 @@ export default class AgendaitemsAgendaController extends Controller {

@controller('agenda.agendaitems') agendaitemsController;

get id() {
return guidFor(this);
}

get element() {
return document.getElementById(this.id);
}

@action
searchAgendaitems(value) {
set(this.agendaitemsController, 'filter', value);
Expand Down Expand Up @@ -64,4 +80,13 @@ export default class AgendaitemsAgendaController extends Controller {
toggleShowModifiedOnly() {
set(this.agendaitemsController, 'showModifiedOnly', !this.agendaitemsController.showModifiedOnly);
}

scrollToAnchor() {
if (this.anchor) {
const itemCardLink = this.element.querySelector(`a[href*='anchor=${this.anchor}']`);
itemCardLink.scrollIntoView({
block: 'nearest',
});
}
}
}
11 changes: 10 additions & 1 deletion app/pods/agenda/agendaitems/index/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ import Route from '@ember/routing/route';
import { hash } from 'rsvp';
import { inject as service } from '@ember/service';
import CONFIG from 'frontend-kaleidos/utils/config';
import { animationFrame } from 'ember-concurrency';

export default class AgendaItemsAgendaRoute extends Route {
queryParams = {
anchor: {
refreshModel: false,
},
};

@service sessionService;
@service agendaService;

Expand Down Expand Up @@ -53,6 +60,8 @@ export default class AgendaItemsAgendaRoute extends Route {
controller.meeting = meeting;
controller.agenda = agenda;
controller.previousAgenda = await agenda.previousVersion;
controller.groupNotasOnGroupName.perform(model.notas);
await controller.groupNotasOnGroupName.perform(model.notas);
await animationFrame(); // make sure rendering has happened before trying to scroll
controller.scrollToAnchor();
}
}
5 changes: 4 additions & 1 deletion app/pods/agenda/agendaitems/index/template.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div class="vlc-panel-layout-agenda__detail auk-u-bg-alt">
<div
id={{this.id}}
class="vlc-panel-layout-agenda__detail auk-u-bg-alt"
>
<div class="vlc-u-box-model-maximize-height vlc-scroll-wrapper">
<Agenda::AgendaitemSearch
@searchText={{readonly this.agendaitemsController.filter}}
Expand Down
73 changes: 3 additions & 70 deletions app/pods/publications/publication/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export default class PublicationController extends Controller {
return this.model.publicationFlow.case.get('title');
}

get documentsCount() {
return `(${this.model.counts.documentCount})`;
}

@action
toggleSidebar() {
this.sidebarIsOpen = !this.sidebarIsOpen;
Expand All @@ -44,72 +40,9 @@ export default class PublicationController extends Controller {
modifiedObject.save();
}

get showStatusForTranslations() {
const totalTranslations = this.model.counts.totalTranslations;
const closedOrWithdrawn = this.model.counts.closedOrWithdrawnTranslationRequests;
const openTranslation = this.model.counts.openTranslationRequests;

// Er zijn geen translations aangemaakt.
if (totalTranslations === 0) {
return {
status: 'not-started',
};
}

// Er is 1 open translation, toon enkel de icon
if (openTranslation === 1 && (totalTranslations === 1)) {
return {
status: '',
};
}

// Er zijn nog open statussen
if (openTranslation !== 0) {
return {
value: `${closedOrWithdrawn}/${totalTranslations}`,
};
}

// Alle requests zijn afgehandeld.
if (totalTranslations === closedOrWithdrawn) {
return {
status: 'done',
};
}
return null;
}

get showStatusForPublicationPreviews() {
const totalPublishPreviewRequests = this.model.counts.totalPublishPreviewRequests;
const closedOrWithdrawnPublishPrevieuwRequests = this.model.counts.closedOrWithdrawnPublishPrevieuwRequests;
const openPublishPreviewRequests = this.model.counts.openPublishPreviewRequests;

// Er zijn geen translations aangemaakt.
if (totalPublishPreviewRequests === 0) {
return {
status: 'not-started',
};
}

// Er is 1 open translation en er is maar 1 publishpreview, toon enkel de icon
if (openPublishPreviewRequests === 1 && (totalPublishPreviewRequests === 1)) {
return {
status: '',
};
}

// Er zijn nog open statussen
if (openPublishPreviewRequests !== 0) {
return {
value: `${closedOrWithdrawnPublishPrevieuwRequests}/${totalPublishPreviewRequests}`,
};
}

// Alle requests zijn afgehandeld.
if (totalPublishPreviewRequests === closedOrWithdrawnPublishPrevieuwRequests) {
return {
status: 'done',
};
get getClassForPublicationNumber() {
if (this.numberIsAlreadyUsed) {
return 'auk-form-group--error';
}
return null;
}
Expand Down
42 changes: 0 additions & 42 deletions app/pods/publications/publication/route.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import Route from '@ember/routing/route';
import { hash } from 'rsvp';
import CONFIG from 'frontend-kaleidos/utils/config';
import { action } from '@ember/object';

export default class PublicationRoute extends Route.extend(AuthenticatedRouteMixin) {
Expand All @@ -24,51 +23,10 @@ export default class PublicationRoute extends Route.extend(AuthenticatedRouteMix
include: 'mandatees',
});

const totalTranslations = await this.store.query('activity', {
'filter[subcase][publication-flow][:id:]': publicationFlow.id,
'filter[type][:id:]': CONFIG.ACTIVITY_TYPES.vertalen.id,
});
const closedTranslationRequests = await this.store.query('activity', {
'filter[subcase][publication-flow][:id:]': publicationFlow.id,
'filter[type][:id:]': CONFIG.ACTIVITY_TYPES.vertalen.id,
'filter[status][:id:]': CONFIG.ACTIVITY_STATUSSES.closed.id,
});
const withdrawnTranslationRequests = await this.store.query('activity', {
'filter[subcase][publication-flow][:id:]': publicationFlow.id,
'filter[type][:id:]': CONFIG.ACTIVITY_TYPES.vertalen.id,
'filter[status][:id:]': CONFIG.ACTIVITY_STATUSSES.withdrawn.id,
});
const totalPublishPreviewRequests = await this.store.query('activity', {
'filter[subcase][publication-flow][:id:]': publicationFlow.id,
'filter[type][:id:]': CONFIG.ACTIVITY_TYPES.drukproeven.id,
});
const withdrawnPublishPreviewRequests = await this.store.query('activity', {
'filter[subcase][publication-flow][:id:]': publicationFlow.id,
'filter[type][:id:]': CONFIG.ACTIVITY_TYPES.drukproeven.id,
'filter[status][:id:]': CONFIG.ACTIVITY_STATUSSES.withdrawn.id,
});
const closedPublishPreviewRequests = await this.store.query('activity', {
'filter[subcase][publication-flow][:id:]': publicationFlow.id,
'filter[type][:id:]': CONFIG.ACTIVITY_TYPES.drukproeven.id,
'filter[status][:id:]': CONFIG.ACTIVITY_STATUSSES.closed.id,
});

const pieces = await _case.get('pieces');
const documentCount = pieces.length;

return hash({
publicationFlow,
latestSubcaseOnMeeting: subcasesOnMeeting.get('firstObject'),
case: _case,
counts: {
documentCount: documentCount,
totalTranslations: totalTranslations.length,
closedOrWithdrawnTranslationRequests: closedTranslationRequests.length + withdrawnTranslationRequests.length,
openTranslationRequests: totalTranslations.length - closedTranslationRequests.length - withdrawnTranslationRequests.length,
totalPublishPreviewRequests: totalPublishPreviewRequests.length,
openPublishPreviewRequests: totalPublishPreviewRequests.length - closedPublishPreviewRequests.length - withdrawnPublishPreviewRequests.length,
closedOrWithdrawnPublishPrevieuwRequests: closedPublishPreviewRequests.length + withdrawnPublishPreviewRequests.length,
},
refreshAction: this.refreshModel,
});
}
Expand Down
26 changes: 2 additions & 24 deletions app/pods/publications/publication/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,8 @@
@size="150"
@custom="true"
@customTextClass="auk-toolbar-complex__title"
>
</WebComponents::AuAbbreviatedText>
<WebComponents::AuTabs @reversed="true">
<WebComponents::AuTab @isHierarchicalBack="true" @route="publications" data-test-publication-case-nav-go-back></WebComponents::AuTab>
<WebComponents::AuTab @route="publications.publication.case" data-test-publication-case-nav-case>{{t "agendaitem-case"}}</WebComponents::AuTab>
<WebComponents::AuTab @route="publications.publication.documents" data-test-publication-case-nav-documents>
<div class="auk-u-flex auk-u-flex--center">
<span class="auk-u-mr-2">{{t "documents"}}</span>
<p>{{this.documentsCount}}</p>
</div>
</WebComponents::AuTab>
<WebComponents::AuTab @route="publications.publication.translations" data-test-publication-case-nav-translations>
<div class="auk-u-flex auk-u-flex--center">
<span class="auk-u-mr-2">{{t "translations"}}</span>
<WebComponents::AuStatusPill @status={{this.showStatusForTranslations.status}}>{{this.showStatusForTranslations.value}}</WebComponents::AuStatusPill>
</div>
</WebComponents::AuTab>
<WebComponents::AuTab @route="publications.publication.publishpreview" data-test-publication-case-nav-publishpreview>
<div class="auk-u-flex auk-u-flex--center">
<span class="auk-u-mr-2">{{t "publishpreview-requests"}}</span>
<WebComponents::AuStatusPill @status={{this.showStatusForPublicationPreviews.status}}>{{this.showStatusForPublicationPreviews.value}}</WebComponents::AuStatusPill>
</div>
</WebComponents::AuTab>
</WebComponents::AuTabs>
/>
<Publications::Publication::PublicationNavigation @publicationFlow={{this.model.publicationFlow}} />
</div>
</WebComponents::AuToolbar::Item>
</WebComponents::AuToolbar::Group>
Expand Down
2 changes: 2 additions & 0 deletions cypress/integration/unit/cancel-editing-document.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ context('Tests for cancelling CRUD operations on document and pieces', () => {
cy.get('@documentName').contains(savedName);
});

// TODO duplicate asserts, we want to check name here
// Verify only 1 piece is affected by change
cy.get(document.showPiecesHistory).click();
cy.get(document.singlePieceHistory).as('pieces');
Expand All @@ -215,6 +216,7 @@ context('Tests for cancelling CRUD operations on document and pieces', () => {
cy.get('.js-vl-accordion > button').click();

// Cancel/save access-level in document card
// TODO use test selector
cy.get('.vlc-document-card__content > .auk-toolbar-complex > .vlc-document-card-toolbar__right').as('accessLevelToolbar')
.within(() => {
cy.get('.auk-pill').contains('Intern Overheid')
Expand Down
Loading

0 comments on commit ffe292b

Please sign in to comment.