private static ProjectFieldDropdownValue GetPreviousVariant([NotNull] this ProjectField field,
                                                                    [CanBeNull] ProjectFieldDropdownValue variant)
        {
            if (variant is null)
            {
                return(field.GetOrderedValues().LastOrDefault());
            }
            var variants     = field.GetOrderedValues().ToList();
            var prevPosition = variants.IndexOf(variant) - 1;

            return(prevPosition < 0 ? null : variants[prevPosition]);
        }
 public void FillNotEditable(ProjectField field, int currentUserId)
 {
     DropdownValues = field.GetOrderedValues()
                      .Select(fv => new GameFieldDropdownValueListItemViewModel(fv))
                      .MarkFirstAndLast();
     FieldViewType = (ProjectFieldViewType)field.FieldType;
     FieldBoundTo  = (FieldBoundToViewModel)field.FieldBoundTo;
     IsActive      = field.IsActive;
     HasValueList  = field.HasValueList();
     CanEditFields = field.HasMasterAccess(currentUserId, acl => acl.CanChangeFields);
 }
 public void FillNotEditable(ProjectField field, int currentUserId)
 {
     DropdownValues = field.GetOrderedValues()
                      .Select(fv => new GameFieldDropdownValueListItemViewModel(fv))
                      .MarkFirstAndLast();
     FieldViewType      = (ProjectFieldViewType)field.FieldType;
     FieldBoundTo       = (FieldBoundToViewModel)field.FieldBoundTo;
     IsActive           = field.IsActive;
     HasValueList       = field.HasValueList();
     WasEverUsed        = field.WasEverUsed;
     CanEditFields      = field.HasMasterAccess(currentUserId, acl => acl.CanChangeFields);
     CanDeleteField     = CanEditFields && !field.IsName() && !field.IsRoomSlot() && !field.IsTimeSlot();
     IsTimeField        = field.IsTimeSlot();
     SupportsMassAdding = field.SupportsMassAdding();
 }
Esempio n. 4
0
 public GameFieldEditViewModel(ProjectField field)
 {
     CanPlayerView          = field.CanPlayerView;
     CanPlayerEdit          = field.CanPlayerEdit;
     Description            = field.Description.Contents;
     ProjectFieldId         = field.ProjectFieldId;
     IsPublic               = field.IsPublic;
     Name                   = field.FieldName;
     ProjectId              = field.ProjectId;
     IsActive               = field.IsActive;
     HasValueList           = field.HasValueList();
     DropdownValues         = field.GetOrderedValues().Select(fv => new GameFieldDropdownValueListItemViewModel(fv)).MarkFirstAndLast();
     FieldViewType          = (ProjectFieldViewType)field.FieldType;
     FieldBoundTo           = (FieldBoundToViewModel)field.FieldBoundTo;
     MandatoryStatus        = (MandatoryStatusViewType)field.MandatoryStatus;
     ShowForGroups          = field.GroupsAvailableFor.Select(c => c.CharacterGroupId).PrefixAsGroups().ToList();
     IncludeInPrint         = field.IncludeInPrint;
     ValidForNpc            = field.ValidForNpc;
     ShowForUnApprovedClaim = field.ShowOnUnApprovedClaims;
 }
Esempio n. 5
0
 public FieldWithValue(ProjectField field, [CanBeNull] string value)
 {
     Field             = field;
     Value             = value;
     OrderedValueCache = new Lazy <IReadOnlyList <ProjectFieldDropdownValue> >(() => Field.GetOrderedValues());
 }