forked from finos/waltz
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter based on flow classifications
- Loading branch information
1 parent
51bc2ba
commit 770945b
Showing
4 changed files
with
143 additions
and
7 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
95 changes: 95 additions & 0 deletions
95
...ient/data-flow/components/svelte/flow-detail-tab/filters/FlowClassificationFilters.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,95 @@ | ||
<script> | ||
import { | ||
mkClassificationFilterId, | ||
mkClassificationFilter, | ||
FilterKinds | ||
} from "./filter-utils"; | ||
import _ from "lodash"; | ||
import {filters, updateFilters} from "../flow-details-store"; | ||
import RatingIndicatorCell | ||
from "../../../../../ratings/components/rating-indicator-cell/RatingIndicatorCell.svelte"; | ||
export let flowClassifications = []; | ||
function selectClassification(classification) { | ||
const filterId = mkClassificationFilterId(); | ||
const existingFilter = _.find($filters, f => f.id === filterId); | ||
const existingClassifications = _.get(existingFilter, "classifications", []); | ||
const newClassifications = _.some(existingClassifications, r => _.isEqual(r, classification.code)) | ||
? _.filter(existingClassifications, d => !_.isEqual(d, classification.code)) | ||
: _.concat(existingClassifications, [classification.code]); | ||
const newFilter = mkClassificationFilter(filterId, newClassifications) | ||
updateFilters(filterId, newFilter); | ||
} | ||
function isSelected(filters, fcCode){ | ||
const classificationFilter = _.find( | ||
filters, | ||
f => f.id === mkClassificationFilterId()); | ||
return _.some( | ||
_.get(classificationFilter, "classifications", []), | ||
selectedFcCode => fcCode === selectedFcCode); | ||
} | ||
function onClearFilters() { | ||
$filters = _.reject($filters, f => f.kind === FilterKinds.FLOW_CLASSIFICATION); | ||
} | ||
$: hasFilters = _.some($filters, f => f.kind === FilterKinds.FLOW_CLASSIFICATION); | ||
</script> | ||
|
||
<div class="help-block" | ||
style="padding-top: 1em;"> | ||
Filters the flows based upon their classification ratings. | ||
</div> | ||
<div style="display: flex; padding-top: 1em; padding-bottom: 1em"> | ||
<table class="table table-condensed table table-hover"> | ||
<thead> | ||
<tr> | ||
<th> | ||
Flow Classification | ||
</th> | ||
<th> | ||
{#if hasFilters} | ||
<button class="btn-skinny" | ||
style="font-weight: lighter" | ||
on:click={onClearFilters}> | ||
Clear | ||
</button> | ||
{/if} | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{#each _.orderBy(flowClassifications, d => d.name) as fc} | ||
<tr class="clickable" | ||
class:selected={isSelected($filters, fc.code)} | ||
on:click={() => selectClassification(fc)}> | ||
<td> | ||
<RatingIndicatorCell {...fc}/> | ||
</td> | ||
<td> | ||
{fc.description} | ||
</td> | ||
</tr> | ||
{/each} | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<style> | ||
.selected { | ||
background-color: #eefaee !important; | ||
} | ||
</style> |
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