Skip to content

Commit

Permalink
Reorder recipient and owner selectors
Browse files Browse the repository at this point in the history
#CTCTOWALTZ-2626
#6368
  • Loading branch information
jessica-woodland-scott-db committed Jan 25, 2023
1 parent f13d994 commit 9d993da
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 10 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 @@ -9,15 +9,17 @@
export let id;
export let groupApprovers = null;
export let owningRole = null;
let ownersCall = null;
let recipientsCall = null;
let viewGroupApproversList = false;
let groupApproversCall = null;
function reload() {
ownersCall = surveyInstanceStore.findOwners(id, true);
recipientsCall = surveyInstanceStore.findRecipients(id, true);
groupApproversCall = surveyInstanceStore.findGroupApprovers(id, true);
}
Expand Down Expand Up @@ -55,8 +57,9 @@
}
$: owners = _.sortBy($ownersCall?.data, d => d.name);
$: recipients = _.sortBy($recipientsCall?.data, d => d.name);
$: owners = _.sortBy($ownersCall?.data, d => _.toLower(d.name));
$: recipients = _.sortBy($recipientsCall?.data, d => _.toLower(d.name));
$: groupApprovers = _.sortBy($groupApproversCall?.data, d => _.toLower(d.name));
$: permissionsCall = id && surveyInstanceStore.getPermissions(id);
$: permissions = $permissionsCall.data;
Expand Down Expand Up @@ -94,12 +97,30 @@
canRemoveSelf={false}/>
</td>
</tr>
{#if !_.isNil(groupApprovers)}
{#if !_.isNil(owningRole)}
<tr style="vertical-align: top">
<td>Group Approvers</td>
<td>
<Icon name="group"/>
{groupApprovers}
{owningRole}
{#if viewGroupApproversList}
<div style="margin-top: 1em"
class:waltz-scroll-region-250={_.size(groupApprovers) > 14}>
<PersonList people={groupApprovers}
canAdd={false}
canRemove={false}
canRemoveSelf={false}/>
</div>
<button class="btn btn-xs btn-skinny"
on:click={() => viewGroupApproversList = false}>
Hide group members
</button>
{:else}
<button class="btn btn-xs btn-skinny"
on:click={() => viewGroupApproversList = true}>
View group members
</button>
{/if}
</td>
</tr>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
People
</h5>
<SurveyPeople id={instanceId}
groupApprovers={survey.surveyInstance?.owningRole}/>
owningRole={survey.surveyInstance?.owningRole}/>
</div>

<div class="mini-section">
Expand Down
10 changes: 7 additions & 3 deletions waltz-ng/client/svelte-stores/survey-instance-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ export function mkSurveyInstanceStore() {
.fetchViewList("GET", `api/survey-instance/${id}/actions`, [], {force});

const findRecipients = (id, force = false) => remote
.fetchViewList("GET",`api/survey-instance/${id}/recipients`, null, {force});
.fetchViewList("GET", `api/survey-instance/${id}/recipients`, null, {force});

const findOwners = (id, force = false) => remote
.fetchViewList("GET",`api/survey-instance/${id}/owners`, null, {force});
.fetchViewList("GET", `api/survey-instance/${id}/owners`, null, {force});

const findGroupApprovers = (id, force = false) => remote
.fetchViewList("GET", `api/survey-instance/${id}/group-approvers`, null, {force});

const findResponses = (id) => remote
.fetchViewList("GET",`api/survey-instance/${id}/responses`);
.fetchViewList("GET", `api/survey-instance/${id}/responses`);

const findPreviousVersions = (originalId) => remote
.fetchViewList("GET", `api/survey-instance/id/${originalId}/previous-versions`);
Expand Down Expand Up @@ -104,6 +107,7 @@ export function mkSurveyInstanceStore() {
findOwners,
findPossibleActions,
findRecipients,
findGroupApprovers,
findResponses,
findPreviousVersions,
findVersions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@
import java.util.*;

import static java.lang.String.format;
import static java.util.Collections.emptySet;
import static org.finos.waltz.common.Checks.*;
import static org.finos.waltz.common.CollectionUtilities.find;
import static org.finos.waltz.common.CollectionUtilities.isEmpty;
import static org.finos.waltz.common.StringUtilities.isEmpty;
import static org.finos.waltz.common.StringUtilities.joinUsing;
import static org.finos.waltz.model.survey.SurveyInstanceStateMachineFactory.simple;
import static org.finos.waltz.model.utils.IdUtilities.indexByOptionalId;
Expand Down Expand Up @@ -578,4 +580,15 @@ public int copyResponses(long sourceSurveyId, CopySurveyResponsesCommand copyCom

return updated;
}

public Set<Person> findGroupApprovers(long id) {
SurveyInstance surveyInstance = getById(id);

if (isEmpty(surveyInstance.owningRole())) {
return emptySet();
} else {
return personDao
.findActivePeopleByUserRole(surveyInstance.owningRole());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void register() {
String findForSurveyRunPath = mkPath(BASE_URL, "run", ":id");
String findPreviousVersionsPath = mkPath(BASE_URL, "id", ":id", "previous-versions");
String findVersionsPath = mkPath(BASE_URL, "id", ":id", "versions");
String findGroupApproversPath = mkPath(BASE_URL, ":id", "group-approvers");
String findRecipientsPath = mkPath(BASE_URL, ":id", "recipients");
String findOwnersPath = mkPath(BASE_URL, ":id", "owners");
String findResponsesPath = mkPath(BASE_URL, ":id", "responses");
Expand Down Expand Up @@ -111,6 +112,9 @@ public void register() {
ListRoute<Person> findRecipientsRoute =
(req, res) -> surveyInstanceService.findRecipients(getId(req));

ListRoute<Person> findGroupApproversRoute =
(req, res) -> surveyInstanceService.findGroupApprovers(getId(req));

ListRoute<Person> findOwnersRoute =
(req, res) -> surveyInstanceService.findOwners(getId(req));

Expand Down Expand Up @@ -258,6 +262,7 @@ public void register() {
getForList(findPreviousVersionsPath, findPreviousVersionsRoute);
getForList(findVersionsPath, findVersionsRoute);
getForList(findRecipientsPath, findRecipientsRoute);
getForList(findGroupApproversPath, findGroupApproversRoute);
getForList(findOwnersPath, findOwnersRoute);
getForList(findResponsesPath, findResponsesRoute);
getForList(findPossibleActionsPath, findPossibleActionsRoute);
Expand Down

0 comments on commit 9d993da

Please sign in to comment.