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 21, 2021
2 parents 1ddf514 + c599729 commit 9465d0d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 45 deletions.
10 changes: 6 additions & 4 deletions app/components/publications/publication-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { timeout } from 'ember-concurrency';
import { tracked } from '@glimmer/tracking';
import moment from 'moment';
import CONFIG from 'frontend-kaleidos/utils/config';
import CONSTANTS from 'frontend-kaleidos/config/constants';

export default class PublicationsPublicationSidebarComponent extends Component {
/**
Expand Down Expand Up @@ -89,8 +89,9 @@ export default class PublicationsPublicationSidebarComponent extends Component {
} else {
this.publicationFlow.status = status;
this.loadPublicationStatus.perform();
this.publicationFlow.closingDate = status.isPublished ? new Date() : null;
if (this.args.didChange) {
this.args.didChange(this.publicationFlow, 'status');
this.args.didChange(this.publicationFlow, ['status', 'closingDate']);
}
}
}
Expand All @@ -102,11 +103,12 @@ export default class PublicationsPublicationSidebarComponent extends Component {
@action
async withdrawPublicationFlow() {
const publicationStatus = await this.store.findRecordByUri('publication-status', CONFIG.PUBLICATION_STATUSES.withdrawn.uri);
const publicationStatus = await this.store.findRecordByUri('publication-status', CONSTANTS.PUBLICATION_STATUSES.WITHDRAWN);
this.publicationFlow.status = publicationStatus;
this.publicationFlow.closingDate = new Date();
this.loadPublicationStatus.perform();
if (this.args.didChange) {
await this.args.didChange(this.publicationFlow, 'status');
await this.args.didChange(this.publicationFlow, ['status', 'closingDate']);
}
this.showConfirmWithdraw = false;
}
Expand Down
8 changes: 8 additions & 0 deletions app/config/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
export default {
// GENERAL
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',
},
// PUBLICATIONS
PUBLICATION_STATUSES: {
PENDING: 'http://themis.vlaanderen.be/id/concept/publicatie-status/fa62e050-3960-440d-bed9-1c3d3e9923a8',
PUBLISHED: 'http://themis.vlaanderen.be/id/concept/publicatie-status/2f8dc814-bd91-4bcf-a823-baf1cdc42475',
PAUSED: 'http://themis.vlaanderen.be/id/concept/publicatie-status/bc294fde-45c8-11eb-b378-0242ac130002',
WITHDRAWN: 'http://themis.vlaanderen.be/id/concept/publicatie-status/9b9b0b5e-45c8-11eb-b378-0242ac130002',
},
};
2 changes: 2 additions & 0 deletions app/models/publication-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default class PublicationFlow extends Model {
@attr('datetime') publishDateRequested;
@attr('datetime') publishedAt;
@attr('string') remark;
@attr('date') closingDate;
@attr('date') openingDate;
@attr('datetime') created;
@attr('datetime') modified;

Expand Down
10 changes: 5 additions & 5 deletions app/models/publication-status.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Model, {
attr, hasMany
} from '@ember-data/model';
import CONFIG from 'frontend-kaleidos/utils/config';
import CONSTANTS from 'frontend-kaleidos/config/constants';

export default class PublicationStatus extends Model {
@attr('string') uri;
Expand All @@ -10,15 +10,15 @@ export default class PublicationStatus extends Model {
@hasMany('publication-flow') publicaties;

get isPending() {
return this.uri === CONFIG.PUBLICATION_STATUSES.pending.uri;
return this.uri === CONSTANTS.PUBLICATION_STATUSES.PENDING;
}
get isPublished() {
return this.uri === CONFIG.PUBLICATION_STATUSES.published.uri;
return this.uri === CONSTANTS.PUBLICATION_STATUSES.PUBLISHED;
}
get isWithdrawn() {
return this.uri === CONFIG.PUBLICATION_STATUSES.withdrawn.uri;
return this.uri === CONSTANTS.PUBLICATION_STATUSES.WITHDRAWN;
}
get isPaused() {
return this.uri === CONFIG.PUBLICATION_STATUSES.paused.uri;
return this.uri === CONSTANTS.PUBLICATION_STATUSES.PAUSED;
}
}
6 changes: 3 additions & 3 deletions app/pods/publications/index/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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 CONSTANTS from 'frontend-kaleidos/config/constants';
import tableColumns from 'frontend-kaleidos/config/publications/overview-table-columns';
import PublicationFilter from 'frontend-kaleidos/utils/publication-filter';

Expand Down Expand Up @@ -112,15 +113,14 @@ export default class PublicationsIndexController extends Controller {
});
await caze.save();

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

const publicationFlow = this.store.createRecord('publication-flow', {
publicationNumber,
publicationSuffix,
case: caze,
created: creationDatetime,
openingDate: new Date(),
status: toPublishStatus,
modified: creationDatetime,
});
Expand Down
32 changes: 17 additions & 15 deletions app/pods/publications/index/route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Route from '@ember/routing/route';
import { action } from '@ember/object';
import CONFIG from 'frontend-kaleidos/utils/config';
import CONSTANTS from 'frontend-kaleidos/config/constants';
import { dasherize } from '@ember/string';
import PublicationFilter from 'frontend-kaleidos/utils/publication-filter';

Expand All @@ -20,26 +20,28 @@ export default class PublicationsIndexRoute extends Route {
},
}

statusFilters = Object.freeze({ // map filter name to concept uri
publishedFilterOption: CONSTANTS.PUBLICATION_STATUSES.PUBLISHED,
pausedFilterOption: CONSTANTS.PUBLICATION_STATUSES.PAUSED,
withdrawnFilterOption: CONSTANTS.PUBLICATION_STATUSES.WITHDRAWN,
toPublishFilterOption: CONSTANTS.PUBLICATION_STATUSES.PENDING,
});

beforeModel() {
this.publicationFilter = new PublicationFilter(JSON.parse(localStorage.getItem('publicationFilter')) || {});
}

async model(params) {
const ids = [];
const statusIds = [];
let ministerFilter = {};

if (this.publicationFilter.publishedFilterOption) {
ids.push(CONFIG.PUBLICATION_STATUSES.published.id);
}
if (this.publicationFilter.pausedFilterOption) {
ids.push(CONFIG.PUBLICATION_STATUSES.paused.id);
}
if (this.publicationFilter.withdrawnFilterOption) {
ids.push(CONFIG.PUBLICATION_STATUSES.withdrawn.id);
}
if (this.publicationFilter.toPublishFilterOption) {
ids.push(CONFIG.PUBLICATION_STATUSES.pending.id);
for (const statusFilter of Object.keys(this.statusFilters)) {
if (this.publicationFilter[statusFilter]) {
const status = await this.store.findRecordByUri('publication-status', this.statusFilters[statusFilter]);
statusIds.push(status.id);
}
}

if (!(this.publicationFilter.ministerFilterOption && this.publicationFilter.notMinisterFilterOption)) {
if (this.publicationFilter.ministerFilterOption) {
ministerFilter = {
Expand All @@ -61,9 +63,9 @@ export default class PublicationsIndexRoute extends Route {
filter.case = ministerFilter;
}

if (ids.length > 0) {
if (statusIds.length > 0) {
filter.status = {
id: ids.join(','),
':id:': statusIds.join(','),
};
}

Expand Down
18 changes: 0 additions & 18 deletions app/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,6 @@ export default EmberObject.create({
KENNISNAME: 'http://kanselarij.vo.data.gift/id/concept/beslissings-resultaat-codes/9f342a88-9485-4a83-87d9-245ed4b504bf',
INGETROKKEN: 'http://kanselarij.vo.data.gift/id/concept/beslissings-resultaat-codes/453a36e8-6fbd-45d3-b800-ec96e59f273b',
},
PUBLICATION_STATUSES: {
pending: {
id: 'fa62e050-3960-440d-bed9-1c3d3e9923a8',
uri: 'http://themis.vlaanderen.be/id/concept/publicatie-status/fa62e050-3960-440d-bed9-1c3d3e9923a8',
},
published: {
id: '2f8dc814-bd91-4bcf-a823-baf1cdc42475',
uri: 'http://themis.vlaanderen.be/id/concept/publicatie-status/2f8dc814-bd91-4bcf-a823-baf1cdc42475',
},
paused: {
id: 'bc294fde-45c8-11eb-b378-0242ac130002',
uri: 'http://themis.vlaanderen.be/id/concept/publicatie-status/bc294fde-45c8-11eb-b378-0242ac130002',
},
withdrawn: {
id: '9b9b0b5e-45c8-11eb-b378-0242ac130002',
uri: 'http://themis.vlaanderen.be/id/concept/publicatie-status/9b9b0b5e-45c8-11eb-b378-0242ac130002',
},
},
LANGUAGE_NL: {
uri: 'http://publications.europa.eu/resource/authority/language/NLD',
},
Expand Down

0 comments on commit 9465d0d

Please sign in to comment.