ToolJet/server/migrations/1633370361564-SetShowBulkSelectorToTrue.ts
Sherfin Shamsudeen eaaccc247e
Bulk selection for table widget 🔥
* Functional implementation of checkbox selector for table

* Add inspector toggle to display bulk selector checkboxes

* Expose selectedRows variable of Table

* Refactor select-all checkbox into a separate function

* Remove unnecessary import of v4 package

* Add TODO comment for adding checkbox color

* Revert typo that accidentally got committed

* Add explanatory comment in selectedRows data generation code

* Combine original row data and displayed row data for selectedRows

* Show only original data in selectedRows

* Use useRowSelect hook to for implementing table selector

* Show selector column only when it is enable from inspector

* Add migration to set showBulkSelector to false for all tables

* Add documentation for bulk selection

* Set label of toggle that (en/dis)ables bulk selection: 'Bulk selection'
2021-10-05 12:37:17 +05:30

44 lines
1.5 KiB
TypeScript

import { AppVersion } from '../src/entities/app_version.entity';
import { MigrationInterface, QueryRunner } from 'typeorm';
export class SetShowBulkSelectorToTrue1633370361564 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const entityManager = queryRunner.manager;
const queryBuilder = queryRunner.connection.createQueryBuilder();
const appVersionRepository = entityManager.getRepository(AppVersion);
const appVersions = await appVersionRepository.find();
for (const version of appVersions) {
const definition = version['definition'];
if (definition) {
const components = definition['components'];
for (const componentId of Object.keys(components)) {
const component = components[componentId];
if (component.component.component === 'Table') {
component.component.definition.properties.showBulkSelector = { value: false };
components[componentId] = {
...component,
component: {
...component.component,
definition: {
...component.component.definition,
},
},
};
}
}
definition['components'] = components;
version.definition = definition;
await queryBuilder.update(AppVersion).set({ definition }).where('id = :id', { id: version.id }).execute();
}
}
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}