diff --git a/waltz-data/src/main/java/org/finos/waltz/data/rating_scheme/RatingSchemeDAO.java b/waltz-data/src/main/java/org/finos/waltz/data/rating_scheme/RatingSchemeDAO.java index 191d1e1ba1..29745027ea 100644 --- a/waltz-data/src/main/java/org/finos/waltz/data/rating_scheme/RatingSchemeDAO.java +++ b/waltz-data/src/main/java/org/finos/waltz/data/rating_scheme/RatingSchemeDAO.java @@ -71,7 +71,8 @@ public class RatingSchemeDAO { RatingSchemeItemRecord r = record.into(RATING_SCHEME_ITEM); - ImmutableRatingSchemeItem.Builder builder = ImmutableRatingSchemeItem.builder() + ImmutableRatingSchemeItem.Builder builder = ImmutableRatingSchemeItem + .builder() .id(r.getId()) .ratingSchemeId(r.getSchemeId()) .name(r.getName()) @@ -81,7 +82,8 @@ public class RatingSchemeDAO { .position(r.getPosition()) .description(r.getDescription()) .externalId(ofNullable(r.getExternalId())) - .ratingGroup(r.getRatingGroup()); + .ratingGroup(r.getRatingGroup()) + .requiresComment(r.getRequiresComment()); if (record.field(IS_RESTRICTED_FIELD) != null){ @@ -245,6 +247,7 @@ public Long saveRatingItem(long schemeId, r.setPosition(item.position()); r.setUserSelectable(item.userSelectable()); r.setRatingGroup(item.ratingGroup()); + r.setRequiresComment(item.requiresComment()); item.externalId().ifPresent(r::setExternalId); diff --git a/waltz-model/src/main/java/org/finos/waltz/model/rating/RatingSchemeItem.java b/waltz-model/src/main/java/org/finos/waltz/model/rating/RatingSchemeItem.java index 197d1ec43d..8cfcb81aa6 100644 --- a/waltz-model/src/main/java/org/finos/waltz/model/rating/RatingSchemeItem.java +++ b/waltz-model/src/main/java/org/finos/waltz/model/rating/RatingSchemeItem.java @@ -51,4 +51,9 @@ public boolean userSelectable() { @Nullable public abstract String ratingGroup(); + @Value.Default + public boolean requiresComment() { + return false; + } + } diff --git a/waltz-ng/client/assessments/components/rating-editor/RatingAddView.svelte b/waltz-ng/client/assessments/components/rating-editor/RatingAddView.svelte index 58260b5a29..e1ec5c6495 100644 --- a/waltz-ng/client/assessments/components/rating-editor/RatingAddView.svelte +++ b/waltz-ng/client/assessments/components/rating-editor/RatingAddView.svelte @@ -1,15 +1,11 @@

Add New Rating:

@@ -83,27 +83,48 @@ {/each} {/if} +
+ {#if selectedRating} + + {:else} + Please select a rating + {/if} +
+ {#if selectedRating?.requiresComment} +
+ A comment is mandatory for this rating +
+ {/if}
+ + + + + - - + \ No newline at end of file diff --git a/waltz-ng/client/assessments/components/rating-editor/RatingDetailView.svelte b/waltz-ng/client/assessments/components/rating-editor/RatingDetailView.svelte index 8c2361b705..cf14687c93 100644 --- a/waltz-ng/client/assessments/components/rating-editor/RatingDetailView.svelte +++ b/waltz-ng/client/assessments/components/rating-editor/RatingDetailView.svelte @@ -19,6 +19,7 @@ import {displayError} from "../../../common/error-utils"; import {cardinality} from "../../../common/services/enums/cardinality"; import EditableRatingValue from "./EditableRatingValue.svelte"; + import Markdown from "../../../common/svelte/Markdown.svelte"; export let onCancel; export let onRemove; @@ -134,6 +135,9 @@ showGroup={true} disablementReason={ratingDisablementReason} onSave={saveRating}/> +
+ +
@@ -142,6 +146,7 @@
diff --git a/waltz-ng/client/common/svelte/TextEditableField.svelte b/waltz-ng/client/common/svelte/TextEditableField.svelte index 9872e5bd43..61c4f0f93f 100644 --- a/waltz-ng/client/common/svelte/TextEditableField.svelte +++ b/waltz-ng/client/common/svelte/TextEditableField.svelte @@ -10,6 +10,7 @@ export let onSave = (text) => console.log("Text to save", {text}); export let editable; export let label; + export let mandatory = false; let workingText; let savePromise @@ -37,52 +38,64 @@ savePromise .then(() => activeMode = Modes.VIEW); } - - -{#if activeMode === Modes.VIEW} - {#if !_.isEmpty(label)} - - {#if editable} - + {/if} + {/if} +
+ +
+ {#if mandatory} +
+ A comment is mandatory +
+ {/if} + {#if _.isEmpty(label) && editable} + {/if} - {/if} -
- -
- {#if _.isEmpty(label) && editable} + {:else if activeMode === Modes.EDIT} + {#if !_.isEmpty(label)} + + {/if} + + {#if mandatory} +
+ A comment is mandatory +
+ {/if} + + {:else if activeMode === Modes.SAVING} + {/if} -{:else if activeMode === Modes.EDIT} - {#if !_.isEmpty(label)} - - {/if} -