Skip to content

Commit

Permalink
Merge pull request #250 in WALTZ/waltz from WALTZ/waltz-jws:CTCTOWALT…
Browse files Browse the repository at this point in the history
…Z-2635-survey-self-issuance-bugs-6397 to db-feature/waltz-6397-survey-self-service-fixes-enhancements

* commit '9d993da5edc766cced7b4bdefd337a08ba7f2419':
  Reorder recipient and owner selectors
  Reorder recipient and owner selectors
  Surveys self-issuance should allow selection of involvement kinds and owners. - Refer to owners as 'Approvers' thoughout survey pages
  • Loading branch information
db-waltz committed Jan 30, 2023
2 parents 86b159a + 9d993da commit 9e949f2
Show file tree
Hide file tree
Showing 14 changed files with 371 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import static org.finos.waltz.schema.Tables.USER_ROLE;
import static org.finos.waltz.schema.tables.AttestationInstanceRecipient.ATTESTATION_INSTANCE_RECIPIENT;
import static org.finos.waltz.schema.tables.Person.PERSON;
import static org.finos.waltz.schema.tables.PersonHierarchy.PERSON_HIERARCHY;
Expand Down Expand Up @@ -244,4 +245,14 @@ public Set<Person> findActivePeopleByEmails(Set<String> emails) {
.and(PERSON.IS_REMOVED.isFalse()))
.fetchSet(personMapper);
}


public Set<Person> findActivePeopleByUserRole(String role) {
return dsl
.select(PERSON.fields())
.from(USER_ROLE)
.innerJoin(PERSON).on(PERSON.EMAIL.eq(USER_ROLE.USER_NAME)
.and(PERSON.IS_REMOVED.isFalse()))
.fetchSet(personMapper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.finos.waltz.model.attestation.SyncRecipientsResponse;
import org.finos.waltz.model.survey.*;
import org.finos.waltz.schema.tables.records.ChangeLogRecord;
import org.finos.waltz.schema.tables.records.SurveyInstanceOwnerRecord;
import org.finos.waltz.schema.tables.records.SurveyInstanceRecipientRecord;
import org.finos.waltz.schema.tables.records.SurveyInstanceRecord;
import org.jooq.*;
Expand All @@ -48,6 +49,7 @@
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toSet;
import static org.finos.waltz.common.Checks.checkNotNull;
import static org.finos.waltz.common.CollectionUtilities.map;
import static org.finos.waltz.common.DateTimeUtilities.*;
import static org.finos.waltz.common.ListUtilities.newArrayList;
import static org.finos.waltz.common.StringUtilities.lower;
Expand Down Expand Up @@ -415,7 +417,7 @@ private int getCountByStatus(Result<Record2<String, Integer>> countsByStatus, Su
}

public int[] createInstanceRecipients(Long instanceId, Collection<Long> personIds) {
Collection<SurveyInstanceRecipientRecord> records = CollectionUtilities.map(
Collection<SurveyInstanceRecipientRecord> records = map(
personIds,
p -> {
SurveyInstanceRecipientRecord record = new SurveyInstanceRecipientRecord();
Expand All @@ -427,6 +429,20 @@ public int[] createInstanceRecipients(Long instanceId, Collection<Long> personId
return dsl.batchInsert(records).execute();
}


public int[] createInstanceOwners(Long instanceId, Collection<Long> personIds) {
Collection<SurveyInstanceOwnerRecord> records = map(
personIds,
p -> {
SurveyInstanceOwnerRecord record = new SurveyInstanceOwnerRecord();
record.setSurveyInstanceId(instanceId);
record.setPersonId(p);
return record;
});

return dsl.batchInsert(records).execute();
}

public Set<SurveyInstance> findForOwner(Long personId) {
return dsl.select(si.fields())
.select(ENTITY_NAME_FIELD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
import org.finos.waltz.model.Nullable;
import org.immutables.value.Value;

import java.util.List;
import java.util.Set;

@Value.Immutable
@JsonSerialize(as = ImmutableSurveyInstanceRecipientsAndOwners.class)
@JsonDeserialize(as = ImmutableSurveyInstanceRecipientsAndOwners.class)
public abstract class SurveyInstanceRecipientsAndOwners {

public abstract List<Long> personIds();
public abstract Set<Long> recipientPersonIds();

public abstract Set<Long> ownerPersonIds();

@Nullable
public abstract String owningRole();
Expand Down
84 changes: 42 additions & 42 deletions waltz-ng/client/survey/components/survey-run-create-general.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,50 @@ <h4><strong>General</strong></h4>
</div>
</div>

<div class="form-group">
<label for="involvementKinds"
class="col-sm-2 control-label">
Recipient Involvement Kind/s <span class="text-danger">*</span>
</label>
<div class="col-sm-10">
<select id="involvementKinds"
required
type="date"
class="form-control"
ng-options="kind as kind.name for kind in $ctrl.availableInvolvementKinds | orderBy:'name' track by kind.id"
ng-model="$ctrl.surveyRun.involvementKinds"
multiple
style="height: 250px;">
</select>
<div ng-if="$ctrl.surveyRun.involvementKinds" )>
<ul class="list-inline">
<li>Selected Recipients:</li>
<li ng-repeat="role in $ctrl.surveyRun.involvementKinds">
<strong ng-bind="role.name"></strong>
<span ng-if="$ctrl.isLastInList(role, $ctrl.surveyRun.involvementKinds)">; </span>
</li>
<li>
<button class="btn btn-skinny small"
ng-click="$ctrl.surveyRun.involvementKinds = null">
<waltz-icon name="trash"></waltz-icon>
Clear
</button>
</li>
</ul>
</div>
<div class="small help-block">
Recipients can complete, submit and reopen surveys they have been assigned.
This is involvement-based and will give permissions specific
to the person with that involvement as listed in the 'people' section on the surveyed entity.
</div>
</div>
</div>

<div class="form-group">
<div>
<label for="owningRole"
class="col-sm-2 control-label">
Survey admin role/s
Approver role
</label>
</div>
<div class="col-sm-10">
Expand Down Expand Up @@ -225,7 +264,7 @@ <h4><strong>General</strong></h4>
<div class="form-group">
<label for="ownerInvKinds"
class="col-sm-2 control-label">
Owner Involvement Kind/s
Approver Involvement Kind/s
</label>
<div class="col-sm-10">
<select id="ownerInvKinds"
Expand All @@ -238,7 +277,7 @@ <h4><strong>General</strong></h4>
</select>
<div ng-if="$ctrl.surveyRun.ownerInvolvementKinds">
<ul class="list-inline">
<li>Selected Owners:</li>
<li>Selected Approvers:</li>
<li ng-repeat="role in $ctrl.surveyRun.ownerInvolvementKinds">
<strong ng-bind="role.name"></strong>
<span ng-if="$ctrl.isLastInList(role, $ctrl.surveyRun.ownerInvolvementKinds)">; </span>
Expand All @@ -259,45 +298,6 @@ <h4><strong>General</strong></h4>
</div>
</div>

<div class="form-group">
<label for="involvementKinds"
class="col-sm-2 control-label">
Recipient Involvement Kind/s <span class="text-danger">*</span>
</label>
<div class="col-sm-10">
<select id="involvementKinds"
required
type="date"
class="form-control"
ng-options="kind as kind.name for kind in $ctrl.availableInvolvementKinds | orderBy:'name' track by kind.id"
ng-model="$ctrl.surveyRun.involvementKinds"
multiple
style="height: 250px;">
</select>
<div ng-if="$ctrl.surveyRun.involvementKinds")>
<ul class="list-inline">
<li>Selected Recipients:</li>
<li ng-repeat="role in $ctrl.surveyRun.involvementKinds">
<strong ng-bind="role.name"></strong>
<span ng-if="$ctrl.isLastInList(role, $ctrl.surveyRun.involvementKinds)">; </span>
</li>
<li>
<button class="btn btn-skinny small"
ng-click="$ctrl.surveyRun.involvementKinds = null">
<waltz-icon name="trash"></waltz-icon>
Clear
</button>
</li>
</ul>
</div>
<div class="small help-block">
Recipients can complete, submit and reopen surveys they have been assigned.
This is involvement-based and will give permissions specific
to the person with that involvement as listed in the 'people' section on the surveyed entity.
</div>
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label">
Issuance Kind <span class="text-danger">*</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ function controller(appGroupStore, involvementKindStore, serviceBroker) {
vm.availableAppGroups = [].concat(publicGroups, privateGroups);
});

involvementKindStore.findAll().then(
involvementKinds => {
involvementKindStore.findAll()
.then(involvementKinds => {
vm.availableInvolvementKinds = involvementKinds;
}
);
});

vm.$onInit = () => {
serviceBroker.loadViewData(CORE_API.RoleStore.findAllRoles)
Expand Down
Loading

0 comments on commit 9e949f2

Please sign in to comment.