Skip to content

Commit 1057dfd

Browse files
committed
Basic changes Excel export.
1 parent 85d3c38 commit 1057dfd

3 files changed

Lines changed: 67 additions & 12 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Dates should be in`YYYY-MM-DD` format and versions are in [semantic versioning](
1212
### Added
1313

1414
- Check for duplicates on new process creation.
15+
- Basic changes Excel export.
1516

1617
## v0.8.1
1718

src/routes/org/[orgid]/export/+page.svelte

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
const hows = $derived(data.hows);
1515
const assignments = $derived(data.assignments);
1616
const profiles = $derived(data.profiles);
17+
const changes = $derived(data.changes);
1718
1819
function howToString(how: HowRow, depth = 0): string {
1920
return `\n${'\t'.repeat(depth)}${depth > 0 ? '' : ''} ${how.what}${how.how.map((id) => {
@@ -24,7 +25,7 @@
2425
}
2526
2627
async function exportOrg() {
27-
const headers = [
28+
const processHeaders = [
2829
{
2930
value: 'Process',
3031
fontWeight: 'bold' as const
@@ -71,15 +72,64 @@
7172
];
7273
});
7374
74-
const data: SheetData = [headers, ...processRows];
75-
await writeXlsxFile(data, {
75+
const processData: SheetData = [processHeaders, ...processRows];
76+
77+
const changeHeaders = [
78+
{
79+
value: 'What',
80+
fontWeight: 'bold' as const
81+
},
82+
{
83+
value: 'Status',
84+
fontWeight: 'bold' as const
85+
},
86+
{
87+
value: 'Visiblity',
88+
fontWeight: 'bold' as const
89+
},
90+
{
91+
value: 'Description',
92+
fontWeight: 'bold' as const
93+
},
94+
{
95+
value: 'Proposal',
96+
fontWeight: 'bold' as const
97+
},
98+
{
99+
value: 'Lead',
100+
fontWeight: 'bold' as const
101+
}
102+
];
103+
104+
const changesRows = changes.map((change) => {
105+
return [
106+
{ value: change.what, wrap: true, alignVertical: 'top' as const },
107+
{ value: change.status, wrap: true, alignVertical: 'top' as const },
108+
{ value: change.visibility, wrap: true, alignVertical: 'top' as const },
109+
{ value: change.description, wrap: true, alignVertical: 'top' as const },
110+
{ value: change.proposal, wrap: true, alignVertical: 'top' as const },
111+
{
112+
value: profiles.find((profile) => profile.id === change.lead)?.name || '',
113+
wrap: true,
114+
alignVertical: 'top' as const
115+
}
116+
];
117+
});
118+
119+
const changeData: SheetData = [changeHeaders, ...changesRows];
120+
121+
await writeXlsxFile([processData, changeData], {
76122
columns: [
77-
{ width: 30 },
78-
{ width: 60 },
79-
...roles.map(() => {
80-
return { width: 3 };
81-
})
123+
[
124+
{ width: 30 },
125+
{ width: 60 },
126+
...roles.map(() => {
127+
return { width: 3 };
128+
})
129+
],
130+
[{ width: 30 }, { width: 60 }, { width: 60 }, { width: 20 }]
82131
],
132+
sheets: ['processes', 'changes'],
83133
fileName: 'export.xlsx'
84134
});
85135
}

src/routes/org/[orgid]/export/+page.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@ export async function load({ parent }) {
99
{ data: processes },
1010
{ data: hows },
1111
{ data: assignments },
12-
{ data: profiles }
12+
{ data: profiles },
13+
{ data: changes }
1314
] = await Promise.all([
1415
Organization.queryRoles(supabase, org.id),
1516
Organization.queryProcesses(supabase, org.id),
1617
Organization.queryHows(supabase, org.id),
1718
Organization.queryAssignments(supabase, org.id),
18-
Organization.queryProfiles(supabase, org.id)
19+
Organization.queryProfiles(supabase, org.id),
20+
Organization.queryChanges(supabase, org.id)
1921
]);
2022

2123
if (
2224
roles === null ||
2325
processes === null ||
2426
hows === null ||
2527
assignments === null ||
26-
profiles === null
28+
profiles === null ||
29+
changes === null
2730
)
2831
error(404, {
2932
message: 'Unable to retrieve data to export this organization.'
@@ -34,6 +37,7 @@ export async function load({ parent }) {
3437
processes,
3538
hows,
3639
assignments,
37-
profiles
40+
profiles,
41+
changes
3842
};
3943
}

0 commit comments

Comments
 (0)