How can I add new sections to an existing card on Gmail Addon?

后端 未结 1 1217
伪装坚强ぢ
伪装坚强ぢ 2021-01-27 05:44

I\'m actually trying to create a Chat interface in Gmail using Add-ons with App Script. All the interactions are working. But it keeps navigating to different cards rather than

相关标签:
1条回答
  • 2021-01-27 06:13

    Update : Try this

        function renderRootCard(){
            var card = CardService.newCardBuilder();
            var section = CardService.newCardSection();
            var btnSet = CardService.newButtonSet();
            section.addWidget(CardService.newTextParagraph().setText("old widget"));
            section.addWidget(btnSet.addButton(addTaskBtn));
            card.addSection(section);
    
            var addTask = CardService.newAction().setFunctionName("addTask");
            var addTaskBtn = CardService.newTextButton()
                .setText("Add Task")
                .setOnClickAction(addTask); 
    
    
            return card.build();
        }
    
        function addTask(e) {
            var card = CardService.newCardBuilder();
            var section = CardService.newCardSection();
            var btnSet = CardService.newButtonSet();
            section.addWidget(CardService.newTextParagraph().setText("old widget"));
            section.addWidget(btnSet.addButton(addTaskBtn));
            section.addWidget(CardService.newTextParagraph().setText("new widget"));
    var addTask = CardService.newAction().setFunctionName("addTask");
            var addTaskBtn = CardService.newTextButton()
                .setText("Add Task")
                .setOnClickAction(addTask); 
            return CardService.newNavigation().updateCard(card.build());
        }
    

    Original answer:

    In short: Possible

    I understand what you are trying to do. This involves replacing the current card by updating it with a new card that has the same widgets as that of current card and additional widgets that are required.

    Let's say, you are building a to-do app. When you click add task(say), you just create the same card, add some widgets and replace the current card with a new one.

    0 讨论(0)
提交回复
热议问题