Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nsteenbeek committed Feb 5, 2021
2 parents 8257ebd + afd5f88 commit 5da9549
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 295 deletions.
2 changes: 1 addition & 1 deletion bin/main.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion bin/root/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
webpack.config.js
karma.conf.js
i18next-scanner.config.js
test-main.js
postcss.config.js
msbuild-formatter.js
Expand Down
38 changes: 0 additions & 38 deletions bin/root/i18next-scanner.config.js

This file was deleted.

58 changes: 39 additions & 19 deletions bin/root/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
// Karma configuration
// Generated on Tue Oct 23 2018 17:26:53 GMT+0200 (W. Europe Daylight Time)
var path = require("path");
var webpackConfig = require("./webpack.config.js");
webpackConfig.module.rules.push({
test: /\.ts$/,
exclude: [
path.resolve(__dirname, "test"),
/node_modules|\.spec\.ts$/,
],
enforce: "post",
use: {
loader: "istanbul-instrumenter-loader",
options: { esModules: true }
}
});

const webpackConfig = {
resolve: {
extensions: [".js", ".json", ".ts", ".tsx"]
},
module: {
rules: [{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/
}, {
test: /\.ts$/,
enforce: "post",
use: {
loader: "coverage-istanbul-loader",
options: { esModules: true }
}
}]
},
devtool: "inline-source-map",
}

module.exports = function (config) { //eslint-disable-line max-lines-per-function
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "../..",
basePath: "",


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ["jasmine"],

frameworks: ["jasmine", "webpack"],

plugins: [
"karma-webpack",
"karma-jasmine",
"karma-coverage",
"karma-junit-reporter",
"karma-sourcemap-loader",
"karma-chrome-launcher"
],

// list of files / patterns to load in the browser
files: [
Expand All @@ -41,7 +55,7 @@ module.exports = function (config) { //eslint-disable-line max-lines-per-functio
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"./test-main.js": ["webpack", "sourcemap"],
"./test-main.js": ["webpack", "sourcemap", "coverage"],
},


Expand Down Expand Up @@ -95,9 +109,15 @@ module.exports = function (config) { //eslint-disable-line max-lines-per-functio
coverageReporter: {
// specify a common output directory
dir: "testresults/coverage",
instrumenterOptions: {
istanbul: {
noCompact: true
}
},
reporters: [
// reporters not supporting the `file` property
{ type: "html", subdir: "report-html" },
// { type: 'lcov', subdir: 'report-lcov' },
// reporters supporting the `file` property, use `subdir` to directly
// output them in the `dir` directory
//{ type: 'text', subdir: '.', file: 'text.txt' },
Expand Down
10 changes: 4 additions & 6 deletions bin/root/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"setFormCustomizable:true": "node tools/setFormCustomizable.js --customizable true",
"setFormCustomizable:false": "node tools/setFormCustomizable.js --customizable false",
"clean": "IF exist dist (rmdir /s /q dist)",
"deploy": "hso-d365 deploy",
"watch": "webpack --watch",
"start": "webpack serve",
"starthttps": "webpack serve --https",
"lint": "eslint ./ --ext .js,.ts,.tsx",
"i18next-scanner": "i18next-scanner --config i18next-scanner.config.js src/**/*.{js,ts,tsx}"
"lint": "eslint ./ --ext .js,.ts,.tsx"
},
"devDependencies": {
"@babel/core": "^7.12.10",
Expand All @@ -32,14 +32,12 @@
"babel-loader": "^8.2.2",
"babel-plugin-istanbul": "^6.0.0",
"copy-webpack-plugin": "^7.0.0",
"coverage-istanbul-loader": "^3.0.5",
"cross-env": "^7.0.3",
"css-loader": "^5.0.1",
"cssnano": "^4.1.10",
"eslint": "^7.16.0",
"eslint-loader": "^4.0.2",
"i18next": "^19.8.4",
"i18next-scanner": "^3.0.0",
"istanbul-instrumenter-loader": "^3.0.1",
"json-loader": "^0.5.7",
"karma": "^5.2.3",
"karma-chrome-launcher": "^3.1.0",
Expand All @@ -48,7 +46,7 @@
"karma-junit-reporter": "^2.0.1",
"karma-sourcemap-loader": "^0.3.8",
"karma-tap": "^4.2.0",
"karma-webpack": "^4.0.2",
"karma-webpack": "^5.0.0",
"mini-css-extract-plugin": "^1.3.3",
"moment": "^2.29.1",
"node-sass": "^5.0.0",
Expand Down
17 changes: 6 additions & 11 deletions bin/root/src/translation/Translation.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import crmJson from '../../tools/crm.json';
import {TranslationI18n} from './TranslationI18n';

export class Translation {
public static translate(text: string): string {
if (crmJson.webresource.translation === 'i18n') {
return TranslationI18n.translate(text);
} else {
try {
const relativePath = `${crmJson.crm.publisher_prefix}_/${(crmJson).webresource.namespace}/locales`;
return Xrm.Utility.getResourceString(`${relativePath}/locales`, text);
} catch (e) {
console.log('You probably miss resx dependencies on your javascript file. Please read https://github.com/hso-nn/d365-cli/wiki/Translations');
throw e;
}
try {
const relativePath = `${crmJson.crm.publisher_prefix}_/${(crmJson).webresource.namespace}/locales`;
return Xrm.Utility.getResourceString(`${relativePath}/locales`, text);
} catch (e) {
console.log('You probably miss resx dependencies on your javascript file. Please read https://github.com/hso-nn/d365-cli/wiki/Translations');
throw e;
}
}

Expand Down
76 changes: 0 additions & 76 deletions bin/root/src/translation/TranslationI18n.ts

This file was deleted.

24 changes: 21 additions & 3 deletions bin/root/src/util/FormUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class FormUtil {

static setDisabled(executionContext: Xrm.Events.EventContext, disabled: boolean, attributeNames: string[]): void {
const formContext = executionContext.getFormContext();

attributeNames.forEach((fieldname: string) => {
const formControl: Xrm.Controls.StandardControl = formContext.getControl(fieldname);
if (formControl) {
Expand All @@ -31,7 +30,6 @@ export class FormUtil {

static setVisible(executionContext: Xrm.Events.EventContext, visible: boolean, attributeNames: string[]): void {
const formContext = executionContext.getFormContext();

attributeNames.forEach((fieldname: string) => {
const formControl: Xrm.Controls.StandardControl = formContext.getControl(fieldname);
if (formControl) {
Expand All @@ -40,12 +38,32 @@ export class FormUtil {
});
}

static setValue(executionContext: Xrm.Events.EventContext, value: any, attributeNames: string[]): void {
const formContext = executionContext.getFormContext();
attributeNames.forEach((fieldname: string) => {
const attribute: Xrm.Attributes.Attribute = formContext.getAttribute(fieldname);
if (attribute) {
attribute.setValue(value);
}
});
}

static setRequiredLevel(executionContext: Xrm.Events.EventContext, level: Xrm.Attributes.RequirementLevel, attributeNames: string[]): void {
const formContext = executionContext.getFormContext();
attributeNames.forEach((fieldname: string) => {
const attribute: Xrm.Attributes.Attribute = formContext.getAttribute(fieldname);
if (attribute) {
attribute.setRequiredLevel(level);
}
});
}

static async getLookupValue(attributeName: string, id: string, executionContext: Xrm.Events.EventContext): Promise<Xrm.LookupValue> {
const formContext = executionContext.getFormContext(),
entityName = formContext.data.entity.getEntityName(),
entityMetadata = await Xrm.Utility.getEntityMetadata(entityName, [attributeName]),
attributeMetadata = entityMetadata.Attributes.get(attributeName);
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
for (const target of attributeMetadata.Targets) {
try {
Expand Down
3 changes: 1 addition & 2 deletions bin/root/tools/crm.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"url": "<%= environment %>"
},
"webresource": {
"namespace": "<%= namespace %>",
"translation": "<%= translationtype %>"
"namespace": "<%= namespace %>"
},
"adal": {
"clientId": "3d14ef79-de44-4358-bb18-75b54d1c4e4e",
Expand Down
Loading

0 comments on commit 5da9549

Please sign in to comment.