Skip to content

Commit

Permalink
show validation errors on saving recording
Browse files Browse the repository at this point in the history
  • Loading branch information
hinanaya committed Jun 14, 2024
1 parent d7428bb commit 9bfd088
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ui/fields/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class OBFieldMedia extends OBField {
}
</div>
${(this.#mediaItems.length === 0 && this.dataset.hasOwnProperty('single') && this.dataset.hasOwnProperty('record')) && html`
<div id="validation-error" class="hidden"></div>
<div id="input-container">
<ob-field-input-device data-edit></ob-field-input-device>
</div>
Expand Down Expand Up @@ -286,6 +287,17 @@ class OBFieldMedia extends OBField {
ob-field-input-device {
width: 100%;
}
#validation-error {
color: #f33;
font-size: 14px;
width: 100%;
vertical-align: center;
&.hidden {
display: none;
}
}
}
`;
}
Expand Down Expand Up @@ -529,8 +541,14 @@ class OBFieldMedia extends OBField {
});
media.then((data) => {
if (! data.status) {
console.error(data.msg);
let error = data.data.reduce((errMsg, elem) => {
return errMsg + elem[2] + ' ';
}, '');

this.root.querySelector('#validation-error').classList.remove('hidden');
this.root.querySelector('#validation-error').innerText = error;
} else {
this.root.querySelector('#validation-error').classList.add('hidden');
this.value = data.data;
}
});
Expand Down

0 comments on commit 9bfd088

Please sign in to comment.