Skip to content

Commit

Permalink
pick existing on array
Browse files Browse the repository at this point in the history
  • Loading branch information
acoreyj committed Apr 9, 2024
1 parent 54005e3 commit e7b89e6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion public/js/form-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ async function pickFileEventHandler(cb) {
if (filesResponse) {
const chooseFileButtons =
fileModal._dialog.querySelectorAll('.choose-file-btn');
console.log('chooseFileButtons', chooseFileButtons);
chooseFileButtons.forEach((btn) => {
let newButton = btn.cloneNode(true);
newButton.addEventListener('click', () => {
console.log('file clicked', newButton.getAttribute('data-file'));
const file = newButton.getAttribute('data-file');
cb(file);
});
Expand Down Expand Up @@ -491,12 +493,22 @@ function setupFilePreviews(fileFields, form) {
}
}
function handleCustomEvent(event, uppy, form) {
console.log({ event });
if (event.component.attributes.key === 'upload') {
chooseFileEventHandler(uppy, event);
} else if (event.component.attributes.key === 'pick') {
pickFileEventHandler((v) => {
const field = event.component.attributes['data-field'];
const component = form.getComponent(field);
let component = form.getComponent(field);
console.log({ component });
if (component.component.type === 'datagrid') {
let tr = event.event.target;
while (tr.tagName !== 'TR') {
tr = tr.parentElement;
}
const textInput = tr.querySelector('input[type="text"]');
component = form.getComponentById(textInput.id.split('-')[0]);
}
component.setValue(v);
fileModal.hide();
});
Expand Down

0 comments on commit e7b89e6

Please sign in to comment.