From 149462e3abb9f6d85217ed689ca22e255711889a Mon Sep 17 00:00:00 2001 From: Zack Rauen Date: Fri, 22 Sep 2023 04:58:06 -0400 Subject: [PATCH] Add option for promoted alias --- .../promoted_attribute_definition_parser.js | 5 ++++ .../attribute_widgets/attribute_detail.js | 23 +++++++++++++++++++ .../ribbon_widgets/promoted_attributes.js | 3 ++- .../promoted_attribute_definition_parser.js | 5 ++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/public/app/services/promoted_attribute_definition_parser.js b/src/public/app/services/promoted_attribute_definition_parser.js index 423164fc1..81d097c42 100644 --- a/src/public/app/services/promoted_attribute_definition_parser.js +++ b/src/public/app/services/promoted_attribute_definition_parser.js @@ -17,6 +17,11 @@ function parse(value) { defObj.numberPrecision = parseInt(chunks[1]); } + else if (token.startsWith('alias')) { + const chunks = token.split('='); + + defObj.promotedAlias = chunks[1]; + } else if (token.startsWith('inverse')) { const chunks = token.split('='); diff --git a/src/public/app/widgets/attribute_widgets/attribute_detail.js b/src/public/app/widgets/attribute_widgets/attribute_detail.js index 7ddfe2882..715d3f093 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_widgets/attribute_detail.js @@ -98,6 +98,14 @@ const TPL = ` Promoted: + + Alias: + +
+ +
+ + Multiplicity: @@ -323,6 +331,10 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget { this.$inputPromoted = this.$widget.find('.attr-input-promoted'); this.$inputPromoted.on('change', () => this.userEditedAttribute()); + this.$rowPromotedAlias = this.$widget.find('.attr-row-promoted-alias'); + this.$inputPromotedAlias = this.$widget.find('.attr-input-promoted-alias'); + this.$inputPromotedAlias.on('change', () => this.userEditedAttribute()); + this.$rowMultiplicity = this.$widget.find('.attr-row-multiplicity'); this.$inputMultiplicity = this.$widget.find('.attr-input-multiplicity'); this.$inputMultiplicity.on('change', () => this.userEditedAttribute()); @@ -453,6 +465,11 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget { .prop("checked", !!definition.isPromoted) .attr('disabled', () => !isOwned); + this.$rowPromotedAlias.toggle(!!definition.isPromoted); + this.$inputPromotedAlias + .val(definition.promotedAlias) + .attr('disabled', () => !isOwned); + this.$rowMultiplicity.toggle(['label-definition', 'relation-definition'].includes(this.attrType)); this.$inputMultiplicity .val(definition.multiplicity) @@ -673,6 +690,10 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget { if (this.$inputPromoted.is(":checked")) { props.push("promoted"); + + if (this.$inputPromotedAlias.val() !== '') { + props.push(`alias=${this.$inputPromotedAlias.val()}`); + } } props.push(this.$inputMultiplicity.val()); @@ -693,6 +714,8 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget { this.attrType === 'label-definition' && this.$inputLabelType.val() === 'number'); + this.$rowPromotedAlias.toggle(this.$inputPromoted.is(":checked")); + return props.join(","); } diff --git a/src/public/app/widgets/ribbon_widgets/promoted_attributes.js b/src/public/app/widgets/ribbon_widgets/promoted_attributes.js index 2af449815..6ab75d0b1 100644 --- a/src/public/app/widgets/ribbon_widgets/promoted_attributes.js +++ b/src/public/app/widgets/ribbon_widgets/promoted_attributes.js @@ -32,6 +32,7 @@ const TPL = ` } .promoted-attribute-cell strong { word-break:keep-all; + white-space: nowrap; } @@ -137,7 +138,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget { .attr("nowrap", true); const $wrapper = $('