Skip to content

Commit 107436a

Browse files
CB-6181 fix: show save/cancel buttons in json docs (#3222)
* CB-6181 fix: show save/cancel buttons in json docs * CB-6181 refactor: change condition for SAVE/CANCEL buttons The problem is that for select 1 in TE we get different result from other product, because in CE/EE we use ResultSetFooterMenuService, while for TE we use regular TableFooterMenuService. model.source.isReadOnly flag doesn't return true anymore since we extracted hasRowIdentifier flag from it, so we get redundant buttons in tables like that in TE. Since the only difference is products where we are executing this script, it's quite hard to detect it inside a component. I decided to check editor's features, they are empty in this case (select 1) in all products, so we can be 100% sure that if there are no features, we don't need any buttons. The other problem that for Document type of data format we also don't have features (and we use the same footer menu service). If it's not read-only, we need to have those buttons to save/cancel edits. The first solution is to check data format is Document (or check the editor type or to try get action with needed type). The other solution that I used is to check hasRowIdentifier flag(hasElementIdentifier) because editable documents will have it true, while datasets like select 1 don't have them. It looks more generic for me and should work in more cases in future * СB-6181 refactor: update isReadonly flag for resultset --------- Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com>
1 parent 4388491 commit 107436a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

webapp/packages/plugin-data-viewer/src/ResultSet/ResultSetDataSource.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ export abstract class ResultSetDataSource<TOptions = IDatabaseDataOptions> exten
3939
}
4040

4141
override isReadonly(resultIndex: number): boolean {
42-
return super.isReadonly(resultIndex) || !this.executionContext?.context;
42+
return (
43+
super.isReadonly(resultIndex) ||
44+
!this.executionContext?.context ||
45+
!!this.getResult(resultIndex)?.data?.columns?.every(column => column.readOnly)
46+
);
4347
}
4448

4549
override async cancel(): Promise<void> {

webapp/packages/plugin-data-viewer/src/TableViewer/TableFooter/TableFooterMenu/TableFooterMenuService.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ export class TableFooterMenuService {
8282
case ACTION_REVERT: {
8383
return editor.hasFeature('revert');
8484
}
85-
case ACTION_SAVE:
86-
case ACTION_CANCEL: {
87-
return editor.hasFeature('add') || editor.hasFeature('delete') || editor.hasFeature('revert');
88-
}
8985
}
9086
return true;
9187
},

0 commit comments

Comments
 (0)