예제 #1
0
        public FormPropertyBuilder(IFormConfig formConfig, LambdaExpression fieldExpression)
            : base(formConfig.AllFields, fieldExpression)
        {
            _fieldConditions = formConfig.FieldConditions;
            _fieldExpression = fieldExpression;
            var fieldName = ReflectionExtensions.GetMemberName(fieldExpression);

            _field = formConfig.AllFields.FirstOrDefault(f => f.FieldName == fieldName);
        }
예제 #2
0
        private void BuildForm(IFormConfig formConfig, IGridConfig gridConfig, EntityConfig entityConfig, bool hasConfiguration, Type modelType)
        {
            //var modelConfig = adminBaseConfig.ModelConfig;
            //var entityConfig = adminBaseConfig.EntityConfig;
            if (!hasConfiguration)
            {
                //Register by default settings and fields
                PopulateFields(modelType, formConfig);
            }

            //PopulateEntityConfig(entityType, entityConfig);

            //Adding primary keys to KeyField

            var hasExcludeFields = formConfig?.FieldConfig?.ExcludedFields?.Count > 0;



            if (hasExcludeFields)
            {
                PopulateFields(modelType, formConfig, formConfig.FieldConfig.ExcludedFields);
            }

            var fields = formConfig.AllFields;

            foreach (var field in fields)
            {
                PopulateFieldOptions(field, formConfig.FieldConditions, entityConfig);
            }

            if (gridConfig != null)
            {
                var hasListFields = gridConfig.Fields.Count > 0;
                if (hasListFields)
                {
                    foreach (var field in gridConfig.Fields)
                    {
                        PopulateFieldOptions(field, formConfig.FieldConditions, entityConfig);
                    }
                }
                else
                {
                    var properties = GetProperties(modelType);
                    foreach (var prop in properties)
                    {
                        var field = new Field
                        {
                            FieldExpression = ExpressionHelper.GetPropertyExpression(modelType, prop)
                        };
                        PopulateFieldOptions(field, formConfig.FieldConditions, entityConfig);
                        gridConfig.AddField(field);
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="myConfig"></param>
        /// <param name="WorkflowStateId"></param>
        /// <returns></returns>
        public static FormConfigDTO GetFormConfigDTO(IFormConfig myConfig, long WorkflowStateId)
        {
            FormConfigDTO result = new FormConfigDTO();

            ToolBox.MapObject(myConfig, result, true);
            result.formGroups = new List <FormGroupDTO>();
            foreach (IFormGroup curGroup in myConfig.GetFormGroups().Where(g => g.Active).OrderBy(s => s.GroupOrder))
            {
                result.formGroups.Add(GetFormGroupDTO(curGroup, WorkflowStateId));
            }
            return(result);
        }
예제 #4
0
        private void PopulateFields(Type modelType, IFormConfig formConfig, ICollection <Field> excludeField = null)
        {
            var properties = GetProperties(modelType);

            foreach (var prop in properties)
            {
                var isExclude = (excludeField != null && excludeField.Any(f => f.FieldClrType == prop.PropertyType));

                if (!isExclude)
                {
                    formConfig.FieldConfig.AddField(new Field
                    {
                        FieldExpression = ExpressionHelper.GetPropertyExpression(modelType, prop)
                    });
                }
            }
        }
예제 #5
0
 private void BuildForm(IFormConfig formConfig, bool hasConfiguration, Type modelType)
 {
     BuildForm(formConfig, null, null, hasConfiguration, modelType);
 }