Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Remove checkbox from JdbcTableSelectorComponent html templates
Browse files Browse the repository at this point in the history
- removed checkbox from JDBC tables column template
- removed checkbox from JDBC tables cell template
  • Loading branch information
elvisisking committed Jan 5, 2018
1 parent 41be2e1 commit 910406b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@
[columnMode]="'force'"
[reorderable]="false"
[selectionType]="'checkbox'"
(select)="tableSelectionChanged($event)"
[sorts]="[{prop: 'name', dir: 'asc'}]"
[cssClasses]="customClasses">
<ngx-datatable-column name="Tables"
[prop]="'name'"
[sortable]="true"
[comparator]="nameComparator"
[checkboxable]="true"
[headerCheckboxable]="true"
[canAutoResize]="true"
[width]="300"
[draggable]="false"
[resizeable]="false">
<ng-template ngx-datatable-header-template let-value="value" let-allRowsSelected="selectedAllRows" let-selectFn="selectAllTables">
<input type="checkbox" [checked]="selectedAllRows" (change)="selectAllTables()"/><span class="jdbc-table-header">Tables</span>
Tables
<input type="text"
class="col-sm-12"
style='border:solid 1px #dddddd;padding:8px;margin:0 auto;width:100%;height:24px'
placeholder='Filter tables'
(keyup)='tableFilterChanged($event)'/>
</ng-template>
<ng-template ngx-datatable-cell-template let-row="row" let-isSelected="row.selected" let-onCheckboxChangeFn="selectedTableChanged">
<input type="checkbox" [checked]="row.selected" (change)="selectedTableChanged( row )"/><span class="jdbc-table-cell">{{ row.name }}</span>
style="border:solid 1px #dddddd;padding:8px;margin:0 auto;width:100%;height:24px"
placeholder="Filter tables"
(keyup)="tableFilterChanged($event)"/>
</ng-template>
</ngx-datatable-column>
</ngx-datatable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,48 +343,23 @@ export class JdbcTableSelectorComponent implements OnInit, TableSelector {
return this.tables.filter( ( table ) => table.selected );
}

public selectAllTables(): void {
this.selectedAllRows = !this.selectedAllRows;
const self = this;
public tableSelectionChanged( event: any ): void {
const selectedTables = event.selected;
const self = this;

// sync up the UI row selections with the actual table selections
this.filteredTables.forEach( ( table ) => {
if ( table.selected !== self.selectedAllRows ) {
self.selectedTableChanged( table );
}
} );
}

/*
* Handler for changes in table selection
*/
public selectedTableChanged(table: Table): void {
table.selected = !table.selected;
if ( ( !table.selected && this.isSelected( selectedTables, table ) )
|| ( table.selected && !this.isSelected( selectedTables, table )) ) {
table.selected = !table.selected;

if (table.selected) {
this.tableSelectionAdded.emit(table);

// check column header checkbox if all are selected
if ( !this.selectedAllRows ) {
let selectAll = true;

for ( const tbl of this.filteredTables ) {
if ( !tbl.selected ) {
selectAll = false;
}
}

if ( selectAll ) {
this.selectedAllRows = true;
if ( table.selected ) {
this.tableSelectionAdded.emit(table);
} else {
this.tableSelectionRemoved.emit(table);
}
}
} else {
this.tableSelectionRemoved.emit(table);

// uncheck column header checkbox if needed
if ( this.selectedAllRows ) {
this.selectedAllRows = false;
}
}
} );
}

/**
Expand All @@ -404,6 +379,17 @@ export class JdbcTableSelectorComponent implements OnInit, TableSelector {
}
}

private isSelected( selectedTables: Table[],
table: Table ): boolean {
for ( const selected of selectedTables ) {
if ( selected.getName() === table.getName() ) {
return true;
}
}

return false;
}

/*
* Builds the array of CatalogSchema items from the SchemaInfo coming from
* the Komodo rest call
Expand Down

0 comments on commit 910406b

Please sign in to comment.