Skip to content

Commit

Permalink
Merge pull request #6264 from deutschebank/db-contrib/waltz-6232-jexl…
Browse files Browse the repository at this point in the history
…-links

Db contrib/waltz 6232 jexl links
  • Loading branch information
davidwatkins73 authored Oct 24, 2022
2 parents ba027c5 + af9c5c1 commit 3b05c17
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import NoData from "../../../../common/svelte/NoData.svelte";
import {columnDefs, hasChanged, lastMovedColumn, selectedColumn, selectedGrid,} from "../report-grid-store";
import ColumnRemovalConfirmation from "./ColumnRemovalConfirmation.svelte";
import {entity} from "../../../../common/services/enums/entity";
import Markdown from "../../../../common/svelte/Markdown.svelte";
import {derivedColumnHelpText} from "./column-definition-utils";
export let gridId;
Expand Down Expand Up @@ -298,6 +299,8 @@
rows="6"
placeholder="Enter script here"
bind:value={workingDerivedCol.derivationScript}/>
<br>
<Markdown text={derivedColumnHelpText}/>
</div>
<span>
<button class="btn btn-skinny"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import {sameColumnRef} from "../report-grid-utils";
import Icon from "../../../../common/svelte/Icon.svelte";
import {columnDefs, selectedGrid} from "../report-grid-store";
import ColumnDefinitionHeader from "./ColumnDefinitionHeader.svelte";
import ColumnDefinitionHeader from "./ColumnDefinitionHeader.svelte"
import Markdown from "../../../../common/svelte/Markdown.svelte";
import {derivedColumnHelpText} from "./column-definition-utils";
export let column;
export let onCancel = () => console.log("Close");
export let onRemove = () => console.log("Remove");
let working = {
id: column.id,
displayName: column.displayName,
Expand All @@ -20,18 +23,6 @@
onCancel();
}
$: {
if (column && column.id !== working.id) {
working = {
id: column.id,
displayName: column.displayName,
externalId: column.externalId,
derivationScript: column.derivationScript
}
}
}
function updateDisplayName(workingDisplayName, column) {
const originalColumn = _.find($selectedGrid.definition.derivedColumnDefinitions, d => sameColumnRef(d, column));
const newColumn = Object.assign(
Expand Down Expand Up @@ -71,6 +62,17 @@
$columnDefs = _.concat(columnsWithoutCol, newColumn);
}
$: {
if (column && column.id !== working.id) {
working = {
id: column.id,
displayName: column.displayName,
externalId: column.externalId,
derivationScript: column.derivationScript
}
}
}
</script>
<h4>
Expand Down Expand Up @@ -125,6 +127,8 @@
on:change={() => updateDerivationScript(working.derivationScript, column)}
placeholder="Enter script here"
bind:value={working.derivationScript}/>
<br>
<Markdown text={derivedColumnHelpText}/>
</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@
}
function determineColumnName(column) {
if (column.displayName) {
return column.displayName;
} else {
return mkColumnName(column);
}
const name = column.displayName
? column.displayName
: mkColumnName(column);
return column.externalId
? `${name} (${column.externalId})`
: name;
}
</script>
Expand All @@ -85,7 +87,7 @@
</colgroup>
<thead>
<tr>
<th>Entity</th>
<th>Column (external id)</th>
<th colspan="4">Position</th>
<th colspan="2">Actions</th>
</tr>
Expand Down Expand Up @@ -124,24 +126,24 @@
</span>
</td>
<td>
<span style="text-align: center">
<button class="btn btn-skinny waltz-visibility-child-50"
title="move down"
disabled={column.position === _.maxBy($columnDefs, d => d.position)?.position}
on:click={() => moveDown(column)}>
<Icon name="arrow-down"/>
</button>
</span>
<span style="text-align: center">
<button class="btn btn-skinny waltz-visibility-child-50"
title="move down"
disabled={column.position === _.maxBy($columnDefs, d => d.position)?.position}
on:click={() => moveDown(column)}>
<Icon name="arrow-down"/>
</button>
</span>
</td>
<td>
<span style="text-align: center">
<button class="btn btn-skinny waltz-visibility-child-50"
title="move to bottom"
disabled={column.position === _.maxBy($columnDefs, d => d.position)?.position}
on:click={() => moveToBottom(column)}>
<Icon name="step-forward" rotate="90"/>
</button>
</span>
<span style="text-align: center">
<button class="btn btn-skinny waltz-visibility-child-50"
title="move to bottom"
disabled={column.position === _.maxBy($columnDefs, d => d.position)?.position}
on:click={() => moveToBottom(column)}>
<Icon name="step-forward" rotate="90"/>
</button>
</span>
</td>
<td>
<button class="btn btn-skinny waltz-visibility-child-50"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

export const derivedColumnHelpText = `
* \`< <= > >= == != && || ! \`: logical operators
* \`anyCellsProvided(cellExtId, ...) allCellsProvided(...) ratioProvided(....) percentageProvided(....)\`: cell checks
* \`mkResult(value, <optionText>, <optionCode>)\`: makes a result cell
* Example:
* \`allCellsProvided('CRITICALITY', 'INVEST')
? mkResult("y")
: mkResult("n");\`
See the <a href="https://commons.apache.org/proper/commons-jexl/reference/syntax.html" target="_blank">JEXL documentation</a> for more information.
`;
2 changes: 2 additions & 0 deletions waltz-ng/client/survey/survey-template-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ See the documentation for a complete list of functions and their arguments. Bel
* \`hasInvolvement(roleName)\`: returns whether the subject entity has any involvement record with the given role name
* \`hasLifecyclePhase(lifecyclePhase)\`: returns true of the given lifecycle phase matches the entities lifecycles phase. (PRODUCTION, DEVELOPMENT, CONCEPTUAL, RETIRED)
* \`isAppKind(applicationKind)\`: returns true of the given app kind phase matches the application kind. ( IN&#95;HOUSE, INTERNALLY&#95;HOSTED, EXTERNALLY&#95;HOSTED, EUC, THIRD&#95;PARTY, CUSTOMISED, EXTERNAL)
See the <a href="https://commons.apache.org/proper/commons-jexl/reference/syntax.html" target="_blank">JEXL documentation</a>.
`;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public Map<String, Object> getContext() {
public boolean anyCellsProvided(String... cellExtIds) {
checkAllCellsExist(cellExtIds);

return Stream.of(cellExtIds)
return Stream
.of(cellExtIds)
.map(ctx::get)
.filter(Objects::nonNull)
.filter(d -> d instanceof CellVariable)
Expand All @@ -65,7 +66,8 @@ public boolean anyCellsProvided(String... cellExtIds) {
public boolean allCellsProvided(String... cellExtIds) {
checkAllCellsExist(cellExtIds);

return Stream.of(cellExtIds)
return Stream
.of(cellExtIds)
.map(ctx::get)
.allMatch(c -> Objects.nonNull(c) && !hasErrors(c));
}
Expand All @@ -86,7 +88,8 @@ private BigDecimal calcRatio(String[] cellExtIds) {

checkAllCellsExist(cellExtIds);

long foundColumns = Stream.of(cellExtIds)
long foundColumns = Stream
.of(cellExtIds)
.map(ctx::get)
.filter(c -> Objects.nonNull(c) && !hasErrors(c))
.count();
Expand Down

0 comments on commit 3b05c17

Please sign in to comment.