diff --git a/waltz-data/src/main/java/org/finos/waltz/data/person/PersonDao.java b/waltz-data/src/main/java/org/finos/waltz/data/person/PersonDao.java index 836ac12440..d44d7757ec 100644 --- a/waltz-data/src/main/java/org/finos/waltz/data/person/PersonDao.java +++ b/waltz-data/src/main/java/org/finos/waltz/data/person/PersonDao.java @@ -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; @@ -244,4 +245,14 @@ public Set findActivePeopleByEmails(Set emails) { .and(PERSON.IS_REMOVED.isFalse())) .fetchSet(personMapper); } + + + public Set 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); + } } diff --git a/waltz-ng/client/survey/components/svelte/inline-panel/SurveyPeople.svelte b/waltz-ng/client/survey/components/svelte/inline-panel/SurveyPeople.svelte index bcfdd9beaa..67509eb9c6 100644 --- a/waltz-ng/client/survey/components/svelte/inline-panel/SurveyPeople.svelte +++ b/waltz-ng/client/survey/components/svelte/inline-panel/SurveyPeople.svelte @@ -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); } @@ -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; @@ -94,12 +97,30 @@ canRemoveSelf={false}/> - {#if !_.isNil(groupApprovers)} + {#if !_.isNil(owningRole)} Group Approvers - {groupApprovers} + {owningRole} + {#if viewGroupApproversList} +
14}> + +
+ + {:else} + + {/if} {/if} diff --git a/waltz-ng/client/survey/components/svelte/inline-panel/SurveyViewerContextPanel.svelte b/waltz-ng/client/survey/components/svelte/inline-panel/SurveyViewerContextPanel.svelte index b66c41a3c7..e90f1e302b 100644 --- a/waltz-ng/client/survey/components/svelte/inline-panel/SurveyViewerContextPanel.svelte +++ b/waltz-ng/client/survey/components/svelte/inline-panel/SurveyViewerContextPanel.svelte @@ -152,7 +152,7 @@ People + owningRole={survey.surveyInstance?.owningRole}/>
diff --git a/waltz-ng/client/svelte-stores/survey-instance-store.js b/waltz-ng/client/svelte-stores/survey-instance-store.js index 7d996dcb40..bd2908188c 100644 --- a/waltz-ng/client/svelte-stores/survey-instance-store.js +++ b/waltz-ng/client/svelte-stores/survey-instance-store.js @@ -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`); @@ -104,6 +107,7 @@ export function mkSurveyInstanceStore() { findOwners, findPossibleActions, findRecipients, + findGroupApprovers, findResponses, findPreviousVersions, findVersions, diff --git a/waltz-service/src/main/java/org/finos/waltz/service/survey/SurveyInstanceService.java b/waltz-service/src/main/java/org/finos/waltz/service/survey/SurveyInstanceService.java index 59d37c60cd..508cb1c9d9 100644 --- a/waltz-service/src/main/java/org/finos/waltz/service/survey/SurveyInstanceService.java +++ b/waltz-service/src/main/java/org/finos/waltz/service/survey/SurveyInstanceService.java @@ -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; @@ -578,4 +580,15 @@ public int copyResponses(long sourceSurveyId, CopySurveyResponsesCommand copyCom return updated; } + + public Set findGroupApprovers(long id) { + SurveyInstance surveyInstance = getById(id); + + if (isEmpty(surveyInstance.owningRole())) { + return emptySet(); + } else { + return personDao + .findActivePeopleByUserRole(surveyInstance.owningRole()); + } + } } diff --git a/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/SurveyInstanceEndpoint.java b/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/SurveyInstanceEndpoint.java index f1908f72b2..d11ef8ecad 100644 --- a/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/SurveyInstanceEndpoint.java +++ b/waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/SurveyInstanceEndpoint.java @@ -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"); @@ -111,6 +112,9 @@ public void register() { ListRoute findRecipientsRoute = (req, res) -> surveyInstanceService.findRecipients(getId(req)); + ListRoute findGroupApproversRoute = + (req, res) -> surveyInstanceService.findGroupApprovers(getId(req)); + ListRoute findOwnersRoute = (req, res) -> surveyInstanceService.findOwners(getId(req)); @@ -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);