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 20, 2021
2 parents 3ce025c + 2152631 commit da8f1b5
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 188 deletions.
10 changes: 5 additions & 5 deletions app/components/access-level-pill.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency-decorators';
import { inject as service } from '@ember/service';
import CONFIG from 'frontend-kaleidos/utils/config';
import CONSTANTS from 'frontend-kaleidos/config/constants';

export default class AccessLevelPillComponent extends Component {
/**
Expand Down Expand Up @@ -36,14 +36,14 @@ export default class AccessLevelPillComponent extends Component {
const classes = [baseClass, 'auk-u-cursor-pointer'];
let modifier;
if (this.args.accessLevel) {
switch (this.args.accessLevel.id) {
case CONFIG.publiekAccessLevelId:
switch (this.args.accessLevel.uri) {
case CONSTANTS.ACCESS_LEVELS.PUBLIEK:
modifier = 'success';
break;
case CONFIG.internOverheidAccessLevelId:
case CONSTANTS.ACCESS_LEVELS.INTERN_OVERHEID:
modifier = 'warning';
break;
case CONFIG.internRegeringAccessLevelId:
case CONSTANTS.ACCESS_LEVELS.INTERN_REGERING:
modifier = 'danger';
break;
}
Expand Down
10 changes: 2 additions & 8 deletions app/components/agenda/agendaitem/agendaitem-decision.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency-decorators';
import { sortPieces } from 'frontend-kaleidos/utils/documents';
import CONSTANTS from 'frontend-kaleidos/config/constants';
import CONFIG from 'frontend-kaleidos/utils/config';

export default class AgendaitemDecisionComponent extends Component {
Expand All @@ -28,14 +29,7 @@ export default class AgendaitemDecisionComponent extends Component {

@task
*loadCodelists() {
this.defaultAccessLevel = this.store.peekRecord('access-level', CONFIG.internRegeringAccessLevelId);
if (!this.defaultAccessLevel) {
const accessLevels = yield this.store.query('access-level', {
'page[size]': 1,
'filter[:id:]': CONFIG.internRegeringAccessLevelId,
});
this.defaultAccessLevel = accessLevels.firstObject;
}
this.defaultAccessLevel = yield this.store.findRecordByUri('access-level', CONSTANTS.ACCESS_LEVELS.INTERN_REGERING);
this.decisionDocType = this.store.peekRecord('document-type', CONFIG.decisionDocumentTypeId);
if (!this.decisionDocType) {
const docTypes = yield this.store.query('document-type', {
Expand Down
13 changes: 2 additions & 11 deletions app/components/documents/document-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { action } from '@ember/object';
import { A } from '@ember/array';
import moment from 'moment';
import VRDocumentName from 'frontend-kaleidos/utils/vr-document-name';
import config from 'frontend-kaleidos/utils/config';
import CONSTANTS from 'frontend-kaleidos/config/constants';
import { sortPieces } from 'frontend-kaleidos/utils/documents';

export default class DocumentsDocumentCardComponent extends Component {
Expand Down Expand Up @@ -52,16 +52,7 @@ export default class DocumentsDocumentCardComponent extends Component {

@task
*loadCodelists() {
this.defaultAccessLevel = this.store.peekRecord('access-level', config.internRegeringAccessLevelId);
if (!this.defaultAccessLevel) {
const accessLevels = yield this.store.query('access-level', {
page: {
size: 1,
},
'filter[:id:]': config.internRegeringAccessLevelId,
});
this.defaultAccessLevel = accessLevels.firstObject;
}
this.defaultAccessLevel = yield this.store.findRecordByUri('access-level', CONSTANTS.ACCESS_LEVELS.INTERN_REGERING);
}

@task
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<WebComponents::AuPanel>
<WebComponents::AuPanel::Body class="auk-panel--editing">
<div class="auk-u-flex">
<div class="auk-form-group auk-u-maximize-width auk-u-mr-2">
<WebComponents::AuLabel for="blockInput">{{t "name-document" }}</WebComponents::AuLabel>
<WebComponents::AuInput @value={{this.filter.documentName}} type="text" id="blockInput" @block="true" />
</div>
<div class="auk-form-group auk-u-maximize-width auk-u-mr-2 auk-u-ml-2">
<WebComponents::AuLabel for="blockInput">{{t "file-extension" }}</WebComponents::AuLabel>
<PowerSelectMultiple @options={{this.fileTypes}} @searchEnabled={{true}}
@selected={{this.filter.fileTypes}}
@onchange={{fn (mut this.filter.fileTypes)}}
as
|fileExtension|>
{{fileExtension}}
</PowerSelectMultiple>
</div>
<div class="auk-form-group auk-u-maximize-width auk-u-ml-2">
<WebComponents::AuLabel for="blockInput">{{t "file-type" }}</WebComponents::AuLabel>
{{#unless this.loadDocumentTypes.isRunning}}
<PowerSelectMultiple @options={{this.documentTypes}} @isSearchable={{false}}
@selected={{this.filter.documentTypes}}
@onchange={{fn (mut this.filter.documentTypes)}}
as |pieceType|>
{{get pieceType "label"}}
</PowerSelectMultiple>
{{/unless}}
</div>
</div>
<div class="auk-u-flex auk-u-flex--justify-end">
<div>
<WebComponents::AuButton data-test-publication-filter-reset @skin="secondary" {{on "click" this.reset}}>
{{t "reset"}}
</WebComponents::AuButton>
<WebComponents::AuButton @icon="filter" data-test-publication-filter @skin="primary"
{{on "click" this.apply}}>
{{t "filter-plural"}}
</WebComponents::AuButton>
</div>
</div>
</WebComponents::AuPanel::Body>
</WebComponents::AuPanel>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { inject } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency-decorators';

export default class PublicationsPublicationDocumentsFilterComponent extends Component {
@inject store;
@inject fileService;

@tracked documentTypes = [];
@tracked fileTypes = [];
@tracked state;

constructor(owner, args) {
super(owner, args);

// clone for internal use
this.filter = this.args.filter.clone();

this.loadDocumentTypes.perform();
this.loadFileTypes.perform();
}

@task
*loadDocumentTypes() {
if (!this.documentTypes.length) {
this.documentTypes = yield this.store.query('document-type', {
page: {
size: 50,
},
sort: 'priority',
});
}
}

@task
*loadFileTypes() {
if (!this.fileTypes.length) {
this.fileTypes = yield this.fileService.getFileExtensions();
}
}

@action
reset() {
this.filter.reset();

const filter = this.filter.clone();
this.args.onChange(filter);
}

@action
apply() {
const filter = this.filter.clone();
this.args.onChange(filter);
}
}
7 changes: 7 additions & 0 deletions app/config/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
ACCESS_LEVELS: {
INTERN_REGERING: 'http://kanselarij.vo.data.gift/id/concept/toegangs-niveaus/d335f7e3-aefd-4f93-81a2-1629c2edafa3',
INTERN_OVERHEID: 'http://kanselarij.vo.data.gift/id/concept/toegangs-niveaus/abe4c18d-13a9-45f0-8cdd-c493eabbbe29',
PUBLIEK: 'http://kanselarij.vo.data.gift/id/concept/toegangs-niveaus/6ca49d86-d40f-46c9-bde3-a322aa7e5c8e',
},
};
1 change: 1 addition & 0 deletions app/models/access-level.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
} = DS;

export default DS.Model.extend({
uri: attr('string'),
label: attr('string'),
priority: attr('string'),
altLabel: attr('string'),
Expand Down
11 changes: 2 additions & 9 deletions app/pods/agenda/agendaitems/agendaitem/documents/route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Route from '@ember/routing/route';
import config from 'frontend-kaleidos/utils/config';
import { action } from '@ember/object';
import CONSTANTS from 'frontend-kaleidos/config/constants';
import { sortPieces } from 'frontend-kaleidos/utils/documents';

export default class DocumentsAgendaitemAgendaitemsAgendaRoute extends Route {
Expand All @@ -20,14 +20,7 @@ export default class DocumentsAgendaitemAgendaitemsAgendaRoute extends Route {
}

async afterModel() {
this.defaultAccessLevel = this.store.peekRecord('access-level', config.internRegeringAccessLevelId);
if (!this.defaultAccessLevel) {
const accessLevels = await this.store.query('access-level', {
'page[size]': 1,
'filter[:id:]': config.internRegeringAccessLevelId,
});
this.defaultAccessLevel = accessLevels.firstObject;
}
this.defaultAccessLevel = await this.store.findRecordByUri('access-level', CONSTANTS.ACCESS_LEVELS.INTERN_REGERING);
}

setupController(controller) {
Expand Down
11 changes: 2 additions & 9 deletions app/pods/agenda/documents/route.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Route from '@ember/routing/route';
import config from 'frontend-kaleidos/utils/config';
import CONSTANTS from 'frontend-kaleidos/config/constants';
import { sortPieces } from 'frontend-kaleidos/utils/documents';
import { action } from '@ember/object';

Expand All @@ -16,14 +16,7 @@ export default class AgendaDocumentsRoute extends Route {
}

async afterModel() {
this.defaultAccessLevel = this.store.peekRecord('access-level', config.internRegeringAccessLevelId);
if (!this.defaultAccessLevel) {
const accessLevels = await this.store.query('access-level', {
'page[size]': 1,
'filter[:id:]': config.internRegeringAccessLevelId,
});
this.defaultAccessLevel = accessLevels.firstObject;
}
this.defaultAccessLevel = await this.store.findRecordByUri('access-level', CONSTANTS.ACCESS_LEVELS.INTERN_REGERING);
}

setupController(controller) {
Expand Down
11 changes: 2 additions & 9 deletions app/pods/cases/case/subcases/subcase/documents/route.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Route from '@ember/routing/route';
import config from 'frontend-kaleidos/utils/config';
import CONSTANTS from 'frontend-kaleidos/config/constants';
import { action } from '@ember/object';
import { sortPieces } from 'frontend-kaleidos/utils/documents';

Expand Down Expand Up @@ -29,14 +29,7 @@ export default class DocumentsSubcaseSubcasesRoute extends Route {
}

async afterModel() {
this.defaultAccessLevel = this.store.peekRecord('access-level', config.internRegeringAccessLevelId);
if (!this.defaultAccessLevel) {
const accessLevels = await this.store.query('access-level', {
'page[size]': 1,
'filter[:id:]': config.internRegeringAccessLevelId,
});
this.defaultAccessLevel = accessLevels.firstObject;
}
this.defaultAccessLevel = await this.store.findRecordByUri('access-level', CONSTANTS.ACCESS_LEVELS.INTERN_REGERING);
}

setupController(controller) {
Expand Down
Loading

0 comments on commit da8f1b5

Please sign in to comment.