diff --git a/waltz-model/src/main/java/org/finos/waltz/model/change_initiative/ChangeInitiativeView.java b/waltz-model/src/main/java/org/finos/waltz/model/change_initiative/ChangeInitiativeView.java new file mode 100644 index 0000000000..1c7240de5e --- /dev/null +++ b/waltz-model/src/main/java/org/finos/waltz/model/change_initiative/ChangeInitiativeView.java @@ -0,0 +1,20 @@ +package org.finos.waltz.model.change_initiative; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.finos.waltz.model.assessment_definition.AssessmentDefinition; +import org.finos.waltz.model.assessment_rating.AssessmentRating; +import org.finos.waltz.model.rating.RatingSchemeItem; +import org.immutables.value.Value; + +import java.util.Set; + +@Value.Immutable +@JsonSerialize(as=ImmutableChangeInitiativeView.class) +public abstract class ChangeInitiativeView { + + public abstract Set changeInitiatives(); + public abstract Set assessmentDefinitions(); + public abstract Set ratingSchemeItems(); + public abstract Set ratings(); + +} diff --git a/waltz-ng/client/assessments/assessment-utils.js b/waltz-ng/client/assessments/assessment-utils.js index d8069d6739..6549f2258b 100644 --- a/waltz-ng/client/assessments/assessment-utils.js +++ b/waltz-ng/client/assessments/assessment-utils.js @@ -17,8 +17,6 @@ */ import _ from "lodash"; import { indexRatingSchemes } from "../ratings/rating-utils"; -import { nest } from "d3-collection"; -import { grey } from "../common/colors"; import { refToString } from "../common/entity-utils"; import {CORE_API} from "../common/services/core-api-utils"; import {resolveResponses} from "../common/promise-utils"; @@ -70,48 +68,6 @@ export function mkEnrichedAssessmentDefinitions(definitions = [], } -export function mkAssessmentSummaries(definitions = [], schemes = [], ratings = [], total = 0) { - const indexedRatingSchemes = indexRatingSchemes(schemes); - const definitionsById = _.keyBy(definitions, d => d.id); - - const nestedRatings = nest() - .key(d => d.assessmentDefinitionId) - .key(d => d.ratingId) - .rollup(xs => xs.length) - .entries(ratings); - - return _ - .chain(nestedRatings) - .map(d => { - const definition = definitionsById[Number(d.key)]; - const assignedTotal = _.sumBy(d.values, v => v.value); - const values = _ - .chain(d.values) - .map(v => { - const propPath = [definition.ratingSchemeId, "ratingsById", v.key]; - const rating = _.get(indexedRatingSchemes, propPath); - return Object.assign({}, v, { rating, count: v.value }); - }) - .concat([{ - key: "z", - rating: { - id: -1, - name: "Not Provided", - color: grey - }, - count: _.max([0, total - assignedTotal]) - }]) - .filter(d => d.count > 0) - .value(); - - const extension = { definition, values }; - return Object.assign({}, d , extension); - }) - .orderBy(d => d.definition.name) - .value(); -} - - /** * Given a list of entities, a list of assessment ratings and a desired * rating will filter the list of entities accordingly @@ -154,6 +110,7 @@ export function filterByAssessmentRating(entities = [], * @param $q * @param serviceBroker * @param kind + * @param options * @param primaryOnly * @returns {*} */ diff --git a/waltz-ng/client/change-initiative/components/change-initiative-section/change-initiative-section.html b/waltz-ng/client/change-initiative/components/change-initiative-section/change-initiative-section.html index d7c27dacfa..f40d6b63e6 100644 --- a/waltz-ng/client/change-initiative/components/change-initiative-section/change-initiative-section.html +++ b/waltz-ng/client/change-initiative/components/change-initiative-section/change-initiative-section.html @@ -15,9 +15,19 @@ ~ See the License for the specific ~ --> + +