- {{cases/subcase-mandatees
- showSelected=true
- mandateeRows=mandateeRows
- isEditing=isEditing
- isAdding=isAdding
- }}
-
-
-{{/if}}
diff --git a/app/components/subcase/subcase-case/subcase-mandatees.js b/app/components/subcase/subcase-case/subcase-mandatees.js
deleted file mode 100644
index 5589151c29..0000000000
--- a/app/components/subcase/subcase-case/subcase-mandatees.js
+++ /dev/null
@@ -1,143 +0,0 @@
-/* eslint-disable class-methods-use-this */
-import Component from '@ember/component';
-import EmberObject, {
- action, computed
-} from '@ember/object';
-import { inject as service } from '@ember/service';
-
-import { saveChanges as saveMandateeChanges } from 'frontend-kaleidos/utils/agendaitem-utils';
-import DS from 'ember-data';
-
-// TODO code cuplication with agendaitem-case/agendaitem-mandatees
-export default class SubcaseMandatees extends Component {
- @service store;
-
- @service currentSession;
-
- classNames = ['auk-u-mb-8'];
-
- subcase = null;
-
- propertiesToSet = Object.freeze(['mandatees', 'governmentDomains']);
-
- @computed('subcase', 'mandatees.@each')
- get mandateeRows() {
- return DS.PromiseArray.create({
- promise: this.constructMandateeRows().then((rows) => this.get('subcase.requestedBy').then((requestedBy) => {
- if (!requestedBy && rows.get('length') > 0) {
- rows.get('firstObject').set('isSubmitter', true);
- } else {
- const foundMandatee = rows.find((row) => row.get('mandatee.id') === requestedBy.get('id'));
- if (foundMandatee) {
- foundMandatee.set('isSubmitter', true);
- }
- }
- return rows.sortBy('mandateePriority');
- })),
- });
- }
-
- async createMandateeRow(mandatee, iseCodes) {
- const fields = [...new Set(await Promise.all(iseCodes.map((iseCode) => iseCode.get('field'))))];
- const domains = [...new Set(await Promise.all(fields.map((field) => field.get('domain'))))];
-
- const domainsToShow = domains.map((domain) => domain.get('label')).join(', ');
- const fieldsToShow = fields.map((field) => field.get('label')).join(', ');
-
- return EmberObject.create({
- fieldsToShow,
- domainsToShow,
- mandatee,
- mandateePriority: mandatee.get('priority'),
- domains,
- fields,
- iseCodes,
- });
- }
-
- async getIseCodesOfMandatee(iseCodes, mandatee) {
- const iseCodesOfMandatee = await mandatee.get('iseCodes');
- return iseCodes.filter((iseCodeOfMandatee) => {
- const foundIseCode = iseCodesOfMandatee.find((iseCode) => iseCode.get('id') === iseCodeOfMandatee.get('id'));
-
- return !!foundIseCode;
- });
- }
-
- async constructMandateeRows() {
- const subcase = await this.subcase;
- const iseCodes = await subcase.get('iseCodes');
- const mandatees = await (await subcase.get('mandatees')).sortBy('priority');
- let selectedMandatee = await subcase.get('requestedBy');
- const mandateeLength = mandatees.get('length');
- if (mandateeLength === 1) {
- selectedMandatee = mandatees.get('firstObject');
- }
- return Promise.all(mandatees.map(async(mandatee) => {
- const filteredIseCodes = await this.getIseCodesOfMandatee(iseCodes, mandatee);
- const row = await this.createMandateeRow(mandatee, filteredIseCodes);
- if (selectedMandatee && mandatee.get('id') === selectedMandatee.get('id')) {
- row.set('isSubmitter', true);
- } else if (mandateeLength === 0) {
- row.set('isSubmitter', true);
- }
- return row;
- }));
- }
-
- async parseDomainsAndMandatees() {
- const mandateeRows = await this.get('mandateeRows');
- const mandatees = [];
- const iseCodes = [];
- let requestedBy = null;
- if (mandateeRows && mandateeRows.get('length') > 0) {
- mandateeRows.map(async(row) => {
- if (row.get('isSubmitter')) {
- requestedBy = row.get('mandatee');
- }
- mandatees.push(row.get('mandatee'));
- const rowIseCodes = await row.get('iseCodes');
- rowIseCodes.map((code) => {
- iseCodes.push(code);
- });
- });
- }
- return {
- mandatees, iseCodes, requestedBy,
- };
- }
-
- @action
- toggleIsEditing() {
- this.toggleProperty('isEditing');
- }
-
- @action
- async cancelEditing() {
- this.notifyPropertyChange('mandateeRows');
- this.toggleProperty('isEditing');
- }
-
- @action
- async saveChanges() {
- this.set('isLoading', true);
- const propertiesToSetOnSubcase = await this.parseDomainsAndMandatees();
- const propertiesToSetOnAgendaitem = {
- mandatees: propertiesToSetOnSubcase.mandatees,
- };
- const resetFormallyOk = true;
- try {
- await saveMandateeChanges(this.subcase, propertiesToSetOnAgendaitem, propertiesToSetOnSubcase, resetFormallyOk);
- this.set('isLoading', false);
- this.toggleProperty('isEditing');
- } catch (exception) {
- this.set('isLoading', false);
- throw (exception);
- }
- }
-
- @action
- addRow() {
- this.toggleProperty('isAdding');
- }
-}
diff --git a/app/components/utils/domains-selector.hbs b/app/components/utils/domains-selector.hbs
deleted file mode 100644
index 297a388bd6..0000000000
--- a/app/components/utils/domains-selector.hbs
+++ /dev/null
@@ -1,34 +0,0 @@
-{{#if (not singleSelect)}}
- {{#if selectedDomainsOnly}}
- {{#power-select-multiple
- options=domains
- selected=selectedDomains
- onchange=(action "chooseDomain")
- as |domain|
- }}
- {{domain.label}}
- {{/power-select-multiple}}
- {{else}}
- {{#power-select-multiple
- options=domains
- selected=selectedDomains
- search=(perform searchDomain)
- oninput=(action "resetValueIfEmpty")
- onchange=(action "chooseDomain")
- as |domain|
- }}
- {{domain.label}}
- {{/power-select-multiple}}
- {{/if}}
-{{else}}
- {{#power-select
- options=domains
- selected=selectedDomains
- search=(perform searchDomain)
- oninput=(action "resetValueIfEmpty")
- onchange=(action "chooseDomain")
- as |domain|
- }}
- {{domain.label}}
- {{/power-select}}
-{{/if}}
\ No newline at end of file
diff --git a/app/components/utils/domains-selector.js b/app/components/utils/domains-selector.js
deleted file mode 100644
index 69568444af..0000000000
--- a/app/components/utils/domains-selector.js
+++ /dev/null
@@ -1,47 +0,0 @@
-import Component from '@ember/component';
-import {
- task, timeout
-} from 'ember-concurrency';
-import { inject } from '@ember/service';
-import { computed } from '@ember/object';
-
-export default Component.extend({
- classNames: ['domains-selector-container'],
- store: inject(),
- selectedDomains: null,
- selectedDomainsOnly: false, // property to disable all fetch/search functionality.
-
- searchDomain: task(function *(searchValue) {
- if (!this.get('selectedDomainsOnly')) {
- yield timeout(300);
- return this.store.query('government-domain', {
- filter: {
- label: searchValue,
- },
- });
- }
- }),
-
- domains: computed('store', function() {
- if (!this.get('selectedDomainsOnly')) {
- return this.store.findAll('government-domain');
- }
- return null;
- }),
-
- actions: {
- async chooseDomain(domains) {
- this.set('selectedDomains', domains);
- this.chooseDomain(domains);
- },
- resetValueIfEmpty(param) {
- if (!this.get('selectedDomainsOnly')) {
- if (param === '') {
- return this.set('domains', this.store.findAll('government-domain'));
- }
- return null;
- }
- return this.set('domains', this.get('selectedDomains'));
- },
- },
-});
diff --git a/app/components/utils/minister-modal.hbs b/app/components/utils/minister-modal.hbs
deleted file mode 100644
index f72f175871..0000000000
--- a/app/components/utils/minister-modal.hbs
+++ /dev/null
@@ -1,63 +0,0 @@
-{{#web-components/vl-modal
- closeModal=(action "cancel")
- isOverlay=true
- title=title
-}}
-
-
{{t "select-minister"}}
-
- {{#if isAddingMinister}}
- {{utils/mandatee-selector
- data-test-mandatee-selector=true
- singleSelect=true
- selectedMandatees=selectedMandatee
- chooseMandatee=(action "mandateeSelected")
- }}
- {{else}}
- {{utils/mandatee-selector
- singleSelect=true
- readOnly=true
- selectedMandatees=selectedMandatee
- }}
- {{/if}}
-
- {{#if (and isLoading and isAddingMinister)}}
- {{web-components/vl-loader text=(t "please-be-patient")}}
- {{else}}
- {{#each rowToShow.domains as |domain|}}
-
-
- {{web-components/vl-checkbox
- value=domain.selected
- label=domain.label
- toggle=(action "selectDomain" domain)
- }}
-
- {{#each rowToShow.fields as |field|}}
- {{#if (eq (await field.domain.id) domain.id)}}
-
- {{web-components/vl-checkbox
- value=field.selected
- label=field.label
- toggle=(action "selectField" domain)
- }}
- {{field.name}}
-
- {{/if}}
- {{/each}}
-
-
-
-
- {{/each}}
- {{/if}}
-
- {{web-components/vl-modal-footer
- isLoading=isLoading
- nonBordered=true
- cancelButtonText=(t "cancel")
- saveButtonText=(t "add")
- cancelAction=(action "cancel")
- saveAction=(action "saveChanges")
- }}
-{{/web-components/vl-modal}}
\ No newline at end of file
diff --git a/app/components/utils/minister-modal.js b/app/components/utils/minister-modal.js
deleted file mode 100644
index 6ca7813015..0000000000
--- a/app/components/utils/minister-modal.js
+++ /dev/null
@@ -1,60 +0,0 @@
-import Component from '@ember/component';
-import {
- refreshData,
- selectDomain,
- selectField,
- prepareMandateeRowAfterEdit
-} from 'frontend-kaleidos/utils/manage-minister-util';
-import { inject } from '@ember/service';
-import { tracked } from '@glimmer/tracking';
-
-export default Component.extend({
- intl: inject(),
- rowToShow: null,
- selectedMandatee: null,
- @tracked title: '',
-
- willRender() {
- if (this.isAddingMinister) {
- this.title = this.intl.t('add-minister');
- } else {
- this.title = this.intl.t('edit-minister');
- }
- },
-
- actions: {
-
- async saveChanges() {
- this.set('isLoading', true);
- const {
- selectedMandatee, rowToShow,
- } = this;
- const newMinisterRow = await prepareMandateeRowAfterEdit(selectedMandatee, rowToShow);
- this.saveChanges(selectedMandatee, newMinisterRow);
- this.set('isLoading', false);
- this.cancel();
- },
-
- async selectField(domain, value) {
- const foundDomain = await this.get('rowToShow.domains');
- await selectField(foundDomain, domain, value);
- },
-
- async mandateeSelected(mandatee) {
- this.set('selectedMandatee', mandatee);
- this.set('isLoading', true);
- const rowsToShow = await refreshData(mandatee, await this.get('mandateeRows'));
- this.set('rowToShow', rowsToShow);
- this.set('isLoading', false);
- },
-
- async selectDomain(domain, value) {
- const rowToShowFields = await this.get('rowToShow.fields');
- await selectDomain(rowToShowFields, domain, value);
- },
-
- cancel() {
- this.cancel();
- },
- },
-});
diff --git a/app/components/web-components/vl-mandatee-link.hbs b/app/components/web-components/vl-mandatee-link.hbs
deleted file mode 100644
index 9e23e3d9fa..0000000000
--- a/app/components/web-components/vl-mandatee-link.hbs
+++ /dev/null
@@ -1,45 +0,0 @@
-