Skip to content

Commit

Permalink
Исправить ошибку с невозможностью отредактировать персонажа, когда вы…
Browse files Browse the repository at this point in the history
…ключено редактирование групп (#2846)
  • Loading branch information
leotsarev authored Oct 16, 2024
1 parent 5ca65a5 commit 8751994
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using JoinRpg.DataModel;
using JoinRpg.Helpers.Validation;
using JoinRpg.PrimitiveTypes;
using JoinRpg.PrimitiveTypes.ProjectMetadata;

Expand All @@ -25,7 +24,7 @@ public abstract class CharacterViewModelBase : IProjectIdAware, IValidatableObje

public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (!ParentCharacterGroupIds.Any())
if (AllowToSetGroups && ParentCharacterGroupIds.Length == 0)
{
yield return new ValidationResult(
"Персонаж должен принадлежать хотя бы к одной группе");
Expand All @@ -34,11 +33,11 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex

public CustomFieldsViewModel Fields { get; set; }

[CannotBeEmpty, DisplayName("Является частью групп")]
[DisplayName("Является частью групп")]
public int[] ParentCharacterGroupIds { get; set; } = [];

[ReadOnly(true)]
public bool AllowToSetGroups { get; set; } = true;
public bool AllowToSetGroups { get; set; }

protected void FillFields(Character field, int currentUserId, ProjectInfo projectInfo)
{
Expand Down

0 comments on commit 8751994

Please sign in to comment.