Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metadata update function catch case fixes #6559 #6571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
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 || '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why check the existence of an element on your own static form?
I'm just not a fan of overly secure programming (just checking for the sake of checking). 😅


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
Loading