Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
]
})
);
}
// Only show the template external URL for 'Custom' option
if (this.properties.selectedLayout === ResultsLayoutOption.Custom) {
stylingFields.splice(6, 0, PropertyPaneTextField('externalTemplateUrl', {
label: strings.TemplateUrlFieldLabel,
placeholder: strings.TemplateUrlPlaceholder,
deferredValidationTime: 500,
onGetErrorMessage: this._onTemplateUrlChange.bind(this)
}));
}
if (this.codeRendererIsSelected()) {
const currentCodeRenderer = find(this._codeRenderers, (renderer) => renderer.id === (this.properties.selectedLayout as any));
if (!this.properties.customTemplateFieldValues) {
this.properties.customTemplateFieldValues = currentCodeRenderer.customFields.map(field => {
return {
fieldName: field,
searchProperty: ''
};
});
}
if (currentCodeRenderer.customFields && currentCodeRenderer.customFields.length > 0) {
const searchPropertyOptions = this.properties.selectedProperties.split(',').map(prop => {
return ({
key: prop,
text: prop
});
});
stylingFields.push(PropertyFieldCollectionData('customTemplateFieldValues', {
private _onSelectionChanged = async (args: Visio.SelectionChangedEventArgs): Promise => {
try {
console.log("Selection Changed Event " + JSON.stringify(args));
if (args.shapeNames.length > 0 && this._shapes && this._shapes.length > 0) {
// get name of selected item
const selectedShapeText: string = args.shapeNames[0];
// find selected shape on the list of pre-loaded shapes
this._selectedShape = find(this._shapes,
s => s.name === selectedShapeText
);
// call delegate function from the react component
this.onSelectionChanged(this._selectedShape);
} else {
// shape was deselected
this._selectedShape = null;
}
} catch (error) {
this.logError(error);
}
}
public selectShape = async (name: string): Promise => {
try {
// find the correct shape from the pre-loaded list of shapes
// check the ShapeData item with the 'Name' key
const shape: Visio.Shape = find(this._shapes,
s => (find(s.shapeDataItems.items, i => i.label === "Name").value === name)
);
// only select shape if not the currently selected one
if (this._selectedShape === null
|| this._selectedShape === undefined
|| (this._selectedShape && this._selectedShape.name !== shape.name)) {
await Visio.run(this._session, async (context: Visio.RequestContext) => {
const page: Visio.Page = context.document.getActivePage();
const shapesCollection: Visio.ShapeCollection = page.shapes;
shapesCollection.load();
await context.sync();
const diagramShape: Visio.Shape = shapesCollection.getItem(shape.name);
// select shape on diagram
s => (find(s.shapeDataItems.items, i => i.label === "Name").value === name)
);
userFavoriteLinks.forEach(userLink => {
let linkMatch = find(allFavoriteLinks, (favoriteLink => favoriteLink.id === userLink.id));
if (linkMatch && (!isEqual(linkMatch.url, userLink.url) || !isEqual(linkMatch.displayText, userLink.displayText) || !isEqual(linkMatch.icon, userLink.icon))) {
shouldUpdate = true;
personalLinks.push(linkMatch);
} else {
personalLinks.push(userLink);
}
});
if (shouldUpdate) {
userFavoriteLinks.forEach(userLink => {
let linkMatch = find(allFavoriteLinks, (favoriteLink => favoriteLink.id === userLink.id));
if (linkMatch && (!isEqual(linkMatch.url, userLink.url) || !isEqual(linkMatch.displayText, userLink.displayText) || !isEqual(linkMatch.icon, userLink.icon))) {
shouldUpdate = true;
personalLinks.push(linkMatch);
} else {
personalLinks.push(userLink);
}
});