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
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ describe('DbTableWidgetsComponent', () => {
},
{
field_name: '',
widget_type: '',
widget_params: '',
widget_type: 'Default',
widget_params: '// No settings required',
name: '',
description: ''
}
Expand All @@ -173,44 +173,6 @@ describe('DbTableWidgetsComponent', () => {
expect(component.fields).toEqual(['user_id', 'last_name', 'email']);
});

it('should set empty string in widget_type if widget does not need another appearance', () => {
component.widgets = [
{
field_name: 'user_id',
widget_type: 'textarea',
widget_params: '',
name: '',
description: ''
},
{
field_name: 'user_name',
widget_type: 'Default',
widget_params: '// No settings required',
name: 'name',
description: ''
}
];

component.widgetTypeChange('user_name');

expect(component.widgets).toEqual([
{
field_name: 'user_id',
widget_type: 'textarea',
widget_params: '',
name: '',
description: ''
},
{
field_name: 'user_name',
widget_type: '',
widget_params: '// No settings required',
name: 'name',
description: ''
}
])
});

xit('should open dialog to confirm deletion of widget', () => {
component.fields = ['user_age'];
component.widgets = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ export class DbTableWidgetsComponent implements OnInit {
addNewWidget() {
this.widgets.push({
field_name: '',
widget_type: '',
widget_params: '',
widget_type: 'Default',
widget_params: '// No settings required',
name: '',
description: ''
});
Expand All @@ -319,8 +319,6 @@ export class DbTableWidgetsComponent implements OnInit {

widgetTypeChange(fieldName) {
let currentWidget = this.widgets.find(widget => widget.field_name === fieldName);

if (currentWidget.widget_type === 'Default') currentWidget.widget_type = '';
currentWidget.widget_params = this.defaultParams[currentWidget.widget_type || 'Default'];

this.widgetParamsChange({fieldName: currentWidget.field_name, value: currentWidget.widget_params});
Expand Down Expand Up @@ -373,12 +371,20 @@ export class DbTableWidgetsComponent implements OnInit {
.subscribe(res => {
const currentWidgetTypes = res.map((widget: Widget) => widget.field_name);
this.fields = difference(this.fields, currentWidgetTypes);
res.forEach((widget: Widget) => {
if (widget.widget_type === '') widget.widget_type = 'Default';
})
this.widgets = res;
});
}

updateWidgets(afterDeleteAll?: boolean) {
this.submitting = true;

this.widgets.forEach(widget => {
if (widget.widget_type === 'Default') widget.widget_type = '';
});

this._tables.updateTableWidgets(this.connectionID, this.tableName, this.widgets)
.subscribe(() => {
this.submitting = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<form #tableFiltersForm="ngForm" (ngSubmit)="handleSaveFilters()" class="filters-form">
<h1 mat-dialog-title class="filters-header">
<span>New Fast Filter for <strong>{{ data.displayTableName }}</strong></span>
<span>New fast filter for <strong>{{ data.displayTableName }}</strong></span>
</h1>
<app-content-loader *ngIf="!fields || !tableTypes; else filterControls"></app-content-loader>
<ng-template #filterControls>
<mat-dialog-content class="filters-content">
<!-- Filter Name and Description Fields -->
<mat-form-field appearance="outline" class="full-width">
<mat-label>Fast Filter name</mat-label>
<mat-label>Fast filter name</mat-label>
<input matInput required
name="filters_set_name"
[(ngModel)]="data.filtersSet.name">
Expand All @@ -16,9 +16,9 @@ <h1 mat-dialog-title class="filters-header">
</mat-error>
</mat-form-field>

<h3 class="section-title">Conditions & Main column</h3>
<h3 class="section-title">Conditions & main column</h3>
<p class="section-description">
Select which conditions to add and choose a Main column. Main columns remain editable, while conditions are set.
Select which conditions to add and choose a main column. Main columns remain editable, while conditions are set.
</p>

<!-- Filter Selection -->
Expand Down Expand Up @@ -165,7 +165,7 @@ <h3 class="section-title">Conditions & Main column</h3>
Cancel
</button>
<button mat-flat-button color="primary" type="submit">
Save Filter
Save filter
</button>
</mat-dialog-actions>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
angularticsAction="Saved filters: first time setup is clicked"
(click)="handleOpenSavedFiltersDialog()">
<mat-icon>tune</mat-icon>
Create Fast Filter
Create fast filter
</button>

<button *ngIf="accessLevel === 'edit' && savedFilterData.length !== 0"
mat-icon-button type="button"
matTooltip="Set up, edit, or remove Fast Filters"
matTooltip="Set up, edit, or remove fast filters"
[matMenuTriggerFor]="menu"
angulartics2On="click"
angularticsAction="Saved filters: open menu is clicked">
Expand All @@ -22,7 +22,7 @@
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="handleOpenSavedFiltersDialog()">
<mat-icon>add</mat-icon>
New Fast Filter
New fast filter
</button>
<button mat-menu-item
*ngFor="let filter of savedFilterData"
Expand Down