Пример #1
0
        /// <summary>
        /// Handles adding new item to repeatable edit group
        /// </summary>
        /// <param name="repeatableEditGroup">Repeatable edit group for adding new item</param>
        /// <inheritdoc />
        public override void UserWillInsertNewGroupInRepeatableEditGroup(UPMRepeatableEditGroup repeatableEditGroup)
        {
            Dictionary <string, string> childInitialValues = null;
            string key = this.ChildGroupKey;

            if (key.StartsWith("."))
            {
                key = $"#{key.Substring(1)}";
            }

            List <Dictionary <string, string> > childInitialValueArray = this.EditPageContext.InitialValues.ValueOrDefault(key) as List <Dictionary <string, string> >;

            if (childInitialValueArray?.Count > 0)
            {
                childInitialValues = childInitialValueArray[0];
            }

            UPMStandardGroup group = this.CreateNewGroup(childInitialValues);

            if (group != null)
            {
                repeatableEditGroup.AddChild(group);
            }

            if (this.MaxChildren > 0 && repeatableEditGroup.Groups.Count >= this.MaxChildren)
            {
                repeatableEditGroup.AddingEnabled = false;
            }
        }
Пример #2
0
        UPMGroup GroupFromParticipantControl()
        {
            UPMRepeatableEditGroup repeatableEditGroup = new UPMRepeatableEditGroup(this.TabIdentifierForRecordIdentification(this.LinkRecordIdentification));

            repeatableEditGroup.LabelText         = this.TabLabel();
            repeatableEditGroup.AddGroupLabelText = upText_AddNewGroup;
            repeatableEditGroup.AddingEnabled     = this.AddRecordEnabled;
            foreach (UPCRMRepParticipant participant in this.ParticipantsControl.Participants)
            {
                string           repIdString           = participant.Key;
                UPMIdentifier    participantIdentifier = UPMStringIdentifier.IdentifierWithStringId(repIdString);
                UPMStandardGroup group = new UPMStandardGroup(participantIdentifier);
                NSNumber         num   = participant.Options.ObjectForKey("must");
                group.Deletable = this.DeleteRecordEnabled && !num.IntegerValue;
                UPMDependsEditField editField = this.CreateEditFieldWithParticipantIdentifierEditGroup(participantIdentifier, group);
                editField.MainField.FieldValue = participant.RepIdString;
                if (this.ParticipantsControl.HasRepAcceptance && participant.CanChangeAcceptanceState)
                {
                    editField.DependField.FieldValue = participant.AcceptanceText;
                }
                else
                {
                    editField.DependField.FieldValue = null;
                }

                editField.DependField2.FieldValue = participant.RequirementText;
                group.AddField(editField);
                repeatableEditGroup.AddGroup(group);
                this.AddGroupForKey(group, repIdString);
            }
            this.Group           = repeatableEditGroup;
            this.ControllerState = UPGroupModelControllerStateFinished;
            return(repeatableEditGroup);
        }
Пример #3
0
        private UPMGroup GroupFromParticipantControl()
        {
            var repeatableEditGroup = new UPMRepeatableEditGroup(this.TabIdentifierForRecordIdentification(this.LinkRecordIdentification))
            {
                LabelText         = this.TabLabel,
                AddGroupLabelText = LocalizedString.TextAddNewGroup,
                AddingEnabled     = this.AddRecordEnabled
            };

            if (this.ParticipantsControl.Participants.Count > 0)
            {
                UPCRMRepParticipant sparticipant           = (UPCRMRepParticipant)this.ParticipantsControl.Participants[0];
                IIdentifier         sparticipantIdentifier = StringIdentifier.IdentifierWithStringId(sparticipant.Key);
                var group = new UPMStandardGroup(sparticipantIdentifier);


                foreach (UPCRMRepParticipant participant in this.ParticipantsControl.Participants)
                {
                    var         repIdString           = participant.Key;
                    IIdentifier participantIdentifier = StringIdentifier.IdentifierWithStringId(repIdString);
                    //var group = new UPMStandardGroup(participantIdentifier);

                    var num = participant.Options.ValueOrDefault("must") as string;
                    group.Deletable = this.DeleteRecordEnabled && Convert.ToInt32(num) == 0;

                    var editField = this.CreateEditFieldWithParticipantIdentifierEditGroup(participantIdentifier, group);
                    editField.MainField.FieldValue = participant.RepIdString;

                    if (this.ParticipantsControl.HasRepAcceptance && participant.CanChangeAcceptanceState)
                    {
                        editField.DependField.FieldValue = participant.AcceptanceText;
                    }
                    else
                    {
                        editField.DependField.FieldValue = null;
                    }

                    editField.DependField2.FieldValue = participant.RequirementText;
                    group.AddField(editField);
                }

                repeatableEditGroup.AddChild(group);
                this.AddGroupForKey(group, sparticipant.Key);
            }
            else
            {
                IIdentifier sparticipantIdentifier = StringIdentifier.IdentifierWithStringId("00000");
                var         group     = new UPMStandardGroup(sparticipantIdentifier);
                var         editField = this.CreateEditFieldWithParticipantIdentifierEditGroup(sparticipantIdentifier, group);
                group.AddField(editField);
                repeatableEditGroup.AddChild(group);
                this.AddGroupForKey(group, "00000");
            }

            this.Group           = repeatableEditGroup;
            this.ControllerState = GroupModelControllerState.Finished;
            return(repeatableEditGroup);
        }
        private UPMGroup GroupFromParticipantControl()
        {
            UPMRepeatableEditGroup repeatableEditGroup = new UPMRepeatableEditGroup(this.TabIdentifierForRecordIdentification(this.LinkRecordIdentification));

            repeatableEditGroup.LabelText = this.TabLabel;
            this.selectorArray            = new List <UPRecordSelector>();

            for (int fieldNumber = 0; fieldNumber < this.TabConfig.NumberOfFields; fieldNumber++)
            {
                UPConfigFieldControlField configFieldControlField = this.TabConfig.Fields[fieldNumber];
                var selector = configFieldControlField.Attributes.Selector;

                if (selector != null)
                {
                    var recordSelector = new UPRecordSelector("KP", null, -1, selector, null, this.ParticipantsField);
                    this.selectorArray.Add(recordSelector);
                }
            }

            if (this.selectorArray.Count < 1)
            {
                repeatableEditGroup.AddingEnabled = false;
                if (this.ParticipantsControl.Participants.Count < 1)
                {
                    this.Group           = null;
                    this.ControllerState = GroupModelControllerState.Empty;
                    return(null);
                }
            }
            else
            {
                repeatableEditGroup.AddGroupLabelText = LocalizedString.TextAddNewGroup;
                repeatableEditGroup.AddingEnabled     = this.AddRecordEnabled;
            }

            foreach (UPCRMLinkParticipant participant in this.ParticipantsControl.Participants)
            {
                string           recordIdentification  = participant.RecordIdentification;
                IIdentifier      participantIdentifier = new RecordIdentifier(recordIdentification);
                UPMStandardGroup group = new UPMStandardGroup(participantIdentifier);
                string           num   = participant.Options.ValueOrDefault("must") as string;
                group.Deletable = !participant.MayNotBeDeleted && this.DeleteRecordEnabled && num.ToInt() == 0;
                UPMDependsEditField editField = this.CreateEditFieldWithParticipantIdentifierEditGroup(participantIdentifier, group);
                editField.MainField.FieldValue = participant.Name;
                ((UPMParticipantsRecordSelectorEditField)editField.MainField).Participant = participant;
                editField.DependField.FieldValue  = participant.AcceptanceText;
                editField.DependField2.FieldValue = participant.RequirementText;
                bool editOfflineRecord = ConfigurationUnitStore.DefaultStore.ConfigValueIsSetDefaultValue("RecordSelect.EditOfflineRecord", false);
                editField.Deletable = !participant.IsOfflineEmptyParticipant || editOfflineRecord;
                group.AddField(editField);
                repeatableEditGroup.AddChild(group);
                this.AddGroupForKey(group, participant.Key);
            }

            this.Group           = repeatableEditGroup;
            this.ControllerState = GroupModelControllerState.Finished;
            return(repeatableEditGroup);
        }
        /// <summary>
        /// Adds the groups with initial values.
        /// </summary>
        /// <param name="_initialValues">The initial values.</param>
        public override void AddGroupsWithInitialValues(List <Dictionary <string, object> > _initialValues)
        {
            UPMRepeatableEditGroup repeatableEditGroup = (UPMRepeatableEditGroup)this.Group;

            foreach (var initialValuesForGroup in _initialValues)
            {
                UPMStandardGroup group = null;
                string           key   = (initialValuesForGroup[".Key"] as List <string>)?[0];

                if (!string.IsNullOrEmpty(key))
                {
                    group = this.groupForKey[key];
                    UPChildEditContext childEditContext = this.ChildEditContextForGroup(group);
                    if (childEditContext != null && repeatableEditGroup.Groups.Contains(group))
                    {
                        this.UpdateChildEditContext(childEditContext, initialValuesForGroup);
                        return;
                    }
                    else
                    {
                        group = null;
                    }
                }

                if (group == null)
                {
                    group = this.CreateNewGroup(initialValuesForGroup);
                    if (group != null)
                    {
                        repeatableEditGroup.AddChild(group);
                        if (!string.IsNullOrEmpty(key))
                        {
                            if (this.groupForKey != null)
                            {
                                this.groupForKey.SetObjectForKey(group, key);
                            }
                            else
                            {
                                this.groupForKey = new Dictionary <string, UPMStandardGroup> {
                                    { key, group }
                                };
                            }
                        }
                    }
                }
            }
        }
        private int AddRecordsToGroup(UPMRepeatableEditGroup repeatableEditGroup, List <UPCRMRecord> addedRecords, int count)
        {
            if (addedRecords != null)
            {
                foreach (var record in addedRecords)
                {
                    var standardGroup = this.CreateNewGroupFromRecordAsNew(record, true);
                    if (standardGroup != null)
                    {
                        ++count;
                        repeatableEditGroup.AddChild(standardGroup);
                    }
                }
            }

            return(count);
        }
        private UPMGroup GroupFromChildResult(UPCRMResult childResult)
        {
            var repeatableEditGroup =
                new UPMRepeatableEditGroup(this.TabIdentifierForRecordIdentification(this.LinkRecordIdentification))
            {
                LabelText         = this.TabLabel,
                AddGroupLabelText = LocalizedString.TextAddNewGroup,
                AddingEnabled     = this.AddRecordEnabled
            };
            var count = childResult?.RowCount ?? 0;

            this.retainedResult = childResult;
            var childFieldControlTab = this.ChildFieldControl.TabAtIndex(0);

            this.ChildEditContexts = new Dictionary <string, UPChildEditContext>();

            this.PopulateRecords(out var addedRecords, out var changedRecords);

            if (count > 0)
            {
                this.AddRecordsToGroup(repeatableEditGroup, count, childResult, changedRecords, childFieldControlTab);
            }
            else if (this.EditPageContext.IsNewRecord && string.IsNullOrEmpty(this.EditPageContext.OfflineRequest?.Error))
            {
                count = this.AddRecordsToGroup(repeatableEditGroup);
                if (count == 0 && !this.AddRecordEnabled)
                {
                    return(null);
                }
            }

            count = this.AddRecordsToGroup(repeatableEditGroup, addedRecords, count);

            if (this.MaxChildren > 0 && repeatableEditGroup.Groups.Count >= this.MaxChildren)
            {
                repeatableEditGroup.AddingEnabled = false;
            }

            this.Group = repeatableEditGroup;
            return(this.Group);
        }
        private int AddRecordsToGroup(UPMRepeatableEditGroup repeatableEditGroup)
        {
            var count = 0;
            var parentInitialValues            = this.EditPageContext.InitialValues;
            var childGroupKey                  = this.ChildGroupKey;
            var parentInitialValueDictionaries = parentInitialValues.ValueOrDefault(childGroupKey) as List <Dictionary <string, object> >;

            if (parentInitialValueDictionaries != null)
            {
                foreach (var parentInitialValueForChild in parentInitialValueDictionaries)
                {
                    var standardGroup = this.CreateNewGroup(parentInitialValueForChild);
                    if (standardGroup != null)
                    {
                        ++count;
                        repeatableEditGroup.AddChild(standardGroup);
                    }
                }
            }

            return(count);
        }
        /// <summary>
        /// Handles adding new item to repeatable edit group
        /// </summary>
        /// <param name="repeatableEditGroup">Repeatable edit group for adding new item</param>
        public override void UserWillInsertNewGroupInRepeatableEditGroup(UPMRepeatableEditGroup repeatableEditGroup)
        {
            string key = $"#{this.ChildInfoAreaId}.{(this.LinkId < 0 ? 0 : this.LinkId)}";
            var    childInitialValueArray = this.EditPageContext.InitialValues[key] as List <Dictionary <string, object> >;
            Dictionary <string, object> childInitialValues = null;

            if (childInitialValueArray?.Count > 0)
            {
                childInitialValues = childInitialValueArray[0];
            }

            UPMStandardGroup group = this.CreateNewGroup(childInitialValues);

            if (group != null)
            {
                repeatableEditGroup.AddChild(group);
            }

            if (this.MaxChildren > 0 && repeatableEditGroup.Groups.Count >= this.MaxChildren)
            {
                repeatableEditGroup.AddingEnabled = false;
            }
        }
        private void AddRecordsToGroup(
            UPMRepeatableEditGroup repeatableEditGroup,
            int count,
            UPCRMResult childResult,
            Dictionary <string, UPCRMRecord> changedRecords,
            FieldControlTab childFieldControlTab)
        {
            for (var i = 0; i < count; i++)
            {
                var childRow         = (UPCRMResultRow)childResult.ResultRowAtIndex(i);
                var childEditContext = new UPChildEditContext(childRow, this.NextPostfix);
                var changedRecord    = changedRecords.ValueOrDefault(childRow.RootRecordId);
                var initialRecords   = changedRecord != null ? new List <UPCRMRecord> {
                    changedRecord
                } : null;

                var editFieldContextArray = this.EditContextsForResultRow(childRow, childFieldControlTab, childEditContext.EditFieldContext, null, childEditContext.FieldLabelPostfix, initialRecords);
                var editFieldCount        = editFieldContextArray.Count;
                if (editFieldCount > 0)
                {
                    var standardGroup = new UPMStandardGroup(new RecordIdentifier(childRow.RootRecordIdentification))
                    {
                        Deletable = this.DeleteRecordEnabled
                    };
                    childEditContext.Group = standardGroup;
                    this.AddChildRecordContext(childEditContext);
                    for (var j = 0; j < editFieldCount; j++)
                    {
                        var field = editFieldContextArray[j];
                        AddFieldToGroup(standardGroup, field, childEditContext);
                    }

                    childEditContext.HandleDependentFields();
                    repeatableEditGroup.AddChild(standardGroup);
                }
            }
        }
 /// <summary>
 /// Handles adding new item to repeatable edit group
 /// </summary>
 /// <param name="repeatableEditGroup">Repeatable edit group for adding new item</param>
 public virtual void UserWillInsertNewGroupInRepeatableEditGroup(UPMRepeatableEditGroup repeatableEditGroup)
 {
 }
 /// <summary>
 /// Handles removing an item from repeatable edit group
 /// </summary>
 /// <param name="group">Group to remove</param>
 /// <param name="repeatableEditGroup">Repeatable edit group to remove from</param>
 public virtual void UserWillDeleteGroupInRepeatableEditGroup(UPMGroup group, UPMRepeatableEditGroup repeatableEditGroup)
 {
 }
        /// <summary>
        /// Handles removing an item from repeatable edit group
        /// </summary>
        /// <param name="group">Group to remove</param>
        /// <param name="repeatableEditGroup">Repeatable edit group to remove from</param>
        public override void UserWillDeleteGroupInRepeatableEditGroup(UPMGroup group, UPMRepeatableEditGroup repeatableEditGroup)
        {
            UPChildEditContext editContext = this.ChildContextForGroup(group);

            if (editContext != null)
            {
                repeatableEditGroup.RemoveChild(group);
                if (this.MaxChildren > 0)
                {
                    repeatableEditGroup.AddingEnabled = this.AddRecordEnabled;
                }

                editContext.DeleteRecord = true;
                if (this.AddedChildEditContexts.Contains(editContext))
                {
                    this.AddedChildEditContexts.Remove(editContext);
                }
            }
        }
Пример #14
0
        /// <summary>
        /// Handles removing an item from repeatable edit group
        /// </summary>
        /// <param name="group">Group to remove</param>
        /// <param name="repeatableEditGroup">Repeatable edit group to remove from</param>
        public override void UserWillDeleteGroupInRepeatableEditGroup(UPMGroup group, UPMRepeatableEditGroup repeatableEditGroup)
        {
            string participantKey = this.KeyForEditGroup(group);

            if (!string.IsNullOrEmpty(participantKey))
            {
                UPCRMParticipant participant = this.ParticipantsControl.ParticipantWithKey(participantKey);
                if (participant != null && this.ParticipantsControl.MarkParticipantAsDeleted(participant))
                {
                    repeatableEditGroup.RemoveChild(group);
                    if (this.MaxChildren > 0)
                    {
                        repeatableEditGroup.AddingEnabled = this.AddRecordEnabled;
                    }
                }
            }
        }