Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion packages/qgrid-core/src/highlight/highlight.let.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export class HighlightLet {
hasChanges = true;
}
}

if (hasChanges) {
model.highlight({ rows }, {
source: 'highlight.view'
Expand All @@ -78,6 +77,36 @@ export class HighlightLet {
}
});

this.oneRow = new Command({
source: 'highlight.oneRow',
canExecute: () => !this.isRendering,
execute: (row, state) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should not be a state argument, this command just should highlight a row, not to unhighlight

let rows = Array.from(model.highlight().rows);
const index = rows.indexOf(row);
let hasChanges = false;
if (state) {
if (index < 0) {
rows.push(row);
hasChanges = true;
}
}
else {
if (index >= 0) {
rows.splice(index, 1);
hasChanges = true;
}
}
if (hasChanges) {
if(rows.length > 1) {
rows = rows.splice(rows.length-1, 1);
}
model.highlight({ rows }, {
source: 'highlight.oneRow'
});
}
}
});

this.cell = new Command({
source: 'highlight.view',
canExecute: () => !this.isRendering,
Expand Down
2 changes: 1 addition & 1 deletion packages/qgrid-core/src/model/model.bind.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { noop, toCamelCase, isUndefined, isArray } from '../utility/kit';
import { Log } from '../infrastructure//log';
import { isArray, isUndefined, noop, toCamelCase } from '../utility/kit';

export class ModelBinder {
constructor(host, plugin) {
Expand Down
4 changes: 2 additions & 2 deletions packages/qgrid-core/src/model/model.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GridError } from '../infrastructure/error';
import { Event } from '../event/event';
import { GridError } from '../infrastructure/error';
import { Guard } from '../infrastructure/guard';
import { isArray, isObject, getTypeName } from '../utility/kit';
import { Log } from '../infrastructure/log';
import { getTypeName, isArray, isObject } from '../utility/kit';

function equals(x, y) {
// TODO: improve equality algorithm
Expand Down
12 changes: 4 additions & 8 deletions packages/qgrid-core/src/view/view.host.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { final } from '../infrastructure/final';
import {
checkButtonCode, getButtonCode, LEFT_BUTTON,
NO_BUTTON, stringify
checkButtonCode, getButtonCode, LEFT_BUTTON,
NO_BUTTON, stringify
} from '../mouse/mouse.code';
import { PathService } from '../path/path.service';
import { PipeUnit } from '../pipe/pipe.unit';
Expand Down Expand Up @@ -209,12 +209,8 @@ export class ViewHost {
if (tr) {
const { index } = tr;

if (highlight.row.canExecute(index)) {
rows
.filter(i => i !== index)
.forEach(i => highlight.row.execute(i, false));

highlight.row.execute(index, true);
if (highlight.oneRow.canExecute(index)) {
highlight.oneRow.execute(index, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ import { GridPlugin, TemplateHostService } from '@qgrid/ngx';
providers: [GridPlugin, TemplateHostService],
})

//TODO: Re-name to TooltipDirective
export class CellTooltipDirective implements OnChanges {
@Input() host: HTMLElement;
@Input() showDelay = 1000;
@Input() position: (host: HTMLElement) => [number, number] = (host) => {
const { top, left, height } = host.getBoundingClientRect();
const box = this.getBoxRect(host);

return [left - box.left, top - box.top + height];
};

private job = jobLine(this.showDelay);

Expand All @@ -28,13 +35,12 @@ export class CellTooltipDirective implements OnChanges {
}

if (e.host && this.host) {
const { top, left, height } = this.host.getBoundingClientRect();
const box = this.getBoxRect(this.host);
const host = this.elementRef.nativeElement;
const nativeElement = this.elementRef.nativeElement;
this.job(() => {
this.renderer.setStyle(host, 'top', top - box.top + height + 'px');
this.renderer.setStyle(host, 'left', left - box.left + 'px');
this.renderer.removeClass(host, 'q-grid-hide');
const [left, top] = this.position(this.host);
this.renderer.setStyle(nativeElement, 'top', top + 'px');
this.renderer.setStyle(nativeElement, 'left', left + 'px');
this.renderer.removeClass(nativeElement, 'q-grid-hide');
});

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
</ng-container>
<ng-container *ngIf="$view.row.canResize">
<div [q-grid-drag]="$view.row.resize"
[q-grid-resize]="$cell.row"
q-grid-resize-selector="parent"
[q-grid-resize]="$cell.row"
q-grid-resize-selector="parent"
q-grid-resize-path="rows"
[q-grid-can-resize]="$view.row.resize.canExecute">
<mat-icon class="q-grid-icon q-grid-row-size-indicator">unfold_more</mat-icon>
</div>
</ng-container>
</ng-template>
24 changes: 14 additions & 10 deletions packages/qgrid-ngx/src/lib/layer/layer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,26 @@ export class LayerService {
const { nativeElement } = container.element;
nativeElement.parentElement.classList.add(`q-grid-layer-${name}`);
this.getHostElement()?.classList.add(`q-grid-${name}`);
container.createEmbeddedView(link.template, {});
}
const embeddedViewRef = container.createEmbeddedView(link.template, {});


const destroy = container
? () => {
const destroy = () => {
this.layers.delete(name);
const { nativeElement } = container.element;
nativeElement.parentElement.classList.add(`q-grid-layer-${name}`);
nativeElement.parentElement.classList.remove(`q-grid-layer-${name}`);
this.getHostElement()?.classList.remove(`q-grid-${name}`);
container.clear();
embeddedViewRef.destroy();
}
: () => this.layers.delete(name);

const layer = new Layer(destroy);
this.layers.set(name, layer);
return layer;
const layer = new Layer(destroy);
this.layers.set(name, layer);
return layer;
}

const noopLayer = new Layer(() => this.layers.delete(name));

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove new line

this.layers.set(name, noopLayer);
return noopLayer;
}

get count() {
Expand Down
14 changes: 13 additions & 1 deletion packages/qgrid-ngx/src/lib/row/row.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TemplateHostService } from '../template/template-host.service';

@Component({
selector: 'q-grid-row',
template: '<ng-content></ng-content>',
template: `<ng-container></ng-container>`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ng-content

providers: [
TemplateHostService,
GridPlugin,
Expand Down Expand Up @@ -90,10 +90,22 @@ export class RowComponent implements OnChanges, OnInit {
});
}
}


}

ngOnChanges() {
const { model } = this.plugin;
this.stateAccessor.write(model);
}

private addRowResizeLayer(): void {
const rowResizeLayer = 'row-resize';
const table = this.plugin.table;
if (table.view.hasLayer(rowResizeLayer)) {
table.view.removeLayer(rowResizeLayer);
}

table.view.addLayer(rowResizeLayer);
}
}
6 changes: 6 additions & 0 deletions packages/qgrid-ngx/src/lib/row/row.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { NgModule } from '@angular/core';
import { LayerModule } from '../layer/layer.module';
import { TemplateModule } from '../template/template.module';
import { RowComponent } from './row.component';
import { TrCoreDirective } from './tr-core.directive';
import { TrhCoreDirective } from './trh-core.directive';

@NgModule({
imports: [
LayerModule,
TemplateModule
],
declarations: [
RowComponent,
TrCoreDirective,
Expand Down
13 changes: 13 additions & 0 deletions packages/qgrid-styles/focus.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ td.q-grid-focused {
}
}


.q-grid-row-size-indicator {
display: none;
}

.q-grid-highlighted {
.q-grid-row-size-indicator {
display: block;
position: absolute;
bottom: 0;
}
}

.q-grid-view.q-grid-active {
td.q-grid-focused {
outline-color: $blue-outline025;
Expand Down