Skip to content

Commit db4621a

Browse files
committed
feature completed with data table update
1 parent c21222a commit db4621a

7 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/components.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export namespace Components {
5757
"selectHandler": any;
5858
}
5959
interface DataTable {
60+
"canDeleteRow": boolean;
61+
"canEditRow": boolean;
6062
"columns": {
6163
id: number | string;
6264
key: string;
@@ -848,6 +850,8 @@ declare namespace LocalJSX {
848850
"selectHandler"?: any;
849851
}
850852
interface DataTable {
853+
"canDeleteRow"?: boolean;
854+
"canEditRow"?: boolean;
851855
"columns"?: {
852856
id: number | string;
853857
key: string;

src/components/common/items/data-table/data-table.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ export class DataTable {
9999
@Prop() data: Array<any> = [];
100100
@State() processedData: Array<any> = [];
101101
@Prop() showActions: boolean = false;
102+
@Prop() canEditRow: boolean = false;
103+
@Prop() canDeleteRow: boolean = false;
102104
@Prop() onEdit: (id: number | string, changes: Array<{ prevValue: number | Date | string; newValue: number | Date | string; name: string }>) => Promise<any>;
103105
@Prop() onDelete: (index: number, row: { [field: string]: number | Date | string }) => Promise<any>;
104106
@Prop() onPaginate: (tcurrentPage: number, limit: number) => Promise<void>;
@@ -283,8 +285,8 @@ export class DataTable {
283285
if (!this.isEditing)
284286
return (
285287
<td class={`py-3 whitespace-nowrap text-sm text-gray-900 ${column.customStyle?.cellClass}`} style={{ cursor: 'auto', ...(column.customStyle?.cellStyle || {}) }}>
286-
{getEditingButton()}
287-
{getDeleteButton()}
288+
{getEditingButton(!this.canEditRow)}
289+
{getDeleteButton(!this.canDeleteRow)}
288290
</td>
289291
);
290292

src/components/common/items/data-table/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
| Property | Attribute | Description | Type | Default |
1111
| ---------------- | ----------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
12+
| `canDeleteRow` | `can-delete-row` | | `boolean` | `false` |
13+
| `canEditRow` | `can-edit-row` | | `boolean` | `false` |
1214
| `columns` | -- | | `{ id: string \| number; key: string; name: string; type: "string" \| "number" \| "date" \| "datetime"; prefix?: string; suffix?: string; maxChar?: number; decimal?: boolean; decimalPlaces?: number; seperator?: string; isSortable: boolean; isFilterable: boolean; isEditable: boolean; isDeletable: boolean; onSort?: (key: string) => Promise<void>; onFilter?: (column: any) => Promise<void>; onRowClick?: (id: string \| number, key: string, value: any) => Promise<void>; customColumnComponent?: (name: string) => any; customRowComponent?: (value: any) => any; customStyle?: { headerStyle?: { [index: string]: string \| number; }; headerClass?: string; cellStyle?: { [index: string]: string \| number; }; cellClass?: string; }; }[]` | `[]` |
1315
| `customClass` | `custom-class` | | `string` | `undefined` |
1416
| `customStyle` | -- | | `{ [style: string]: string \| number; }` | `undefined` |

src/components/editorPage/editor-page/editor-page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class EditorPage {
151151
<code-editor formatter={() => this.formatter()} onClickRun={this.onClickRun} fetchNavigators={this.fetchNavigators} permissions={this.permissions}></code-editor>
152152
{state.isFetchedData && state.nodes.length === 0 && !state.isLoading && !state.isError && (
153153
<div class="flex items-center bg-gray-500 text-white text-sm font-bold px-4 py-3" role="alert">
154-
<p>No Data Found in Database</p>
154+
<p>Nothing returned from the database.</p>
155155
</div>
156156
)}
157157
{state.nodes.length > 0 && !state.isLoading && !state.isError && <tab-component permissions={this.permissions}></tab-component>}

src/components/editorPage/editor-res/editor-res.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ export class EditorRes {
4949
@State() isFilterKey: string = null;
5050
@State() type: string = null;
5151
@State() isModalOpen: boolean = false;
52+
@State() canEditRow: boolean = false;
53+
@State() canDeleteRow: boolean = false;
5254

5355
componentWillLoad() {
5456
this.parsedPermissions = JSON.parse(this.permissions || '[]');
57+
this.canEditRow = hasAccess(this.parsedPermissions, { name: 'editor', permission: 'update' })
58+
this.canDeleteRow = hasAccess(this.parsedPermissions, { name: 'editor', permission: 'delete' })
5559
}
5660

5761
removeSortChip = item => {
@@ -156,6 +160,8 @@ export class EditorRes {
156160
columns={columns}
157161
data={state.nodes}
158162
showActions={state.canEdit && !state.isCustomQuery}
163+
canEditRow={this.canEditRow}
164+
canDeleteRow={this.canDeleteRow}
159165
showPagination={!state.isCustomQuery}
160166
total={state.total}
161167
limit={state.limit}

src/components/editorPage/tab-component/tab-component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class TabComponent {
2828
Showing results for <strong>{state.selectedNodeName !== null ? state.selectedNodeName : 'Custom Query'}</strong>
2929
</p>
3030

31-
<div class="flex justify-between border-b border-gray-200 ">
31+
<div class="flex justify-between border-b border-gray-200">
3232
<ul class="flex flex-wrap -mb-px text-sm font-medium text-center text-gray-500">
3333
<li class="mr-2">
3434
<button

src/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<!-- <editor-res></editor-res> -->
2828
<!-- <permission-editor url="http://localhost:3000/api/permissions" rolesurl="http://localhost:3000/api/permissions/all"></permission-editor> -->
2929
<!-- <tabs-component></tabs-component> -->
30-
<!-- <editor-page url="http://localhost:3000/api/editor"></editor-page> -->
30+
<editor-page url="http://localhost:3000/api/editor"></editor-page>
3131
<!-- <query-logs ></query-logs> -->
3232
<!-- <navigators-component></navigators-component> -->
3333
<!-- <users-component></users-component> -->
@@ -48,7 +48,7 @@
4848
<!-- <reset-component url="abcd" apiurl="dsfdsfdfdsfd" email="durga@tv.com"></reset-component> -->
4949
<!-- <login-form></login-form> -->
5050
</fluid-container>
51-
<banner-component></banner-component>
51+
<!-- <banner-component></banner-component> -->
5252
</div>
5353
</body>
5454

0 commit comments

Comments
 (0)