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

Add button to reset metadata in metadata editor #5604

Merged
merged 3 commits into from
Aug 27, 2024
Merged
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
40 changes: 40 additions & 0 deletions src/components/metadataEditor/metadataEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,44 @@ function bindAll(elems, eventName, fn) {
}
}

function onResetClick() {
const resetElementId = ['#txtName', '#txtOriginalName', '#txtSortName', '#txtCommunityRating', '#txtCriticRating', '#txtIndexNumber',
'#txtAirsBeforeSeason', '#txtAirsAfterSeason', '#txtAirsBeforeEpisode', '#txtParentIndexNumber', '#txtAlbum',
'#txtAlbumArtist', '#txtArtist', '#txtOverview', '#selectStatus', '#txtAirTime', '#txtPremiereDate', '#txtDateAdded', '#txtEndDate',
'#txtProductionYear', '#selectHeight', '#txtOriginalAspectRatio', '#select3dFormat', '#selectOfficialRating', '#selectCustomRating',
'#txtSeriesRuntime', '#txtTagline'];
const form = currentContext?.querySelector('form');
resetElementId.forEach(function (id) {
form.querySelector(id).value = null;
});
form.querySelector('#selectDisplayOrder').value = '';
form.querySelector('#selectLanguage').value = '';
form.querySelector('#selectCountry').value = '';
form.querySelector('#listGenres').innerHTML = '';
form.querySelector('#listTags').innerHTML = '';
form.querySelector('#listStudios').innerHTML = '';
form.querySelector('#peopleList').innerHTML = '';
currentItem.People = [];

const checkedItems = form.querySelectorAll('.chkAirDay:checked') || [];
checkedItems.forEach(function (checkbox) {
checkbox.checked = false;
});

const idElements = form.querySelectorAll('.txtExternalId');
idElements.forEach(function (idElem) {
idElem.value = null;
});

form.querySelector('#chkLockData').checked = false;
showElement('.providerSettingsContainer');

const lockedFields = form.querySelectorAll('.selectLockedField');
lockedFields.forEach(function (checkbox) {
checkbox.checked = true;
});
}

function init(context) {
if (!layoutManager.desktop) {
context.querySelector('.btnBack').classList.remove('hide');
Expand Down Expand Up @@ -334,6 +372,8 @@ function init(context) {
form.removeEventListener('submit', onSubmit);
form.addEventListener('submit', onSubmit);

context.querySelector('.btnReset').addEventListener('click', onResetClick);

context.querySelector('#btnAddPerson').addEventListener('click', function () {
editPerson(context, {}, -1);
});
Expand Down
3 changes: 3 additions & 0 deletions src/components/metadataEditor/metadataEditor.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ <h2>${HeaderMetadataSettings}</h2>
<button is="emby-button" type="button" class="raised button-cancel block btnCancel formDialogFooterItem">
<span>${ButtonCancel}</span>
</button>
<button is="emby-button" type="button" class="raised button-reset block btnReset formDialogFooterItem">
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure if should be in a diff colour than the other 2 btns.

<span>${Reset}</span>
</button>
<button is="emby-button" type="submit" class="raised button-submit block btnSave formDialogFooterItem">
<span>${SaveChanges}</span>
</button>
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 @@ -1365,6 +1365,7 @@
"RepeatOne": "Repeat one",
"ReplaceAllMetadata": "Replace all metadata",
"ReplaceExistingImages": "Replace existing images",
"Reset": "Reset",
"ResetPassword": "Reset Password",
"ResolutionMatchSource": "Match Source",
"Restart": "Restart",
Expand Down
Loading