Skip to content

Commit

Permalink
metadata update function catch case
Browse files Browse the repository at this point in the history
  • Loading branch information
jagadam97 committed Feb 23, 2025
1 parent 7904bdd commit ae4e64d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/components/metadataEditor/metadataEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,32 @@ function closeDialog() {
}
}

function submitUpdatedItem(form, item) {
function afterContentTypeUpdated() {
async function submitUpdatedItem(form, item) {
const afterContentTypeUpdated = () => {
toast(globalize.translate('MessageItemSaved'));

loading.hide();
closeDialog();
}

};
const apiClient = getApiClient();

apiClient.updateItem(item).then(function () {
const newContentType = form.querySelector('#selectContentType').value || '';
try {
await apiClient.updateItem(item);
const newContentType = form.querySelector('#selectContentType')?.value || '';

if ((metadataEditorInfo.ContentType || '') !== newContentType) {
apiClient.ajax({
await apiClient.ajax({
url: apiClient.getUrl(`Items/${item.Id}/ContentType`, {
ContentType: newContentType
}),

url: apiClient.getUrl('Items/' + item.Id + '/ContentType', {
ContentType: newContentType
}),

type: 'POST'
type: 'POST'
});

}).then(function () {
afterContentTypeUpdated();
});
} else {
afterContentTypeUpdated();
}
});
afterContentTypeUpdated();
} catch {
toast(globalize.translate('MessageItemSaveFailed'));
loading.hide();
}
}

function getSelectedAirDays(form) {
Expand Down
1 change: 1 addition & 0 deletions src/strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@
"MessageInvalidUser": "Invalid username or password. Please try again.",
"MessageItemsAdded": "Items added.",
"MessageItemSaved": "Item saved.",
"MessageItemSaveFailed": "Failed to save item",
"MessageLeaveEmptyToInherit": "Leave empty to inherit settings from a parent item or the global default value.",
"MessageNoItemsAvailable": "No Items are currently available.",
"MessageNoFavoritesAvailable": "No favorites are currently available.",
Expand Down

0 comments on commit ae4e64d

Please sign in to comment.