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