mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-07 00:13:53 +00:00
chore: clarifying comments
This commit is contained in:
committed by
Alex Christoffer Rasmussen
parent
9e78ff4d1c
commit
9d6ec3758b
@@ -389,7 +389,7 @@ export async function upload(sheetId: string, options: ImportMap) {
|
||||
// update the corresponding row with event data
|
||||
rundown.order.forEach((entryId, index) => {
|
||||
const entry = rundown.entries[entryId];
|
||||
return updateRundown.push(cellRequestFromEvent(entry, index, worksheetId, sheetMetadata));
|
||||
updateRundown.push(cellRequestFromEvent(entry, index, worksheetId, sheetMetadata));
|
||||
});
|
||||
|
||||
const writeResponse = await sheets({ version: 'v4', auth: currentAuthClient }).spreadsheets.batchUpdate({
|
||||
|
||||
@@ -89,21 +89,19 @@ export function cellRequestFromEvent(
|
||||
worksheetId: number,
|
||||
metadata: object,
|
||||
): sheets_v4.Schema$Request {
|
||||
const rowData = Object.entries(metadata)
|
||||
.filter(([_, value]) => value !== undefined)
|
||||
.sort(([_a, a], [_b, b]) => a['col'] - b['col']) as [keyof OntimeEntry | 'blank', { col: number; row: number }][];
|
||||
|
||||
const titleCol = rowData[0][1].col;
|
||||
const rowData = Object.entries(metadata) // check what headings are available in the sheet
|
||||
.filter(([_, value]) => value !== undefined) // drop anything that is undefined
|
||||
.sort(([_a, a], [_b, b]) => a['col'] - b['col']) as [keyof OntimeEntry | 'blank', { col: number; row: number }][]; // sort the array by the column index
|
||||
|
||||
// inset blank data is there is spacing between relevant ontime columns
|
||||
for (const [index, e] of rowData.entries()) {
|
||||
if (index !== 0) {
|
||||
const prevCol = rowData[index - 1][1].col;
|
||||
const thisCol = e[1].col;
|
||||
const diff = thisCol - prevCol;
|
||||
if (diff > 1) {
|
||||
const fillArr = new Array<(typeof rowData)[0]>(1).fill(['blank', { row: e[1].row, col: prevCol + 1 }]);
|
||||
rowData.splice(index, 0, ...fillArr);
|
||||
}
|
||||
if (index === 0) continue;
|
||||
const prevCol = rowData[index - 1][1].col;
|
||||
const thisCol = e[1].col;
|
||||
const diff = thisCol - prevCol;
|
||||
if (diff > 1) {
|
||||
const fillArr = new Array<(typeof rowData)[0]>(1).fill(['blank', { row: e[1].row, col: prevCol + 1 }]);
|
||||
rowData.splice(index, 0, ...fillArr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,12 +127,14 @@ export function cellRequestFromEvent(
|
||||
return { ...getCellData(key, entry), ...cellColor };
|
||||
});
|
||||
|
||||
const headerLocation = rowData[0][1];
|
||||
|
||||
return {
|
||||
updateCells: {
|
||||
start: {
|
||||
sheetId: worksheetId,
|
||||
rowIndex: index + rowData[0][1]['row'] + 1,
|
||||
columnIndex: titleCol,
|
||||
rowIndex: index + headerLocation.row + 1,
|
||||
columnIndex: headerLocation.col,
|
||||
},
|
||||
fields: 'userEnteredValue,userEnteredFormat',
|
||||
rows: [
|
||||
|
||||
Reference in New Issue
Block a user