Skip to content

Commit fb1508b

Browse files
authored
Temporary disable new character group selector (#1519)
1 parent e7000b0 commit fb1508b

File tree

4 files changed

+60
-75
lines changed

4 files changed

+60
-75
lines changed

src/JoinRpg.Portal/Controllers/CharacterController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public async Task<ActionResult> Edit(int projectId, int characterId)
8080
IsAcceptingClaims = field.IsAcceptingClaims,
8181
HidePlayerForCharacter = field.HidePlayerForCharacter,
8282
Name = field.CharacterName,
83-
ParentCharacterGroupIds = field.Groups.Where(gr => !gr.IsSpecial).Select(pg => pg.CharacterGroupId).ToArray(),
83+
ParentCharacterGroupIds = field.GetParentGroupsForEdit(),
8484
IsHot = field.IsHot,
8585
}.Fill(field, CurrentUserId));
8686
}
@@ -104,7 +104,7 @@ await CharacterService.EditCharacter(
104104
viewModel.ProjectId,
105105
viewModel.Name,
106106
viewModel.IsPublic,
107-
viewModel.ParentCharacterGroupIds,
107+
viewModel.ParentCharacterGroupIds.GetUnprefixedGroups(),
108108
viewModel.IsAcceptingClaims &&
109109
field.ApprovedClaim == null,
110110
viewModel.HidePlayerForCharacter,
@@ -144,7 +144,7 @@ public async Task<ActionResult> Create(int projectid, int? charactergroupid, boo
144144
{
145145
ProjectId = projectid,
146146
ProjectName = characterGroup.Project.ProjectName,
147-
ParentCharacterGroupIds = new[] { characterGroup.CharacterGroupId },
147+
ParentCharacterGroupIds = characterGroup.AsPossibleParentForEdit(),
148148
ContinueCreating = continueCreating,
149149
}.Fill(characterGroup, CurrentUserId));
150150
}
@@ -154,14 +154,14 @@ public async Task<ActionResult> Create(int projectid, int? charactergroupid, boo
154154
[ValidateAntiForgeryToken]
155155
public async Task<ActionResult> Create(AddCharacterViewModel viewModel)
156156
{
157-
var characterGroupId = viewModel.ParentCharacterGroupIds.FirstOrDefault();
157+
var characterGroupId = viewModel.ParentCharacterGroupIds.GetUnprefixedGroups().FirstOrDefault();
158158
try
159159
{
160160
await CharacterService.AddCharacter(new AddCharacterRequest(
161161
ProjectId: viewModel.ProjectId,
162162
Name: viewModel.Name,
163163
IsAcceptingClaims: viewModel.IsAcceptingClaims,
164-
ParentCharacterGroupIds: viewModel.ParentCharacterGroupIds,
164+
ParentCharacterGroupIds: viewModel.ParentCharacterGroupIds.GetUnprefixedGroups(),
165165
HidePlayerForCharacter: viewModel.HidePlayerForCharacter,
166166
IsHot: viewModel.IsHot,
167167
IsPublic: viewModel.IsPublic,

src/JoinRpg.Portal/Views/Character/Create.cshtml

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,100 +2,90 @@
22
@model JoinRpg.Web.Models.Characters.AddCharacterViewModel
33

44
@{
5-
ViewBag.Title = "Добавление персонажа в игру " + Model.ProjectName;
5+
ViewBag.Title = "Добавление персонажа в игру " + Model.ProjectName;
66
}
77

88
<h2>@ViewBag.Title</h2>
99

1010

11-
@using (Html.BeginForm("Create", "Character", new { Model.ProjectId }, FormMethod.Post))
11+
@using (Html.BeginForm("Create", "Character", new {Model.ProjectId}, FormMethod.Post))
1212
{
13-
@Html.AntiForgeryToken()
14-
@Html.HiddenFor(model => model.ProjectId)
13+
@Html.AntiForgeryToken()
14+
@Html.HiddenFor(model => model.ProjectId)
1515

16-
<div class="form-horizontal">
16+
<div class="form-horizontal">
1717
@if (Model.LegacyNameMode)
1818
{
19-
<div class="form-group">
19+
<div class="form-group">
2020
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
2121
<div class="col-md-10">
22-
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
23-
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
22+
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
23+
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
2424
</div>
25-
</div>
25+
</div>
2626
}
2727

2828
<div class="form-group">
29-
@Html.LabelFor(model => model.ParentCharacterGroupIds, htmlAttributes: new { @class = "control-label col-md-2" })
30-
<div class="col-md-10">
31-
<component type="typeof(JoinRpg.Web.CharacterGroups.CharacterGroupSelector)"
32-
param-ProjectId="Model.ProjectId"
33-
param-Name="@("ParentCharacterGroupIds")"
34-
param-SelectedGroups="@(Model.ParentCharacterGroupIds)"
35-
render-mode="WebAssembly" />
36-
</div>
29+
@Html.LabelFor(model => model.ParentCharacterGroupIds, htmlAttributes: new { @class = "control-label col-md-2" })
30+
<div class="col-md-10">
31+
@Html.MagicSelectParent(model => model.ParentCharacterGroupIds)
32+
@Html.ValidationMessageFor(model => model.ParentCharacterGroupIds, "", new { @class = "text-danger" })
33+
</div>
3734
</div>
3835

3936
<div class="form-group">
40-
@Html.LabelFor(model => model.IsPublic, htmlAttributes: new { @class = "control-label col-md-2" })
41-
<div class="col-md-10">
42-
@Html.EditorFor(model => model.IsPublic)
43-
@Html.ValidationMessageFor(model => model.IsPublic, "", new { @class = "text-danger" })
44-
</div>
37+
@Html.LabelFor(model => model.IsPublic, htmlAttributes: new { @class = "control-label col-md-2" })
38+
<div class="col-md-10">
39+
@Html.EditorFor(model => model.IsPublic)
40+
@Html.ValidationMessageFor(model => model.IsPublic, "", new { @class = "text-danger" })
41+
</div>
4542
</div>
4643

4744
<div class="form-group">
48-
@Html.LabelFor(model => model.IsAcceptingClaims, htmlAttributes: new { @class = "control-label col-md-2" })
49-
<div class="col-md-10">
50-
@Html.EditorFor(model => model.IsAcceptingClaims)
51-
@Html.ValidationMessageFor(model => model.IsAcceptingClaims, "", new { @class = "text-danger" })
52-
</div>
45+
@Html.LabelFor(model => model.IsAcceptingClaims, htmlAttributes: new { @class = "control-label col-md-2" })
46+
<div class="col-md-10">
47+
@Html.EditorFor(model => model.IsAcceptingClaims)
48+
@Html.ValidationMessageFor(model => model.IsAcceptingClaims, "", new { @class = "text-danger" })
49+
</div>
5350
</div>
5451

5552
<div class="form-group">
56-
@Html.LabelFor(model => model.HidePlayerForCharacter, htmlAttributes: new { @class = "control-label col-md-2" })
57-
<div class="col-md-10">
58-
@Html.EditorFor(model => model.HidePlayerForCharacter)
59-
@Html.ValidationMessageFor(model => model.HidePlayerForCharacter, "", new { @class = "text-danger" })
60-
</div>
53+
@Html.LabelFor(model => model.HidePlayerForCharacter, htmlAttributes: new { @class = "control-label col-md-2" })
54+
<div class="col-md-10">
55+
@Html.EditorFor(model => model.HidePlayerForCharacter)
56+
@Html.ValidationMessageFor(model => model.HidePlayerForCharacter, "", new { @class = "text-danger" })
57+
</div>
6158
</div>
6259

6360
<div class="form-group">
64-
@Html.LabelFor(model => model.IsHot, htmlAttributes: new { @class = "control-label col-md-2" })
65-
<div class="col-md-10">
66-
@Html.EditorFor(model => model.IsHot)
67-
@Html.ValidationMessageFor(model => model.IsHot, "", new { @class = "text-danger" })
68-
</div>
61+
@Html.LabelFor(model => model.IsHot, htmlAttributes: new { @class = "control-label col-md-2" })
62+
<div class="col-md-10">
63+
@Html.EditorFor(model => model.IsHot)
64+
@Html.ValidationMessageFor(model => model.IsHot, "", new { @class = "text-danger" })
65+
</div>
6966
</div>
7067

7168
@await Html.PartialAsync("_EditFieldsPartial", Model.Fields)
7269

7370
@if (Model.Fields.Fields.Any(f => f.HasPrice))
7471
{
75-
Html.RenderPartial("_CharacterFieldsSubtotal", Model.Fields);
72+
Html.RenderPartial("_CharacterFieldsSubtotal", Model.Fields);
7673
}
7774

7875
<div class="form-group">
79-
@Html.LabelFor(model => model.ContinueCreating, htmlAttributes: new { @class = "control-label col-md-2" })
80-
<div class="col-md-10">
81-
@Html.EditorFor(model => model.ContinueCreating)
82-
@Html.ValidationMessageFor(model => model.ContinueCreating, "", new { @class = "text-danger" })
83-
@Html.DescriptionFor(model => model.ContinueCreating)
84-
</div>
76+
@Html.LabelFor(model => model.ContinueCreating, htmlAttributes: new { @class = "control-label col-md-2" })
77+
<div class="col-md-10">
78+
@Html.EditorFor(model => model.ContinueCreating)
79+
@Html.ValidationMessageFor(model => model.ContinueCreating, "", new { @class = "text-danger" })
80+
@Html.DescriptionFor(model => model.ContinueCreating)
81+
</div>
8582
</div>
8683

8784
<div class="form-group">
88-
<div class="col-md-offset-2 col-md-10">
89-
<input type="submit" value="Создать персонажа" class="btn btn-success" /> |
90-
@Html.ActionLink("Назад к сетке ролей", "Index", "GameGroups", new { @Model.ProjectId }, null)
91-
</div>
85+
<div class="col-md-offset-2 col-md-10">
86+
<input type="submit" value="Создать персонажа" class="btn btn-success" /> |
87+
@Html.ActionLink("Назад к сетке ролей", "Index", "GameGroups", new { @Model.ProjectId }, null)
88+
</div>
9289
</div>
93-
</div>
94-
}
95-
96-
@section Scripts {
97-
<script src="/_framework/blazor.webassembly.js"></script>
98-
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
99-
<script src="/Scripts/blazor-interop.js"></script>
100-
90+
</div>
10191
}

src/JoinRpg.Portal/Views/Character/Edit.cshtml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11

22
@model JoinRpg.Web.Models.Characters.EditCharacterViewModel
33
@section Scripts {
4-
<script src="~/Scripts/claim.js"></script>
5-
<script src="/_framework/blazor.webassembly.js"></script>
6-
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
7-
<script src="/Scripts/blazor-interop.js"></script>
4+
<script src="~/Scripts/claim.js"></script>
85
}
96

107

@@ -92,16 +89,13 @@
9289
</div>
9390
</div>
9491

95-
<div class="form-group">
96-
@Html.LabelFor(model => model.ParentCharacterGroupIds, htmlAttributes: new { @class = "control-label col-md-2" })
97-
<div class="col-md-10">
98-
<component type="typeof(JoinRpg.Web.CharacterGroups.CharacterGroupSelector)"
99-
param-ProjectId="Model.ProjectId"
100-
param-Name="@("ParentCharacterGroupIds")"
101-
param-SelectedGroups="@(Model.ParentCharacterGroupIds)"
102-
render-mode="WebAssembly" />
92+
<div class="form-group">
93+
@Html.LabelFor(model => model.ParentCharacterGroupIds, htmlAttributes: new { @class = "control-label col-md-2" })
94+
<div class="col-md-8">
95+
@Html.MagicSelectParent(model => model.ParentCharacterGroupIds)
96+
@Html.ValidationMessageFor(model => model.ParentCharacterGroupIds, "", new { @class = "text-danger" })
97+
</div>
10398
</div>
104-
</div>
10599

106100
@await Html.PartialAsync("_EditFieldsPartial", Model.Fields)
107101

@@ -129,3 +123,4 @@
129123
</div>
130124
</div>
131125
}
126+

src/JoinRpg.WebPortal.Models/Characters/CharacterViewModels.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
4848
public bool LegacyNameMode { get; protected set; }
4949

5050
[CannotBeEmpty, DisplayName("Является частью групп")]
51-
public int[] ParentCharacterGroupIds { get; set; } = new int[0] { };
51+
public List<string> ParentCharacterGroupIds { get; set; } = new();
5252

5353
protected void FillFields(Character field, int currentUserId)
5454
{

0 commit comments

Comments
 (0)