mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
caf830db08
Summary: Adds a new Record Card view section to each non-summary table, which can be from opened from various parts of the Grist UI to view and edit records in a popup card view. Work is still ongoing, so the feature is locked away behind a flag; follow-up work is planned to finish up the implementation and add end-to-end tests. Test Plan: Python and server tests. Browser tests will be included in a follow-up. Reviewers: jarek, paulfitz Reviewed By: jarek Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D4114
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { allCommands } from 'app/client/components/commands';
|
|
import { makeT } from 'app/client/lib/localization';
|
|
import { menuDivider, menuItemCmd } from 'app/client/ui2018/menus';
|
|
import { dom } from 'grainjs';
|
|
|
|
const t = makeT('CardContextMenu');
|
|
|
|
export interface ICardContextMenu {
|
|
disableInsert: boolean;
|
|
disableDelete: boolean;
|
|
isViewSorted: boolean;
|
|
numRows: number;
|
|
}
|
|
|
|
export function CardContextMenu({
|
|
disableInsert,
|
|
disableDelete,
|
|
isViewSorted,
|
|
numRows
|
|
}: ICardContextMenu) {
|
|
const result: Element[] = [];
|
|
if (isViewSorted) {
|
|
result.push(
|
|
menuItemCmd(allCommands.insertRecordAfter, t("Insert card"),
|
|
dom.cls('disabled', disableInsert)),
|
|
);
|
|
} else {
|
|
result.push(
|
|
menuItemCmd(allCommands.insertRecordBefore, t("Insert card above"),
|
|
dom.cls('disabled', disableInsert)),
|
|
menuItemCmd(allCommands.insertRecordAfter, t("Insert card below"),
|
|
dom.cls('disabled', disableInsert)),
|
|
);
|
|
}
|
|
result.push(
|
|
menuItemCmd(allCommands.duplicateRows, t("Duplicate card"),
|
|
dom.cls('disabled', disableInsert || numRows === 0)),
|
|
);
|
|
result.push(
|
|
menuDivider(),
|
|
menuItemCmd(allCommands.deleteRecords, t("Delete card"),
|
|
dom.cls('disabled', disableDelete)),
|
|
);
|
|
result.push(
|
|
menuDivider(),
|
|
menuItemCmd(allCommands.copyLink, t("Copy anchor link"))
|
|
);
|
|
return result;
|
|
}
|