Refactor /popup args and docs, add 'cancelButton'

a9c0dd38c7878f059e58f6b075a5160eb914563d

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +37 -18Ignore whitespace
public/scripts/slash-commands.js+37 -18
@@ -1267,21 +1267,41 @@ export function initDefaultSlashCommands() {
12671267 callback: popupCallback,
12681268 returns: 'popup text',
12691269 namedArgumentList: [
12701270 new SlashCommandNamedArgument.fromProps({
1271- 'large', 'show large popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
1271+ name: 'large',
1272- ),
1272+ description: 'show large popup',
1273- new SlashCommandNamedArgument(
1273+ typeList: [ARGUMENT_TYPE.BOOLEAN],
1274- 'wide', 'show wide popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
1274+ enumList: commonEnumProviders.boolean('onOff')(),
12751275 }),
12761276 new SlashCommandNamedArgument.fromProps({
1277- 'wider', 'show wider popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
1277+ name: 'wide',
1278- ),
1278+ description: 'show wide popup',
1279- new SlashCommandNamedArgument(
1279+ typeList: [ARGUMENT_TYPE.BOOLEAN],
1280- 'transparent', 'show transparent popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(),
1280+ enumList: commonEnumProviders.boolean('onOff')(),
12811281 }),
12821282 new SlashCommandNamedArgument.fromProps({
1283- 'okButton', 'text for the OK button', [ARGUMENT_TYPE.STRING], false,
1283+ name: 'wider',
1284- ),
1284+ description: 'show wider popup',
1285+ typeList: [ARGUMENT_TYPE.BOOLEAN],
1286+ enumList: commonEnumProviders.boolean('onOff')(),
1287+ }),
1288+ SlashCommandNamedArgument.fromProps({
1289+ name: 'transparent',
1290+ description: 'show transparent popup',
1291+ typeList: [ARGUMENT_TYPE.BOOLEAN],
1292+ enumList: commonEnumProviders.boolean('onOff')(),
1293+ }),
1294+ SlashCommandNamedArgument.fromProps({
1295+ name: 'okButton',
1296+ description: 'text for the OK button',
1297+ typeList: [ARGUMENT_TYPE.STRING],
1298+ defaultValue: 'OK',
1299+ }),
1300+ SlashCommandNamedArgument.fromProps({
1301+ name: 'cancelButton',
1302+ description: 'text for the Cancel button',
1303+ typeList: [ARGUMENT_TYPE.STRING],
1304+ }),
12851305 ],
12861306 unnamedArgumentList: [
12871307 new SlashCommandArgument(
@@ -1297,7 +1317,7 @@ export function initDefaultSlashCommands() {
12971317 <strong>Example:</strong>
12981318 <ul>
12991319 <li>
13001320 <pre><code>/popup large=on wide=on okButton="SubmitConfirm" EnterPlease someconfirm text:this action.</code></pre>
13011321 </li>
13021322 </ul>
13031323 </div>
@@ -1896,10 +1916,9 @@ async function popupCallback(args, value) {
18961916 wider: isTrueBoolean(args?.wider),
18971917 transparent: isTrueBoolean(args?.transparent),
18981918 okButton: args?.okButton !== undefined && typeof args?.okButton === 'string' ? args.okButton : 'Ok',
1919+ cancelButton: args?.cancelButton !== undefined && typeof args?.cancelButton === 'string' ? args.cancelButton : null,
18991920 };
1900- await delay(1);
19011921 await callGenericPopup(safeValue, POPUP_TYPE.TEXT, '', popupOptions);
1902- await delay(1);
19031922 return String(value);
19041923}
19051924