Skip to content

Commit

Permalink
add cascade delete to software tablesAdd toggle to finter direct and …
Browse files Browse the repository at this point in the history
…all involvements (including inherited)

- filter parent involvements that cannot be removed form edit screen
- fix arch unit test - command interface

#CTCTOWALTZ-2705
finos#6629
finos#6648
  • Loading branch information
jessica-woodland-scott-db committed Jun 22, 2023
1 parent 8363976 commit 0e5edd5
Show file tree
Hide file tree
Showing 7 changed files with 3,822 additions and 6,705 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package org.finos.waltz.model.involvement_group;

import org.finos.waltz.model.command.Command;
import org.immutables.value.Value;

import java.util.Collections;
import java.util.Set;

@Value.Immutable
public abstract class InvolvementGroupCreateCommand {
public abstract class InvolvementGroupCreateCommand implements Command {

public abstract InvolvementGroup involvementGroup();

@Value.Default
public Set<Long> involvementKindIds() {
return Collections.emptySet();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Entity</th>
<th>Person</th>
<th>Involvement</th>
<th></th>
</tr>
Expand Down Expand Up @@ -99,6 +99,7 @@
<br />

<select ng-model="$ctrl.currentInvolvement.involvement"
required
ng-options="rel.value as rel.name for rel in $ctrl.allowedInvolvements | orderBy:'name'"
class="form-control">
</select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@ const bindings = {
currentInvolvements: "<",
parentEntityRef: "<",
targetEntityKind: "<",

onAdd: "<",
onRemove: "<"
};


const initialState = {
allowedInvolvements: [],
currentInvolvement: {},
currentInvolvement: {
involvement: null,
entity: null
},
currentInvolvements: [],
parentEntityRef: null,
targetEntityKind: null,
targetEntityDisplayName: null,

onAdd: () => console.log("default onAdd handler for entity-involvement-editor"),
onRemove: () => console.log("default onRemove handler for entity-involvement-editor")
};
Expand Down Expand Up @@ -69,8 +70,10 @@ function controller() {
vm.onInvolvementAdd = () => {
const currentInvolvement = vm.currentInvolvement;
invokeFunction(vm.onAdd, currentInvolvement)
.catch(e => displayError(`Could not add person with involvement`, e));
vm.currentInvolvement = {};
vm.currentInvolvement = {
involvement: null,
entity: null
};
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@

<!-- Viewer -->
<div ng-if="$ctrl.visibility.editor === false">

<div class="help-block"
style="padding-bottom: 1em"
ng-if="$ctrl.hierarchyScope !== 'EXACT'">
People are related to this <span ng-bind="$ctrl.parentEntityRef.kind | toDisplayName: 'entity'"></span>
either directly or inherited from a parent.
Use the toggle to filter the view.
<div style="padding-top: 1em">
<waltz-toggle
state="$ctrl.showDirectOnly"
on-toggle="$ctrl.onToggleScope()"
label-on="Showing direct involvements only"
label-off="Showing all involvements (including inherited)">
</waltz-toggle>
</div>
</div>

<div ng-if="$ctrl.gridData.length > 0">
<waltz-grid-with-search column-defs="$ctrl.columnDefs"
entries="$ctrl.gridData"
Expand Down
45 changes: 33 additions & 12 deletions waltz-ng/client/involvement/components/involved-people-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,19 @@ const initialState = {
currentInvolvements: [],
gridData: [],
columnDefs,
exportGrid: () => {},
exportGrid: () => {
},
showDirectOnly: true,
visibility: {
editor: false
}
};


function mkGridData(involvements = [], displayNameService, descriptionService) {
return _.chain(involvements)
return _
.chain(involvements)
.filter(inv => !_.isEmpty(inv.involvements))
.map(inv => {
const roles = _.map(inv.involvements, pInv => ({
provenance: pInv.provenance,
Expand Down Expand Up @@ -136,16 +140,27 @@ function controller($q, displayNameService, descriptionService, serviceBroker, i

const vm = initialiseData(this, initialState);

function refreshGridData() {
const involvements = vm.showDirectOnly
? vm.aggDirectInvolvements
: vm.aggInvolvements;

vm.gridData = mkGridData(involvements, displayNameService, descriptionService);
}

const refresh = () => {
const options = mkSelectionOptions(vm.parentEntityRef, determineUpwardsScopeForKind(vm.parentEntityRef.kind));

vm.hierarchyScope = determineUpwardsScopeForKind(vm.parentEntityRef.kind);
const options = mkSelectionOptions(vm.parentEntityRef, vm.hierarchyScope);

const kindPromise = serviceBroker
.loadAppData(CORE_API.InvolvementKindStore.findAll, [])
.then(r => r.data);

const involvementPromise = serviceBroker
.loadViewData(
CORE_API.InvolvementStore.findBySelector,
[ options ],
[options],
{force: true})
.then(r => r.data);

Expand All @@ -163,28 +178,29 @@ function controller($q, displayNameService, descriptionService, serviceBroker, i
return $q
.all([involvementPromise, peoplePromise, kindPromise, userRolesPromise])
.then(([involvements = [], people = [], involvementKinds = [], userRoles = []]) => {
const aggInvolvements = aggregatePeopleInvolvements(involvements, people);
vm.gridData = mkGridData(aggInvolvements, displayNameService, descriptionService);
vm.currentInvolvements = mkCurrentInvolvements(aggInvolvements);
vm.involvementKinds = involvementKinds;

const directInvolvements = _.filter(involvements, d => d.entityReference.id === vm.parentEntityRef.id);

vm.aggInvolvements = aggregatePeopleInvolvements(involvements, people);
vm.aggDirectInvolvements = aggregatePeopleInvolvements(directInvolvements, people);
vm.currentInvolvements = mkCurrentInvolvements(vm.aggDirectInvolvements);

vm.allowedInvolvements = _
.chain(involvementKinds)
.filter(ik => ik.userSelectable)
.filter(ik => ik.subjectKind === vm.parentEntityRef.kind)
.filter(ik => _.isEmpty(ik.permittedRole) || _.includes(userRoles, ik.permittedRole))
.map(ik => ({ value: ik.id, name: ik.name }))
.map(ik => ({value: ik.id, name: ik.name}))
.value();
});
})
.then(refreshGridData);
};


vm.$onChanges = (changes) => {
if (changes.parentEntityRef && vm.parentEntityRef) {
refresh();
}


};


Expand All @@ -205,6 +221,11 @@ function controller($q, displayNameService, descriptionService, serviceBroker, i
.removeInvolvement(vm.parentEntityRef, entityInvolvement)
.then(refresh);
};

vm.onToggleScope = () => {
vm.showDirectOnly = !vm.showDirectOnly;
refreshGridData();
}
}


Expand Down
16 changes: 14 additions & 2 deletions waltz-ng/client/involvement/services/involved-section-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ function service(involvementStore) {
return involvementStore.changeInvolvement(
entityRef,
mkChangeCommand("ADD", entityInvolvement.entity, entityInvolvement.involvement))
.then(result => toasts.success("Involvement added successfully"))
.then(successful => {
if (successful) {
toasts.success("Involvement added successfully");
} else {
toasts.warning("Involvement was not added, it may already exist");
}
})
.catch(e => displayError("Failed to add involvement", e));
};

Expand All @@ -38,7 +44,13 @@ function service(involvementStore) {
.changeInvolvement(
entityRef,
mkChangeCommand("REMOVE", entityInvolvement.entity, entityInvolvement.involvement))
.then(result => toasts.success("Involvement removed successfully"))
.then(successful => {
if (successful) {
toasts.success("Involvement removed successfully");
} else {
toasts.warning("Involvement was not removed, it may have already been remvoed");
}
})
.catch(e => displayError("Failed to remove involvement", e));
};

Expand Down
Loading

0 comments on commit 0e5edd5

Please sign in to comment.