Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 73 additions & 16 deletions types/google-apps-script/google-apps-script.card-service.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,27 +640,84 @@ declare namespace GoogleAppsScript {
/**
* An input field that allows choosing between a set of predefined options.
*
* var checkboxGroup = CardService.newSelectionInput()
* .setType(CardService.SelectionInputType.CHECK_BOX)
* .setTitle("A group of checkboxes. Multiple selections are allowed.")
* .setFieldName("checkbox_field")
* .addItem("checkbox one title", "checkbox_one_value", false)
* .addItem("checkbox two title", "checkbox_two_value", true)
* .addItem("checkbox three title", "checkbox_three_value", false)
* .setOnChangeAction(CardService.newAction()
* .setFunctionName("handleCheckboxChange"));
* const checkboxGroup =
* CardService.newSelectionInput()
* .setType(CardService.SelectionInputType.CHECK_BOX)
* .setTitle('A group of checkboxes. Multiple selections are allowed.')
* .setFieldName('checkbox_field')
* .addItem('checkbox one title', 'checkbox_one_value', false)
* .addItem('checkbox two title', 'checkbox_two_value', true)
* .addItem('checkbox three title', 'checkbox_three_value', true)
* .setOnChangeAction(
* CardService.newAction().setFunctionName('handleCheckboxChange'),
* );
*
* const radioGroup =
* CardService.newSelectionInput()
* .setType(CardService.SelectionInputType.RADIO_BUTTON)
* .setTitle(
* 'A group of radio buttons. Only a single selection is allowed.')
* .setFieldName('checkbox_field')
* .addItem('radio button one title', 'radio_one_value', true)
* .addItem('radio button two title', 'radio_two_value', false)
* .addItem('radio button three title', 'radio_three_value', false);
*
* var radioGroup = CardService.newSelectionInput()
* .setType(CardService.SelectionInputType.RADIO_BUTTON)
* .setTitle("A group of radio buttons. Only a single selection is allowed.")
* .setFieldName("checkbox_field")
* .addItem("radio button one title", "radio_one_value", true)
* .addItem("radio button two title", "radio_two_value", true)
* .addItem("radio button three title", "radio_three_value", false);
* const multiSelect =
* CardService.newSelectionInput()
* .setType(CardService.SelectionInputType.MULTI_SELECT)
* .setFieldName('multiselect')
* .setTitle('A multi select input example.')
* .addMultiSelectItem(
* 'Contact 1',
* 'contact-1',
* false,
* 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
* 'Contact one description',
* )
* .addMultiSelectItem(
* 'Contact 2',
* 'contact-2',
* false,
* 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
* 'Contact two description',
* )
* .addMultiSelectItem(
* 'Contact 3',
* 'contact-3',
* false,
* 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
* 'Contact three description',
* )
* .addMultiSelectItem(
* 'Contact 4',
* 'contact-4',
* false,
* 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
* 'Contact four description',
* )
* .addMultiSelectItem(
* 'Contact 5',
* 'contact-5',
* false,
* 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',
* 'Contact five description',
* )
* .setMultiSelectMaxSelectedItems(3)
* .setMultiSelectMinQueryLength(1);
*/
interface SelectionInput {
addItem(text: any, value: any, selected: boolean): SelectionInput;
addMultiSelectItem(
text: string,
value: string,
selected: boolean,
startIconUri: string,
bottomText: string,
): SelectionInput;
setExternalDataSource(action: Action): SelectionInput;
setFieldName(fieldName: string): SelectionInput;
setMultiSelectMaxSelectedItems(maxSelectedItems: Integer): SelectionInput;
setMultiSelectMinQueryLength(queryLength: Integer): SelectionInput;
setOnChangeAction(action: Action): SelectionInput;
setTitle(title: string): SelectionInput;
setType(type: SelectionInputType): SelectionInput;
Expand Down
7 changes: 7 additions & 0 deletions types/google-apps-script/test/google-apps-script-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,13 @@ CardService.newOpenLink().setOnClose(CardService.OnClose.RELOAD_ADD_ON); // $Exp
// Class CardService.SelectionInput
// https://developers.google.com/apps-script/reference/card-service/selection-input
CardService.newSelectionInput(); // $ExpectType SelectionInput
CardService.newSelectionInput().addItem("", "", true); // $ExpectType SelectionInput
CardService.newSelectionInput().addMultiSelectItem("", "", false, "", ""); // $ExpectType SelectionInput
CardService.newSelectionInput().setFieldName(""); // $ExpectType SelectionInput
CardService.newSelectionInput().setMultiSelectMaxSelectedItems(5); // $ExpectType SelectionInput
CardService.newSelectionInput().setMultiSelectMinQueryLength(1); // $ExpectType SelectionInput
CardService.newSelectionInput().setTitle(""); // $ExpectType SelectionInput
CardService.newSelectionInput().setType(CardService.SelectionInputType.CHECK_BOX); // $ExpectType SelectionInput

// Enum SelectionInputType
// https://developers.google.com/apps-script/reference/card-service/selection-input-type
Expand Down