Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fix: make all attribute groups except for wps single column (#13338)

Yuleb832fb80bbf5
diff --git a/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.sass b/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.sass
index 17fd975cea8..6be5d8599dd 100644
--- a/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.sass
+++ b/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.component.sass
@@ -1,8 +1,69 @@
@import "src/assets/sass/helpers"
+// The attribute groups for work packages are a bit different thant on other pages:
+//
+// In summary, we get the following:
+//
+// Parent < 800px: 1 Column view where only the long text fields have labels on top
+// Parent > 800px: 2 Column view where all fields have left-right labels, and long text fields span both columns
+//
+// More specifically:
+//
+// Requirements for the attribute sections in the WP view
+// * Number of columns: min 1, max 2.
+// * Min-width: 400px, max-width: not wider than the parent.
+// * When two-columns are shown, each column has 50% width of the parent.
+// * We cannot use breakpoints, since the width of the parent can be changed
+// dynamically by sliding the sidemenu or split view.
+// * Some attributes span 2 columns, like long text fields.
+// * Labels should be left-right, except for long text fields when the layout
+// is in single-column mode.
+// * Labels should be a fixed 140px wide, all having the same width
.wp-attribute-group
+ display: flex
+ flex-direction: row
+ flex-wrap: wrap
+
+ // We want a margin between items, but not between items and the parent box.
+ //
+ // We don't know if any one item is on the right,
+ // the left, or spanning both columns. The easy way to get a gutter is to give
+ // *all* elements margins on both sides, and then negating this margin on the parent.
+ // This also explains all of the + and - xrem calc() values below.
+ margin: 0 -1 * $spot-spacing-1_5
+ width: calc(100% + #{$spot-spacing-3})
+
&--attribute
+ flex-basis: 400px
+ flex-grow: 1
+ flex-shrink: 1
+ min-width: calc(50% - 3rem)
+ max-width: calc(100% - 3rem)
+ margin: 0 1.5rem
+
&_span-all
flex-basis: calc(100% - #{$spot-spacing-3})
flex-shrink: 0
flex-wrap: wrap
+
+ &-key
+ flex-basis: 140px
+
+ @media screen and (min-width: $breakpoint-md)
+ // The reason we add this is because the base `attributes-key-value--key` class will override this at this
+ // breakpoint, since it will always stay single column. However, for work package attributes we go double column
+ // and thus want the labels to stay smaller
+ flex-basis: 140px
+
+ &-value-container
+ flex-basis: 260px
+
+ &_span-all &-value-container
+ flex-shrink: 0
+ // This is a magic number that was obtained by trial and error
+ // The goal is to have span-all containers move to label-on-top
+ // right as the layout goes from 2-column to 1-column.
+ // There problably is some calculation by which you can derive this,
+ // but I'm currently too lazy to figure it out
+ flex-basis: 708px
+ max-width: 100%
diff --git a/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.template.html b/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.template.html
index 946b529d7cd..22dbea0e0d5 100644
--- a/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.template.html
+++ b/frontend/src/app/features/work-packages/components/wp-form-group/wp-attribute-group.template.html
@@ -5,7 +5,7 @@
>
<ng-template [ngIf]="!shouldHideField(descriptor)">
<div
- class="attributes-key-value--key"
+ class="wp-attribute-group--attribute-key attributes-key-value--key"
*ngIf="!descriptor.multiple && descriptor.field"
>
<wp-replacement-label [fieldName]="descriptor.name">
@@ -19,7 +19,7 @@
</div>
<div
*ngIf="!descriptor.multiple && descriptor.field"
- class="attributes-key-value--value-container"
+ class="wp-attribute-group--attribute-value-container attributes-key-value--value-container"
>
<op-editable-attribute-field
[ngClass]="{'wp-edit-formattable-field': descriptor.field!.isFormattable }"
diff --git a/frontend/src/global_styles/content/_attributes_group.sass b/frontend/src/global_styles/content/_attributes_group.sass
index 325b5f7dc22..c984957424d 100644
--- a/frontend/src/global_styles/content/_attributes_group.sass
+++ b/frontend/src/global_styles/content/_attributes_group.sass
@@ -80,13 +80,4 @@
.attributes-group--attributes
display: flex
- flex-direction: row
- flex-wrap: wrap
-
- // We want a margin between items, but don't know if any one item is on the right,
- // the left, or spanning both columns. The easy way to get a gutter is to give
- // *all* elements margins on both sides, and then negating this margin on the parent.
- // This also explains all of the + and - xrem calc() values below.
- margin: 0 -1 * $spot-spacing-1_5
- width: calc(100% + #{$spot-spacing-3})
-
+ flex-direction: column
diff --git a/frontend/src/global_styles/content/_attributes_key_value.sass b/frontend/src/global_styles/content/_attributes_key_value.sass
index a414435c420..510e1acbb02 100644
--- a/frontend/src/global_styles/content/_attributes_key_value.sass
+++ b/frontend/src/global_styles/content/_attributes_key_value.sass
@@ -31,14 +31,7 @@
// flex-wrap: wrap
font-size: 0.875rem
margin-bottom: 0.1875rem
- flex-basis: 400px
- flex-grow: 1
- flex-shrink: 1
- min-width: calc(50% - 3rem)
- max-width: calc(100% - 3rem)
- margin: 0 1.5rem
line-height: 1.5em
- gap: 10px
&--key
@extend .form--label
@@ -50,6 +43,12 @@
overflow-wrap: break-word
hyphens: auto
+ @media screen and (min-width: $breakpoint-md)
+ flex-basis: 200px
+
+ @media screen and (min-width: $breakpoint-lg)
+ flex-basis: 240px
+
> wp-replacement-label
padding-right: $spot-spacing-0_5
flex: 1 1 auto
@@ -79,16 +78,6 @@
@include grid-visible-overflow
word-wrap: anywhere
- @at-root &.wp-attribute-group--attribute_span-all &--value-container
- flex-shrink: 0
- // This is a magic number that was obtained by trial and error
- // The goal is to have span-all containers move to label-on-top
- // right as the layout goes from 2-column to 1-column.
- // There problably is some calculation by which you can derive this,
- // but I'm currently too lazy to figure it out
- flex-basis: 708px
- max-width: 100%
-
// Alternative implementation to the one above.
// It's main advantage is that it can act on the whole of the key/value-pairs.
// It can e.g. determine the width of the widest label and by that align all key value pairs equally.