Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UMT-10 decimal precision setting support for data class #29

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/Enums/FormComponents.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
|`TFormComponentValue`||`ObjectSelectorBase`|`TProperties`|**abstract**|
|`TFormComponentValue`||`SingleObjectSelectorBase`|`TProperties`|**abstract**|
|`Kentico.Xperience.Admin.Base.Forms.TileSelectorItem`|`Kentico.Administration.TileSelector`|`TileSelectorComponent`|`TileSelectorProperties`||
|`TValue`||`DateInputComponentBase`|`TProperties`|**abstract**|
|`TValue`||`DateTimeInputComponentBase`|`TProperties`|**abstract**|
|`TValue`||`FormComponent`|`FormComponentProperties`|**abstract**|
|`TValue`||`FormComponentWithNestedComponents`|`TProperties`|**abstract**|

Expand Down
6 changes: 4 additions & 2 deletions docs/Model/ContentItemCommonDataModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ This sample describes how to create content item data inside XbyK
"ArticleText": "This article is only example of creation UMT model for en-US language",
"RelatedArticles": null,
"RelatedFaq": null,
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]"
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]",
"ArticleDecimalNumberSample": 123456.12345
}
```

Expand All @@ -44,7 +45,8 @@ This sample describes how to create content item data inside XbyK
"ArticleText": "This article is only example of creation UMT model for en-GB language",
"RelatedArticles": null,
"RelatedFaq": null,
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]"
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]",
"ArticleDecimalNumberSample": 123456.12345
}
```

Expand Down
12 changes: 8 additions & 4 deletions docs/Model/ContentItemDataModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ This sample describes how to create content item data inside XbyK
"ArticleText": "This article is only example of creation UMT model for en-US language",
"RelatedArticles": null,
"RelatedFaq": null,
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]"
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]",
"ArticleDecimalNumberSample": 123456.12345
}
```

Expand All @@ -42,7 +43,8 @@ This sample describes how to create content item data inside XbyK
"ArticleText": "This article is only example of creation UMT model for en-GB language",
"RelatedArticles": null,
"RelatedFaq": null,
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]"
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]",
"ArticleDecimalNumberSample": 123456.12345
}
```

Expand Down Expand Up @@ -83,7 +85,8 @@ This sample describes how to create content item data inside XbyK
"ArticleTitle": "en-US UMT model creation",
"ArticleText": "This article is only example of creation UMT model for en-US language",
"RelatedArticles": "[{\u0022WebPageGuid\u0022:\u00226e995319-77e7-475e-9ebb-607bdbf5af9a\u0022}]",
"RelatedFaq": "[{\u0022Identifier\u0022:\u0022b64b3e3e-f5a9-4d02-8cdb-6d81805c0fee\u0022}]"
"RelatedFaq": "[{\u0022Identifier\u0022:\u0022b64b3e3e-f5a9-4d02-8cdb-6d81805c0fee\u0022}]",
"ArticleDecimalNumberSample": 123456.12345
}
```

Expand All @@ -98,6 +101,7 @@ This sample describes how to create content item data inside XbyK
"ArticleTitle": "en-GB UMT model creation",
"ArticleText": "This article is only example of creation UMT model for en-GB language",
"RelatedArticles": "[{\u0022WebPageGuid\u0022:\u00226e995319-77e7-475e-9ebb-607bdbf5af9a\u0022}]",
"RelatedFaq": "[{\u0022Identifier\u0022:\u0022b64b3e3e-f5a9-4d02-8cdb-6d81805c0fee\u0022}]"
"RelatedFaq": "[{\u0022Identifier\u0022:\u0022b64b3e3e-f5a9-4d02-8cdb-6d81805c0fee\u0022}]",
"ArticleDecimalNumberSample": 123456.12345
}
```
17 changes: 17 additions & 0 deletions docs/Model/DataClassModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ This sample describes how to create class inside XbyK to hold Article data
"ControlName": "Kentico.Administration.TextInput"
}
},
{
"AllowEmpty": true,
"Column": "ArticleDecimalNumberSample",
"ColumnSize": 15,
"ColumnType": "decimal",
"Enabled": true,
"Guid": "8e749651-773b-47b9-a888-c541c3c3e1b7",
"Visible": true,
"Properties": {
"FieldCaption": "Article decimal number sample"
},
"Settings": {
"ControlName": "Kentico.Administration.DecimalNumberInput"
},
"Precision": 5
},
{
"AllowEmpty": true,
"Column": "ArticleText",
Expand Down Expand Up @@ -275,6 +291,7 @@ Represents information about custom data field
|Visible|Field visibility in administration form|bool||
|Properties|[definition](#FormFieldProperties)|Kentico.Xperience.UMT.Model.FormFieldProperties||
|Settings|[definition](#FormFieldSettings)|Kentico.Xperience.UMT.Model.FormFieldSettings||
|Precision|Specifies precision, relevant for fields with ColumnType "decimal"|int?||

<p>*) value is required</p>

Expand Down
22 changes: 8 additions & 14 deletions docs/Model/UMT.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
"type": "null"
}
]
},
"properties": {
"CustomProperties": {
"type": "object",
"additionalProperties": {}
}
}
},
"ChannelModel": {
Expand Down Expand Up @@ -630,6 +624,14 @@
},
"Settings": {
"$ref": "#/definitions/FormFieldSettings"
},
"Precision": {
"type": [
"integer",
"null"
],
"description": "Specifies precision, relevant for fields with ColumnType \"decimal\" ",
"format": "int32"
}
}
},
Expand All @@ -651,10 +653,6 @@
"string"
],
"description": "Friendly name displayed in form"
},
"CustomProperties": {
"type": "object",
"additionalProperties": {}
}
}
},
Expand All @@ -676,10 +674,6 @@
"string"
],
"description": "Admin UI Component used for field data editing"
},
"CustomProperties": {
"type": "object",
"additionalProperties": {}
}
}
},
Expand Down
61 changes: 46 additions & 15 deletions docs/Samples/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,24 @@
},
"Settings": {
"ControlName": "Kentico.Administration.TextInput"
}
},
"Precision": null
},
{
"AllowEmpty": true,
"Column": "ArticleDecimalNumberSample",
"ColumnSize": 15,
"ColumnType": "decimal",
"Enabled": true,
"Guid": "8e749651-773b-47b9-a888-c541c3c3e1b7",
"Visible": true,
"Properties": {
"FieldCaption": "Article decimal number sample"
},
"Settings": {
"ControlName": "Kentico.Administration.DecimalNumberInput"
},
"Precision": 5
},
{
"AllowEmpty": true,
Expand All @@ -211,7 +228,8 @@
},
"Settings": {
"ControlName": "Kentico.Administration.TextArea"
}
},
"Precision": null
},
{
"AllowEmpty": true,
Expand All @@ -231,7 +249,8 @@
"MaximumPages": 5,
"Sortable": "False",
"TreePath": "/Articles"
}
},
"Precision": null
},
{
"AllowEmpty": true,
Expand All @@ -249,7 +268,8 @@
"Settings": {
"ControlName": "Kentico.Administration.ContentItemSelector",
"AllowedContentItemTypeIdentifiers": "[\u00227ed6604e-613b-4ce0-8c21-acfb372c416a\u0022]"
}
},
"Precision": null
},
{
"AllowEmpty": true,
Expand All @@ -267,7 +287,8 @@
"Settings": {
"ControlName": "Kentico.Administration.TagSelector",
"TaxonomyGroup": "[\u0022bd88fd9b-8d36-4d02-a4a6-9a2b26c48488\u0022]"
}
},
"Precision": null
}
]
},
Expand Down Expand Up @@ -309,7 +330,8 @@
},
"Settings": {
"ControlName": "Kentico.Administration.TextInput"
}
},
"Precision": null
},
{
"AllowEmpty": false,
Expand All @@ -324,7 +346,8 @@
},
"Settings": {
"ControlName": "Kentico.Administration.TextInput"
}
},
"Precision": null
}
]
},
Expand Down Expand Up @@ -361,7 +384,8 @@
},
"Settings": {
"ControlName": "Kentico.Administration.TextInput"
}
},
"Precision": null
},
{
"AllowEmpty": true,
Expand All @@ -376,7 +400,8 @@
},
"Settings": {
"ControlName": "Kentico.Administration.TextArea"
}
},
"Precision": null
},
{
"AllowEmpty": true,
Expand All @@ -391,7 +416,8 @@
},
"Settings": {
"ControlName": "Kentico.Administration.DateTimeInput"
}
},
"Precision": null
},
{
"AllowEmpty": true,
Expand All @@ -406,7 +432,8 @@
},
"Settings": {
"ControlName": "Kentico.Administration.Checkbox"
}
},
"Precision": null
}
]
},
Expand Down Expand Up @@ -595,7 +622,8 @@
"ArticleText": "This article is only example of creation UMT model for en-US language",
"RelatedArticles": null,
"RelatedFaq": null,
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]"
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]",
"ArticleDecimalNumberSample": 123456.12345
},
{
"$type": "ContentItemData",
Expand All @@ -606,7 +634,8 @@
"ArticleText": "This article is only example of creation UMT model for en-GB language",
"RelatedArticles": null,
"RelatedFaq": null,
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]"
"CoffeaTaxonomy": "[{\u0022Identifier\u0022:\u0022ffe48372-2bac-4a14-ad8c-c86f3f54c7c5\u0022}]",
"ArticleDecimalNumberSample": 123456.12345
},
{
"$type": "ContentItemLanguageMetadata",
Expand Down Expand Up @@ -704,7 +733,8 @@
"ArticleTitle": "en-US UMT model creation",
"ArticleText": "This article is only example of creation UMT model for en-US language",
"RelatedArticles": "[{\u0022WebPageGuid\u0022:\u00226e995319-77e7-475e-9ebb-607bdbf5af9a\u0022}]",
"RelatedFaq": "[{\u0022Identifier\u0022:\u0022b64b3e3e-f5a9-4d02-8cdb-6d81805c0fee\u0022}]"
"RelatedFaq": "[{\u0022Identifier\u0022:\u0022b64b3e3e-f5a9-4d02-8cdb-6d81805c0fee\u0022}]",
"ArticleDecimalNumberSample": 123456.12345
},
{
"$type": "ContentItemReference",
Expand All @@ -721,7 +751,8 @@
"ArticleTitle": "en-GB UMT model creation",
"ArticleText": "This article is only example of creation UMT model for en-GB language",
"RelatedArticles": "[{\u0022WebPageGuid\u0022:\u00226e995319-77e7-475e-9ebb-607bdbf5af9a\u0022}]",
"RelatedFaq": "[{\u0022Identifier\u0022:\u0022b64b3e3e-f5a9-4d02-8cdb-6d81805c0fee\u0022}]"
"RelatedFaq": "[{\u0022Identifier\u0022:\u0022b64b3e3e-f5a9-4d02-8cdb-6d81805c0fee\u0022}]",
"ArticleDecimalNumberSample": 123456.12345
},
{
"$type": "ContentItemReference",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public static class ContentItemSamples
["CoffeaTaxonomy"] = System.Text.Json.JsonSerializer.Serialize(new List<object>
{
new {Identifier = TaxonomySamples.SampleTagCoffeaArabicaGuid},
})
}),
["ArticleDecimalNumberSample"] = 123456.12345M
}
};


[Sample("contentitemlanguagemetadata.sample.article.enus", "This sample describes how to create class inside XbyK to hold Content Item Language Metadata", "ContentItemLanguageMetadata Sample")]
public static ContentItemLanguageMetadataModel SampleArticleContentItemLanguageMetadataEnUs => new()
{
Expand Down Expand Up @@ -129,7 +129,8 @@ public static class ContentItemSamples
["CoffeaTaxonomy"] = System.Text.Json.JsonSerializer.Serialize(new List<object>
{
new {Identifier = TaxonomySamples.SampleTagCoffeaArabicaGuid},
})
}),
["ArticleDecimalNumberSample"] = 123456.12345M
}
};

Expand Down Expand Up @@ -221,7 +222,8 @@ public static class ContentItemSamples
["RelatedArticles"] = $$"""[{"WebPageGuid":"{{SampleArticleWebPageItem.WebPageItemGUID}}"}]""",
["RelatedFaq"] = $$"""
[{"Identifier":"{{SampleFaqContentItemGuid}}"}]
"""
""",
["ArticleDecimalNumberSample"] = 123456.12345M
}
};

Expand Down Expand Up @@ -291,7 +293,8 @@ public static class ContentItemSamples
["RelatedArticles"] = $$"""[{"WebPageGuid":"{{SampleArticleWebPageItem.WebPageItemGUID}}"}]""",
["RelatedFaq"] = $$"""
[{"Identifier":"{{SampleFaqContentItemGuid}}"}]
"""
""",
["ArticleDecimalNumberSample"] = 123456.12345M
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ public static class DataClassSamples
Properties = new FormFieldProperties { FieldCaption = "Article title", },
Settings = new FormFieldSettings { ControlName = "Kentico.Administration.TextInput" }
},

new()
{
Column = "ArticleDecimalNumberSample",
ColumnType = "decimal",
ColumnSize = 15,
Precision = 5,
AllowEmpty = true,
Visible = true,
Enabled = true,
Guid = new Guid("8E749651-773B-47B9-A888-C541C3C3E1B7"),
Properties = new FormFieldProperties { FieldCaption = "Article decimal number sample", },
Settings = new FormFieldSettings { ControlName = "Kentico.Administration.DecimalNumberInput" }
},

new()
{
Expand Down
6 changes: 5 additions & 1 deletion src/Kentico.Xperience.UMT/InfoAdapter/DataClassAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ public override DataClassInfo Adapt(IUmtModel input)
DataType = field.ColumnType,
Enabled = field.Enabled,
Visible = field.Visible,
Size = field.ColumnSize
Size = field.ColumnSize,
};
if (field.Precision is { } precision)
{
nfi.Precision = precision;
}
nfi.Caption = field.Properties.FieldCaption;
nfi.Settings[CONTROL_NAME] = field.Settings.ControlName;

Expand Down
Loading
Loading