[go: nahoru, domu]

Skip to content

Commit

Permalink
feat(InsertSheetCommand): allow using partial sheet from params as sh…
Browse files Browse the repository at this point in the history
…eetconfig (#2429)

* feat(InsertSheetCommand): allow using partial sheet from params as sheetconfig

* style: format
  • Loading branch information
a1yamino committed Jun 5, 2024
1 parent ed39371 commit ce85854
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/sheets/src/commands/commands/insert-sheet.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ export const InsertSheetCommand: ICommand = {

const { unitId, workbook } = target;
let index = workbook.getSheets().length;
let sheetConfig = mergeWorksheetSnapshotWithDefault({});
const sheet = params?.sheet;
const sheetId = sheet?.id;
const sheetConfig = mergeWorksheetSnapshotWithDefault(sheet || {});

if (params) {
index = params.index ?? index;
if (params.sheet) {
sheetConfig = params.sheet;
} else {
sheetConfig.id = Tools.generateRandomId();
sheetConfig.name = workbook.generateNewSheetName(`${localeService.t('sheets.tabs.sheet')}`);
}
sheetConfig.id = sheetId || Tools.generateRandomId();
sheetConfig.name = sheet?.name || workbook.generateNewSheetName(`${localeService.t('sheets.tabs.sheet')}`);
} else {
sheetConfig.id = Tools.generateRandomId();
sheetConfig.name = workbook.generateNewSheetName(`${localeService.t('sheets.tabs.sheet')}`);
Expand Down

0 comments on commit ce85854

Please sign in to comment.