Refactor /popup args and docs, add 'cancelButton'

a9c0dd38c7878f059e58f6b075a5160eb914563d

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +37 -18Showing whitespace changes
public/scripts/slash-commands.js+37 -18
@@ -1267,21 +1267,41 @@ export function initDefaultSlashCommands() {
1267 callback: popupCallback,1267 callback: popupCallback,
1268 returns: 'popup text',1268 returns: 'popup text',
1269 namedArgumentList: [1269 namedArgumentList: [
1270 new SlashCommandNamedArgument(1270 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')(),
1275 ),1275 }),
1276 new SlashCommandNamedArgument(1276 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')(),
1281 ),1281 }),
1282 new SlashCommandNamedArgument(1282 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 }),
1285 ],1305 ],
1286 unnamedArgumentList: [1306 unnamedArgumentList: [
1287 new SlashCommandArgument(1307 new SlashCommandArgument(
@@ -1297,7 +1317,7 @@ export function initDefaultSlashCommands() {
1297 <strong>Example:</strong>1317 <strong>Example:</strong>
1298 <ul>1318 <ul>
1299 <li>1319 <li>
1300 <pre><code>/popup large=on wide=on okButton="Submit" Enter some text:</code></pre>1320 <pre><code>/popup large=on wide=on okButton="Confirm" Please confirm this action.</code></pre>
1301 </li>1321 </li>
1302 </ul>1322 </ul>
1303 </div>1323 </div>
@@ -1896,10 +1916,9 @@ async function popupCallback(args, value) {
1896 wider: isTrueBoolean(args?.wider),1916 wider: isTrueBoolean(args?.wider),
1897 transparent: isTrueBoolean(args?.transparent),1917 transparent: isTrueBoolean(args?.transparent),
1898 okButton: args?.okButton !== undefined && typeof args?.okButton === 'string' ? args.okButton : 'Ok',1918 okButton: args?.okButton !== undefined && typeof args?.okButton === 'string' ? args.okButton : 'Ok',
1919 cancelButton: args?.cancelButton !== undefined && typeof args?.cancelButton === 'string' ? args.cancelButton : null,
1899 };1920 };
1900 await delay(1);
1901 await callGenericPopup(safeValue, POPUP_TYPE.TEXT, '', popupOptions);1921 await callGenericPopup(safeValue, POPUP_TYPE.TEXT, '', popupOptions);
1902 await delay(1);
1903 return String(value);1922 return String(value);
1904}1923}
19051924