Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 0 additions & 22 deletions .eslintignore

This file was deleted.

60 changes: 0 additions & 60 deletions .eslintrc.js

This file was deleted.

6 changes: 2 additions & 4 deletions addon-test-support/rows-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Row, RowsFetcherResponse } from '@upfluence/hypertable/core/interfaces';

export default class RowsFetcher {
// @ts-ignore
fetch(page: number, perPage: number): Promise<RowsFetcherResponse> {
fetch(_page: number, _perPage: number): Promise<RowsFetcherResponse> {
return Promise.resolve({
rows: [
{
Expand Down Expand Up @@ -59,8 +58,7 @@ export default class RowsFetcher {
}

export class AllRowsFetcher {
// @ts-ignore
fetch(page: number, perPage: number): Promise<RowsFetcherResponse> {
fetch(_page: number, _perPage: number): Promise<RowsFetcherResponse> {
return Promise.resolve({
rows: [
{
Expand Down
2 changes: 1 addition & 1 deletion addon-test-support/table-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@upfluence/hypertable/core/interfaces';

export const buildColumnDefinition = (key: string, extra?: { [key: string]: any }): ColumnDefinition => {
let defaultColumnDefinition = {
const defaultColumnDefinition = {
key: key,
type: 'text',
name: `Name: ${key}`,
Expand Down
4 changes: 2 additions & 2 deletions addon/components/hyper-table-v2/column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class HyperTableV2Column extends Component<HyperTableV2ColumnArgs
this.elementId = guidFor(args.column.definition.key);
}

@computed('args.column.filters.[]', 'args.column.order.direction', 'sizeClass')
@computed('args.column.{filters.[],order.direction}', 'sizeClass', 'stickyColumnClass')
get computedClasses(): string {
const classes = ['hypertable__column'];

Expand Down Expand Up @@ -80,7 +80,7 @@ export default class HyperTableV2Column extends Component<HyperTableV2ColumnArgs
return `hypertable__column--size-${size}`;
}

@computed('args.column.order.direction')
@computed('args.column.{definition.orderable,order.direction}')
get isOrderingIndicatorVisible(): boolean {
return this.args.column.definition.orderable && !this.args.column.order?.direction;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class HyperTableV2FilteringRenderersCommonColumnActions extends C
return !this.args.column.definition.position?.sticky;
}

@computed('args.column.filters.[]', 'args.column.order')
@computed('args.column.{filters.[],order}')
get displayClearButton(): boolean {
return (this.args.column.filters?.length ?? 0) > 0 || this.args.column.order !== undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ export default class HyperTableV2FacetsLoader extends Component<FacetsLoaderArgs
if (this.ongoingFacetApply) return;

this.ongoingFacetApply = true;
this.appliedFacets.includes(facet.identifier) ? this.removeFacet(facet) : this.addFacet(facet);
if (this.appliedFacets.includes(facet.identifier)) {
this.removeFacet(facet);
} else {
this.addFacet(facet);
}
}

private addFacet(facet: Facet): void {
Expand Down
8 changes: 4 additions & 4 deletions addon/components/hyper-table-v2/filtering-renderers/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class HyperTableV2FilteringRenderersDate extends Component<HyperT
constructor(owner: unknown, args: HyperTableV2FilteringRenderersDateArgs) {
super(owner, args);

let filter = this.args.column.filters.find((f) => f.key === this.movingOptionKey);
const filter = this.args.column.filters.find((f) => f.key === this.movingOptionKey);
this._currentMovingDateOption = filter ? filter.value : null;
this.filterOption = this._currentMovingDateOption ? this.movingOptionKey : 'fixed';
args.handler.on('reset-columns', (columns) => {
Expand All @@ -60,8 +60,8 @@ export default class HyperTableV2FilteringRenderersDate extends Component<HyperT
}

private _initBounderingFilters(): void {
let lowerBoundFilter = this.args.column.filters.find((filter) => filter.key === 'lower_bound');
let upperBoundFilter = this.args.column.filters.find((filter) => filter.key === 'upper_bound');
const lowerBoundFilter = this.args.column.filters.find((filter) => filter.key === 'lower_bound');
const upperBoundFilter = this.args.column.filters.find((filter) => filter.key === 'upper_bound');
if (lowerBoundFilter && upperBoundFilter) {
this._currentDateValue = [
moment.unix(parseInt(lowerBoundFilter.value)).toDate(),
Expand Down Expand Up @@ -104,7 +104,7 @@ export default class HyperTableV2FilteringRenderersDate extends Component<HyperT

@action
selectFixedDate(value: any): void {
let [fromDate, toDate] = value;
const [fromDate, toDate] = value;

if (fromDate && toDate) {
this.sendEndOfTheDayOnDate(toDate);
Expand Down
2 changes: 1 addition & 1 deletion addon/components/hyper-table-v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class HyperTableV2 extends Component<HyperTableV2Args> {
return !!this.initialLoadAnimation?.includeSelectionColumnInExtraEffect;
}

@computed('args.handler.columns.@each.{filters,order}')
@computed('args.handler.columns.@each.{filters,order}', 'features.global_filters_reset')
get displayResetButton(): boolean {
const filtersApplied: boolean = this.args.handler.columns.some((col) => col.filters?.length || col.order);
return filtersApplied && this.features.global_filters_reset;
Expand Down
2 changes: 1 addition & 1 deletion addon/components/hyper-table-v2/manage-columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class HyperTableV2ManageColumns extends Component<HyperTableV2Man
}

get orderedFilteredClusters(): Map<string, ManagedColumn[]> {
let fields = A(
const fields = A(
(this.args.handler.columnDefinitions || []).filter((columnDefinition) => {
const search = (this.searchColumnDefinitionKeyword || '').toLowerCase();
const hasSearched =
Expand Down
2 changes: 1 addition & 1 deletion addon/components/hyper-table-v2/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class HyperTableV2Selection extends Component<HyperTableV2Selecti
}

get classes(): string {
let classes = ['selection-container'];
const classes = ['selection-container'];

if (this.args.selected > 0) {
classes.push('selection-container--visible');
Expand Down
50 changes: 27 additions & 23 deletions addon/core/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export default class TableHandler {
* @returns {TableHandler}
*/
on(event: string, handler: (...args: any[]) => any): TableHandler {
// @ts-ignore Works but the declaration from @types/ember__object does not match the documentation/actual code.
addListener(this, event, handler);

return this;
Expand All @@ -184,7 +183,7 @@ export default class TableHandler {
return this.tableManager
.upsertColumns({ columns: [...this.columns, ...[{ definition: definition, filters: [] }]] })
.then(({ columns }) => {
this._reinitColumnsAndRows(columns);
this.reinitColumnsAndRows(columns);
});
}

Expand All @@ -203,7 +202,7 @@ export default class TableHandler {
.then(({ columns }) => {
this.columns = columns;
if (columnToRemove.length > 0 && columnToRemove[0].filters.length > 0) {
this._reinitColumnsAndRows(columns);
this.reinitColumnsAndRows(columns);
this.triggerEvent('remove-column');
}
});
Expand Down Expand Up @@ -235,7 +234,7 @@ export default class TableHandler {

// Triggers the redraw of the table.
if (shouldRefresh) {
this.rows = this.rows;
this.rows = [...this.rows];
this.triggerEvent('mutate-rows');
}

Expand Down Expand Up @@ -282,7 +281,7 @@ export default class TableHandler {
set(column, 'filters', newFilters);

return this.tableManager.upsertColumns({ columns: this.columns }).then(({ columns }) => {
return this._reinitColumnsAndRows(columns).then(() => {
return this.reinitColumnsAndRows(columns).then(() => {
this.triggerEvent('apply-filters', column, filters);
});
});
Expand All @@ -304,7 +303,7 @@ export default class TableHandler {

return this.tableManager.upsertColumns({ columns: this.columns }).then(({ columns }) => {
this._lastOrderedColumn = column;
this._reinitColumnsAndRows(columns);
this.reinitColumnsAndRows(columns);
this.triggerEvent('apply-order', column, direction);
});
}
Expand All @@ -326,7 +325,7 @@ export default class TableHandler {
}

return this.tableManager.upsertColumns({ columns: this.columns }).then(({ columns }) => {
this._reinitColumnsAndRows(columns);
this.reinitColumnsAndRows(columns);
this.triggerEvent('reset-columns', columnsToReset);
});
}
Expand Down Expand Up @@ -432,18 +431,7 @@ export default class TableHandler {
triggerTetherContainer(on: string, options: Tether.ITetherOptions): void {
if (this.tetherOn !== on) {
this.tetherOn = on;

scheduleOnce('afterRender', this, () => {
if (this.tetherInstance) {
this.tetherInstance.setOptions(options);
} else {
this.tetherInstance = new Tether(options);
}

scheduleOnce('afterRender', this, () => {
(<any>this.tetherInstance).element.classList.add(`js--visible`);
});
});
scheduleOnce('afterRender', this, this.upsertTetherInstance, options);
} else {
this.tetherOn = '';
this.destroyTetherInstance();
Expand All @@ -462,7 +450,7 @@ export default class TableHandler {
*/
destroyTetherInstance(): void {
if (this.tetherInstance) {
//@ts-ignore
//@ts-expect-error - element does not exist on Tether
this.tetherInstance.element.remove();
this.tetherInstance.destroy();
this.tetherInstance = undefined;
Expand All @@ -474,18 +462,34 @@ export default class TableHandler {
this.currentPage = 1;
}

private _reinitColumnsAndRows(columns: Column[]): Promise<void> {
private upsertTetherInstance(options: Tether.ITetherOptions): void {
if (this.tetherInstance) {
this.tetherInstance.setOptions(options);
} else {
this.tetherInstance = new Tether(options);
}

scheduleOnce('afterRender', this, this.showTetherInstance);
}

private showTetherInstance(): void {
if (!this.tetherInstance) return;

(<any>this.tetherInstance).element.classList.add('js--visible');
}

private reinitColumnsAndRows(columns: Column[]): Promise<void> {
let shouldRedraw = false;
columns.forEach((column) => {
let existingColumn = this.columns.find((c) => c.definition.key === column.definition.key);
const existingColumn = this.columns.find((c) => c.definition.key === column.definition.key);

if (!existingColumn) {
this.columns.splice(columns.indexOf(column), 0, column);
shouldRedraw = true;
}
});
if (shouldRedraw) {
this.columns = this.columns;
this.columns = [...this.columns];
}

this.rows = [];
Expand Down
2 changes: 1 addition & 1 deletion addon/types/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default EmberObject.extend({
toggleColumnVisibility(field, column) {
return new Promise((resolve) => {
let _c = this.columns.findBy('key', field.key);
let _action = null;
let _action;

if (_c) {
field.set('visible', false);
Expand Down
5 changes: 5 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check
import { defineConfig } from 'eslint/config';
import upfluence from '@upfluence/w-conf/eslint';

export default defineConfig(...upfluence);
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = {
this._super.included.apply(this, arguments);

if (parent.project.pkg.name === name) {
// eslint-disable-next-line node/no-unpublished-require
this.options.babel.plugins.push(...require('ember-cli-code-coverage').buildBabelPlugin());
}
},
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@
"@types/rsvp": "^4.0.4",
"@types/sinon": "^10.0.6",
"@types/tether": "^1.4.6",
"@typescript-eslint/parser": "^5.32.0",
"@upfluence/oss-components": "^3.98.16",
"@upfluence/w-conf": "^0.2.0",
"@upfluence/w-conf": "^0.4.0",
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.28.6",
"ember-cli-code-coverage": "^3.0.0",
Expand All @@ -110,7 +109,7 @@
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^3.15.0",
"ember-try": "^4.0.0",
"eslint": "^7.32.0",
"eslint": "^10.5.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ember": "^10.5.8",
"eslint-plugin-node": "^11.1.0",
Expand All @@ -119,7 +118,7 @@
"loader.js": "^4.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.8.1",
"qunit": "^2.17.2",
"qunit": "^2.20.0",
"qunit-dom": "^1.6.0",
"typescript": "^4.7.4",
"webpack": "5"
Expand All @@ -128,7 +127,7 @@
"@babel/helper-compilation-targets": "7.9.6"
},
"engines": {
"node": "12.* || 14.* || >= 16"
"node": ">= 20"
},
"ember": {
"edition": "octane"
Expand Down
Loading
Loading