Как открыть диалог с помощью кнопки «Лента» в веб-надстройке Outlook? - PullRequest
0 голосов
/ 20 сентября 2018

Я пытаюсь открыть диалог с помощью кнопки ленты.

Я добавил кнопку ленты Engagement в MessageComposeCommandSurface, которая будет выполнять функцию в файле функций для открытия диалога

     <?xml version="1.0" encoding="UTF-8"?>
<OfficeApp
          xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
          xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
          xsi:type="MailApp">

  <!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->

  <!-- IMPORTANT! Id must be unique for your add-in, if you reuse this manifest ensure that you change this id to a new GUID. -->
  <Id>d52ea32e-267b-422c-85be-72fabbf1f5c9</Id>

  <!--Version. Updates from the store only get triggered if there is a version change. -->
  <Version>1.0.0.0</Version>
  <ProviderName>APP</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
  <DisplayName DefaultValue="Appliaction " />
  <Description DefaultValue="Application Description"/>

  <!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
  <IconUrl DefaultValue="https://localhost:44340/assets/icon-32.png" />
  <HighResolutionIconUrl DefaultValue="https://localhost:44340/assets/hi-res-icon.png"/>

  <!--If you plan to submit this add-in to the Office Store, uncomment the SupportUrl element below-->
  <SupportUrl DefaultValue="http://support.contoso.com" />

  <!-- Domains that will be allowed when navigating. For example, if you use ShowTaskpane and then have an href link, navigation will only be allowed if the domain is on this list. -->
  <AppDomains>
    <AppDomain>https://localhost:44340</AppDomain>
    <AppDomain>https://appsforoffice.microsoft.com</AppDomain>
    <AppDomain>https://ajax.aspnetcdn.com</AppDomain>
  </AppDomains>
  <!--End Basic Settings. -->

  <Hosts>
    <Host Name="Mailbox" />
  </Hosts>
  <Requirements>
    <Sets>
      <Set Name="Mailbox" MinVersion="1.1" />
    </Sets>
  </Requirements>
  <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://localhost:44340/"/>
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
  </FormSettings>

  <Permissions>ReadWriteItem</Permissions>
  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
  </Rule>
  <DisableEntityHighlighting>false</DisableEntityHighlighting>

  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Requirements>
      <bt:Sets DefaultMinVersion="1.3">
        <bt:Set Name="Mailbox" />
      </bt:Sets>
    </Requirements>
    <Hosts>
      <Host xsi:type="MailHost">

        <DesktopFormFactor>
          <!-- Location of the Functions that UI-less buttons can trigger (ExecuteFunction Actions). -->
          <FunctionFile resid="functionFile" />
          <!-- Message Compose -->
          <ExtensionPoint xsi:type="MessageComposeCommandSurface">
            <OfficeTab id="TabDefault">
              <Group id ="msgComposeGroup">
                <Label resid="groupLabel"/>
                <Control xsi:type="Button" id="msgComposeOpenPane">
                  <Label resid="paneComposeButtonLabel"/>
                  <Supertip>
                    <Title resid="paneComposeSuperTipTitle" />
                    <Description resid="paneComposeSuperTipDescription" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="icon16" />
                    <bt:Image size="32" resid="icon32" />
                    <bt:Image size="80" resid="icon80" />
                  </Icon>
                  <Action xsi:type="ExecuteFunction">
                    <FunctionName>openEngagementDiag</FunctionName>
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>


          <!-- Message Read -->
          <ExtensionPoint xsi:type="MessageReadCommandSurface">
            <!-- Use the default tab of the ExtensionPoint or create your own with <CustomTab id="myTab"> -->
            <OfficeTab id="TabDefault">
              <!-- Up to 6 Groups added per Tab -->
              <Group id="msgReadGroup">
                <Label resid="groupLabel" />
                <!-- Launch the add-in : task pane button -->
                <Control xsi:type="Button" id="msgReadOpenPaneButton">
                  <Label resid="paneReadButtonLabel" />
                  <Supertip>
                    <Title resid="paneReadSuperTipTitle" />
                    <Description resid="paneReadSuperTipDescription" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="icon16" />
                    <bt:Image size="32" resid="icon32" />
                    <bt:Image size="80" resid="icon80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="messageReadTaskPaneUrl" />
                  </Action>
                </Control>
                <!-- Go to http://aka.ms/ButtonCommands to learn how to add more Controls: ExecuteFunction and Menu -->
              </Group>
            </OfficeTab>
          </ExtensionPoint>
          <!-- Go to http://aka.ms/ExtensionPointsCommands to learn how to add more Extension Points: MessageRead, AppointmentOrganizer, AppointmentAttendee -->
        </DesktopFormFactor>
      </Host>
    </Hosts>

    <Resources>
      <bt:Images>
        <bt:Image id="icon16" DefaultValue="https://localhost:44340/assets/app-16.png"/>
        <bt:Image id="icon32" DefaultValue="https://localhost:44340/assets/app-32.png"/>
        <bt:Image id="icon80" DefaultValue="https://localhost:44340/assets/app-80.png"/>
      </bt:Images>
      <bt:Urls>
        <bt:Url id="functionFile" DefaultValue="https://localhost:44340/Function-File/function-file.html"/>
        <bt:Url id="messageReadTaskPaneUrl" DefaultValue="https://localhost:44340/Home/ReadPane"/>
        <bt:Url id="messageComposeTaskPaneUrl" DefaultValue="https://localhost:44340/Home/Compose"/>
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="groupLabel" DefaultValue="Sample Label"/>
        <bt:String id="customTabLabel"  DefaultValue="Application"/>
        <bt:String id="paneReadButtonLabel" DefaultValue="Engagement"/>
        <bt:String id="paneReadSuperTipTitle" DefaultValue="Map to Engagement"/>
        <bt:String id="paneComposeSuperTipTitle" DefaultValue="Map to Engagement"/>
        <bt:String id="paneComposeButtonLabel" DefaultValue="Engagement"/>
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="paneReadSuperTipDescription" DefaultValue="Opens a pane displaying current engagement"/>
        <bt:String id="paneComposeSuperTipDescription" DefaultValue="Opens a pane displaying current engagement"/>
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>

Ниже приведен файл функции.

declare var Office;

(() => {
  // The initialize function must be run each time a new page is loaded
  Office.initialize = () => {
      console.log("Hello World")
  };

function openEngagementDiag(){
  Office.context.ui.displayDialogAsync(
    'https://localhost:4200/#/MessageCompose', 
    {height: 30, width: 20},
    function(asyncResult){
      if (asyncResult.status === Office.AsyncResultStatus.Failed) {
        let errorMessage = null;

        switch (asyncResult.error.code) {
        case 12004:
            errorMessage = 'Domain is not trusted';
            break;
        case 12005:
            errorMessage = 'HTTPS is required';
            break;
        case 12007:
            errorMessage = 'A dialog is already opened.';
            break;
        default:
            errorMessage = asyncResult.error.message;
            break;
        }        
    }
    else {       
    }
    });
}
})();

Отображается кнопка ленты, и при ее щелчке появляется информационная панель, как показано ниже: «TestApp работает над запросом», указывая, что что-то происходит за кулисами

enter image description here

Что я здесь не так делаю?

РЕДАКТИРОВАТЬ: мой проект надстройки Outlook Web является SPA с использованием angular v6.x

1 Ответ

0 голосов
/ 20 сентября 2018

Это может или не может сделать это для вас, но, основываясь на недавнем опыте, который я имел с надстройкой Word, шансы велики.Добавьте параметр event в функцию-обработчик и обязательно сообщите о завершении события, вызвав его метод completed.

function openEngagementDiag(event) {
    // ...
    event.completed();
}

Надеюсь, это поможет.

...