Upgrading Widget Snippets: Updating a Custom Built Widget Snippet - akumina/AkuminaTraining GitHub Wiki

Updating a Custom Built Widget Snippet

In this sample we are updating a Custom Built Widget Snippet. We will need to add our widget to the Widget Manager.

Retrieving the Original Snippet

We will take the same steps as in the previous example to retrieve our original snippet from this custom Stock Ticker widget. image 11

We end up retrieving the following snippet:

<div class="ak-controls ak-stockticker-widget" id="{{RandomGuid}}" ak:stocklist="MSFT,AAPL" ak:displaytemplateurl="/sites/3316100661InterChange/Style%20Library/digitalworkplace/Content/Templates/StockTicker.html"></div>

At this point, the snippet above needs to be pasted in a text file on your local machine. You will also need to retrieve the class name of the widget. As this is a custom widget, it will be found in the digitalworkplace.custom.js file. In this sample, the class name is

Akumina.AddIn.StockTickerWidget

Creating a new Widget

At this point we will use the snippet and class name acquired that we acquired to create a new widget within the Widget Manager. Open up the Widget Manager by going to the Management Apps tab of AppManager and clicking on the Widget Manager app. Click Add Widget.

image 12

Widget Manager - Add Widget

image 13 We will fill in the fields within the Widget Manager using the data within the original snippet

Widget Name

When we create the Widget Name we base it off of the ak--widget class name. So in our case we have the following class:

div class="ak-controls ak-stockticker-widget"

So our Widget name will be StockTicker

Widget Class

We will use the name of the widget class that we acquired from digitalworkplace.custom.js

Akumina.AddIn.StockTickerWidget

Widget Properties

When we create properties we base them off of the ak: elements within our original snippet. We omit the ak:displaytemplateurl since that will be handled in the Widget Views section.

We create a property called “StockList” modeled off of the ak:stocklist in our snippet

ak:stocklist="MSFT,AAPL"

The property value will be MSFT,AAPL The property type will be Text.

Widget Views

We will use the View Picker to select our view. We will use the value of ak:displaytemplateurl within our snippet as a reference

ak:displaytemplateurl="/sites/3316100661InterChange/Style%20Library/digitalworkplace/Content/Templates/StockTicker.html"

We will want to select the template from the following path in the view picker digitalworkplace/Content/Templates/StockTicker.html We will name this view View 1.

Once all the fields are completed, click ‘Save & Exit’.

Creating the Widget Instance

Your StockTicker Widget should now appear in the Manage Widgets menu. Click its ‘View Instances’ button

image 14 Click Add Widget Instance

image 15 Make the Title StockTicker-1, make sure Display View and Selected View are checked for View 1. Click Save & Exit

image 16 Copy the Widget Snippet. Navigate back to the page with your original snippet, edit the page, edit the source of the Content Editor, delete the original snippet and paste the updated snippet in its place. The Custom Widget can now be leveraged from the Widget Manager.

image 17

Multiple Instances

If you have multiple instances of a custom widget on your site, you will add a Widget Instance for each, changing the properties as necessary.

References

⚠️ **GitHub.com Fallback** ⚠️