microsoft / Viva-Connections-Extensibility-Beta

38 stars 6 forks source link

[ACE]: [It is possible to render a template in the CardView] #23

Closed TJ-Klug closed 2 years ago

TJ-Klug commented 3 years ago

Versions

[ Big Sur ] Operating System [ 12.13.0 ] Node version [ CLI version: 2.3.0 ] [ Local version: 4.0.2 ] Gulp version [ @microsoft/generator-sharepoint@1.13.0-beta.5 ] SPFx Generator version

Expected or Desired Behavior

I shouldn't be able to render my own CardView utilizing Adaptive Card Templates

Observed Behavior

If you provide the correct methods, you can actually render a CardView with an adaptive card template.

Steps to Reproduce

image

import { ISPFxAdaptiveCard, BaseAdaptiveCardView } from '@microsoft/sp-adaptive-card-extension-base';
import * as strings from 'HelloWorldAdaptiveCardExtensionStrings';
import { IHelloWorldAdaptiveCardExtensionProps, IHelloWorldAdaptiveCardExtensionState } from '../HelloWorldAdaptiveCardExtension';

export interface IQuickViewData {
  subTitle: string;
  title: string;
  description: string;
}

export class QuickView extends BaseAdaptiveCardView<
  IHelloWorldAdaptiveCardExtensionProps,
  IHelloWorldAdaptiveCardExtensionState,
  IQuickViewData
> {
  public get data(): IQuickViewData {
    return {
      subTitle: strings.SubTitle,
      title: strings.Title,
      description: this.state.description
    };
  }

  public cardButtons;

  public onCardSelection;

  public get template(): ISPFxAdaptiveCard {
    return require('./template/QuickViewTemplate.json');
  }
}

Now you can register it as a cardview

 public onInit(): Promise<void> {
    this.state = {
      description: this.properties.description
    };

    this.cardNavigator.register(CARD_VIEW_REGISTRY_ID, () => new QuickView());

    return Promise.resolve();
  }
MarlonCopeland commented 3 years ago

In all actuality, I would like to be able to do this. I think the Card Views are too restrictive

johnguy0 commented 2 years ago

We'll be fixing this in a future release.