Skip to content

Commit

Permalink
Squash merge spr/main/d90419ee
Browse files Browse the repository at this point in the history
  • Loading branch information
Jondyr committed Mar 4, 2025
1 parent 35378c0 commit fa68406
Show file tree
Hide file tree
Showing 18 changed files with 623 additions and 319 deletions.
66 changes: 39 additions & 27 deletions backend/src/Designer/Controllers/LayoutController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class LayoutController(ILayoutService layoutService) : Controller
[ProducesResponseType(StatusCodes.Status404NotFound)]
[HttpGet("pages")]
public async Task<ActionResult<Pages>> GetPages(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
Expand All @@ -37,16 +37,20 @@ [FromRoute] string layoutSetId
[ProducesResponseType(StatusCodes.Status409Conflict)]
[HttpPost("pages")]
public async Task<ActionResult<Page>> CreatePage(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromBody] Page page
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromBody] Page page
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);

Page existingPage = await layoutService.GetPageById(editingContext, layoutSetId, page.id);
Page existingPage = await layoutService.GetPageById(
editingContext,
layoutSetId,
page.id
);
if (existingPage != null)
{
return Conflict();
Expand All @@ -61,10 +65,10 @@ [FromBody] Page page
[HttpGet("pages/{pageId}")]
[ProducesResponseType<Page>(StatusCodes.Status200OK)]
public async Task<ActionResult<Page>> GetPage(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromRoute] string pageId
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromRoute] string pageId
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
Expand All @@ -82,16 +86,20 @@ [FromRoute] string pageId
[ProducesResponseType(StatusCodes.Status404NotFound)]
[HttpPut("pages/{pageId}")]
public async Task<ActionResult<Page>> ModifyPage(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromRoute] string pageId,
[FromBody] Page page
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromRoute] string pageId,
[FromBody] Page page
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
var editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);
Page existingPage = await layoutService.GetPageById(editingContext, layoutSetId, pageId);
Page existingPage = await layoutService.GetPageById(
editingContext,
layoutSetId,
pageId
);
if (existingPage == null)
{
return NotFound();
Expand All @@ -106,10 +114,10 @@ [FromBody] Page page
[ProducesResponseType(StatusCodes.Status404NotFound)]
[HttpDelete("pages/{pageId}")]
public async Task<ActionResult> DeletePage(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromRoute] string pageId
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromRoute] string pageId
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
Expand All @@ -128,14 +136,18 @@ [FromRoute] string pageId
[ProducesResponseType(StatusCodes.Status200OK)]
[HttpPut("pages")]
public async Task<ActionResult> ModifyPages(
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromBody] Pages pages
[FromRoute] string org,
[FromRoute] string app,
[FromRoute] string layoutSetId,
[FromBody] Pages pages
)
{
string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext);
AltinnRepoEditingContext editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer);
AltinnRepoEditingContext editingContext = AltinnRepoEditingContext.FromOrgRepoDeveloper(
org,
app,
developer
);
await layoutService.UpdatePageOrder(editingContext, layoutSetId, pages);
return Ok();
}
Expand Down
Loading

0 comments on commit fa68406

Please sign in to comment.