-
Notifications
You must be signed in to change notification settings - Fork 27
Pinned rows navigation - draft #591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
1b0bd8f
fcd76b2
57964ec
115e405
fee7f2c
2acb7cd
ddc0190
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,30 +10,44 @@ export class SelectorMark { | |
| select() { | ||
| const result = []; | ||
| const addNext = this.addFactory(result); | ||
|
|
||
| addNext('left'); | ||
| addNext('mid'); | ||
| addNext('right'); | ||
|
|
||
| if (this.name == 'body') { | ||
| addNext('left','top'); | ||
| addNext('mid','top'); | ||
| addNext('right','top'); | ||
| addNext('left','mid'); | ||
| addNext('mid','mid'); | ||
|
||
| addNext('right','mid'); | ||
| addNext('left','bottom'); | ||
| addNext('mid','bottom'); | ||
| addNext('right','bottom'); | ||
| } | ||
| else { | ||
| addNext('left', null); | ||
gwhrus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| addNext('mid', null); | ||
| addNext('right', null); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| addFactory(result) { | ||
| const { model } = this; | ||
| const { rows } = model.scene(); | ||
| const columnArea = model.scene().column.area; | ||
|
|
||
| return pin => { | ||
| const name = pin ? `${this.name}-${pin}` : this.name; | ||
| return (pinLR, pinTB) => { | ||
| const rows = pinTB == 'top' ? model.row().pinTop : pinTB == 'bottom' ? model.row().pinBottom : model.scene().rows; | ||
| const name = this.name + ((pinTB && pinTB !== 'mid') ? `-${pinTB}` : '') + (pinLR ? `-${pinLR}` : ''); | ||
| const element = this.markup[name]; | ||
| if (element) { | ||
| const prev = result[result.length - 1]; | ||
| const prev = result[result.length - 1] && result[result.length - 1].name === (this.name + ((pinTB == 'top' || pinTB == 'bottom') ? `-${pinTB}` : '')) ? | ||
| result[result.length - 1] : null; | ||
| const columnStart = prev ? prev.columnRange.end : 0; | ||
| const columnCount = columnArea[pin].length; | ||
| const rowStart = 0; | ||
| const columnCount = columnArea[pinLR].length; | ||
| const rowStart = pinTB === 'mid' ? model.row().pinTop.length : pinTB === 'bottom' ? | ||
| model.row().pinTop.length + model.scene().rows.length : 0; | ||
| const rowCount = rows.length; | ||
|
|
||
| result.push({ | ||
| name: this.name + ((pinTB == 'top' || pinTB == 'bottom') ? `-${pinTB}` : ''), | ||
| element, | ||
| columnRange: new Range(columnStart, columnStart + columnCount), | ||
| rowRange: new Range(rowStart, rowStart + rowCount) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,8 +44,9 @@ export class View extends Unit { | |
| } | ||
|
|
||
| isFocused() { | ||
| return this.getElementsCore('body') | ||
| .some(element => this.isFocusedCore(element)); | ||
| return this.getElementsCore('body').some(element => this.isFocusedCore(element)) || | ||
| this.getElementsCore('body-top').some(element => this.isFocusedCore(element)) || | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix formatting, add offset |
||
| this.getElementsCore('body-bottom').some(element => this.isFocusedCore(element)); | ||
| } | ||
|
|
||
| addLayer(name) { | ||
|
|
@@ -107,12 +108,12 @@ export class View extends Unit { | |
| bodyMid.scrollLeft = value; | ||
| } | ||
|
|
||
| const bodyTop = markup['body-top']; | ||
| const bodyTop = markup['body-top-mid']; | ||
| if (bodyTop) { | ||
| bodyTop.scrollLeft = value; | ||
| } | ||
|
|
||
| const bodyBottom = markup['body-bottom']; | ||
| const bodyBottom = markup['body-bottom-mid']; | ||
| if (bodyBottom) { | ||
| bodyBottom.scrollLeft = value; | ||
| } | ||
|
|
@@ -157,7 +158,16 @@ export class View extends Unit { | |
| break; | ||
| } | ||
| case 'top': { | ||
| return true; | ||
| target = target.element; | ||
| if (target) { | ||
| const { markup } = this.context; | ||
| const bodyLeft = markup['body-left']; | ||
| const bodyMid = markup['body-mid']; | ||
| const bodyRight = markup['body-right']; | ||
| return (bodyLeft && isParentOf(bodyLeft, target)) || | ||
| (bodyMid && isParentOf(bodyMid, target)) || | ||
| (bodyRight && isParentOf(bodyRight, target)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -206,15 +206,22 @@ export class ViewHost { | |
| } | ||
|
|
||
| const tr = this.findRow(e); | ||
| if (tr) { | ||
| const { index } = tr; | ||
| if (tr) { | ||
| const { index, pin } = tr; | ||
|
|
||
| if (highlight.row.canExecute(index)) { | ||
| let correctedIndex = index; | ||
| if (highlight.row.canExecute(correctedIndex)) { | ||
|
||
| rows | ||
| .filter(i => i !== index) | ||
| .forEach(i => highlight.row.execute(i, false)); | ||
|
|
||
| highlight.row.execute(index, true); | ||
| if (pin === 'body') { | ||
| correctedIndex += model.row().pinTop.length; | ||
| } | ||
| if (pin === 'bottom') { | ||
| correctedIndex += model.row().pinTop.length + model.scene().rows.length; | ||
| } | ||
| highlight.row.execute(correctedIndex, true); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -344,7 +351,7 @@ export class ViewHost { | |
| const { table } = this.plugin; | ||
| const pathFinder = new PathService(table.box.bag.body); | ||
| const path = eventPath(e); | ||
| return pathFinder.row(path); | ||
| return pathFinder.row(path); | ||
|
||
| } | ||
|
|
||
| clearHighlight() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
|
|
||
| <mat-menu #menu="matMenu" | ||
| class="q-grid-mat-menu"> | ||
| <mat-card *ngIf="trigger.menuOpen"> | ||
| <mat-card *ngIf="trigger.menuOpen" [q-grid-stop-propagate]="['keydown', 'keypress', 'keyup']"> | ||
|
||
| <mat-form-field> | ||
| <input id="q-grid-menu-input" | ||
| matInput | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,11 +38,12 @@ | |
| <tr *ngFor="let $row of $view.body.render.rows[pin]; index as $rowIndex; trackBy: rowId" | ||
| [q-grid-core-tr]="$row" | ||
| [q-grid-core-index]="$rowIndex" | ||
| q-grid-core-source="body"> | ||
| q-grid-core-source="body" | ||
| [q-grid-core-pin]="pin"> | ||
| <td *ngFor="let $column of $view.body.render.columns($row, $table.pin, $rowIndex); index as $columnIndex; trackBy: columnId" | ||
| [attr.rowspan]="$view.body.render.rowspan($row, $column, $rowIndex, $columnIndex)" | ||
| [attr.colspan]="$view.body.render.colspan($row, $column, $rowIndex, $columnIndex)"> | ||
| <ng-container [q-grid-core-td]="$column" | ||
| <ng-container [q-grid-core-td]="$column" [q-grid-core-pin]="pin" | ||
|
||
| [q-grid-core-label]="$view.body.render.getLabel($row, $column.model, $rowIndex, $columnIndex)" | ||
| [q-grid-core-value]="$view.body.render.getValue($row, $column.model, $rowIndex, $columnIndex)"> | ||
| </ng-container> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,9 +23,13 @@ export class TdCoreDirective implements DomTd, OnInit, OnDestroy, OnChanges { | |
|
|
||
| @Input('q-grid-core-td') columnView: ColumnView; | ||
|
|
||
| @Input('q-grid-core-pin') pin: string; | ||
|
|
||
| element: HTMLElement; | ||
| changes: SimpleChange; | ||
|
|
||
| model; | ||
|
|
||
| constructor( | ||
| public $view: GridLet, | ||
| private root: GridRoot, | ||
|
|
@@ -40,7 +44,10 @@ export class TdCoreDirective implements DomTd, OnInit, OnDestroy, OnChanges { | |
| } | ||
|
|
||
| ngOnInit() { | ||
| const { table } = this.root; | ||
| const { table, model } = this.root; | ||
|
|
||
| this.model = model; | ||
|
||
|
|
||
| table.box.bag.body.addCell(this); | ||
|
|
||
| this.cellClass.toBody(this.element, this.column); | ||
|
|
@@ -132,7 +139,14 @@ export class TdCoreDirective implements DomTd, OnInit, OnDestroy, OnChanges { | |
| } | ||
|
|
||
| get rowIndex() { | ||
| return this.tr.index; | ||
| let index = this.tr.index; | ||
| if (this.pin == 'body') { | ||
| index += this.model.row().pinTop.length; | ||
| } | ||
| if (this.pin == 'bottom') { | ||
| index += this.model.row().pinTop.length + this.model.scene().rows.length; | ||
|
||
| } | ||
| return index; | ||
| } | ||
|
|
||
| get dataRowIndex() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this and factory pattern?