Skip to content

Commit

Permalink
Merge branch 'release/5.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
nsteenbeek committed Sep 3, 2021
2 parents fad43b6 + 45a5e4c commit 0913b15
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 20 deletions.
1 change: 0 additions & 1 deletion bin/Entity/Entity.attributesContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* This is a generated file, please regenerate and do not modify */

import {EntityAttributeNames} from './Entity.enum';
import FormContext = Xrm.FormContext;

export class EntityFormContext {}
5 changes: 2 additions & 3 deletions bin/Entity/Entity.formContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* This is a generated file, please regenerate and do not modify */

import {EntityFormContext} from '../Entity.formContext';
import FormContext = Xrm.FormContext;
import {EntityFormContext as AttributeFormContext} from '../Entity.formContext';

export class FormNameFormContext extends EntityFormContext {}
export class FormNameFormContext extends AttributeFormContext {}
2 changes: 1 addition & 1 deletion bin/main.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions bin/root/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# Project information

## CLI

This project is generated by and uses the [@hso/d365-cli](https://github.com/hso-nn/d365-cli).

* [Installation](https://github.com/hso-nn/d365-cli/wiki/Installation)
* [Wiki](https://github.com/hso-nn/d365-cli/wiki)
* [CLI Commands](https://github.com/hso-nn/d365-cli/wiki/CLICommands)
* [Debugging](https://github.com/hso-nn/d365-cli/wiki/Debugging)

The project package.json file contains a 'scripts' part as well for if you are familiar with npm
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hso/d365-cli",
"version": "5.5.2",
"version": "5.5.3",
"author": "HSO Innovation <[email protected]> (http://www.hso.com)",
"description": "Dynamics 365 Command Line Interface for TypeScript projects for Dataverse",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/generator/AttributeFormContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class AttributeFormContext {
const xrmAttributeType = await this.getXrmAttributeType(attributeType);
if (xrmAttributeType) {
const pascalSchemaName = AttributeFormContext.capitalize(schemaName);
const methodName = ` static get${pascalSchemaName}Attribute(formContext: FormContext): ${xrmAttributeType} {`;
const methodName = ` static get${pascalSchemaName}Attribute(formContext: Xrm.FormContext): ${xrmAttributeType} {`;
const returnString = `return formContext.getAttribute(${this.entityName}AttributeNames.${pascalSchemaName});`;
formContextAttributesString += `${methodName}\n ${returnString}\n }\n`;
}
Expand Down
29 changes: 17 additions & 12 deletions src/generator/ControlFormContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export class ControlFormContext {
shell.sed('-i', new RegExp('Entity', 'g'), this.entityName, formContextFilepath);
shell.sed('-i', new RegExp('FormName', 'g'), formName, formContextFilepath);
shell.exec(`git add ${formContextFilepath}`);
const filedata = String(fs.readFileSync(formContextFilepath));
const replaceString = `${formName}FormContext extends ${this.entityName}FormContext {`;
const newFileData = filedata.replace(replaceString, `${replaceString}\n${formContextControlsString}`);
const fileData = String(fs.readFileSync(formContextFilepath));
const replaceString = fileData.match(new RegExp(`${formName}FormContext extends AttributeFormContext {`, 'ig'))[0];
const newFileData = fileData.replace(replaceString, `${replaceString}\n${formContextControlsString}`);
shell.ShellString(newFileData).to(formContextFilepath);
await this.log(`Generated ${formName}/${formName}.formContext.ts<br/>`);
}
Expand All @@ -58,13 +58,15 @@ export class ControlFormContext {
return formContextControlsString;
}

private static usedSectionNames: string[];
private async getTabsString(tabs: FormJsonTab[]): Promise<string> {
let tabsControlsString = '';
ControlFormContext.usedSectionNames = [];
for (const tab of tabs) {
const tabName = tab.Name;
if (tabName) {
const pascalTabName = ControlFormContext.capitalize(tabName.replace(/\W/g, ''));
const methodName = ` static get${pascalTabName}Tab(formContext: FormContext): Xrm.Controls.Tab {`;
const methodName = ` static get${pascalTabName}Tab(formContext: Xrm.FormContext): Xrm.Controls.Tab {`;
const returnString = `return formContext.ui.tabs.get('${tabName}');`;
tabsControlsString += `${methodName}\n ${returnString}\n }\n`;
tabsControlsString += await this.getColumnsString(tab, tab.Columns.$values);
Expand All @@ -81,17 +83,20 @@ export class ControlFormContext {
return columnsControlsString;
}

private static usedNames: string[];
private static usedControlNames: string[];
private async getSectionsString(tab: FormJsonTab, sections: FormJsonSection[]): Promise<string> {
let sectionsControlsString = '';
ControlFormContext.usedNames = [];
ControlFormContext.usedControlNames = [];
for (const section of sections) {
const {Name: sectionName} = section;
if (sectionName) {
const pascalSectionName = ControlFormContext.capitalize(sectionName.replace(/\W/g, ''));
const methodName = ` static get${pascalSectionName}Section(formContext: FormContext): Xrm.Controls.Section {`;
const returnString = `return formContext.ui.tabs.get('${tab.Name}').sections.get('${sectionName}');`;
sectionsControlsString += `${methodName}\n ${returnString}\n }\n`;
if (!ControlFormContext.usedSectionNames.includes(pascalSectionName)) {
ControlFormContext.usedSectionNames.push(pascalSectionName);
const methodName = ` static get${pascalSectionName}Section(formContext: Xrm.FormContext): Xrm.Controls.Section {`;
const returnString = `return formContext.ui.tabs.get('${tab.Name}').sections.get('${sectionName}');`;
sectionsControlsString += `${methodName}\n ${returnString}\n }\n`;
}
sectionsControlsString += await this.getRowsString(section.Rows.$values);
}
}
Expand All @@ -118,9 +123,9 @@ export class ControlFormContext {
if (xrmControlType) {
const pascalSchemaName = dataFieldName === id ?
ControlFormContext.capitalize(attributeMetadata.SchemaName) : ControlFormContext.capitalize(id);
if (!ControlFormContext.usedNames.includes(pascalSchemaName)) {
ControlFormContext.usedNames.push(pascalSchemaName);
const methodName = ` static get${pascalSchemaName}Control(formContext: FormContext): ${xrmControlType} {`;
if (!ControlFormContext.usedControlNames.includes(pascalSchemaName)) {
ControlFormContext.usedControlNames.push(pascalSchemaName);
const methodName = ` static get${pascalSchemaName}Control(formContext: Xrm.FormContext): ${xrmControlType} {`;
const returnString = `return formContext.getControl('${id}');`;
cellControlsString += `${methodName}\n ${returnString}\n }\n`;
} else {
Expand Down
1 change: 0 additions & 1 deletion src/generator/Enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class Enum {
shell.ShellString(fileData + enumAttributeNames + navigationPropertyNames + enumStrings + savedQueries).to(enumFilepath);
}

// eslint-disable-next-line max-lines-per-function
private async getSavedQueriesString(): Promise<string> {
let savedQueriesString = '';
savedQueriesString += `export const ${this.entityName.charAt(0).toLowerCase()}${this.entityName.slice(1)}Views = {\n`;
Expand Down

0 comments on commit 0913b15

Please sign in to comment.