Skip to content

Commit 75e6548

Browse files
committed
fix(esigner-api,esigner): show only explicit signing containers in eSigner list, not all files from File Manager
- esigner-api: getDocumentsWithStatus(userId, listMode). list=containers (default): only files with at least one signee; list=all: all owner/invited files - FileController.getFiles: read query param list=all and pass listMode - esigner new container page: load selectable files via GET /api/files?list=all into local state so picker shows any file; main list unchanged (containers only)
1 parent 1ad1039 commit 75e6548

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

platforms/esigner-api/src/controllers/FileController.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export class FileController {
6161
return res.status(401).json({ error: "Authentication required" });
6262
}
6363

64-
const documents = await this.fileService.getDocumentsWithStatus(req.user.id);
64+
const list = req.query.list as string | undefined;
65+
const listMode = list === "all" ? "all" : "containers";
66+
const documents = await this.fileService.getDocumentsWithStatus(req.user.id, listMode);
6567
res.json(documents);
6668
} catch (error) {
6769
console.error("Error getting documents:", error);

platforms/esigner-api/src/services/FileService.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ export class FileService {
100100
return allFiles;
101101
}
102102

103-
async getDocumentsWithStatus(userId: string) {
103+
async getDocumentsWithStatus(userId: string, listMode: 'containers' | 'all' = 'containers') {
104104
const files = await this.getUserFiles(userId);
105-
105+
106106
// Ensure we have all relations loaded
107107
const filesWithRelations = await Promise.all(
108108
files.map(async (file) => {
@@ -117,7 +117,13 @@ export class FileService {
117117
})
118118
);
119119

120-
return filesWithRelations.map(file => {
120+
// When listing only containers, exclude files that were never used as a signing container (no signees).
121+
// This prevents File Manager uploads from appearing as draft containers in eSigner.
122+
const toList = listMode === 'containers'
123+
? filesWithRelations.filter((f) => (f.signees?.length ?? 0) > 0)
124+
: filesWithRelations;
125+
126+
return toList.map(file => {
121127
const totalSignees = file.signees?.length || 0;
122128
const signedCount = file.signees?.filter(s => s.status === 'signed').length || 0;
123129
const pendingCount = file.signees?.filter(s => s.status === 'pending').length || 0;

platforms/esigner/src/routes/(protected)/files/new/+page.svelte

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { onMount } from 'svelte';
33
import { goto } from '$app/navigation';
44
import { isAuthenticated } from '$lib/stores/auth';
5-
import { files, fetchFiles, uploadFile } from '$lib/stores/files';
5+
import { uploadFile } from '$lib/stores/files';
66
import { apiClient } from '$lib/utils/axios';
77
import { inviteSignees } from '$lib/stores/invitations';
88
@@ -18,23 +18,31 @@
1818
let currentUserId = $state<string | null>(null);
1919
let displayName = $state('');
2020
let description = $state('');
21+
// All files available to select for a new container (includes File Manager–only uploads)
22+
let selectableFiles = $state<any[]>([]);
2123
2224
onMount(async () => {
2325
isAuthenticated.subscribe((auth) => {
2426
if (!auth) {
2527
goto('/auth');
2628
}
2729
});
28-
30+
2931
// Get current user ID from API
3032
try {
3133
const response = await apiClient.get('/api/users');
3234
currentUserId = response.data.id;
3335
} catch (err) {
3436
console.error('Failed to get current user:', err);
3537
}
36-
37-
fetchFiles();
38+
39+
// Load all files for picker (list=all) so user can select any file, including those not yet used as containers
40+
try {
41+
const res = await apiClient.get('/api/files', { params: { list: 'all' } });
42+
selectableFiles = res.data ?? [];
43+
} catch (err) {
44+
console.error('Failed to load selectable files:', err);
45+
}
3846
});
3947
4048
async function handleFileUpload(file: File) {
@@ -278,11 +286,11 @@
278286
<!-- Or Select Existing -->
279287
<div>
280288
<h3 class="text-lg font-semibold text-gray-900 mb-4">Or Select Existing File</h3>
281-
{#if $files.filter(file => !file.signatures || file.signatures.length === 0).length === 0}
289+
{#if selectableFiles.filter(file => !file.signatures || file.signatures.length === 0).length === 0}
282290
<p class="text-gray-600 text-center py-8">No unused files available</p>
283291
{:else}
284292
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 max-h-96 overflow-y-auto">
285-
{#each $files.filter(file => !file.signatures || file.signatures.length === 0) as file}
293+
{#each selectableFiles.filter(file => !file.signatures || file.signatures.length === 0) as file}
286294
<button
287295
onclick={() => {
288296
selectedFile = file;

0 commit comments

Comments
 (0)