Skip to content

Commit 978d815

Browse files
committed
Improve documentation of a new project
1 parent 8297b14 commit 978d815

5 files changed

Lines changed: 51 additions & 7 deletions

File tree

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,37 @@
1-
import { MnComponent, OnInit } from "@primno/core";
1+
import { MnComponent, PageType, MnOnFormLoad, MnOnFieldChange, FormEventArg } from "@primno/core";
22

3+
/**
4+
* The AppComponent class is defined as a component by the @MnComponent decorator.
5+
* A component is a class that contains an individual piece of functionality to apply to a form or a grid.
6+
* This sample component will show a notification when the form is loaded and when the name field is changed.
7+
*/
38
@MnComponent({
9+
/**
10+
* The scope define when the component will be loaded.
11+
* In this case, the component will be loaded on forms of the account entity.
12+
*/
413
scope: {
5-
pageType: "entityrecord"
14+
pageType: PageType.record,
15+
entityName: "account"
616
}
717
})
8-
export class AppComponent implements OnInit {
9-
public mnOnInit(): void {
10-
Xrm.Navigation.openAlertDialog({ text: "Welcome from Primno" });
18+
export class AppComponent {
19+
/**
20+
* onFormLoad is an event handler that will be called when the form is loaded due to the @MnOnFormLoad decorator.
21+
* Show the notification "Welcome from Primno".
22+
*/
23+
@MnOnFormLoad()
24+
public onFormLoad(eventArg: FormEventArg) {
25+
eventArg.formCtx.ui.setFormNotification("Welcome from Primno", "INFO", "welcome");
26+
}
27+
28+
/**
29+
* onNameChange is an event handler that will be called when the name field is changed due to the @MnOnFieldChange decorator.
30+
* Show the notification "Name changed to <name>".
31+
*/
32+
@MnOnFieldChange("name")
33+
public onNameChange(eventArg: FormEventArg) {
34+
const name = eventArg.formCtx.getAttribute("name").getValue();
35+
eventArg.formCtx.ui.setFormNotification(`Name changed to ${name}`, "INFO", "nameChanged");
1136
}
1237
}

dist/template/new/src/app/app.module.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
import { MnModule } from "@primno/core";
22
import { AppComponent } from "./app.component";
33

4+
/**
5+
* The AppModule class is defined as a module by the @MnModule decorator.
6+
* A module is a container of components.
7+
*/
48
@MnModule({
9+
/**
10+
* The bootstrap property defines that AppComponent will be the root component of the module
11+
* and will be created when the module is loaded.
12+
*/
513
bootstrap: AppComponent,
14+
/**
15+
* The declarations property defines the components that will be available to be child components of the others components of this module.
16+
* In this case, the AppComponent is the only component of this module.
17+
* If you want to create a component that will be a child of the AppComponent, you must define it in the declarations property.
18+
* A component can be declared in only one module.
19+
*/
620
declarations: [
721
AppComponent
822
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
/**
2+
* An entry point corresponds to a webresource that will be deployed to PowerApps / Dynamics 365.
3+
* The main(s) module(s) must be exported here to be loaded and run by Primno.
4+
*/
5+
16
export { AppModule } from "../app/app.module";

src/configuration/workspace-configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface WorkspaceConfig {
4343
export const defaultEnvironnements: Environnement[] = [
4444
{
4545
name: "dev",
46-
connectionString: ""
46+
connectionString: "<set connection string>"
4747
}
4848
];
4949

src/core/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export class Workspace {
212212
const workspaceDir = path.join(dirPath, name);
213213

214214
if (fs.existsSync(workspaceDir)) {
215-
throw new Error("Directory already exist");
215+
throw new Error("Directory already exists");
216216
}
217217

218218
fs.mkdirSync(workspaceDir);

0 commit comments

Comments
 (0)