Skip to content

Commit 4fcc423

Browse files
authored
fix picture validation error on upload (#5078)
* fix picture validation error on upload it wasn't using picture profile schema when validating so it was missing info on extra fields. SDANSA-564 * disable upload when loading schema * fix lint
1 parent 1a28926 commit 4fcc423

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/apps/search/MultiImageEdit.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface IScope extends ng.IScope {
1717
metadata: any;
1818
save: any;
1919
close: any;
20+
schemaLoading: boolean;
2021
getSelectedImages(): Array<any>;
2122
saveHandler(images): Promise<void>;
2223
successHandler?(): void;
@@ -134,6 +135,18 @@ export function MultiImageEditController(
134135
getLabelForFieldId = _getLabelForFieldId;
135136
});
136137

138+
let schema = {};
139+
140+
$scope.schemaLoading = true;
141+
142+
content.getType('picture').then((pictureSchema) => {
143+
schema = pictureSchema;
144+
}, (error) => {
145+
logger.warn('Failed to load picture schema', error);
146+
}).finally(() => {
147+
$scope.schemaLoading = false;
148+
});
149+
137150
$scope.save = (close) => {
138151
const imagesForSaving = angular.copy($scope.images);
139152

@@ -146,7 +159,7 @@ export function MultiImageEditController(
146159
validateMediaFieldsThrows(
147160
$scope.validator,
148161
metadata,
149-
content.schema({}, 'picture'),
162+
content.schema(schema, 'picture'),
150163
getLabelForFieldId);
151164
});
152165
} catch (e) {

scripts/apps/search/views/multi-image-edit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h3 class="modal__heading modal__heading--grow" translate>Upload media</h3>
1414
<div class="modal__header-buttons modal__header-buttons--right">
1515
<button class="btn btn--hollow" ng-click="close()" ng-disabled="uploadInProgress" translate>Cancel</button>
1616
<div ng-transclude="select-desk"></div>
17-
<button class="btn btn--primary btn--hollow" ng-click="save(true)" ng-disabled="!images.length" translate data-test-id="multi-image-edit--start-upload">Upload</button>
17+
<button class="btn btn--primary btn--hollow" ng-click="save(true)" ng-disabled="!images.length || schemaLoading === true" translate data-test-id="multi-image-edit--start-upload">Upload</button>
1818
</div>
1919
</div>
2020

0 commit comments

Comments
 (0)