From 646b8b95ad513a3335705418ee95d9d5ff633cbf Mon Sep 17 00:00:00 2001 From: MscrmTools Date: Wed, 26 Jun 2019 11:15:17 +0200 Subject: [PATCH] Added colorization through OptionSet value color --- .../NNCheckboxes/ControlManifest.Input.xml | 10 ++- NNCheckboxes/NNCheckboxes/index.ts | 84 +++++++++++++++++-- .../strings/NNCheckboxes.1033.resx | 4 +- .../strings/NNCheckboxes.1036.resx | 4 +- 4 files changed, 88 insertions(+), 14 deletions(-) diff --git a/NNCheckboxes/NNCheckboxes/ControlManifest.Input.xml b/NNCheckboxes/NNCheckboxes/ControlManifest.Input.xml index 352e027..617d3cd 100644 --- a/NNCheckboxes/NNCheckboxes/ControlManifest.Input.xml +++ b/NNCheckboxes/NNCheckboxes/ControlManifest.Input.xml @@ -1,10 +1,10 @@ - + - - + + @@ -14,6 +14,10 @@ SingleLine.Text OptionSet TwoOptions + + + SingleLine.Text + OptionSet diff --git a/NNCheckboxes/NNCheckboxes/index.ts b/NNCheckboxes/NNCheckboxes/index.ts index 1468bd4..f844e02 100644 --- a/NNCheckboxes/NNCheckboxes/index.ts +++ b/NNCheckboxes/NNCheckboxes/index.ts @@ -17,11 +17,14 @@ export class NNCheckboxes implements ComponentFramework.StandardControl { + if (request.readyState === 4) { + request.onreadystatechange = null; + if (request.status === 200) { + let entityMetadata = JSON.parse(request.response); + let options = entityMetadata.value[0].OptionSet.Options; + thisCtrl._colors = {}; + thisCtrl._colors[attribute] = {} + for (var i = 0; i < options.length; i++) { + thisCtrl._colors[attribute][options[i].Value] = options[i].Color; + } + } else { + let errorText = request.responseText; + console.log(errorText); + } + } + }; + request.send(); + } + public async GetNNRelationshipNameByEntityNames() { let schemaNameParameter = this._context.parameters.relationshipSchemaName; if (schemaNameParameter != undefined && schemaNameParameter.raw != null) { return Promise.resolve(schemaNameParameter.raw); } @@ -307,7 +378,6 @@ export class NNCheckboxes implements ComponentFramework.StandardControl): void { - debugger; if(context.parameters.nnRelationshipDataSet.paging.hasNextPage) { context.parameters.nnRelationshipDataSet.paging.loadNextPage(); diff --git a/NNCheckboxes/NNCheckboxes/strings/NNCheckboxes.1033.resx b/NNCheckboxes/NNCheckboxes/strings/NNCheckboxes.1033.resx index 1b53566..1954a10 100644 --- a/NNCheckboxes/NNCheckboxes/strings/NNCheckboxes.1033.resx +++ b/NNCheckboxes/NNCheckboxes/strings/NNCheckboxes.1033.resx @@ -89,13 +89,13 @@ Background color - Attribute that contains the color to use as background. This attribute must be exposed in the selected view + Attribute that contains the color to use as background. If text attribute, can be color name of hexadecimal code. If optionset attribute, the color of the option will be used. This attribute must be exposed in the selected view Color - Attribute that contains the color to use as forecolor. This attribute must be exposed in the selected view + Attribute that contains the color to use as forecolor. If text attribute, can be color name of hexadecimal code. If optionset attribute, the color of the option will be used. This attribute must be exposed in the selected view Columns diff --git a/NNCheckboxes/NNCheckboxes/strings/NNCheckboxes.1036.resx b/NNCheckboxes/NNCheckboxes/strings/NNCheckboxes.1036.resx index a3e666e..880a164 100644 --- a/NNCheckboxes/NNCheckboxes/strings/NNCheckboxes.1036.resx +++ b/NNCheckboxes/NNCheckboxes/strings/NNCheckboxes.1036.resx @@ -89,13 +89,13 @@ Couleur de fond - Attribut qui sert à définir la couleur de fond de l'enregistrement. L'attribut doit être exposé dans la vue sélectionnée + Attribut qui sert à définir la couleur de fond de l'enregistrement. Si attribut de type texte, la valeur doit être un nom de couleur ou un code hexadécimal. Si attribut de type OptionSet, la couleur de l'option sera utilisée. L'attribut doit être exposé dans la vue sélectionnée Couleur du texte - Attribut qui sert à définir la couleur d'affichage de l'enregistrement. L'attribut doit être exposé dans la vue sélectionnée + Attribut qui sert à définir la couleur d'affichage de l'enregistrement. Si attribut de type texte, la valeur doit être un nom de couleur ou un code hexadécimal. Si attribut de type OptionSet, la couleur de l'option sera utilisée. L'attribut doit être exposé dans la vue sélectionnée Grouper par