Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private onDateExpressionChange(newValue: string): string {
// Validates the picker
let regex = new RegExp(/^\[Today\](\s{0,}[\+-]\s{0,}\[{0,1}\d{1,4}\]{0,1}){0,1}$/);
let isValid = regex.test(newValue) || isEmpty(newValue);
let errorMsg = isValid ? '' : this.props.strings.datePickerExpressionError;
if(isValid) {
// If the change is NOT triggered by the date picker change
if(!(isEmpty(newValue) && this.state.filter.value != null)) {
this.state.filter.value = null;
this.state.filter.expression = newValue;
this.setState({ filter: this.state.filter, pickersKey: this.state.pickersKey });
this.onAnyChange();
}
}
return errorMsg;
}
},
]
})
);
}
// 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);
}
}
return (
<div>
{loading}
{error}
{/* Shows the validation checklist if mandatory properties aren't all configured */}
{ !mandatoryFieldsConfigured && !this.state.loading && !this.state.error &&
<div>
{ this.props.strings.mandatoryProperties }
</div>
}
{/* Shows the query results once loaded */}
{ mandatoryFieldsConfigured && !this.state.loading && !this.state.error &&
<div></div>
}
</div>
);
}
}
private isFilterEmpty(filter:IQueryFilter) {
let isFilterEmpty = false;
// If the filter has no field
if(filter.field == null) {
isFilterEmpty = true;
}
// If the filter has a null or empty value
if(filter.value == null || isEmpty(filter.value.toString())) {
// And has no date time expression
if(isEmpty(filter.expression)) {
// And isn't a [Me] switch
if(!filter.me) {
// And isn't a or operator
if(filter.operator != QueryFilterOperator.IsNull && filter.operator != QueryFilterOperator.IsNotNull) {
isFilterEmpty = true;
}
}
}
}
return isFilterEmpty;
}
const mandatoryFieldsConfigured = this.areMandatoryFieldsConfigured();
return (
<div>
{loading}
{error}
{/* Shows the validation checklist if mandatory properties aren't all configured */}
{ !mandatoryFieldsConfigured && !this.state.loading && !this.state.error &&
<div>
{ this.props.strings.mandatoryProperties }
</div>
}
{/* Shows the query results once loaded */}
{ mandatoryFieldsConfigured && !this.state.loading && !this.state.error &&
<div></div>
}
</div>
);
}
}
public getFilterFields(webUrl: string, listId: string):Promise {
Log.verbose(this.logSource, "Loading dropdown options for toolpart property 'Filters'...", this.context.serviceScope);
// Resolves an empty array if no web or no list has been selected
if (isEmpty(webUrl) || isEmpty(listId)) {
return Promise.resolve(new Array());
}
// Resolves the already loaded data if available
if(this.filterFields) {
return Promise.resolve(this.filterFields);
}
// Otherwise gets the options asynchronously
return new Promise((resolve, reject) => {
this.listService.getListFields(webUrl, listId, ['InternalName', 'Title', 'TypeAsString'], 'Title').then((data:any) => {
let fields:any[] = data.value;
let options:IQueryFilterField[] = fields.map((field) => { return {
internalName: field.InternalName,
displayName: field.Title,
type: this.getFieldTypeFromString(field.TypeAsString)
private async loadEvents() {
try {
// Teste Properties
if (!this.props.list || !this.props.siteUrl || !this.props.eventStartDate.value || !this.props.eventEndDate.value) return;
this.userListPermissions = await this.spService.getUserPermissions(this.props.siteUrl, this.props.list);
const eventsData: IEventData[] = await this.spService.getEvents(escape(this.props.siteUrl), escape(this.props.list), this.props.eventStartDate.value, this.props.eventEndDate.value);
this.setState({ eventData: eventsData, hasError: false, errorMessage: "" });
} catch (error) {
this.setState({ hasError: true, errorMessage: error.message, isloading: false });
}
}
/**
iconText='Configure your web part'
description='Please configure the web part.'
buttonLabel='Configure'
hideButton={this.props.displayMode === DisplayMode.Read}
onConfigure={() => this._onConfigure()} />
}
{/* Show description web part property, when set */}
{this.props.sitekey &&
<div>
<p>
</p>
{ this.captcha = el; } }
sitekey={escape(this.props.sitekey)}
onChange={this.onChange} />
<p>
</p><p> { this._messageContainer = elm; }}>
</p>
<p></p>
this.buttonClicked()} />
</div>
}
);
}
return;
// Handling the top placeholder
if (!this._topPlaceholder) {
this._topPlaceholder = this.context.placeholderProvider.tryCreateContent(
PlaceholderName.Top,
{
onDispose: this._onDispose
});
}
if (this._topPlaceholder && this._topPlaceholder.domElement) {
this._topPlaceholder.domElement.innerHTML = `
<div class="${styles.app}">
<div class="ms-bgColor-themeDark ms-fontColor-white ${styles.header}">
<i aria-hidden="true" class="ms-Icon ms-Icon--Info"></i> ${escape(strings.Message)}
<a href="${this._viewUrl}">${escape(strings.GoToList)}</a>
</div>
</div>`;
}
}