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 @@ -28,24 +28,29 @@
}
}

.row-actions_desktop {
.row-actions {
display: flex;
align-items: center;
}

.custom-actions_desktop {
display: flex;
align-items: center;
gap: 4px;
}

@media (width <= 600px) {
.row-actions_desktop {
.custom-actions_desktop {
display: none;
}
}

.row-actions_mobile {
.custom-actions_mobile {
display: none;
}

@media (width <= 600px) {
.row-actions_mobile {
.custom-actions_mobile {
display: flex;
flex-wrap: wrap;
gap: 8px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,37 @@
<div *ngIf="tableRowValues" class="wrapper">
<div class="row-edit-header">
<app-breadcrumbs [crumbs]="getCrumbs(currentConnection.title || currentConnection.database)"></app-breadcrumbs>
<div *ngIf="rowActions && rowActions.length">
<div class="row-actions_desktop">
<button type="button" mat-icon-button *ngFor="let action of rowActions"
[matTooltip]="action.title"
(click)="handleActivateAction(action)">
<mat-icon fontSet="material-icons-outlined">
{{action.icon}}
</mat-icon>
</button>
</div>
<div class="row-actions_mobile">
<button type="button" mat-stroked-button *ngFor="let action of rowActions"
(click)="handleActivateAction(action)">
<mat-icon fontSet="material-icons-outlined">
{{action.icon}}
</mat-icon>
{{action.title}}
</button>
<div class="row-actions">
<a mat-icon-button *ngIf="permissions.add && hasKeyAttributesFromURL"
routerLink="/dashboard/{{connectionID}}/{{tableName}}/entry"
[queryParams]="dubURLParams"
matTooltip="Duplicate row">
<mat-icon fontSet="material-icons-outlined">difference</mat-icon>
</a>
<button type="button" mat-icon-button *ngIf="permissions.delete && hasKeyAttributesFromURL"
matTooltip="Delete row"
(click)="handleDeleteRow()">
<mat-icon fontSet="material-icons-outlined">delete</mat-icon>
</button>
<div *ngIf="rowActions && rowActions.length">
<div class="custom-actions_desktop">
<button type="button" mat-icon-button *ngFor="let action of rowActions"
[matTooltip]="action.title"
(click)="handleActivateAction(action)">
<mat-icon fontSet="material-icons-outlined">
{{action.icon}}
</mat-icon>
</button>
</div>
<div class="custom-actions_mobile">
<button type="button" mat-stroked-button *ngFor="let action of rowActions"
(click)="handleActivateAction(action)">
<mat-icon fontSet="material-icons-outlined">
{{action.icon}}
</mat-icon>
{{action.title}}
</button>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as JSON5 from 'json5';
import { ActivatedRoute, Router } from '@angular/router';
import { Alert, AlertType, ServerError } from 'src/app/models/alert';
import { Component, NgZone, OnInit } from '@angular/core';
import { CustomAction, CustomEvent, TableField, TableForeignKey, TablePermissions, Widget } from 'src/app/models/table';
import { CustomAction, CustomActionType, CustomEvent, TableField, TableForeignKey, TablePermissions, Widget } from 'src/app/models/table';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatProgressSpinnerModule, MatSpinner } from '@angular/material/progress-spinner';
import { UIwidgets, defaultTimestampValues, fieldTypes, timestampTypes } from 'src/app/consts/field-types';
Expand Down Expand Up @@ -80,6 +80,7 @@ export class DbTableRowEditComponent implements OnInit {
public nonModifyingFields: string[];
public keyAttributesFromURL: object = {};
public hasKeyAttributesFromURL: boolean;
public dubURLParams: object;
public keyAttributesFromStructure: [] = [];
public isPrimaryKeyUpdated: boolean;
public tableTypes: object;
Expand Down Expand Up @@ -110,6 +111,7 @@ export class DbTableRowEditComponent implements OnInit {
}

private routeSub: Subscription | undefined;
private confirmationDialogRef: any;

originalOrder = () => { return 0; }

Expand Down Expand Up @@ -193,6 +195,7 @@ export class DbTableRowEditComponent implements OnInit {
};

this.keyAttributesFromURL = primaryKeys;
this.dubURLParams = {...primaryKeys, action: 'dub'};
this.hasKeyAttributesFromURL = !!Object.keys(this.keyAttributesFromURL).length;
this._tableRow.fetchTableRow(this.connectionID, this.tableName, params)
.subscribe(res => {
Expand Down Expand Up @@ -551,12 +554,25 @@ export class DbTableRowEditComponent implements OnInit {
)
}

handleDeleteRow(){
this.handleActivateAction({
title: 'Delete row',
require_confirmation: true
} as CustomEvent);
}

handleActivateAction(action: CustomEvent) {
if (action.require_confirmation) {
this.dialog.open(BbBulkActionConfirmationDialogComponent, {
this.confirmationDialogRef = this.dialog.open(BbBulkActionConfirmationDialogComponent, {
width: '25em',
data: {id: action.id, title: action.title, primaryKeys: [this.keyAttributesFromURL]}
});

if (!action.id) {
this.confirmationDialogRef.afterClosed().subscribe((res) => {
this.router.navigate([`/dashboard/${this.connectionID}/${this.tableName}`], { queryParams: this.backUrlParams});
});
}
} else {
this._tables.activateActions(this.connectionID, this.tableName, action.id, action.title, [this.keyAttributesFromURL])
.subscribe((res) => {
Expand Down