Skip to content

Commit

Permalink
Update interface to include sub form prop (#477)
Browse files Browse the repository at this point in the history
* add property for allowing a datatype to be used in a sub form

* migration changes

* fix test issue

* Revert "migration changes"

This reverts commit 5ca3c75.
  • Loading branch information
HauklandJ authored Aug 28, 2024
1 parent f147a15 commit ef586ce
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/Storage.Interface/Models/ApplicationLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ public class ApplicationLogic
/// </summary>
[JsonProperty(PropertyName = "allowUserDelete")]
public bool AllowUserDelete { get; set; }


/// <summary>
/// Specifies whether the data type is compatible with sub form usage.
/// Defaults to false if not specified.
/// </summary>
[JsonProperty(PropertyName = "allowInSubform")]
public bool AllowInSubform { get; set; }

/// <summary>
/// Gets or sets a property containing configuration for shadow fields for the data type.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Linq;
using Altinn.Platform.Storage.Interface.Models;
using FluentAssertions;
using Xunit;

namespace Altinn.Platform.Storage.Interface.Tests.AllowInSubform;

public class AllowInSubformTests
{
[Fact]
public void MetadataWithoutShadowFields_ShouldBeFalse()
{
Application applicationBefore = TestdataHelper.LoadDataFromEmbeddedResourceAsType<Application>("AllowInSubform.applicationMetadata_beforeChange.json");

applicationBefore.DataTypes.First(d => d.Id == "Veileder").AppLogic.AllowInSubform.Should().BeFalse();
}

[Fact]
public void MetadataWithShadowFields_ShouldBeTrue()
{
Application applicationBefore = TestdataHelper.LoadDataFromEmbeddedResourceAsType<Application>("AllowInSubform.applicationMetadata_afterChange.json");

applicationBefore.DataTypes.First(d => d.Id == "Veileder").AppLogic.AllowInSubform.Should().BeTrue();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"id": "ttd/anonymous-stateless",
"org": "ttd",
"title": {
"nb": "anonymous-stateless",
"en": "Oppstart av bedrift"
},
"dataTypes": [
{
"id": "ref-data-as-pdf",
"allowedContentTypes": [
"application/pdf"
],
"maxCount": 0,
"minCount": 0,
"enablePdfCreation": true
},
{
"id": "Veileder",
"allowedContentTypes": [
"application/xml"
],
"appLogic": {
"autoCreate": true,
"classRef": "Altinn.App.Models.StarteBedrift",
"allowUserCreate": true,
"allowUserDelete": true,
"allowInSubform": true
},
"taskId": "Task_1",
"maxCount": 1,
"minCount": 1,
"enablePdfCreation": true
}
],
"onEntry": {
"show": "stateless"
},
"partyTypesAllowed": {
"bankruptcyEstate": false,
"organisation": false,
"person": false,
"subUnit": false
},
"autoDeleteOnProcessEnd": false,
"created": "2022-04-27T08:00:46.5336752Z",
"createdBy": "Ronny",
"lastChanged": "2022-04-27T08:00:46.533678Z",
"lastChangedBy": "Ronny"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"id": "ttd/anonymous-stateless",
"org": "ttd",
"title": {
"nb": "anonymous-stateless",
"en": "Oppstart av bedrift"
},
"dataTypes": [
{
"id": "ref-data-as-pdf",
"allowedContentTypes": [
"application/pdf"
],
"maxCount": 0,
"minCount": 0,
"enablePdfCreation": true
},
{
"id": "Veileder",
"allowedContentTypes": [
"application/xml"
],
"appLogic": {
"autoCreate": true,
"classRef": "Altinn.App.Models.StarteBedrift",
"allowUserCreate": true,
"allowUserDelete": true
},
"taskId": "Task_1",
"maxCount": 1,
"minCount": 1,
"enablePdfCreation": true
}
],
"onEntry": {
"show": "stateless"
},
"partyTypesAllowed": {
"bankruptcyEstate": false,
"organisation": false,
"person": false,
"subUnit": false
},
"autoDeleteOnProcessEnd": false,
"created": "2022-04-27T08:00:46.5336752Z",
"createdBy": "Ronny",
"lastChanged": "2022-04-27T08:00:46.533678Z",
"lastChangedBy": "Ronny"
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@

<ItemGroup>
<EmbeddedResource Include="AllowAnonymousOnStateless\applicationMetadata_beforeChange.json" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="AllowAnonymousOnStateless\applicationMetadata_afterChange.json" />
<EmbeddedResource Include="AllowUserActions\applicationMetadata_afterChange.json" />
<EmbeddedResource Include="AllowUserActions\applicationMetadata_beforeChange.json" />
<EmbeddedResource Include="AllowInSubform\applicationMetadata_afterChange.json" />
<EmbeddedResource Include="AllowInSubform\applicationMetadata_beforeChange.json" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit ef586ce

Please sign in to comment.