如何在Gmail插件上的现有卡中添加新部分? [英] How can I add new sections to an existing card on Gmail Addon?

查看:49
本文介绍了如何在Gmail插件上的现有卡中添加新部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上正在尝试使用带有应用脚本"的附件在Gmail中创建聊天界面.所有交互都在起作用.但是,它一直在导航到不同的卡上,而不是全部都放在一张卡中.就像在Google任务中一样.

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 have it all in one card. Like in Google Tasks.

有没有一种方法可以让我不断地在同一张卡上动态添加部分,以创建类似于聊天的界面.

Is there a way in which I can just keep adding sections to the same card dynamically to create a chat like interface.

我认为在这种情况下,如果也可以在Google Tasks Add-on上使用.请帮我,因为这是必要条件.

I assume if it is possible on Google Tasks Add-on it should be possible in this case too. Please help me out as it is a necessary requirement.

推荐答案

更新试试这个

    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());
    }

原始答案:

简而言之:可能

我了解您正在尝试做什么.这涉及通过用具有与当前卡相同的小部件的新卡和所需的其他小部件来更新它来替换当前卡.

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.

这篇关于如何在Gmail插件上的现有卡中添加新部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆