Merge pull request #3121 from ceruleandeep/fix/handleIdForQRMenuAdd Wire up id= parameter for /qr-context*
Signed| @@ -419,30 +419,35 @@ export class SlashCommandHandler { | ||
| 419 | 419 | namedArgumentList: [ |
| 420 | 420 | SlashCommandNamedArgument.fromProps({ |
| 421 | 421 | name: 'set', |
| 422 | 422 | description: 'Name of QR set nameto add the context menu to', |
| 423 | 423 | typeList: [ARGUMENT_TYPE.STRING], |
| 424 | 424 | isRequired: true, |
| 425 | 425 | enumProvider: localEnumProviders.qrSets, |
| 426 | 426 | }), |
| 427 | 427 | SlashCommandNamedArgument.fromProps({ |
| 428 | 428 | name: 'label', |
| 429 | 429 | description: 'Label of Quick Reply labelto add the context menu to', |
| 430 | 430 | typeList: [ARGUMENT_TYPE.STRING], |
| 431 | 431 | enumProvider: localEnumProviders.qrEntries, |
| 432 | 432 | }), |
| 433 | 433 | SlashCommandNamedArgument.fromProps({ |
| 434 | 434 | name: 'id', |
| 435 | 435 | description: 'numericNumeric ID of Quick Reply to add the QRcontext menu to, e.g., id=42', |
| 436 | 436 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 437 | 437 | enumProvider: localEnumProviders.qrIds, |
| 438 | 438 | }), |
| 439 | 439 | new SlashCommandNamedArgument( |
| 440 | - 'chain', 'boolean', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false', | |
| 440 | + 'chain', | |
| 441 | + 'If true, button QR is sent together with (before) the clicked QR from the context menu', | |
| 442 | + [ARGUMENT_TYPE.BOOLEAN], | |
| 443 | + false, | |
| 444 | + false, | |
| 445 | + 'false', | |
| 441 | 446 | ), |
| 442 | 447 | ], |
| 443 | 448 | unnamedArgumentList: [ |
| 444 | 449 | SlashCommandArgument.fromProps({ |
| 445 | 450 | description: 'Name of QR set nameto add as a context menu', |
| 446 | 451 | typeList: [ARGUMENT_TYPE.STRING], |
| 447 | 452 | isRequired: true, |
| 448 | 453 | enumProvider: localEnumProviders.qrSets, |
| @@ -450,13 +455,16 @@ export class SlashCommandHandler { | ||
| 450 | 455 | ], |
| 451 | 456 | helpString: ` |
| 452 | 457 | <div> |
| 453 | 458 | Add a context menu preset to a QR. |
| 459 | + </div> | |
| 460 | + <div> | |
| 461 | + If <code>id</code> and <code>label</code> are both provided, <code>id</code> will be used. | |
| 454 | 462 | </div> |
| 455 | 463 | <div> |
| 456 | 464 | <strong>Example:</strong> |
| 457 | 465 | <ul> |
| 458 | 466 | <li> |
| 459 | 467 | <pre><code>/qr-contextadd set=MyPresetMyQRSetWithTheButton label=MyButton chain=true MyOtherPresetMyQRSetWithContextItems</code></pre> |
| 460 | 468 | </li> |
| 461 | 469 | </ul> |
| 462 | 470 | </div> |
| @@ -470,27 +478,27 @@ export class SlashCommandHandler { | ||
| 470 | 478 | namedArgumentList: [ |
| 471 | 479 | SlashCommandNamedArgument.fromProps({ |
| 472 | 480 | name: 'set', |
| 473 | 481 | description: 'Name of QR set nameto remove the context menu from', |
| 474 | 482 | typeList: [ARGUMENT_TYPE.STRING], |
| 475 | 483 | isRequired: true, |
| 476 | 484 | enumProvider: localEnumProviders.qrSets, |
| 477 | 485 | }), |
| 478 | 486 | SlashCommandNamedArgument.fromProps({ |
| 479 | 487 | name: 'label', |
| 480 | 488 | description: 'Label of Quick Reply labelto remove the context menu from', |
| 481 | 489 | typeList: [ARGUMENT_TYPE.STRING], |
| 482 | 490 | enumProvider: localEnumProviders.qrEntries, |
| 483 | 491 | }), |
| 484 | 492 | SlashCommandNamedArgument.fromProps({ |
| 485 | 493 | name: 'id', |
| 486 | 494 | description: 'numericNumeric ID of Quick Reply to remove the QRcontext menu from, e.g., id=42', |
| 487 | 495 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 488 | 496 | enumProvider: localEnumProviders.qrIds, |
| 489 | 497 | }), |
| 490 | 498 | ], |
| 491 | 499 | unnamedArgumentList: [ |
| 492 | 500 | SlashCommandArgument.fromProps({ |
| 493 | 501 | description: 'Name of QR set nameto remove', |
| 494 | 502 | typeList: [ARGUMENT_TYPE.STRING], |
| 495 | 503 | isRequired: true, |
| 496 | 504 | enumProvider: localEnumProviders.qrSets, |
| @@ -501,6 +509,9 @@ export class SlashCommandHandler { | ||
| 501 | 509 | Remove context menu preset from a QR. |
| 502 | 510 | </div> |
| 503 | 511 | <div> |
| 512 | + If <code>id</code> and <code>label</code> are both provided, <code>id</code> will be used. | |
| 513 | + </div> | |
| 514 | + <div> | |
| 504 | 515 | <strong>Example:</strong> |
| 505 | 516 | <ul> |
| 506 | 517 | <li> |
| @@ -542,6 +553,9 @@ export class SlashCommandHandler { | ||
| 542 | 553 | Remove all context menu presets from a QR. |
| 543 | 554 | </div> |
| 544 | 555 | <div> |
| 556 | + If <code>id</code> and a label are both provided, <code>id</code> will be used. | |
| 557 | + </div> | |
| 558 | + <div> | |
| 545 | 559 | <strong>Example:</strong> |
| 546 | 560 | <ul> |
| 547 | 561 | <li> |
| @@ -908,12 +922,11 @@ export class SlashCommandHandler { | ||
| 908 | 922 | } |
| 909 | 923 | } |
| 910 | 924 | |
| 911 | - | |
| 912 | 925 | createContextItem(args, name) { |
| 913 | 926 | try { |
| 914 | 927 | this.api.createContextItem( |
| 915 | 928 | args.set, |
| 916 | - args.label, | |
| 929 | + args.id !== undefined ? Number(args.id) : args.label, | |
| 917 | 930 | name, |
| 918 | 931 | isTrueBoolean(args.chain), |
| 919 | 932 | ); |
| @@ -923,14 +936,14 @@ export class SlashCommandHandler { | ||
| 923 | 936 | } |
| 924 | 937 | deleteContextItem(args, name) { |
| 925 | 938 | try { |
| 926 | 939 | this.api.deleteContextItem(args.set, args.id !== undefined ? Number(args.id) : args.label, name); |
| 927 | 940 | } catch (ex) { |
| 928 | 941 | toastr.error(ex.message); |
| 929 | 942 | } |
| 930 | 943 | } |
| 931 | 944 | clearContextMenu(args, label) { |
| 932 | 945 | try { |
| 933 | 946 | this.api.clearContextMenu(args.set, args.id !== undefined ? Number(args.id) : args.label ?? label); |
| 934 | 947 | } catch (ex) { |
| 935 | 948 | toastr.error(ex.message); |
| 936 | 949 | } |