private void UserDidChangeCatalogField(UPMCatalogEditField editField)
        {
            UPEditPageContext  fieldEditPageContext = (UPEditPageContext)editField.EditFieldsContext;
            UPEditFieldContext context = fieldEditPageContext.ContextForEditField(editField);

            if (context.HasDependentFields)
            {
                context.NotifyDependentFields();
                this.SimpleChangedValue(editField);
                this.Delegate.ForceRedraw(this);
            }
            else
            {
                this.SimpleChangedValue(editField);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates the edit field.
        /// </summary>
        /// <returns>
        /// The <see cref="UPMEditField"/>.
        /// </returns>
        public override UPMEditField CreateEditField()
        {
            var field = new UPMCatalogEditField(this.FieldIdentifier);

            foreach (var option in this.options)
            {
                var possibleValue = new UPMCatalogPossibleValue
                {
                    Key             = option.Key,
                    TitleLabelField = new UPMStringField(StringIdentifier.IdentifierWithStringId("x"))
                    {
                        StringValue = option.Value
                    }
                };

                field.AddPossibleValue(possibleValue);
            }

            field.NullValueKey = string.Empty;
            this.ApplyAttributesOnEditFieldConfig(field, this.FieldConfig);

            return(field);
        }
        /// <summary>
        /// Creates the edit field.
        /// </summary>
        /// <returns>
        /// The <see cref="UPMEditField"/>.
        /// </returns>
        public override UPMEditField CreateEditField()
        {
            var field = new UPMCatalogEditField(this.FieldIdentifier, this.MultiSelect);

            if (this.MultiSelect)
            {
                field.MultiSelectMaxCount = this.ChildFields.Count + 1;
            }

            var possibleValues   = this.Catalog?.TextValuesForFieldValues(true);
            var explicitKeyOrder = this.Catalog != null &&
                                   ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("FixedCatalog.SortByCode")
                                       ? this.Catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false)
                                       : this.Catalog?.ExplicitKeyOrderEmptyValueIncludeHidden(false, false);

            var attributes =
                ConfigurationUnitStore.DefaultStore.CatalogAttributesForInfoAreaIdFieldId(
                    this.FieldConfig.InfoAreaId,
                    this.FieldConfig.FieldId);
            var valueForCode0 = possibleValues.ValueOrDefault("0");

            if (string.IsNullOrEmpty(valueForCode0))
            {
                field.NullValueKey = "0";
            }
            else
            {
                field.NullValueText = valueForCode0;
            }

            foreach (var p in possibleValues ?? new Dictionary <string, string>())
            {
                var possibleValue = new UPMCatalogPossibleValue
                {
                    Key             = p.Key,
                    TitleLabelField = new UPMStringField(StringIdentifier.IdentifierWithStringId("x"))
                    {
                        StringValue = p.Value
                    }
                };

                if (!this.MultiSelect || !p.Key.Equals(field.NullValueKey))
                {
                    field.AddPossibleValue(possibleValue);
                }
            }

            var allKeys = field.AllKeysFromPossibleValues;

            foreach (var theObject in allKeys)
            {
                var temp = attributes?.ValuesByCode?.ValueOrDefault(JObjectExtensions.ToInt(theObject));
                if (temp == null)
                {
                    continue;
                }

                var possibleValue = field.PossibleValueForKey(theObject);
                var colorString   = temp.ColorKey;
                if (!string.IsNullOrEmpty(colorString))
                {
                    var color = AureaColor.ColorWithString(colorString);
                    possibleValue.IndicatorColor = color;
                }

                possibleValue.ImageString = temp.ImageName;
            }

            this.ApplyAttributesOnEditFieldConfig(field, this.FieldConfig);
            if (explicitKeyOrder != null)
            {
                field.ExplicitKeyOrder = explicitKeyOrder;
            }

            return(field);
        }
        /// <summary>
        /// Creates the edit field.
        /// </summary>
        /// <returns>
        /// The <see cref="UPMEditField"/>.
        /// </returns>
        public override UPMEditField CreateEditField()
        {
            var field = new UPMCatalogEditField(this.FieldIdentifier, this.MultiSelect)
            {
                NullValueKey = "0"
            };

            if (this.MultiSelect)
            {
                field.MultiSelectMaxCount = this.ChildFields.Count + 1;
            }

            var possibleValues   = this.Catalog?.TextValuesForFieldValues(false);
            var explicitKeyOrder = this.Catalog?.ExplicitKeyOrderEmptyValueIncludeHidden(!this.MultiSelect, false);

            if (possibleValues != null)
            {
                foreach (var p in possibleValues)
                {
                    var possibleValue = new UPMCatalogPossibleValue
                    {
                        Key             = p.Key,
                        TitleLabelField = new UPMStringField(StringIdentifier.IdentifierWithStringId("X"))
                        {
                            StringValue = p.Value
                        }
                    };

                    if (!this.MultiSelect || p.Key != field.NullValueKey)
                    {
                        field.AddPossibleValue(possibleValue);
                    }
                }
            }

            UPEditFieldContext currentFieldContext = this;
            var childEditIndex = 0;
            List <UPCatalogValue> _lockedCurrentValues = null;

            while (currentFieldContext != null)
            {
                if (!string.IsNullOrEmpty(currentFieldContext.Value) &&
                    possibleValues.ValueOrDefault(currentFieldContext.Value) == null)
                {
                    var textValue = this.Catalog?.TextValueForKey(currentFieldContext.Value);
                    if (string.IsNullOrEmpty(textValue))
                    {
                        // Rashan: removed the prefix '?'
                        textValue = $"{currentFieldContext.Value}";
                    }

                    var possibleValue = new UPMCatalogPossibleValue
                    {
                        Key             = currentFieldContext.Value,
                        TitleLabelField = new UPMStringField(StringIdentifier.IdentifierWithStringId("X"))
                        {
                            StringValue = textValue
                        }
                    };

                    field.AddPossibleValue(possibleValue);
                    if (explicitKeyOrder != null)
                    {
                        var newExplicitOrder = new List <string>(explicitKeyOrder)
                        {
                            currentFieldContext.Value
                        };
                        explicitKeyOrder = newExplicitOrder;
                    }

                    var catVal = this.Catalog?.ValueForCode(JObjectExtensions.ToInt(currentFieldContext.Value));
                    if (catVal != null)
                    {
                        if (_lockedCurrentValues == null)
                        {
                            _lockedCurrentValues = new List <UPCatalogValue> {
                                catVal
                            };
                            this.lockedParentValue = catVal.Code >> 16;
                        }
                        else
                        {
                            _lockedCurrentValues.Add(catVal);
                        }
                    }
                }

                currentFieldContext = this.ChildFields != null && this.ChildFields.Count > childEditIndex
                                          ? this.ChildFields[childEditIndex++]
                                          : null;
            }

            this.lockedCurrentValues = _lockedCurrentValues;
            field.ExplicitKeyOrder   = explicitKeyOrder;
            field.ContinuousUpdate   = true;
            this.ApplyAttributesOnEditFieldConfig(field, this.FieldConfig);
            return(field);
        }