Merge pull request #4839 from tsiegleauq/motion-detail-jumping-prevention

Prevent motion-detail jumps
This commit is contained in:
Emanuel Schütze 2019-07-10 23:10:11 +02:00 committed by GitHub
commit 3fe18bad7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 53 deletions

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Input, Output, EventEmitter, OnDestroy, AfterViewInit } from '@angular/core'; import { Component, OnInit, Input, Output, EventEmitter, OnDestroy } from '@angular/core';
import { BehaviorSubject, Subscription } from 'rxjs'; import { BehaviorSubject, Subscription } from 'rxjs';
import { FormGroup, FormBuilder } from '@angular/forms'; import { FormGroup, FormBuilder } from '@angular/forms';
import { Router, NavigationEnd } from '@angular/router'; import { Router, NavigationEnd } from '@angular/router';
@ -8,7 +8,7 @@ import { Router, NavigationEnd } from '@angular/router';
templateUrl: './extension-field.component.html', templateUrl: './extension-field.component.html',
styleUrls: ['./extension-field.component.scss'] styleUrls: ['./extension-field.component.scss']
}) })
export class ExtensionFieldComponent implements OnInit, OnDestroy, AfterViewInit { export class ExtensionFieldComponent implements OnInit, OnDestroy {
/** /**
* Optional additional classes for the `mat-chip`. * Optional additional classes for the `mat-chip`.
*/ */
@ -27,33 +27,11 @@ export class ExtensionFieldComponent implements OnInit, OnDestroy, AfterViewInit
@Input() @Input()
public chipValue: string; public chipValue: string;
/**
* Allow automatically jump into autoEdit
*/
private allowAutoEdit = false;
/** /**
* Boolean, whether the extension should be shown. * Boolean, whether the extension should be shown.
*/ */
private _hasExtension = false; @Input()
public hasExtension = false;
/**
* Setter for the extension condition
*/
@Input() public set hasExtension(extension: boolean) {
this._hasExtension = extension;
if (this.hasExtension && this.allowAutoEdit) {
this.editMode = true;
}
}
/**
* Getter for the extension condition
*/
public get hasExtension(): boolean {
return this._hasExtension;
}
/** /**
* Optional label for the input. * Optional label for the input.
@ -193,13 +171,6 @@ export class ExtensionFieldComponent implements OnInit, OnDestroy, AfterViewInit
} }
} }
/**
* After view inits, allow to automatically open the edit view
*/
public ngAfterViewInit(): void {
this.allowAutoEdit = true;
}
/** /**
* On destroy unsubscribe from the subscriptions * On destroy unsubscribe from the subscriptions
*/ */

View File

@ -19,9 +19,6 @@
</div> </div>
<div class="section-three"> <div class="section-three">
<!-- Extra controls slot using implicit template references --> <!-- Extra controls slot using implicit template references -->
<mat-basic-chip class="bluegrey" disableRipple matTooltip="{{ 'Sequential number' | translate }}">
{{ item.id }}
</mat-basic-chip>
<ng-template [ngTemplateOutlet]="templateRef" [ngTemplateOutletContext]="{ $implicit: item }"></ng-template> <ng-template [ngTemplateOutlet]="templateRef" [ngTemplateOutletContext]="{ $implicit: item }"></ng-template>
</div> </div>
<div class="line" *cdkDragPreview> <div class="line" *cdkDragPreview>

View File

@ -1,8 +1,4 @@
<os-head-bar <os-head-bar [editMode]="hasChanged" (saveEvent)="sendUpdate()" (mainEvent)="onCancel()" [nav]="false">
[editMode]="hasChanged"
(saveEvent)="sendUpdate()"
(mainEvent)="onCancel()"
[nav]="false">
<!-- Title --> <!-- Title -->
<div class="title-slot"> <div class="title-slot">
<h2 *ngIf="category">{{ 'Sort motions' | translate }} ({{ category.prefixedName }})</h2> <h2 *ngIf="category">{{ 'Sort motions' | translate }} ({{ category.prefixedName }})</h2>
@ -13,12 +9,13 @@
<div *ngIf="isMultiSelect"> <div *ngIf="isMultiSelect">
<span>{{ sortSelector.multiSelectedIndex.length }}&nbsp;</span> <span>{{ sortSelector.multiSelectedIndex.length }}&nbsp;</span>
<span translate>selected</span> <span translate>selected</span>
<button mat-button (click)="moveToPosition()"><span translate>move ...</span> <button mat-button (click)="moveToPosition()"><span translate>move ...</span></button>
</button>
</div> </div>
<os-sorting-list <os-sorting-list (sortEvent)="onListUpdate($event)" [input]="motionObservable" #sorter>
(sortEvent)="onListUpdate($event)" <ng-template let-motion>
[input]="motionObservable" <mat-basic-chip class="bluegrey" disableRipple matTooltip="{{ 'Sequential number' | translate }}">
#sorter {{ motion.id }}
></os-sorting-list> </mat-basic-chip>
</ng-template>
</os-sorting-list>
</mat-card> </mat-card>

View File

@ -1,4 +1,3 @@
<div (window:keydown)="onKeyNavigation($event)"></div>
<os-head-bar <os-head-bar
[mainButton]="perms.isAllowed('update', motion)" [mainButton]="perms.isAllowed('update', motion)"
mainButtonIcon="edit" mainButtonIcon="edit"

View File

@ -746,15 +746,15 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
} }
/** /**
* Using Meta, Alt + the arrow keys will navigate between the motions * Using Shift, Alt + the arrow keys will navigate between the motions
* *
* @param event has the key code * @param event has the key code
*/ */
public onKeyNavigation(event: KeyboardEvent): void { @HostListener('document:keydown', ['$event']) public onKeyNavigation(event: KeyboardEvent): void {
if (event.key === 'ArrowLeft' && event.altKey && event.metaKey) { if (event.key === 'ArrowLeft' && event.altKey && event.shiftKey) {
this.navigateToMotion(this.previousMotion); this.navigateToMotion(this.previousMotion);
} }
if (event.key === 'ArrowRight' && event.altKey && event.metaKey) { if (event.key === 'ArrowRight' && event.altKey && event.shiftKey) {
this.navigateToMotion(this.nextMotion); this.navigateToMotion(this.nextMotion);
} }
} }