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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Resizer fixes: set default min-width and avoid text selection while user is dragging. Resizer improvements: show the resizer in red color when the min-width has been reached.
Aleix Suau7be5bca339cc
diff --git a/frontend/src/app/components/resizer/wp-resizer.component.ts b/frontend/src/app/components/resizer/wp-resizer.component.tsindex ef837329a1e..70ad73a814d 100644--- a/frontend/src/app/components/resizer/wp-resizer.component.ts+++ b/frontend/src/app/components/resizer/wp-resizer.component.ts@@ -26,7 +26,7 @@// See docs/COPYRIGHT.rdoc for more details.//++-import {AfterViewInit, Component, ElementRef, Input, OnInit} from '@angular/core';+import {AfterViewInit, Component, ElementRef, Input, OnInit, NgZone, ChangeDetectorRef} from '@angular/core';import {debounceTime, distinctUntilChanged} from 'rxjs/operators';import {TransitionService} from '@uirouter/core';import {MainMenuToggleService} from "core-components/main-menu/main-menu-toggle.service";@@ -39,7 +39,7 @@ import {fromEvent} from "rxjs";selector: 'wp-resizer',template: `<resizer [customHandler]="false"- resizerClass="work-packages--resizer icon-resizer-vertical-lines"+ [resizerClass]="resizerClass"cursorClass="col-resize"(end)="resizeEnd()"(start)="resizeStart()"@@ -57,13 +57,19 @@ export class WpResizerDirective extends UntilDestroyedMixin implements OnInit, Aprivate resizingElement:HTMLElement;private elementWidth:number;private element:HTMLElement;+ private resizer:HTMLElement;+ // Min-width this element is allowed to have+ private elementMinWidth = 530;public moving:boolean = false;+ public resizerClass = 'work-packages--resizer icon-resizer-vertical-lines';constructor(readonly toggleService:MainMenuToggleService,private elementRef:ElementRef,readonly $transitions:TransitionService,- readonly browserDetector:BrowserDetector) {+ readonly browserDetector:BrowserDetector,+ private ngZone:NgZone,+ private changeDetectorRef:ChangeDetectorRef) {super();}@@ -73,13 +79,17 @@ export class WpResizerDirective extends UntilDestroyedMixin implements OnInit, A// Get initial width from local storage and applylet localStorageValue = this.parseLocalStorageValue();- this.elementWidth = localStorageValue || this.resizingElement.offsetWidth;+ this.elementWidth = localStorageValue ||+ (this.resizingElement.offsetWidth < this.elementMinWidth ?+ this.elementMinWidth :+ this.resizingElement.offsetWidth);// This case only happens when the timeline is loaded but not displayed.// Therefor the flexbasis will be set to 50%, just in pxif (this.elementWidth === 0 && this.resizingElement.parentElement) {this.elementWidth = this.resizingElement.parentElement.offsetWidth / 2;}+this.resizingElement.style[this.resizeStyle] = this.elementWidth + 'px';// Add event listener@@ -105,6 +115,9 @@ export class WpResizerDirective extends UntilDestroyedMixin implements OnInit, A}ngAfterViewInit():void {+ // Get the reziser+ this.resizer = <HTMLElement>this.elementRef.nativeElement.getElementsByClassName(this.resizerClass)[0];+this.applyColumnLayout(this.resizingElement, this.elementWidth);}@@ -136,10 +149,32 @@ export class WpResizerDirective extends UntilDestroyedMixin implements OnInit, A}resizeMove(deltas:ResizeDelta) {+ // Avoid text-selection while the user is dragging the resizer+ deltas.origin.preventDefault();+// Get new value depending on the delta- // The resizingElement is not allowed to be smaller than 530pxthis.elementWidth = this.elementWidth - deltas.relative.x;- let newValue = this.elementWidth < 530 ? 530 : this.elementWidth;+ let newValue;++ // The resizingElement is not allowed to be smaller than the elementMinWidth+ if (this.elementWidth < this.elementMinWidth) {+ newValue = this.elementMinWidth;++ // Show the resizer red when it reaches its limit (min-width)+ if (this.resizer.style.color !== 'red') {+ this.resizer.style.color = 'red';++ // Avoid triggering change detection for all the app+ this.ngZone.runOutsideAngular(() => {+ setTimeout(() => {+ this.resizer.style.color = '';+ this.changeDetectorRef.detectChanges();+ }, 500);+ });+ }+ } else {+ newValue = this.elementWidth;+ }// Store item in local storagewindow.OpenProject.guardedLocalStorage(this.localStorageKey, `${newValue}`);@@ -151,7 +186,6 @@ export class WpResizerDirective extends UntilDestroyedMixin implements OnInit, Athis.resizingElement.style[this.resizeStyle] = newValue + 'px';}-private parseLocalStorageValue():number|undefined {let localStorageValue = window.OpenProject.guardedLocalStorage(this.localStorageKey);let number = parseInt(localStorageValue || '', 10);