Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/components/file/src/js/file.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export default class {
const hasTypeError = !acceptedTypes.some((acceptedType) => {
const [type, extension] = acceptedType.split('/');
if (extension) {
const isTypeValid = type === '*' || type.toLowerCase() === fileType.toLowerCase();
const isExtensionValid = extension === '*' || extension.toLowerCase() === fileExtension.toLowerCase();
const isTypeValid = type === '*' || type.toLowerCase() === fileType?.toLowerCase();
const isExtensionValid = extension === '*' || extension.toLowerCase() === fileExtension?.toLowerCase();
return isTypeValid && isExtensionValid;
}
return type === '*' || type.replace('.', '').toLowerCase() === fileExtension.toLowerCase();
return type === '*' || type.replace('.', '').toLowerCase() === fileExtension?.toLowerCase();
});
if (hasTypeError) {
file.errors.type = true;
Expand Down
8 changes: 6 additions & 2 deletions packages/components/file/src/js/file.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@
<span class="oui-file-ellipsis__size" ng-bind="file.infos.size"></span>
</span>
<span class="oui-file-attachments__error"
ng-if="file.errors && file.errors.maxsize"
ng-if="file.errors.maxsizeError"
ng-bind="::$ctrl.translations.maxsizeError">
</span>
<span class="oui-file-attachments__error"
ng-if="file.errors && file.errors.notSingle"
ng-if="file.errors.type"
ng-bind="::$ctrl.translations.typeError">
</span>
<span class="oui-file-attachments__error"
ng-if="file.errors.notSingle"
ng-bind="::$ctrl.translations.notSingleError">
</span>
</span>
Expand Down
1 change: 1 addition & 0 deletions packages/components/file/src/js/file.provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default class {
maxsizeError: 'This file exceeds the size limit',
notSingleError: 'You can only add one file',
removeFile: 'Remove file from selector',
typeError: 'This file extension is not supported',
};

this.units = [
Expand Down