コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DateRangeFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="theme">The theme.</param>
 /// <param name="height">The height.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 public CodeEditorFieldAttribute(string name, string description = "", CodeEditorMode mode = CodeEditorMode.Text, CodeEditorTheme theme = CodeEditorTheme.Rock, int height = 200, bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null)
     : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.CodeEditorFieldType).FullName)
 {
     FieldConfigurationValues.Add(EDITOR_MODE, new Field.ConfigurationValue(mode.ToString()));
     FieldConfigurationValues.Add(EDITOR_THEME, new Field.ConfigurationValue(theme.ToString()));
     FieldConfigurationValues.Add(EDITOR_HEIGHT, new Field.ConfigurationValue(height.ToString()));
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefinedValueFieldAttribute"/> class.
        /// </summary>
        /// <param name="definedTypeGuid">The defined type unique identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="allowMultiple">if set to <c>true</c> [allow multiple].</param>
        /// <param name="enhanced">if set to <c>true</c> [enhanced].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public DefinedValueFieldAttribute(string definedTypeGuid, string name, string description, bool required, bool allowMultiple, bool enhanced, string defaultValue, string category, int order, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.DefinedValueFieldType).FullName)
        {
            var definedType = Rock.Web.Cache.DefinedTypeCache.Read(new Guid(definedTypeGuid));

            if (definedType != null)
            {
                var definedTypeConfigValue = new Field.ConfigurationValue(definedType.Id.ToString());
                FieldConfigurationValues.Add(DEFINED_TYPE_KEY, definedTypeConfigValue);

                var allowMultipleConfigValue = new Field.ConfigurationValue(allowMultiple.ToString());
                FieldConfigurationValues.Add(ALLOW_MULTIPLE_KEY, allowMultipleConfigValue);

                var enhancedConfigValue = new Field.ConfigurationValue(enhanced.ToString());
                FieldConfigurationValues.Add(ENHANCED_SELECTION_KEY, enhancedConfigValue);

                if (string.IsNullOrWhiteSpace(Name))
                {
                    Name = definedType.Name;
                }

                if (string.IsNullOrWhiteSpace(Key))
                {
                    Key = Name.Replace(" ", string.Empty);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SiteFieldAttribute"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultSiteId">The default site identifier.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <param name="shorteningSitesOnly">if set to <c>true</c> [shortening sites only].</param>
        public SiteFieldAttribute(string name = "Site", string description = "", bool required = true, string defaultSiteId = "", string category = "", int order = 0, string key = null, bool shorteningSitesOnly = false)
            : base(name, description, required, defaultSiteId, category, order, key, typeof(Rock.Field.Types.SiteFieldType).FullName)
        {
            var htmlConfig = new Field.ConfigurationValue(shorteningSitesOnly.ToString());

            FieldConfigurationValues.Add(SHORTENING_SITES_ONLY, htmlConfig);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SocialMediaAccountFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="socialNetworkName">The name of the socal media network.</param>
        /// <param name="iconCssClass">The icon that represents the social media network.</param>
        /// <param name="color">The color to use for making buttons for the social media network.</param>
        /// <param name="textTemplate">The text template.</param>
        /// <param name="baseUrl">The base URL.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <param name="fieldTypeClass">The field type class.</param>
        internal SocialMediaAccountFieldAttribute(string name = "", string description = "", bool required = true, string defaultValue            = "",
                                                  string socialNetworkName = "", string iconCssClass = "", string color = "", string textTemplate = "", string baseUrl = "",
                                                  string category          = "", int order = 0, string key = null, string fieldTypeClass = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.SocialMediaAccountFieldType).FullName)
        {
            if (!string.IsNullOrWhiteSpace(socialNetworkName))
            {
                var configValue = new Field.ConfigurationValue(socialNetworkName);
                FieldConfigurationValues.Add(NAME_KEY, configValue);
            }

            if (!string.IsNullOrWhiteSpace(iconCssClass))
            {
                var configValue = new Field.ConfigurationValue(iconCssClass);
                FieldConfigurationValues.Add(ICONCSSCLASS_KEY, configValue);
            }

            if (!string.IsNullOrWhiteSpace(color))
            {
                var configValue = new Field.ConfigurationValue(color);
                FieldConfigurationValues.Add(COLOR_KEY, configValue);
            }

            if (!string.IsNullOrWhiteSpace(textTemplate))
            {
                var configValue = new Field.ConfigurationValue(textTemplate);
                FieldConfigurationValues.Add(TEXT_TEMPLATE, configValue);
            }

            if (!string.IsNullOrWhiteSpace(baseUrl))
            {
                var configValue = new Field.ConfigurationValue(baseUrl);
                FieldConfigurationValues.Add(BASEURL, configValue);
            }
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentFieldAttribute" /> class.
        /// </summary>
        /// <param name="mefContainerAssemblyName">Name of the mef container assembly.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public ComponentsFieldAttribute(string mefContainerAssemblyName, string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.ComponentsFieldType).FullName)
        {
            var configValue = new Field.ConfigurationValue(mefContainerAssemblyName);

            FieldConfigurationValues.Add("container", configValue);

            if (string.IsNullOrWhiteSpace(Name))
            {
                try
                {
                    Type containerType = Type.GetType(mefContainerAssemblyName);
                    var  entityType    = EntityTypeCache.Read(containerType);
                    if (entityType != null)
                    {
                        Name = entityType.FriendlyName;
                    }
                }
                catch { }
            }

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = mefContainerAssemblyName;
            }

            if (string.IsNullOrWhiteSpace(Key))
            {
                Key = Name.Replace(" ", string.Empty);
            }
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EntityTypeFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="includeGlobalAttributeOption">if set to <c>true</c> [include global attribute option].</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public EntityTypeFieldAttribute(string name, bool includeGlobalAttributeOption, string description = "", bool required = true, string category = "", int order = 0, string key = null)
            : base(name, description, required, "", category, order, key, typeof(Rock.Field.Types.EntityTypeFieldType).FullName)
        {
            var configValue = new Field.ConfigurationValue(includeGlobalAttributeOption.ToString());

            FieldConfigurationValues.Add("includeglobal", configValue);
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ContentChannelItemFieldAttribute" /> class.
        /// </summary>
        /// <param name="contentChannelGuid">The content channel GUID.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public ContentChannelItemFieldAttribute(string contentChannelGuid = "", string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.ContentChannelItemFieldType).FullName)
        {
            if (!string.IsNullOrWhiteSpace(contentChannelGuid))
            {
                Guid guid = Guid.Empty;
                if (Guid.TryParse(contentChannelGuid, out guid))
                {
                    var contentChannel = ContentChannelCache.Get(guid);
                    if (contentChannel != null)
                    {
                        var configValue = new Field.ConfigurationValue(contentChannel.Id.ToString());
                        FieldConfigurationValues.Add("contentchannel", configValue);

                        if (string.IsNullOrWhiteSpace(Name))
                        {
                            Name = contentChannel.Name;
                        }

                        if (string.IsNullOrWhiteSpace(Key))
                        {
                            Key = Name.Replace(" ", string.Empty);
                        }
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefinedValueFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="includeInactive">if set to <c>true</c> [include inactive].</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public ConnectionOpportunityFieldAttribute(string name = "", string description = "", bool required = true, string defaultValue = "", bool includeInactive = false, string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.ConnectionOpportunityFieldType).FullName)
        {
            var includeInactiveConfigValue = new Field.ConfigurationValue(includeInactive.ToString());

            FieldConfigurationValues.Add(INCLUDE_INACTIVE_KEY, includeInactiveConfigValue);
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CampusesFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultCampusGuids">The default campus guids.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public CampusesFieldAttribute(string name = "Campuses", string description = "", bool required = true, string defaultCampusGuids = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultCampusGuids, category, order, key, typeof(Rock.Field.Types.CampusesFieldType).FullName)
        {
            var includeInactiveConfigValue = new Field.ConfigurationValue("False");

            FieldConfigurationValues.Add(INCLUDE_INACTIVE_KEY, includeInactiveConfigValue);
        }
コード例 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GroupMemberFieldAttribute"/> class.
        /// </summary>
        /// <param name="groupGuid">The group unique identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="allowMultiple">if set to <c>true</c> [allow multiple].</param>
        /// <param name="enhanced">if set to <c>true</c> [enhanced].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public GroupMemberFieldAttribute(string groupGuid, string name, string description, bool required, bool allowMultiple, bool enhanced, string defaultValue, string category, int order, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.GroupMemberFieldType).FullName)
        {
            Group group = null;

            using (var rockContext = new RockContext())
            {
                group = new GroupService(rockContext).Get(new Guid(groupGuid));
            }

            if (group != null)
            {
                var groupConfigValue = new Field.ConfigurationValue(group.Id.ToString());
                FieldConfigurationValues.Add(GROUP_KEY, groupConfigValue);

                var allowMultipleConfigValue = new Field.ConfigurationValue(allowMultiple.ToString());
                FieldConfigurationValues.Add(ALLOW_MULTIPLE_KEY, allowMultipleConfigValue);

                var enhancedConfigValue = new Field.ConfigurationValue(enhanced.ToString());
                FieldConfigurationValues.Add(ENHANCED_SELECTION_KEY, enhancedConfigValue);

                if (string.IsNullOrWhiteSpace(Name))
                {
                    Name = group.Name;
                }

                if (string.IsNullOrWhiteSpace(Key))
                {
                    Key = Name.Replace(" ", string.Empty);
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ValueListFieldAttribute"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="valuePrompt">The text to display as a prompt in the label textbox.</param>
        /// <param name="definedTypeGuid">An Optional Defined Type Guid to select values from, otherwise values will be free-form text fields..</param>
        /// <param name="customValues">Optional list of options to use for the values.  Format is either 'value1,value2,value3,...', or 'value1:text1,value2:text2,value3:text3,...'.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <param name="fieldTypeClass">The field type class.</param>
        internal ValueListFieldAttribute(string name            = "", string description  = "", bool required = true, string defaultValue = "", string valuePrompt = "",
                                         string definedTypeGuid = "", string customValues = "", string category = "", int order           = 0, string key          = null, string fieldTypeClass = null)
            : base(name, description, required, defaultValue, category, order, key, fieldTypeClass)
        {
            if (!string.IsNullOrWhiteSpace(valuePrompt))
            {
                var configValue = new Field.ConfigurationValue(valuePrompt);
                FieldConfigurationValues.Add(VALUE_PROMPT_KEY, configValue);
            }

            Guid?guid = definedTypeGuid.AsGuidOrNull();

            if (guid.HasValue)
            {
                var definedType = Rock.Web.Cache.DefinedTypeCache.Read(guid.Value);
                if (definedType != null)
                {
                    var definedTypeConfigValue = new Field.ConfigurationValue(definedType.Id.ToString());
                    FieldConfigurationValues.Add(DEFINED_TYPE_KEY, definedTypeConfigValue);
                }
            }

            if (!string.IsNullOrWhiteSpace(customValues))
            {
                var configValue = new Field.ConfigurationValue(customValues);
                FieldConfigurationValues.Add(CUSTOM_VALUES, configValue);
            }
        }
コード例 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BinaryFileFieldAttribute"/> class.
        /// </summary>
        /// <param name="binaryFileTypeGuid">The guid of the type of files</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultBinaryFileGuid">The default binary file guid.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public FileFieldAttribute(string binaryFileTypeGuid, string name = "Binary File", string description = "", bool required = true, string defaultBinaryFileGuid = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultBinaryFileGuid, category, order, key, typeof(Rock.Field.Types.FileFieldType).FullName)
        {
            var configValue = new Field.ConfigurationValue(binaryFileTypeGuid);

            FieldConfigurationValues.Add(BINARY_FILE_TYPE, configValue);
        }
コード例 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefinedValueFieldAttribute" /> class.
        /// </summary>
        /// <param name="groupTypeGuid">The group type GUID.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public GroupRoleFieldAttribute(string groupTypeGuid = "", string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.GroupRoleFieldType).FullName)
        {
            if (!string.IsNullOrWhiteSpace(groupTypeGuid))
            {
                Guid guid = Guid.Empty;
                if (Guid.TryParse(groupTypeGuid, out guid))
                {
                    var groupType = GroupTypeCache.Get(guid);
                    if (groupType != null)
                    {
                        var configValue = new Field.ConfigurationValue(groupType.Id.ToString());
                        FieldConfigurationValues.Add("grouptype", configValue);

                        if (string.IsNullOrWhiteSpace(Name))
                        {
                            Name = groupType.Name + " Role";
                            if (string.IsNullOrWhiteSpace(Key))
                            {
                                Key = Name.Replace(" ", string.Empty);
                            }
                        }
                    }
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ColorFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="selctionType">The selection type.</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public ColorFieldAttribute(string name, string description = "", bool required = true, string selctionType = "Color Picker", string defaultValue = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.ColorFieldType).FullName)
        {
            var selectionTypeConfigValue = new Field.ConfigurationValue(selctionType);

            FieldConfigurationValues.Add(SELECTION_TYPE, selectionTypeConfigValue);
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <param name="hideFilterMode">if set to <c>true</c> then the filter mode selection control is hidden.</param>
        /// <param name="fieldTypeClass">The field type class.</param>
        public TextValueFilterFieldAttribute(string name, string description = "", bool required = true, string defaultValue = "", string category = "",
                                             int order = 0, string key = null, bool hideFilterMode = false, string fieldTypeClass = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.ValueFilterFieldType).FullName)
        {
            var hideFilterModeValue = new Field.ConfigurationValue(hideFilterMode.ToString());

            FieldConfigurationValues.Add(Field.Types.ValueFilterFieldType.HIDE_FILTER_MODE, hideFilterModeValue);
        }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataViewFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="entityTypeName">Name of the entity type.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 public DataViewFieldAttribute(string name, string description = "", bool required = true, string defaultValue = "", string entityTypeName = "", string category = "", int order = 0, string key = null) :
     base(name, description, required, defaultValue, category, order, key, typeof(DataViewFieldType).FullName)
 {
     if (!string.IsNullOrWhiteSpace(entityTypeName))
     {
         FieldConfigurationValues.Add(ENTITY_TYPE_NAME_KEY, new Field.ConfigurationValue(entityTypeName));
     }
 }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SlidingDateRangeFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 /// <param name="enabledSlidingDateRangeTypes">The enabled sliding date range types. Choose from: 'Previous, Last, Current, Next, Upcoming, DateRange'</param>
 public SlidingDateRangeFieldAttribute(string name, string description = "", bool required = true, string defaultValue = ",", string category = "", int order = 0, string key = null, string enabledSlidingDateRangeTypes = null)
     : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.SlidingDateRangeFieldType).FullName)
 {
     if (enabledSlidingDateRangeTypes != null)
     {
         FieldConfigurationValues.Add(ENABLED_SLIDING_DATE_RANGE_TYPES, new Field.ConfigurationValue(enabledSlidingDateRangeTypes));
     }
 }
コード例 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DateFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <param name="allowCurrentOption">if set to <c>true</c> [allow current option].</param>
        public DateFieldAttribute(string name, string description = "", bool required = true, string defaultValue = "", string category = "",
                                  int order = 0, string key = null, bool allowCurrentOption = false)
            : base(name, description, required, defaultValue, category, order, key, typeof(DateFieldType).FullName)
        {
            var displayCurrentConfigValue = new Field.ConfigurationValue(allowCurrentOption.ToString());

            FieldConfigurationValues.Add("displayCurrentOption", displayCurrentConfigValue);
        }
コード例 #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <param name="isPassword">if set to <c>true</c> [is password].</param>
        /// <param name="fieldTypeClass">The field type class.</param>
        public TextFieldAttribute(string name, string description = "", bool required = true, string defaultValue = "", string category = "",
                                  int order = 0, string key = null, bool isPassword = false, string fieldTypeClass = null)
            : base(name, description, required, defaultValue, category, order, key, fieldTypeClass)
        {
            var isPasswordValue = new Field.ConfigurationValue(isPassword.ToString());

            FieldConfigurationValues.Add(IS_PASSWORD_KEY, isPasswordValue);
        }
コード例 #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AttributeFieldAttribute"/> class.
        /// </summary>
        /// <param name="entityTypeGuid">The entity type unique identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="entityTypeQualifierColumn">The entity type qualifier column.</param>
        /// <param name="entityTypeQualifierValue">The entity type qualifier value.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="allowMultiple">if set to <c>true</c> [allow multiple].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public AttributeFieldAttribute(string entityTypeGuid, string entityTypeQualifierColumn, string entityTypeQualifierValue, string name, string description = "", bool required = true, bool allowMultiple = false, string defaultValue = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.AttributeFieldType).FullName)
        {
            var entityTypeConfigValue = new Field.ConfigurationValue(entityTypeGuid);

            FieldConfigurationValues.Add(ENTITY_TYPE_KEY, entityTypeConfigValue);

            var allowMultipleConfigValue = new Field.ConfigurationValue(allowMultiple.ToString());

            FieldConfigurationValues.Add(ALLOW_MULTIPLE_KEY, allowMultipleConfigValue);

            var entityTypeQualifierColumnConfigValue = new Field.ConfigurationValue(entityTypeQualifierColumn);

            FieldConfigurationValues.Add(QUALIFIER_COLUMN_KEY, entityTypeQualifierColumnConfigValue);

            if (entityTypeQualifierColumn.EndsWith("Id") && entityTypeQualifierValue.AsGuid() != Guid.Empty)
            {
                EntityTypeCache itemEntityType = EntityTypeCache.Get("Rock.Model." + entityTypeQualifierColumn.Left(entityTypeQualifierColumn.Length - 2));
                if (itemEntityType.AssemblyName != null)
                {
                    // get the actual type of what is being followed
                    Type entityType = itemEntityType.GetEntityType();
                    if (entityType != null)
                    {
                        var dbContext = Reflection.GetDbContextForEntityType(entityType);
                        if (dbContext != null)
                        {
                            var serviceInstance = Reflection.GetServiceForEntityType(entityType, dbContext);
                            if (serviceInstance != null)
                            {
                                MethodInfo getMethod = serviceInstance.GetType().GetMethod("Get", new Type[] { typeof(Guid) });
                                var        entity    = getMethod.Invoke(serviceInstance, new object[] { entityTypeQualifierValue.AsGuid() }) as Rock.Data.IEntity;
                                if (entity != null)
                                {
                                    FieldConfigurationValues.Add(QUALIFIER_VALUE_KEY, new Field.ConfigurationValue(entity.Id.ToString()));
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                var entityTypeQualifierValueConfigValue = new Field.ConfigurationValue(entityTypeQualifierValue);
                FieldConfigurationValues.Add(QUALIFIER_VALUE_KEY, entityTypeQualifierValueConfigValue);
            }

            if (string.IsNullOrWhiteSpace(Name))
            {
                var entityType = EntityTypeCache.Get(new Guid(entityTypeGuid));
                name = (entityType != null ? entityType.Name : "Entity") + " Attribute";
            }

            if (string.IsNullOrWhiteSpace(Key))
            {
                Key = Name.Replace(" ", string.Empty);
            }
        }
コード例 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkflowAttributeAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 /// <param name="fieldTypeClassNames">The field type class names which are used to filter the pickable workflow attributes</param>
 public WorkflowAttributeAttribute(string name, string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null, string[] fieldTypeClassNames = null)
     : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.WorkflowAttributeFieldType).FullName)
 {
     if (fieldTypeClassNames != null && fieldTypeClassNames.Length > 0)
     {
         var workflowTypeConfigValue = new Field.ConfigurationValue(fieldTypeClassNames.ToList().AsDelimited("|"));
         FieldConfigurationValues.Add(ATTRIBUTE_FIELD_TYPES_KEY, workflowTypeConfigValue);
     }
 }
コード例 #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GroupCategoryFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="allowMultiple">if set to <c>true</c> [allow multiple].</param>
        /// <param name="groupTypeGuid">The group type unique identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <exception cref="System.Exception">
        /// groupTypeGuid must be specified
        /// or
        /// A valid groupTypeGuid must be specified
        /// </exception>
        public GroupCategoryFieldAttribute(string name, string description = "", bool allowMultiple = false, string groupTypeGuid = null,
                                           bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null) :
            base(name, description, required, defaultValue, category, order, key,
                 (allowMultiple ? typeof(CategoriesFieldType).FullName : typeof(CategoryFieldType).FullName))
        {
            FieldConfigurationValues.Add(ENTITY_TYPE_NAME_KEY, new Field.ConfigurationValue("Rock.Model.Group"));
            FieldConfigurationValues.Add(QUALIFIER_COLUMN_KEY, new Field.ConfigurationValue("GroupTypeId"));

            GroupTypeGuid = groupTypeGuid;
        }
コード例 #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatrixFieldAttribute" /> class.
        /// </summary>
        /// <param name="attributeMatrixTemplateGuid">The attribute matrix template unique identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public MatrixFieldAttribute(string attributeMatrixTemplateGuid, string name, string description = "", bool required = true, string category = "", int order = 0, string key = null)
            : base(name, description, required, null, category, order, key, typeof(MatrixFieldType).FullName)
        {
            var attributeMatrixTemplate = new AttributeMatrixTemplateService(new Data.RockContext()).Get(attributeMatrixTemplateGuid.AsGuid());

            if (attributeMatrixTemplate != null)
            {
                FieldConfigurationValues.Add(MatrixFieldType.ATTRIBUTE_MATRIX_TEMPLATE, new Field.ConfigurationValue(attributeMatrixTemplate.Id.ToString()));
            }
        }
コード例 #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CategoryFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="allowMultiple">if set to <c>true</c> [allow multiple].</param>
 /// <param name="entityTypeName">Name of the entity type.</param>
 /// <param name="entityTypeQualifierColumn">The entity type qualifier column.</param>
 /// <param name="entityTypeQualifierValue">The entity type qualifier value.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 public CategoryFieldAttribute(string name, string description = "", bool allowMultiple               = false,
                               string entityTypeName           = "", string entityTypeQualifierColumn = "", string entityTypeQualifierValue = "",
                               bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null) :
     base(name, description, required, defaultValue, category, order, key,
          (allowMultiple ? typeof(CategoriesFieldType).FullName : typeof(CategoryFieldType).FullName))
 {
     FieldConfigurationValues.Add(ENTITY_TYPE_NAME_KEY, new Field.ConfigurationValue(entityTypeName));
     FieldConfigurationValues.Add(QUALIFIER_COLUMN_KEY, new Field.ConfigurationValue(entityTypeQualifierColumn));
     FieldConfigurationValues.Add(QUALIFIER_VALUE_KEY, new Field.ConfigurationValue(entityTypeQualifierValue));
 }
コード例 #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueListFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="keyPrompt">The text to display as a prompt in the key textbox.</param>
 /// <param name="valuePrompt">The text to display as a prompt in the label textbox.</param>
 /// <param name="definedTypeGuid">An Optional Defined Type Guid to select values from, otherwise values will be free-form text fields..</param>
 /// <param name="customValues">Optional list of options to use for the values.  Format is either 'value1,value2,value3,...', or 'value1:text1,value2:text2,value3:text3,...'.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 /// <param name="fieldTypeClass">The field type class.</param>
 public KeyValueListFieldAttribute(string name      = "", string description = "", bool required = true, string defaultValue        = "",
                                   string keyPrompt = "", string valuePrompt = "", string definedTypeGuid = "", string customValues = "",
                                   string category  = "", int order          = 0, string key = null, string fieldTypeClass = null)
     : base(name, description, required, defaultValue, valuePrompt, definedTypeGuid, customValues, category, order, key,
            typeof(Rock.Field.Types.KeyValueListFieldType).FullName)
 {
     if (!string.IsNullOrWhiteSpace(keyPrompt))
     {
         var configValue = new Field.ConfigurationValue(keyPrompt);
         FieldConfigurationValues.Add(KEY_PROMPT_KEY, configValue);
     }
 }
コード例 #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <param name="numberOfRows">The number of rows.</param>
        /// <param name="allowHtml">if set to <c>true</c> [allow HTML].</param>
        public MemoFieldAttribute(string name, string description = "", bool required = true, string defaultValue = "", string category = "",
                                  int order = 0, string key = null, int numberOfRows = 3, bool allowHtml = false)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.MemoFieldType).FullName)
        {
            var rowConfig = new Field.ConfigurationValue(numberOfRows.ToString());

            FieldConfigurationValues.Add(NUMBER_OF_ROWS, rowConfig);

            var htmlConfig = new Field.ConfigurationValue(allowHtml.ToString());

            FieldConfigurationValues.Add(ALLOW_HTML, htmlConfig);
        }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GroupTypeFieldAttribute" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultGroupTypeGuid">The default group type GUID.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 /// <param name="groupTypePurposeValueGuid">The group type purpose value unique identifier.</param>
 public GroupTypeFieldAttribute(string name, string description = "", bool required = true, string defaultGroupTypeGuid = "", string category = "", int order = 0, string key = null, string groupTypePurposeValueGuid = "")
     : base(name, description, required, defaultGroupTypeGuid, category, order, key, typeof(Rock.Field.Types.GroupTypeFieldType).FullName)
 {
     if (!string.IsNullOrWhiteSpace(groupTypePurposeValueGuid))
     {
         Guid?guid = groupTypePurposeValueGuid.AsGuidOrNull();
         if (guid.HasValue)
         {
             FieldConfigurationValues.Add("groupTypePurposeValueGuid", new Field.ConfigurationValue(groupTypePurposeValueGuid));
         }
     }
 }
コード例 #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EnumFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="enumSourceType">Type of the enum source.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.  If multiple values are supported (i.e. checkbox) each value should be delimited by a comma</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public EnumsFieldAttribute(string name, string description, Type enumSourceType, bool required = false, string defaultValue = "", string category = "", int order = 0, string key = null)
            : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.SelectMultiFieldType).FullName)
        {
            var list = new List <string>();

            foreach (var value in Enum.GetValues(enumSourceType))
            {
                list.Add(string.Format("{0}^{1}", (int)value, value.ToString().SplitCase()));
            }

            var listSource = string.Join(",", list);

            FieldConfigurationValues.Add(VALUES, new Field.ConfigurationValue(listSource));
        }
コード例 #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WorkflowAttributeAttribute" /> class.
        /// </summary>
        /// <param name="textLabel">The text label.</param>
        /// <param name="attributeLabel">The attribute label.</param>
        /// <param name="description">The description.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        /// <param name="fieldTypeClassNames">The field type class names.</param>
        /// <param name="rows">The rows.</param>
        public WorkflowTextOrAttributeAttribute(string textLabel, string attributeLabel, string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null, string[] fieldTypeClassNames = null, int rows = 1)
            : base(textLabel + "|" + attributeLabel, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.WorkflowTextOrAttributeFieldType).FullName)
        {
            if (fieldTypeClassNames != null && fieldTypeClassNames.Length > 0)
            {
                var workflowTypeConfigValue = new Field.ConfigurationValue(fieldTypeClassNames.ToList().AsDelimited("|"));
                FieldConfigurationValues.Add(ATTRIBUTE_FIELD_TYPES_KEY, workflowTypeConfigValue);
            }

            if (rows > 1)
            {
                var rowsConfigValue = new Field.ConfigurationValue(rows.ToString());
                FieldConfigurationValues.Add(TEXTBOX_ROWS_KEY, rowsConfigValue);
            }
        }
コード例 #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CategoryFieldAttribute" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        /// <param name="allowMultiple">if set to <c>true</c> [allow multiple].</param>
        /// <param name="entityTypeName">Name of the entity type.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="defaultValue">The default value.</param>
        /// <param name="category">The category.</param>
        /// <param name="order">The order.</param>
        /// <param name="key">The key.</param>
        public AttributeCategoryFieldAttribute(string name, string description = "", bool allowMultiple = false,
                                               string entityTypeName           = "", bool required = true, string defaultValue = "", string category = "",
                                               int order = 0, string key = null) :
            base(name, description, required, defaultValue, category, order, key,
                 (allowMultiple ? typeof(CategoriesFieldType).FullName : typeof(CategoryFieldType).FullName))
        {
            FieldConfigurationValues.Add(ENTITY_TYPE_NAME_KEY, new Field.ConfigurationValue("Rock.Model.Attribute"));
            FieldConfigurationValues.Add(QUALIFIER_COLUMN_KEY, new Field.ConfigurationValue("EntityTypeId"));

            var entityType = EntityTypeCache.Read(entityTypeName, false);

            if (entityType != null)
            {
                FieldConfigurationValues.Add(QUALIFIER_VALUE_KEY, new Field.ConfigurationValue(entityType.Id.ToString()));
            }
        }