-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6150 from deutschebank/db-contrib/waltz-6098-asse…
…ssment-ratings-into-groups Db contrib/waltz 6098 assessment ratings into groups
Showing
22 changed files
with
671 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,4 +157,5 @@ | |
<column name="user_selectable" valueBoolean="true"/> | ||
</insert> | ||
</changeSet> | ||
|
||
</databaseChangeLog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
waltz-ng/client/assessments/components/list/AssessmentDefinitionTooltipContent.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script> | ||
import Markdown from "../../../common/svelte/Markdown.svelte"; | ||
import Icon from "../../../common/svelte/Icon.svelte"; | ||
export let definition; | ||
</script> | ||
|
||
|
||
<h4> | ||
{definition.name} | ||
<span class="text-muted small">({definition.externalId})</span> | ||
</h4> | ||
<Markdown class="force-wrap" text={definition.description}/> | ||
|
||
{#if definition.isReadOnly} | ||
<div class="help-block small"> | ||
<Icon name="lock"/> | ||
Assessments relating to this definition are read-only and cannot be edited. | ||
</div> | ||
{/if} |
167 changes: 167 additions & 0 deletions
167
waltz-ng/client/assessments/components/list/AssessmentRatingList.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<script> | ||
import _ from "lodash"; | ||
import {userPreferenceStore} from "../../../svelte-stores/user-preference-store"; | ||
import {onMount} from "svelte"; | ||
import {createStores} from "./assessment-rating-store"; | ||
import AssessmentRatingListGroup from "./AssessmentRatingListGroup.svelte"; | ||
import Icon from "../../../common/svelte/Icon.svelte"; | ||
let elem; | ||
let stores = null; | ||
let defaultPrimaryList; | ||
let favouriteIncludedIds; | ||
let favouriteExcludedIds; | ||
let favouriteIds; | ||
let setFromPreferences; | ||
let userPreferenceCall = userPreferenceStore.findAllForUser(); | ||
export let assessments = []; | ||
export let primaryEntityRef = []; | ||
export let onSelect = (d) => console.log("selected", d); | ||
onMount(() => { | ||
userPreferenceCall = userPreferenceStore.findAllForUser(); | ||
}) | ||
function toggleGroup(group) { | ||
expansions = _.includes(expansions, group.groupName) | ||
? _.without(expansions, group.groupName) | ||
: _.concat(expansions, group.groupName); | ||
} | ||
function selectAssessment(evt) { | ||
onSelect(evt.detail); | ||
} | ||
function toggleFavourite(row) { | ||
const isExplicitlyIncluded = _.includes($favouriteIncludedIds, row.definition.id); | ||
const isExplicitlyExcluded = _.includes($favouriteExcludedIds, row.definition.id); | ||
const isDefault = _.includes($defaultPrimaryList, row.definition.id); | ||
let message; | ||
if (isExplicitlyIncluded) { | ||
message = "Removing from favourite assessments" | ||
$favouriteIncludedIds = _.without($favouriteIncludedIds, row.definition.id); | ||
} else if (isExplicitlyExcluded) { | ||
message = "Adding to favourite assessments" | ||
$favouriteExcludedIds = _.without($favouriteExcludedIds, row.definition.id); | ||
} else if (isDefault) { | ||
message = "Removing from favourite assessments" | ||
$favouriteExcludedIds = _.concat($favouriteExcludedIds, row.definition.id); | ||
} else { | ||
message = "Adding to favourite assessments" | ||
$favouriteIncludedIds = _.concat($favouriteIncludedIds, row.definition.id); | ||
} | ||
} | ||
$: { | ||
if (primaryEntityRef) { | ||
stores = createStores(primaryEntityRef); | ||
defaultPrimaryList = stores.defaultPrimaryList | ||
favouriteIncludedIds = stores.favouriteIncludedIds, | ||
favouriteExcludedIds = stores.favouriteExcludedIds, | ||
favouriteIds = stores.favouriteIds, | ||
setFromPreferences = stores.setFromPreferences | ||
} | ||
} | ||
$: userPreferences = $userPreferenceCall.data; | ||
$: { | ||
if (userPreferences && stores) { | ||
setFromPreferences(userPreferences) | ||
} | ||
} | ||
$: expansions = _ | ||
.chain(assessments) | ||
.filter(d => _.includes($favouriteIds, d.definition.id)) | ||
.map(d => d.definition.definitionGroup) | ||
.uniq() | ||
.value(); | ||
$: groupedAssessments = _.chain(assessments) | ||
.groupBy(d => d.definition?.definitionGroup) | ||
.map((v, k) => { | ||
const [notProvided, provided] = _ | ||
.chain(v) | ||
.orderBy(d => d.definition.name) | ||
.partition(d => d.rating == null) | ||
.value() | ||
return { | ||
groupName: k, | ||
notProvided, | ||
provided | ||
} | ||
}) | ||
.orderBy([d => d.groupName === "Uncategorized", d => d.groupName]) | ||
.value(); | ||
$: { | ||
if (stores) { | ||
$defaultPrimaryList = _ | ||
.chain(assessments) | ||
.filter(a => a.definition.visibility === "PRIMARY") | ||
.map(r => r.definition.id) | ||
.value(); | ||
} | ||
} | ||
</script> | ||
<div class="row"> | ||
<div class="col-sm-12"> | ||
<table class="table table-hover table-condensed"> | ||
<colgroup> | ||
<col width="10%"/> | ||
<col width="50%"/> | ||
<col width="40%"/> | ||
</colgroup> | ||
{#each groupedAssessments as group} | ||
<tbody> | ||
<tr style="background-color: #eee"> | ||
<td> | ||
<button class="btn btn-skinny" | ||
on:click={() => toggleGroup(group)}> | ||
<Icon size="lg" | ||
name={_.includes(expansions, group.groupName) ? "caret-down" : "caret-right"}/> | ||
</button> | ||
</td> | ||
<td colspan="2"> | ||
<strong> | ||
<span>{group.groupName}</span> | ||
</strong> | ||
</td> | ||
</tr> | ||
{#if _.includes(expansions, group.groupName)} | ||
<AssessmentRatingListGroup group={group} | ||
on:select={selectAssessment} | ||
toggleFavourite={toggleFavourite} | ||
favouriteIds={favouriteIds}/> | ||
{/if} | ||
</tbody> | ||
{/each} | ||
</table> | ||
</div> | ||
</div> | ||
170 changes: 170 additions & 0 deletions
170
waltz-ng/client/assessments/components/list/AssessmentRatingListGroup.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
<script> | ||
import {fade} from "svelte/transition"; | ||
import Icon from "../../../common/svelte/Icon.svelte"; | ||
import Tooltip from "./../../../common/svelte/Tooltip.svelte"; | ||
import {createEventDispatcher} from "svelte"; | ||
import _ from "lodash"; | ||
import RatingIndicatorCell from "../../../ratings/components/rating-indicator-cell/RatingIndicatorCell.svelte"; | ||
import AssessmentDefinitionTooltipContent from "./AssessmentDefinitionTooltipContent.svelte" | ||
import AssessmentRatingTooltipContent from "./AssessmentRatingTooltipContent.svelte" | ||
export let group; | ||
export let toggleFavourite | ||
export let favouriteIds | ||
let notProvidedCollapsed = true; | ||
const dispatch = createEventDispatcher(); | ||
function selectAssessment(row) { | ||
dispatch("select", row); | ||
} | ||
function mkRatingTooltipProps(row) { | ||
return { | ||
rating: row.rating, | ||
ratingItem: row.ratingItem | ||
} | ||
} | ||
function mkDefinitionTooltipProps(row) { | ||
return { | ||
definition: row.definition | ||
} | ||
} | ||
</script> | ||
|
||
{#each group.provided as row} | ||
<tr transition:fade | ||
on:click={() => selectAssessment(row)}> | ||
<td> | ||
<button class="btn btn-skinny" | ||
on:click={() => toggleFavourite(row)}> | ||
<Icon size="lg" | ||
name={_.includes($favouriteIds, row.definition.id) ? "star" : "star-o"}/> | ||
</button> | ||
</td> | ||
<td> | ||
<Tooltip content={AssessmentDefinitionTooltipContent} | ||
props={mkDefinitionTooltipProps(row)}> | ||
<svelte:fragment slot="target"> | ||
<span> | ||
<Icon name={row.definition.isReadOnly ? "lock" : "fw"}/> | ||
{row.definition.name} | ||
</span> | ||
</svelte:fragment> | ||
</Tooltip> | ||
</td> | ||
<td> | ||
<Tooltip content={AssessmentRatingTooltipContent} | ||
props={mkRatingTooltipProps(row)}> | ||
<svelte:fragment slot="target"> | ||
<RatingIndicatorCell {...row.ratingItem} | ||
show-name="true"/> | ||
{#if row.rating.comment} | ||
<Icon name="sticky-note-o"/> | ||
{/if} | ||
</svelte:fragment> | ||
</Tooltip> | ||
</td> | ||
</tr> | ||
{/each} | ||
{#if !_.isEmpty(group.notProvided)} | ||
{#if notProvidedCollapsed} | ||
<tr transition:fade> | ||
<td> | ||
<button class="btn btn-skinny" | ||
on:click={() => notProvidedCollapsed = false}> | ||
<Icon size="lg" | ||
name="caret-right"/> | ||
</button> | ||
</td> | ||
<td> | ||
<strong>Not Rated</strong> | ||
</td> | ||
<td class="force-wrap"> | ||
<ul class="list-inline"> | ||
{#each group.notProvided as row} | ||
{#if row.definition.isReadOnly} | ||
<li class="force-wrap"> | ||
<span class="text-muted"> | ||
<Icon name="lock"/>{row.definition.name} | ||
</span> | ||
</li> | ||
{:else} | ||
<li class="force-wrap"> | ||
<a class="clickable" | ||
on:click={() => selectAssessment(row)}> | ||
{row.definition.name} | ||
</a> | ||
</li> | ||
{/if} | ||
{/each} | ||
</ul> | ||
</td> | ||
</tr> | ||
{:else} | ||
<tr transition:fade> | ||
<td> | ||
<button class="btn btn-skinny" | ||
on:click={() => notProvidedCollapsed = true}> | ||
<Icon size="lg" | ||
name="caret-down"/> | ||
</button> | ||
</td> | ||
<td colspan="2"> | ||
<strong>Not Rated</strong> | ||
</td> | ||
</tr> | ||
{#each group.notProvided as row} | ||
<tr transition:fade> | ||
<td> | ||
<button class="btn btn-skinny" | ||
on:click={() => toggleFavourite(row)}> | ||
<Icon size="lg" | ||
name={_.includes($favouriteIds, row.definition.id) ? "star" : "star-o"}/> | ||
</button> | ||
</td> | ||
<td> | ||
<Tooltip content={AssessmentDefinitionTooltipContent} | ||
props={mkDefinitionTooltipProps(row)}> | ||
<svelte:fragment slot="target"> | ||
<span> | ||
<Icon name={row.definition.isReadOnly ? "lock" : "fw"}/> | ||
{row.definition.name} | ||
</span> | ||
</svelte:fragment> | ||
</Tooltip> | ||
</td> | ||
<td> | ||
<span class="text-muted italics">Not Provided</span> | ||
</td> | ||
</tr> | ||
{/each} | ||
{/if} | ||
{/if} | ||
|
||
|
||
<style> | ||
ul { | ||
padding: 0.1em 0 0 0; | ||
margin: 0 0 0 0; | ||
list-style: none; | ||
} | ||
li::after { | ||
content: ", "; | ||
} | ||
li:last-child::after { | ||
content: ""; | ||
} | ||
li { | ||
padding-top: 0.1em; | ||
} | ||
</style> |
28 changes: 28 additions & 0 deletions
28
waltz-ng/client/assessments/components/list/AssessmentRatingTooltipContent.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script> | ||
import Markdown from "../../../common/svelte/Markdown.svelte"; | ||
import Icon from "../../../common/svelte/Icon.svelte"; | ||
import LastEdited from "../../../common/svelte/LastEdited.svelte"; | ||
export let rating; | ||
export let ratingItem; | ||
</script> | ||
|
||
|
||
<h4>{ratingItem.name}</h4> | ||
<div> | ||
{ratingItem.description} | ||
</div> | ||
{#if rating.comment} | ||
<hr> | ||
<span> | ||
<Icon name="sticky-note-o"/> | ||
<Markdown inline={true} | ||
text={rating.comment}/> | ||
</span> | ||
{/if} | ||
<div class="small"> | ||
Last Modified: | ||
<LastEdited entity={rating}/> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
waltz-ng/client/assessments/components/list/assessment-rating-store.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {derived, writable} from "svelte/store"; | ||
import _ from "lodash"; | ||
import {mkAssessmentDefinitionsIdsBaseKey} from "../../../user"; | ||
import {userPreferenceStore} from "../../../svelte-stores/user-preference-store"; | ||
import {getIdsFromString} from "../../assessment-utils"; | ||
|
||
function writePreference(favouriteIncludedKey, $favouriteIncludedIds) { | ||
const userPreference = {key: favouriteIncludedKey, value: $favouriteIncludedIds.toString()}; | ||
userPreferenceStore.saveForUser(userPreference); | ||
} | ||
|
||
export function createStores(primaryEntityRef) { | ||
|
||
const baseKey = mkAssessmentDefinitionsIdsBaseKey(primaryEntityRef); | ||
const favouriteIncludedKey = `${baseKey}.included`; | ||
const favouriteExcludedKey = `${baseKey}.excluded`; | ||
|
||
const defaultPrimaryList = writable([]); | ||
const favouriteExcludedIds = writable([]); | ||
const favouriteIncludedIds = writable([]); | ||
|
||
const favouriteIds = derived( | ||
[defaultPrimaryList, favouriteExcludedIds, favouriteIncludedIds], | ||
|
||
([$defaultPrimaryList, $favouriteExcludedIds, $favouriteIncludedIds]) => { | ||
return _.reject( | ||
_.concat($defaultPrimaryList, $favouriteIncludedIds), | ||
d => _.includes($favouriteExcludedIds, d)); | ||
}) | ||
|
||
favouriteIds.subscribe(() => { | ||
}) | ||
|
||
derived([favouriteIncludedIds], ($favouriteIncludedIds) => { | ||
writePreference(favouriteIncludedKey, $favouriteIncludedIds); | ||
}).subscribe(() => { | ||
}); | ||
|
||
derived([favouriteExcludedIds], ($favouriteExcludedIds) => { | ||
writePreference(favouriteExcludedKey, $favouriteExcludedIds); | ||
}).subscribe(() => { | ||
}); | ||
|
||
function setFromPreferences(userPreferences) { | ||
|
||
const includedFavouritesString = _.find(userPreferences, d => d.key === favouriteIncludedKey) | ||
const excludedFavouritesString = _.find(userPreferences, d => d.key === favouriteExcludedKey) | ||
|
||
favouriteIncludedIds.set(getIdsFromString(includedFavouritesString)); | ||
favouriteExcludedIds.set(getIdsFromString(excludedFavouritesString)); | ||
} | ||
|
||
return { | ||
defaultPrimaryList, | ||
favouriteIncludedIds, | ||
favouriteExcludedIds, | ||
favouriteIds, | ||
setFromPreferences | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<script> | ||
import tippy from "tippy.js"; | ||
import 'tippy.js/dist/tippy.css'; | ||
import 'tippy.js/themes/light-border.css'; | ||
let elem; | ||
let contentElem; | ||
let open = false; | ||
export let content; | ||
export let props | ||
$: { | ||
if (elem && content) { | ||
tippy(elem, { | ||
content: "loading", | ||
arrow: true, | ||
interactive: true, | ||
trigger: 'mouseenter click', | ||
theme: "light-border", | ||
onShow(instance) { | ||
open = true; | ||
setTimeout(() => instance.setContent(contentElem), 100); | ||
} | ||
}); | ||
} | ||
} | ||
</script> | ||
|
||
<span bind:this={elem}> | ||
<slot name="target"></slot> | ||
</span> | ||
|
||
<div style="display: none"> | ||
<div bind:this={contentElem}> | ||
{#if open} | ||
<svelte:component this={content} {...props}/> | ||
{/if} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Waltz - Enterprise Architecture | ||
* Copyright (C) 2016, 2017, 2018, 2019 Waltz open source project | ||
* See README.md for more information | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific | ||
* | ||
*/ | ||
|
||
import {remote} from "./remote"; | ||
|
||
export function mkUserPreferenceStore() { | ||
|
||
const findAllForUser = (force) => { | ||
return remote | ||
.fetchViewList( | ||
"GET", | ||
"api/user-preference", | ||
[], | ||
{force}); | ||
}; | ||
|
||
const saveForUser = (preference) => { | ||
return remote | ||
.execute( | ||
"POST", | ||
"api/user-preference/save", | ||
preference); | ||
}; | ||
|
||
return { | ||
findAllForUser, | ||
saveForUser | ||
}; | ||
} | ||
|
||
export const userPreferenceStore = mkUserPreferenceStore(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters