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