-
Notifications
You must be signed in to change notification settings - Fork 3
/
Utilities.ts
30 lines (26 loc) · 1.06 KB
/
Utilities.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { TagItem } from "./types/TagItem";
import { TagRecord } from "./types/TagRecord";
export const EntityToTagItem = (entity: ComponentFramework.WebApi.Entity, connectionId?: string, taggedBy?: string): TagItem => {
//@ts-ignore
const tag: TagRecord = entity;
return {
name: tag.skyve_name,
key: tag.skyve_tagid,
tagType: tag['skyve_scope@OData.Community.Display.V1.FormattedValue'],
createdBy: tag['_createdby_value@OData.Community.Display.V1.FormattedValue'],
groups: tag.skyve_skyve_tag_skyve_taggroup ? ((tag.skyve_skyve_tag_skyve_taggroup).map((val) => { return val['skyve_name'] }).join(', ')) : undefined,
toCreate: false,
entityimage: tag.skyve_entityimage,
connectionid: connectionId,
taggedBy: taggedBy
}
}
export const getLocalString = (context: ComponentFramework.Context<any>, key: string, defaultString: string): string => {
const result = context.resources.getString(key);
if (result != key) {
return result;
}
else {
return defaultString;
}
}