feat: add parent name column in excel export

This commit is contained in:
Enishowk 2021-05-07 18:54:59 +02:00
parent 62150ce6c4
commit 3ee0add6f6

View file

@ -235,7 +235,7 @@ export class ExporterExcel {
}, },
{ {
key: 'b', key: 'b',
width: 20, width: 40,
}, },
{ {
key: 'c', key: 'c',
@ -243,25 +243,11 @@ export class ExporterExcel {
}, },
{ {
key: 'd', key: 'd',
width: 20, width: 40,
style: {
font: {
name: TAPi18n.__('excel-font'),
size: '10',
},
numFmt: 'yyyy/mm/dd hh:mm:ss',
},
}, },
{ {
key: 'e', key: 'e',
width: 20, width: 20,
style: {
font: {
name: TAPi18n.__('excel-font'),
size: '10',
},
numFmt: 'yyyy/mm/dd hh:mm:ss',
},
}, },
{ {
key: 'f', key: 'f',
@ -321,6 +307,13 @@ export class ExporterExcel {
{ {
key: 'k', key: 'k',
width: 20, width: 20,
style: {
font: {
name: TAPi18n.__('excel-font'),
size: '10',
},
numFmt: 'yyyy/mm/dd hh:mm:ss',
},
}, },
{ {
key: 'l', key: 'l',
@ -346,6 +339,10 @@ export class ExporterExcel {
key: 'q', key: 'q',
width: 20, width: 20,
}, },
{
key: 'r',
width: 20,
},
]; ];
//add title line //add title line
@ -430,7 +427,7 @@ export class ExporterExcel {
size: 10, size: 10,
bold: true, bold: true,
}; };
ws.mergeCells('F3:Q3'); ws.mergeCells('F3:R3');
ws.getCell('B3').style = { ws.getCell('B3').style = {
font: { font: {
name: TAPi18n.__('excel-font'), name: TAPi18n.__('excel-font'),
@ -509,6 +506,7 @@ export class ExporterExcel {
TAPi18n.__('number'), TAPi18n.__('number'),
TAPi18n.__('title'), TAPi18n.__('title'),
TAPi18n.__('description'), TAPi18n.__('description'),
TAPi18n.__('parent-card'),
TAPi18n.__('owner'), TAPi18n.__('owner'),
TAPi18n.__('createdAt'), TAPi18n.__('createdAt'),
TAPi18n.__('last-modified-at'), TAPi18n.__('last-modified-at'),
@ -542,6 +540,7 @@ export class ExporterExcel {
allBorder('O5'); allBorder('O5');
allBorder('P5'); allBorder('P5');
allBorder('Q5'); allBorder('Q5');
allBorder('R5');
cellCenter('A5'); cellCenter('A5');
cellCenter('B5'); cellCenter('B5');
cellCenter('C5'); cellCenter('C5');
@ -559,6 +558,7 @@ export class ExporterExcel {
cellCenter('O5'); cellCenter('O5');
cellCenter('P5'); cellCenter('P5');
cellCenter('Q5'); cellCenter('Q5');
cellCenter('R5');
ws.getRow(5).font = { ws.getRow(5).font = {
name: TAPi18n.__('excel-font'), name: TAPi18n.__('excel-font'),
size: 12, size: 12,
@ -586,6 +586,11 @@ export class ExporterExcel {
jclabel += jlabel[jcard.labelIds[jl]]; jclabel += jlabel[jcard.labelIds[jl]];
jclabel += ' '; jclabel += ' ';
} }
//get parent name
if (jcard.parentId) {
const parent = result.cards.find(card => card._id === jcard.parentId);
jcard.parentName = parent ? parent.title : '';
}
//add card detail //add card detail
const t = Number(i) + 1; const t = Number(i) + 1;
@ -593,6 +598,7 @@ export class ExporterExcel {
t.toString(), t.toString(),
jcard.title, jcard.title,
jcard.description, jcard.description,
jcard.parentName,
jmeml[jcard.userId], jmeml[jcard.userId],
addTZhours(jcard.createdAt), addTZhours(jcard.createdAt),
addTZhours(jcard.dateLastActivity), addTZhours(jcard.dateLastActivity),
@ -627,6 +633,7 @@ export class ExporterExcel {
allBorder(`O${y}`); allBorder(`O${y}`);
allBorder(`P${y}`); allBorder(`P${y}`);
allBorder(`Q${y}`); allBorder(`Q${y}`);
allBorder(`R${y}`);
cellCenter(`A${y}`); cellCenter(`A${y}`);
ws.getCell(`B${y}`).alignment = { ws.getCell(`B${y}`).alignment = {
wrapText: true, wrapText: true,
@ -634,15 +641,15 @@ export class ExporterExcel {
ws.getCell(`C${y}`).alignment = { ws.getCell(`C${y}`).alignment = {
wrapText: true, wrapText: true,
}; };
ws.getCell(`L${y}`).alignment = {
wrapText: true,
};
ws.getCell(`M${y}`).alignment = { ws.getCell(`M${y}`).alignment = {
wrapText: true, wrapText: true,
}; };
ws.getCell(`N${y}`).alignment = { ws.getCell(`N${y}`).alignment = {
wrapText: true, wrapText: true,
}; };
ws.getCell(`O${y}`).alignment = {
wrapText: true,
};
} }
workbook.xlsx.write(res).then(function() {}); workbook.xlsx.write(res).then(function() {});
} }