From aa2feb8447848caedf4eced5b1e0d9b0c5ddfc41 Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Wed, 6 Nov 2024 13:39:37 -0700 Subject: [PATCH] Fix widgets and applied styles --- .../src/components/Graph.vue | 2 +- .../components/widgets/LimitsbarWidget.vue | 1 + .../components/widgets/LimitscolumnWidget.vue | 1 + .../src/components/widgets/RangebarWidget.vue | 1 + .../components/widgets/ScrollwindowWidget.vue | 42 ++++++++--- .../src/components/widgets/SpacerWidget.vue | 4 +- .../widgets/ValuelimitsbarWidget.vue | 2 +- .../src/components/widgets/Widget.js | 74 +++++-------------- 8 files changed, 56 insertions(+), 71 deletions(-) diff --git a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/Graph.vue b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/Graph.vue index 61390dd78..cb2019e11 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/Graph.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/Graph.vue @@ -302,7 +302,7 @@ -
+
diff --git a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/SpacerWidget.vue b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/SpacerWidget.vue index 6410b0d6d..8b80d1270 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/SpacerWidget.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/SpacerWidget.vue @@ -27,8 +27,8 @@ export default { mixins: [Widget], created() { // Populate the applied settings as if they were in the screen definition - this.appliedSettings.push(['WIDTH', this.parameters[0]]) - this.appliedSettings.push(['HEIGHT', this.parameters[1]]) + this.settings.push(['WIDTH', this.parameters[0]]) + this.settings.push(['HEIGHT', this.parameters[1]]) }, } diff --git a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/ValuelimitsbarWidget.vue b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/ValuelimitsbarWidget.vue index c9b13cf0f..a711be9b9 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/ValuelimitsbarWidget.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/ValuelimitsbarWidget.vue @@ -32,7 +32,7 @@ /> { - const index = parseInt(setting[0]) - if (this.widgetIndex !== null) { - if (this.widgetIndex === index) { - setting = setting.slice(1) - } else { - return - } - } this.applyStyleSetting(setting) }) - const compStyle = { ...this.appliedStyle } // If nothing has yet defined a width then we add flex to the style - if (compStyle['width'] === undefined) { + if (this.appliedStyle['width'] === undefined) { // This flex allows for alignment in our widgets // The value of '0 10 100%' was achieved through trial and error // The larger flex-shrink value was critical for success - compStyle['flex'] = '0 10 100%' // flex-grow, flex-shrink, flex-basis + this.appliedStyle['flex'] = '0 10 100%' // flex-grow, flex-shrink, flex-basis } - return compStyle + return this.appliedStyle }, screen: function () { // This exists for backwards compatibility of screen definitions since widgets no longer have a reference @@ -165,7 +159,7 @@ export default { return setting } // This is our setting so slice off the index and return - // this effectively promotes'the subsetting to a setting + // this effectively promotes the subsetting to a setting // on the current widget if (this.widgetIndex === index) { return setting.slice(1) @@ -269,34 +263,17 @@ export default { // Don't set the width if someone has already set it // This is important in PacketViewer which uses the value-widget // and passes an explicit width setting to use - let foundSetting = null - if (this.widgetIndex !== null) { - foundSetting = this.appliedSettings.find( - (setting) => - parseInt(setting[0]) === this.widgetIndex && setting[1] === 'WIDTH', - ) - } else { - foundSetting = this.appliedSettings.find( - (setting) => setting[0] === 'WIDTH', - ) - } + let foundSetting = this.appliedSettings.find( + (setting) => setting[0] === 'WIDTH', + ) if (foundSetting) { return foundSetting['WIDTH'] } else { if (width) { - let setting = ['WIDTH', `${width}${units}`] - // If we have a widgetIndex apply that so we apply the width to ourselves - if (this.widgetIndex !== null) { - setting.unshift(this.widgetIndex) - } - this.appliedSettings.push(setting) + this.appliedSettings.push(['WIDTH', `${width}${units}`]) return parseInt(width) } else { - let setting = ['WIDTH', `${defaultWidth}${units}`] - if (this.widgetIndex !== null) { - setting.unshift(this.widgetIndex) - } - this.appliedSettings.push(setting) + this.appliedSettings.push(['WIDTH', `${defaultWidth}${units}`]) return parseInt(defaultWidth) } } @@ -304,34 +281,17 @@ export default { setHeight(height, units = 'px', defaultHeight = '20') { // Don't set the height if someone has already set it let foundSetting = null - if (this.widgetIndex !== null) { - foundSetting = this.appliedSettings.find( - (setting) => - parseInt(setting[0]) === this.widgetIndex && - setting[1] === 'HEIGHT', - ) - } else { - foundSetting = this.appliedSettings.find( - (setting) => setting[0] === 'HEIGHT', - ) - } + foundSetting = this.appliedSettings.find( + (setting) => setting[0] === 'HEIGHT', + ) if (foundSetting) { return foundSetting['HEIGHT'] } else { if (height) { - let setting = ['HEIGHT', `${height}${units}`] - // If we have a widgetIndex apply that so we apply the height to ourselves - if (this.widgetIndex !== null) { - setting.unshift(this.widgetIndex) - } - this.appliedSettings.push(setting) + this.appliedSettings.push(['HEIGHT', `${height}${units}`]) return parseInt(height) } else { - let setting = ['HEIGHT', `${defaultHeight}${units}`] - if (this.widgetIndex !== null) { - setting.unshift(this.widgetIndex) - } - this.appliedSettings.push(setting) + this.appliedSettings.push(['HEIGHT', `${defaultHeight}${units}`]) return parseInt(defaultHeight) } }