Skip to content

Commit 620ff98

Browse files
committed
First draft
0 parents  commit 620ff98

13 files changed

+6752
-0
lines changed

.gitignore

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# generated directory
7+
**/generated
8+
9+
# output directory
10+
/out
11+
DataSetControlDemoSolution/DataSetControlDemoSolution.cdsproj
12+
DataSetControlDemoSolution/bin/Debug/DataSetControlDemoSolution.zip
13+
DataSetControlDemoSolution/bin/Debug/SolutionPackager.log
14+
DataSetControlDemoSolution/obj/DataSetControlDemoSolution.cdsproj.nuget.cache
15+
DataSetControlDemoSolution/obj/DataSetControlDemoSolution.cdsproj.nuget.dgspec.json
16+
DataSetControlDemoSolution/obj/DataSetControlDemoSolution.cdsproj.nuget.g.props
17+
DataSetControlDemoSolution/obj/DataSetControlDemoSolution.cdsproj.nuget.g.targets
18+
DataSetControlDemoSolution/obj/project.assets.json
19+
DataSetControlDemoSolution/obj/Debug/Controls/DataSetControlDemo/ControlManifest.xml
20+
DataSetControlDemoSolution/obj/Debug/Controls/DataSetControlDemo/ControlManifest.xml.data.xml
21+
DataSetControlDemoSolution/obj/Debug/Controls/DataSetControlDemo/bundle.js
22+
DataSetControlDemoSolution/obj/Debug/other/Customizations.xml
23+
DataSetControlDemoSolution/obj/Debug/other/Relationships.xml
24+
DataSetControlDemoSolution/obj/Debug/other/Solution.xml
25+
DataSetControlDemoSolution/other/Customizations.xml
26+
DataSetControlDemoSolution/other/Relationships.xml
27+
DataSetControlDemoSolution/other/Solution.xml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<manifest>
3+
<control namespace="dynamicscode" constructor="DataSetControlDemo" version="0.0.1" display-name-key="DataSet Control Demo" description-key="DataSet Control Demo" control-type="standard">
4+
<!-- dataset node represents a set of entity records on CDS; allow more than one datasets -->
5+
<data-set name="dataSetGrid" display-name-key="Dataset Control Demo">
6+
<!-- 'property-set' node represents a unique, configurable property that each record in the dataset must provide. -->
7+
<!-- UNCOMMENT TO ADD PROPERTY-SET NODE
8+
<property-set name="samplePropertySet" display-name-key="Property_Display_Key" description-key="Property_Desc_Key" of-type="SingleLine.Text" usage="bound" required="true" />
9+
-->
10+
</data-set>
11+
<resources>
12+
<code path="index.ts" order="1"/>
13+
<!-- UNCOMMENT TO ADD MORE RESOURCES
14+
<css path="css/DataSetControlDemo.css" order="1" />
15+
<resx path="strings/DataSetControlDemo.1033.resx" version="1.0.0" />
16+
-->
17+
</resources>
18+
</control>
19+
</manifest>

DataSetControlDemo/index.ts

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import {IInputs, IOutputs} from "./generated/ManifestTypes";
2+
import DataSetInterfaces = ComponentFramework.PropertyHelper.DataSetApi;
3+
import * as Vis from 'vis';
4+
import { triggerAsyncId } from "async_hooks";
5+
6+
type DataSet = ComponentFramework.PropertyTypes.DataSet;
7+
8+
// interface Node {
9+
// id: string;
10+
// label: string;
11+
// }
12+
13+
// interface Edge {
14+
// from: string;
15+
// to: string;
16+
// label: string;
17+
// }
18+
19+
export class DataSetControlDemo implements ComponentFramework.StandardControl<IInputs, IOutputs> {
20+
21+
private nodes:any[];
22+
private edges:any[];
23+
private mainContainer: HTMLDivElement;
24+
25+
private vis:Vis.Network;
26+
//let columns:Columns[];
27+
/**
28+
* Empty constructor.
29+
*/
30+
constructor()
31+
{
32+
this.nodes = [];
33+
this.edges = [];
34+
}
35+
36+
/**
37+
* Used to initialize the control instance. Controls can kick off remote server calls and other initialization actions here.
38+
* Data-set values are not initialized here, use updateView.
39+
* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to property names defined in the manifest, as well as utility functions.
40+
* @param notifyOutputChanged A callback method to alert the framework that the control has new outputs ready to be retrieved asynchronously.
41+
* @param state A piece of data that persists in one session for a single user. Can be set at any point in a controls life cycle by calling 'setControlState' in the Mode interface.
42+
* @param container If a control is marked control-type='starndard', it will receive an empty div element within which it can render its content.
43+
*/
44+
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement)
45+
{
46+
// Add control initialization code
47+
this.mainContainer = document.createElement("div");
48+
this.mainContainer.setAttribute("style", "height:400px;");
49+
container.appendChild(this.mainContainer);
50+
}
51+
52+
53+
/**
54+
* Called when any value in the property bag has changed. This includes field values, data-sets, global values such as container height and width, offline status, control metadata values such as label, visible, etc.
55+
* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to names defined in the manifest, as well as utility functions
56+
*/
57+
public updateView(context: ComponentFramework.Context<IInputs>): void
58+
{
59+
// Add code to update control view
60+
//let columns = context.parameters.dataSetGrid.columns;
61+
this.createNodes(context.parameters.dataSetGrid);
62+
this.vis = new Vis.Network(this.mainContainer, { nodes: this.nodes, edges: this.edges}, {});
63+
}
64+
65+
/**
66+
* It is called by the framework prior to a control receiving new data.
67+
* @returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as “bound” or “output”
68+
*/
69+
public getOutputs(): IOutputs
70+
{
71+
return {};
72+
}
73+
74+
/**
75+
* Called when the control is to be removed from the DOM tree. Controls should use this call for cleanup.
76+
* i.e. cancelling any pending remote calls, removing listeners, etc.
77+
*/
78+
public destroy(): void
79+
{
80+
// Add code to cleanup control if necessary
81+
}
82+
83+
private createNodes(gridParam: DataSet): void
84+
{
85+
for (let currentRecordId of gridParam.sortedRecordIds) {
86+
let record1id = (gridParam.records[currentRecordId].getValue("record1id") as any).id.guid;
87+
let record1name = gridParam.records[currentRecordId].getFormattedValue("record1id");
88+
let record2id = (gridParam.records[currentRecordId].getValue("record2id") as any).id.guid;
89+
let record2name = gridParam.records[currentRecordId].getFormattedValue("record2id");
90+
let record2rolename = gridParam.records[currentRecordId].getFormattedValue("record2roleid");
91+
if (this.nodes.find(e => e.id === record2id) === undefined) {
92+
this.nodes.push({
93+
id: record2id,
94+
label: record2name
95+
});
96+
}
97+
98+
if (this.nodes.find(e => e.id === record1id) === undefined) {
99+
this.nodes.push({
100+
id: record1id,
101+
label: record1name
102+
});
103+
}
104+
105+
if (this.edges.find( e=> e.to === record2id) === undefined) {
106+
this.edges.push({
107+
from: record1id,
108+
to: record2id,
109+
label: record2rolename
110+
});
111+
}
112+
}
113+
}
114+
}

PCF-DataSetDemo.pcfproj

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
4+
5+
<PropertyGroup>
6+
<Name>PCF-DataSetDemo</Name>
7+
<ProjectGuid>ec77d592-c1bf-48ed-8139-21ab4ec0a91d</ProjectGuid>
8+
<OutputPath>$(MSBuildThisFileDirectory)out\controls</OutputPath>
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="Microsoft.PowerApps.MSBuild.Pcf" Version="0.1.*"/>
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<Content Include=".\**">
21+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
22+
</Content>
23+
</ItemGroup>
24+
25+
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
26+
</Project>
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"version": 1,
3+
"dgSpecHash": "P4u7IFiiRQ1AaVy5P5PinoeS0qtsVEctp3p+1wiKPlR7CvB80mY5c5grXp+67uZEScGxEvP9WXaKbN/t+7bNlA==",
4+
"success": true
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"format": 1,
3+
"restore": {
4+
"C:\\Tools\\CustomControl\\PCF-DataSetDemo\\PCF-DataSetDemo.pcfproj": {}
5+
},
6+
"projects": {
7+
"C:\\Tools\\CustomControl\\PCF-DataSetDemo\\PCF-DataSetDemo.pcfproj": {
8+
"version": "1.0.0",
9+
"restore": {
10+
"projectUniqueName": "C:\\Tools\\CustomControl\\PCF-DataSetDemo\\PCF-DataSetDemo.pcfproj",
11+
"projectName": "PCF-DataSetDemo",
12+
"projectPath": "C:\\Tools\\CustomControl\\PCF-DataSetDemo\\PCF-DataSetDemo.pcfproj",
13+
"packagesPath": "C:\\Users\\DynamicsCode\\.nuget\\packages\\",
14+
"outputPath": "C:\\Tools\\CustomControl\\PCF-DataSetDemo\\obj\\",
15+
"projectStyle": "PackageReference",
16+
"skipContentFileWrite": true,
17+
"configFilePaths": [
18+
"C:\\Users\\DynamicsCode\\AppData\\Roaming\\NuGet\\NuGet.Config"
19+
],
20+
"originalTargetFrameworks": [
21+
"net40"
22+
],
23+
"sources": {
24+
"https://api.nuget.org/v3/index.json": {}
25+
},
26+
"frameworks": {
27+
"net40": {
28+
"projectReferences": {}
29+
}
30+
}
31+
},
32+
"frameworks": {
33+
"net40": {
34+
"dependencies": {
35+
"Microsoft.PowerApps.MSBuild.Pcf": {
36+
"target": "Package",
37+
"version": "[0.1.*, )"
38+
}
39+
}
40+
}
41+
},
42+
"runtimes": {
43+
"win": {
44+
"#import": []
45+
},
46+
"win-x64": {
47+
"#import": []
48+
},
49+
"win-x86": {
50+
"#import": []
51+
}
52+
}
53+
}
54+
}
55+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
4+
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
5+
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
6+
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">C:\Tools\CustomControl\PCF-DataSetDemo\obj\project.assets.json</ProjectAssetsFile>
7+
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
8+
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\DynamicsCode\.nuget\packages\</NuGetPackageFolders>
9+
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
10+
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.0.0</NuGetToolVersion>
11+
</PropertyGroup>
12+
<PropertyGroup>
13+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
14+
</PropertyGroup>
15+
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
16+
<Import Project="$(NuGetPackageRoot)microsoft.powerapps.msbuild.pcf\0.1.51\build\Microsoft.PowerApps.MSBuild.Pcf.props" Condition="Exists('$(NuGetPackageRoot)microsoft.powerapps.msbuild.pcf\0.1.51\build\Microsoft.PowerApps.MSBuild.Pcf.props')" />
17+
</ImportGroup>
18+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
</PropertyGroup>
6+
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
7+
<Import Project="$(NuGetPackageRoot)microsoft.powerapps.msbuild.pcf\0.1.51\build\Microsoft.PowerApps.MSBuild.Pcf.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.powerapps.msbuild.pcf\0.1.51\build\Microsoft.PowerApps.MSBuild.Pcf.targets')" />
8+
</ImportGroup>
9+
</Project>

0 commit comments

Comments
 (0)