Add Save and Update

4167fe3d2b807f4a77977df29fc0feb65f2e67e6

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +18 -2Showing whitespace changes
public/css/popup.css+2 -0
@@ -149,10 +149,12 @@ body.no-blur .popup[open]::backdrop {
149149 box-shadow: 0 0 5px var(--white20a);
150150}
151151
152+.menu_button.primary,
152153.menu_button.popup-button-ok {
153154 background-color: var(--crimson70a);
154155}
155156
157+.menu_button.primary:hover,
156158.menu_button.popup-button-ok:hover {
157159 background-color: var(--crimson-hover);
158160}
public/scripts/extensions/connection-manager/index.js+16 -2
@@ -1,6 +1,6 @@
11import { event_types, eventSource, main_api, saveSettingsDebounced } from '../../../script.js';
22import { extension_settings, renderExtensionTemplateAsync } from '../../extensions.js';
33import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from '../../popup.js';
44import { SlashCommand } from '../../slash-commands/SlashCommand.js';
55import { SlashCommandAbortController } from '../../slash-commands/SlashCommandAbortController.js';
66import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
@@ -523,6 +523,7 @@ async function renderDetailsContent(detailsContent) {
523523 profile.exclude = [];
524524 }
525525
526+ let saveChanges = false;
526527 const commands = profile.mode === 'cc' ? CC_COMMANDS : TC_COMMANDS;
527528 const settings = commands.reduce((acc, command) => {
528529 const fancyName = FANCY_NAMES[command];
@@ -530,7 +531,16 @@ async function renderDetailsContent(detailsContent) {
530531 return acc;
531532 }, {});
532533 const template = $(await renderExtensionTemplateAsync(MODULE_NAME, 'edit', { name: profile.name, settings }));
533534 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+ });
534544
535545 if (!newName) {
536546 return;
@@ -550,8 +560,12 @@ async function renderDetailsContent(detailsContent) {
550560 for (const command of newExcludeList) {
551561 delete profile[command];
552562 }
563+ if (saveChanges) {
564+ await updateConnectionProfile(profile);
565+ } else {
553566 toastr.info('Press "Update" to record them into the profile.', 'Included settings list updated');
554567 }
568+ }
555569
556570 if (profile.name !== newName) {
557571 toastr.success('Connection profile renamed.');