Add Save and Update
| @@ -149,10 +149,12 @@ body.no-blur .popup[open]::backdrop { | ||
| 149 | 149 | box-shadow: 0 0 5px var(--white20a); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | +.menu_button.primary, | |
| 152 | 153 | .menu_button.popup-button-ok { |
| 153 | 154 | background-color: var(--crimson70a); |
| 154 | 155 | } |
| 155 | 156 | |
| 157 | +.menu_button.primary:hover, | |
| 156 | 158 | .menu_button.popup-button-ok:hover { |
| 157 | 159 | background-color: var(--crimson-hover); |
| 158 | 160 | } |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import { event_types, eventSource, main_api, saveSettingsDebounced } from '../../../script.js'; |
| 2 | 2 | import { extension_settings, renderExtensionTemplateAsync } from '../../extensions.js'; |
| 3 | 3 | import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from '../../popup.js'; |
| 4 | 4 | import { SlashCommand } from '../../slash-commands/SlashCommand.js'; |
| 5 | 5 | import { SlashCommandAbortController } from '../../slash-commands/SlashCommandAbortController.js'; |
| 6 | 6 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; |
| @@ -523,6 +523,7 @@ async function renderDetailsContent(detailsContent) { | ||
| 523 | 523 | profile.exclude = []; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | + let saveChanges = false; | |
| 526 | 527 | const commands = profile.mode === 'cc' ? CC_COMMANDS : TC_COMMANDS; |
| 527 | 528 | const settings = commands.reduce((acc, command) => { |
| 528 | 529 | const fancyName = FANCY_NAMES[command]; |
| @@ -530,7 +531,16 @@ async function renderDetailsContent(detailsContent) { | ||
| 530 | 531 | return acc; |
| 531 | 532 | }, {}); |
| 532 | 533 | const template = $(await renderExtensionTemplateAsync(MODULE_NAME, 'edit', { name: profile.name, settings })); |
| 533 | 534 | const newName = await callGenericPopup(template, POPUP_TYPE.INPUT, profile.name);, { |
| 535 | + customButtons: [{ | |
| 536 | + text: 'Save and Update', | |
| 537 | + classes: ['primary'], | |
| 538 | + result: POPUP_RESULT.AFFIRMATIVE, | |
| 539 | + action: () => { | |
| 540 | + saveChanges = true; | |
| 541 | + }, | |
| 542 | + }], | |
| 543 | + }); | |
| 534 | 544 | |
| 535 | 545 | if (!newName) { |
| 536 | 546 | return; |
| @@ -550,7 +560,11 @@ async function renderDetailsContent(detailsContent) { | ||
| 550 | 560 | for (const command of newExcludeList) { |
| 551 | 561 | delete profile[command]; |
| 552 | 562 | } |
| 553 | - toastr.info('Press "Update" to record them into the profile.', 'Included settings list updated'); | |
| 563 | + if (saveChanges) { | |
| 564 | + await updateConnectionProfile(profile); | |
| 565 | + } else { | |
| 566 | + toastr.info('Press "Update" to record them into the profile.', 'Included settings list updated'); | |
| 567 | + } | |
| 554 | 568 | } |
| 555 | 569 | |
| 556 | 570 | if (profile.name !== newName) { |