adding document when creating process takes a fileBlob type
This commit is contained in:
parent
6167d59501
commit
23a3b2a9e8
@ -32,11 +32,15 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
|
|||||||
storagesInput: HTMLInputElement;
|
storagesInput: HTMLInputElement;
|
||||||
validationRules: ValidationRule[];
|
validationRules: ValidationRule[];
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
type fileBlob = {
|
||||||
|
type: string,
|
||||||
|
data: Uint8Array
|
||||||
|
};
|
||||||
const nonRoleRowStates: {
|
const nonRoleRowStates: {
|
||||||
keyInput: HTMLInputElement,
|
keyInput: HTMLInputElement,
|
||||||
valueInput: HTMLInputElement,
|
valueInput: HTMLInputElement,
|
||||||
fileInput: HTMLInputElement,
|
fileInput: HTMLInputElement,
|
||||||
fileBlob: number[] | null
|
fileBlob: fileBlob | null
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
const inputStyle = 'flex: 1; height: 2.5rem; padding: 0.5rem; border: 1px solid #ccc; border-radius: 0.375rem;';
|
const inputStyle = 'flex: 1; height: 2.5rem; padding: 0.5rem; border: 1px solid #ccc; border-radius: 0.375rem;';
|
||||||
@ -92,8 +96,14 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
|
|||||||
fileInput.onchange = async () => {
|
fileInput.onchange = async () => {
|
||||||
const file = fileInput.files?.[0];
|
const file = fileInput.files?.[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
const buffer = await file.arrayBuffer();
|
const buffer = await file.arrayBuffer();
|
||||||
rowState.fileBlob = Array.from(new Uint8Array(buffer));
|
const uint8 = new Uint8Array(buffer);
|
||||||
|
|
||||||
|
rowState.fileBlob = {
|
||||||
|
type: file.type,
|
||||||
|
data: uint8,
|
||||||
|
};
|
||||||
|
|
||||||
valueInput.value = `📄 ${file.name}`;
|
valueInput.value = `📄 ${file.name}`;
|
||||||
valueInput.disabled = true;
|
valueInput.disabled = true;
|
||||||
@ -105,7 +115,6 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
|
|||||||
attachBtn.style.cssText = 'padding: 0.3rem 0.75rem; border: 1px solid #ccc; border-radius: 0.375rem; background: #f0f0f0; cursor: pointer;';
|
attachBtn.style.cssText = 'padding: 0.3rem 0.75rem; border: 1px solid #ccc; border-radius: 0.375rem; background: #f0f0f0; cursor: pointer;';
|
||||||
attachBtn.onclick = () => fileInput.click();
|
attachBtn.onclick = () => fileInput.click();
|
||||||
|
|
||||||
|
|
||||||
const keyInput = document.createElement('input');
|
const keyInput = document.createElement('input');
|
||||||
const valueInput = document.createElement('input');
|
const valueInput = document.createElement('input');
|
||||||
|
|
||||||
@ -113,7 +122,7 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
|
|||||||
keyInput,
|
keyInput,
|
||||||
valueInput,
|
valueInput,
|
||||||
fileInput,
|
fileInput,
|
||||||
fileBlob: null as File | null
|
fileBlob: null as fileBlob | null
|
||||||
};
|
};
|
||||||
nonRoleRowStates.push(rowState);
|
nonRoleRowStates.push(rowState);
|
||||||
|
|
||||||
@ -170,7 +179,7 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
const data: Record<string, string | Blob> = {};
|
const data: Record<string, string | fileBlob> = {};
|
||||||
for (const row of nonRoleRowStates) {
|
for (const row of nonRoleRowStates) {
|
||||||
const key = row.keyInput.value.trim();
|
const key = row.keyInput.value.trim();
|
||||||
if (!key) continue;
|
if (!key) continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user