本文整理汇总了TypeScript中@microsoft/sp-lodash-subset.isEmpty函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isEmpty函数的具体用法?TypeScript isEmpty怎么用?TypeScript isEmpty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isEmpty函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: generateTaxonomyFilter
/*************************************************************************************************
* Generates a valid CAML filter string based on the specified taxonomy filter
* @param filter : The taxonomy filter that needs to be formatted into a CAML filter string
*************************************************************************************************/
private static generateTaxonomyFilter(filter:IQueryFilter): string
{
let filterOutput = '';
let filterTerms = filter.value as ITag[];
if(isEmpty(filter.value)) {
return '';
}
else if (filter.operator == QueryFilterOperator.ContainsAny || filterTerms == null) {
let values = filterTerms != null ? filterTerms.map(x => Text.format("<Value Type='Integer'>{0}</Value>", x.key)).join('') : '';
filterOutput = Text.format("<In><FieldRef Name='{0}' LookupId='TRUE' /><Values>{1}</Values></In>", filter.field.internalName, values);
}
else if (filter.operator == QueryFilterOperator.ContainsAll) {
let taxFilters: IQueryFilter[] = [];
for(let term of filterTerms) {
let termValue:ITag[] = [ term ];
let taxFilter:IQueryFilter = {
index: null,
field: filter.field,
value: termValue,
join: QueryFilterJoin.And,
operator: QueryFilterOperator.ContainsAny
};
taxFilters.push(taxFilter);
}
filterOutput = this.generateFilters(taxFilters);
}
return filterOutput;
}
示例2:
response.json().then((data:any) => {
let fields:any[] = data.value;
let fieldTermSetId = null;
if(fields.length > 0) {
let field = fields[0];
if(field.IsTermSetValid && !isEmpty(field.TermSetId)) {
fieldTermSetId = field.TermSetId;
}
}
resolve(fieldTermSetId);
})
示例3: generateCamlQuery
/*************************************************************************************************
* Generates a full CAML query based on the provided IQuerySettings
* @param querySettings : A IQuerySettings object required for generating the CAML query
*************************************************************************************************/
public static generateCamlQuery(querySettings:IQuerySettings): string {
let query = '';
// Generates the <Where /> part
if(querySettings.filters && !isEmpty(querySettings.filters)) {
let sortedFilters = querySettings.filters.sort((a, b) => { return a.index - b.index; });
query += Text.format('<Where>{0}</Where>', this.generateFilters(sortedFilters));
}
// Generates the <OrderBy /> part
if(querySettings.orderBy && !isEmpty(querySettings.orderBy)) {
let isAscending = querySettings.orderByDirection == 'desc' ? 'FALSE' : 'TRUE';
query += Text.format("<OrderBy><FieldRef Name='{0}' Ascending='{1}' /></OrderBy>", querySettings.orderBy, isAscending);
}
// Wraps the <Where /> and <OrderBy /> into a <Query /> tag
query = Text.format('<Query>{0}</Query>', query);
// Generates the <RowLimit /> part
if(querySettings.limitEnabled) {
query += Text.format('<RowLimit>{0}</RowLimit>', querySettings.itemLimit);
}
// Generates the <ViewFields /> part
if(querySettings.viewFields && !isEmpty(querySettings.viewFields)) {
query += Text.format('<ViewFields>{0}</ViewFields>', querySettings.viewFields.map(field => Text.format("<FieldRef Name='{0}' />", field)).join(''));
}
// Wraps the everything into a final <View /> tag
if(querySettings.recursiveEnabled) {
query = Text.format('<View Scope="RecursiveAll">{0}</View>', query);
}
else {
query = Text.format('<View>{0}</View>', query);
}
return query;
}
示例4: formatFilterValue
/*************************************************************************************************
* Returns the value of the specified filter correctly formatted based on its type of value
* @param filter : The filter that needs its value to be formatted
*************************************************************************************************/
private static formatFilterValue(filter:IQueryFilter): string
{
let filterValue = "";
if(filter.field.type == QueryFilterFieldType.Datetime) {
if(filter.expression != null && !isEmpty(filter.expression)) {
filterValue = this.formatDateExpressionFilterValue(filter.expression);
}
else {
filterValue = this.formatDateFilterValue(filter.value as string);
}
}
else {
filterValue = this.formatTextFilterValue(filter.value as string);
}
return filterValue;
}
示例5: generateUserFilter
/*************************************************************************************************
* Generates a valid CAML filter string based on the specified user filter
* @param filter : The user filter that needs to be formatted into a CAML filter string
*************************************************************************************************/
private static generateUserFilter(filter:IQueryFilter): string
{
let filterOutput = '';
let filterUsers = filter.value as IPersonaProps[];
if(filter.me) {
filterOutput = Text.format("<Eq><FieldRef Name='{0}' /><Value Type='Integer'><UserID /></Value></Eq>", filter.field.internalName);
}
else if(isEmpty(filter.value)) {
return '';
}
else if (filter.operator == QueryFilterOperator.ContainsAny || filterUsers == null)
{
let values = filterUsers != null ? filterUsers.map(x => Text.format("<Value Type='Integer'>{0}</Value>", x.optionalText)).join('') : '';
filterOutput = Text.format("<In><FieldRef Name='{0}' LookupId='TRUE' /><Values>{1}</Values></In>", filter.field.internalName, values);
}
else if (filter.operator == QueryFilterOperator.ContainsAll)
{
let userFilters: IQueryFilter[] = [];
for(let user of filterUsers) {
let userValue:IPersonaProps[] = [ user ];
let userFilter:IQueryFilter = {
index: null,
field: filter.field,
value: userValue,
join: QueryFilterJoin.And,
operator: QueryFilterOperator.ContainsAny
};
userFilters.push(userFilter);
}
filterOutput = this.generateFilters(userFilters);
}
return filterOutput;
}