-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from syonfoppen/feuture/syon-room-creation-page
Feuture/syon room creation page
- Loading branch information
Showing
16 changed files
with
657 additions
and
39 deletions.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
src/Estiblazor.UI/Estiblazor.UI/Components/Pages/CreateRoom.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
@page "/createroom" | ||
@rendermode InteractiveServer | ||
|
||
@using Estiblazor.UI.Services.Rooms | ||
@using System.Collections.ObjectModel | ||
@using Estiblazor.UI.Enums | ||
|
||
@inject IRoomCreationService RoomCreationService | ||
@inject NavigationManager nav | ||
|
||
<div class="flex-wrapper"> | ||
<div class="flex-header base"> | ||
<h1>Room: </h1> | ||
|
||
<InputSelect @bind-Value="selectedTemplate" @bind-Value:after="SetTemplate"> | ||
<option selected value="">Select a template</option> | ||
@foreach (var template in Enum.GetValues(typeof(RoomTemplates))) | ||
{ | ||
<option value="@template">@template?.ToString()?.Replace("_", " ")</option> | ||
} | ||
</InputSelect> | ||
</div> | ||
<div class="flex-middle"> | ||
<div class="add-stage-wrapper base"> | ||
<div class="add-stage-overview"> | ||
<h2>Stages</h2> | ||
<div class="stages"> | ||
@foreach (var stage in RoomCreationService.GetStages()) | ||
{ | ||
<div @onclick="() => RoomCreationService.SetSelectedStage(stage.Key)" class="stage @(RoomCreationService.IsSelectedStage(stage.Key) ? "selected" : "")">@stage.Value</div> | ||
} | ||
</div> | ||
|
||
</div> | ||
|
||
<div class="add-stage-input"> | ||
<InputText @bind-Value="NewStageName" class="form-control" placeholder="Stage name" /> | ||
<a class="add-button" @onclick="AddStage">Add Stage</a> | ||
</div> | ||
</div> | ||
<div class="choice-wrapper"> | ||
<div class="choice-overview base"> | ||
@{ | ||
var selectedStage1 = RoomCreationService.GetSelectedStage(); | ||
} | ||
@if (selectedStage1 != null) | ||
{ | ||
|
||
<h3>@selectedStage1.StageName Choices</h3> | ||
|
||
<div class="choices"> | ||
|
||
@foreach (var choice in selectedStage1.AvailableChoices) | ||
{ | ||
<div class="choice" @oncontextmenu="() => RoomCreationService.RemoveChoice(choice.ChoiceId)" @oncontextmenu:preventDefault="true">@((MarkupString)choice.ChoiceName)</div> | ||
} | ||
|
||
</div> | ||
|
||
} | ||
else | ||
{ | ||
<span>No stage selected</span> | ||
} | ||
|
||
</div> | ||
<div class="choice-input base"> | ||
<div> <InputText @bind-Value="NewChoiceName" class="form-control" placeholder="Choice name" /> </div> | ||
<div class="button-wrapper"> | ||
<div> <a class="add-button" @onclick="AddAvailableChoice">Add Choice</a> </div> | ||
<div> <a class="add-button" @onclick="CreateRoomAndNavigate">Create Room</a> </div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
|
||
|
||
@code { | ||
public string? NewStageName { get; set; } | ||
|
||
public string? NewChoiceName { get; set; } | ||
|
||
public RoomTemplates? selectedTemplate { get; set; } | ||
|
||
public void AddStage() | ||
{ | ||
if (!string.IsNullOrEmpty(NewStageName)) | ||
{ | ||
RoomCreationService.AddNewStage(NewStageName); | ||
} | ||
} | ||
|
||
public void AddAvailableChoice() | ||
{ | ||
if (RoomCreationService.GetSelectedStage != null && !string.IsNullOrEmpty(NewChoiceName)) | ||
{ | ||
RoomCreationService.AddNewChoice(NewChoiceName); | ||
NewChoiceName = string.Empty; | ||
} | ||
} | ||
|
||
public void SetTemplate() | ||
{ | ||
if (selectedTemplate != null) | ||
{ | ||
RoomCreationService.SetRoomTemplate(selectedTemplate.Value); | ||
} | ||
} | ||
|
||
public void CreateRoomAndNavigate() | ||
{ | ||
var roomId = RoomCreationService.CreateRoom(); | ||
nav.NavigateTo($"/Rooms/{roomId}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Estiblazor.UI.Enums | ||
{ | ||
public enum RoomTemplates | ||
{ | ||
Planning_Poker, | ||
One_till_ten, | ||
LIKE_DISLIKE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/Estiblazor.UI/Estiblazor.UI/Services/Rooms/AddAvailableChoiceViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Estiblazor.UI.Services.Rooms | ||
{ | ||
public class AddAvailableChoiceViewModel | ||
{ | ||
public Guid ChoiceId { get; set; } = Guid.NewGuid(); | ||
public string ChoiceName { get; set; } = ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/Estiblazor.UI/Estiblazor.UI/Services/Rooms/IRoomCreationService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Estiblazor.UI.Enums; | ||
|
||
namespace Estiblazor.UI.Services.Rooms | ||
{ | ||
public interface IRoomCreationService | ||
{ | ||
void SetRoomTemplate(RoomTemplates roomTemplate); | ||
NewStageModel? GetSelectedStage(); | ||
|
||
IEnumerable<KeyValuePair<Guid, string>> GetStages(); | ||
void AddNewStage(string stageName); | ||
void AddNewChoice(string choice); | ||
void RemoveChoice(Guid choiceId); | ||
bool IsSelectedStage(Guid stageId); | ||
void SetSelectedStage(Guid stageId); | ||
string CreateRoom(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Estiblazor.UI/Estiblazor.UI/Services/Rooms/NewRoomModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Estiblazor.UI.Services.Rooms | ||
{ | ||
public class NewRoomModel | ||
{ | ||
public ICollection<NewStageModel> Stages { get; set; } = []; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Estiblazor.UI/Estiblazor.UI/Services/Rooms/NewStageModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Estiblazor.UI.Services.Rooms | ||
{ | ||
public class NewStageModel | ||
{ | ||
public Guid StageId { get; set; } = Guid.NewGuid(); | ||
public string StageName { get; set; } = ""; | ||
public bool IsSelected { get; set; } = false; | ||
|
||
public ICollection<AddAvailableChoiceViewModel> AvailableChoices { get; set; } = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.