Add renaming of profiles + use alphabetical sorting
This commit is contained in:
parent
5b4d524bc0
commit
583cc4b097
|
@ -335,7 +335,7 @@ function renderConnectionProfiles(profiles) {
|
|||
noneOption.selected = !extension_settings.connectionManager.selectedProfile;
|
||||
profiles.appendChild(noneOption);
|
||||
|
||||
for (const profile of extension_settings.connectionManager.profiles) {
|
||||
for (const profile of extension_settings.connectionManager.profiles.sort((a, b) => a.name.localeCompare(b.name))) {
|
||||
const option = document.createElement('option');
|
||||
option.value = profile.id;
|
||||
option.textContent = profile.name;
|
||||
|
@ -472,6 +472,31 @@ async function renderDetailsContent(detailsContent) {
|
|||
await eventSource.emit(event_types.CONNECTION_PROFILE_LOADED, NONE);
|
||||
});
|
||||
|
||||
const renameButton = document.getElementById('rename_connection_profile');
|
||||
renameButton.addEventListener('click', async () => {
|
||||
const selectedProfile = extension_settings.connectionManager.selectedProfile;
|
||||
const profile = extension_settings.connectionManager.profiles.find(p => p.id === selectedProfile);
|
||||
if (!profile) {
|
||||
console.log('No profile selected');
|
||||
return;
|
||||
}
|
||||
|
||||
const newName = await Popup.show.input('Enter a new name', null, profile.name, { rows: 2 });
|
||||
if (!newName) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (extension_settings.connectionManager.profiles.some(p => p.name === newName)) {
|
||||
toastr.error('A profile with the same name already exists.');
|
||||
return;
|
||||
}
|
||||
|
||||
profile.name = newName;
|
||||
saveSettingsDebounced();
|
||||
renderConnectionProfiles(profiles);
|
||||
toastr.success('Connection profile renamed', '', { timeOut: 1500 });
|
||||
});
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
const viewDetails = document.getElementById('view_connection_profile');
|
||||
const detailsContent = document.getElementById('connection_profile_details_content');
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<i id="view_connection_profile" class="menu_button fa-solid fa-info-circle" title="View connection profile details" data-i18n="[title]View connection profile details"></i>
|
||||
<i id="create_connection_profile" class="menu_button fa-solid fa-file-circle-plus" title="Create a new connection profile" data-i18n="[title]Create a new connection profile"></i>
|
||||
<i id="update_connection_profile" class="menu_button fa-solid fa-save" title="Update a connection profile" data-i18n="[title]Update a connection profile"></i>
|
||||
<i id="rename_connection_profile" class="menu_button fa-solid fa-pencil" title="Rename a connection profile" data-i18n="[title]Rename a connection profile"></i>
|
||||
<i id="reload_connection_profile" class="menu_button fa-solid fa-recycle" title="Reload a connection profile" data-i18n="[title]Reload a connection profile"></i>
|
||||
<i id="delete_connection_profile" class="menu_button fa-solid fa-trash-can" title="Delete a connection profile" data-i18n="[title]Delete a connection profile"></i>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue