Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 14, 2024
1 parent b92a1da commit 6c2c675
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/electron/frontend/core/components/BasicTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,9 @@ export class BasicTable extends LitElement {
for (let key in this.ignore) delete entries[key];
for (let key in this.ignore["*"] ?? {}) delete entries[key];

const schemaOrder = this.#itemSchema.order ?? []
const schemaOrder = this.#itemSchema.order ?? [];
const order = this.keyColumn ? [this.keyColumn, ...schemaOrder] : schemaOrder;


// Sort Columns by Key Column and Requirement
const keys =
(this.#keys =
Expand Down
4 changes: 2 additions & 2 deletions src/electron/frontend/core/components/SimpleTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -968,9 +968,9 @@ export class SimpleTable extends LitElement {
for (let key in this.ignore) delete entries[key];
for (let key in this.ignore["*"] ?? {}) delete entries[key];

const schemaOrder = this.#itemSchema.order ?? []
const schemaOrder = this.#itemSchema.order ?? [];
const order = this.keyColumn ? [this.keyColumn, ...schemaOrder] : schemaOrder;
if (!this.keyColumn && !order.includes('name')) order.unshift('name');
if (!this.keyColumn && !order.includes("name")) order.unshift("name");

// Sort Columns by Key Column and Requirement
this.colHeaders = sortTable(
Expand Down
11 changes: 4 additions & 7 deletions src/electron/frontend/core/components/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const rowSymbol = Symbol("row");

const maxRows = 20;

const isRequired = (col, schema) => schema.required?.includes(col)
const isRequired = (col, schema) => schema.required?.includes(col);

export const getEditable = (value, rowData = {}, config, colName) => {
if (typeof config === "boolean") return config;
Expand All @@ -21,7 +21,6 @@ export const getEditable = (value, rowData = {}, config, colName) => {
};

export function sortTable(schema, order = []) {

const cols = Object.keys(schema.properties)

//Sort alphabetically
Expand All @@ -37,17 +36,15 @@ export function sortTable(schema, order = []) {
if (aRequired) return -1;
if (bRequired) return 1;
return 0;
})

});


return cols.sort((a, b) => {
const idxA = order.indexOf(a);
const idxB = order.indexOf(b);
if (idxA === -1) return 1;
if (idxB === -1) return -1;
return idxA - idxB;
})
});
}

// Inject scoped stylesheet
Expand Down Expand Up @@ -257,7 +254,7 @@ export class Table extends LitElement {
}

// Sort Columns by Key Column and Requirement
const order = this.keyColumn ? [this.keyColumn, ...this.#itemSchema.order ?? []] : this.#itemSchema.order;
const order = this.keyColumn ? [this.keyColumn, ...(this.#itemSchema.order ?? [])] : this.#itemSchema.order;

const colHeaders = (this.colHeaders = sortTable(
{
Expand Down
4 changes: 2 additions & 2 deletions tests/components/table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Table component', () => {
const element = await createComponent({ schema, keyColumn: 'name' });

const key = 'John Doe';
const row = { age: 30, aliases: ['Johny', 'Doe'] }
const row = { age: 30, aliases: ['Johny', 'Doe'] }
const data = { [key]: row };
element.data = data;
await element.updated();
Expand All @@ -89,4 +89,4 @@ describe('Table component', () => {
const sortedColumns = sortTable(schema, 'name', ['age', 'email']);
expect(sortedColumns).toEqual(['name', 'age', 'email']);
});
});
});
1 change: 0 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export default defineConfig({
"src/electron/frontend/utils/upload.ts",
"src/electron/frontend/core/components/FileSystemSelector.js", // Uses Electron dialog
"src/electron/frontend/core/components/DandiResults.js", // Needs DANDI API Key and network access (unless possibly with a static mocked response)

],
},
},
Expand Down

0 comments on commit 6c2c675

Please sign in to comment.