public override FormElementItem Convert(IFieldType fieldType, AttributeCache attribute)
        {
            var element = new FormElementItem()
            {
                Type     = FormElementType.Entry,
                Keyboard = Keyboard.Text,
                Options  = new Dictionary <string, string>()
            };

            if (fieldType is TextFieldType)
            {
                var qualifiers = attribute.QualifierValues;
                if (qualifiers.ContainsKey("ispassword") && qualifiers["ispassword"].Value.AsBoolean() == true)
                {
                    element.Attributes.Add("IsPassword", "true");
                }
            }
            else if (fieldType is EmailFieldType)
            {
                element.Keyboard = Keyboard.Email;
            }
            else if (fieldType is UrlLinkFieldType)
            {
                element.Keyboard = Keyboard.Url;
            }
            else if (fieldType is CurrencyFieldType || fieldType is DecimalFieldType)
            {
                element.Keyboard = Keyboard.Numeric;
            }

            return(element);
        }
Beispiel #2
0
 public IActionResult Update([FromBody] FormElementItem data)
 {
     if (service.Get(x => x.Id == data.Id) != null)
     {
         return(Ok(service.Update(data)));
     }
     return(NotFound());
 }
Beispiel #3
0
        public override FormElementItem Convert(IFieldType fieldType, AttributeCache attribute)
        {
            var element = new FormElementItem()
            {
                Type    = FormElementType.Switch,
                Options = Helper.GetConfiguredValues(attribute.QualifierValues)
            };

            return(element);
        }
        public override FormElementItem Convert(IFieldType fieldType, AttributeCache attribute)
        {
            var element = new FormElementItem()
            {
                Type     = FormElementType.CheckboxList,
                Keyboard = Keyboard.Text,
                Options  = Helper.GetConfiguredValues(attribute.QualifierValues)
            };

            return(element);
        }
        public override FormElementItem Convert(IFieldType fieldType, AttributeCache attribute)
        {
            var element = new FormElementItem()
            {
                Type     = FormElementType.Picker,
                Keyboard = Keyboard.Text,
                Options  = CampusCache.All().ToDictionary(c => c.Guid.ToString(), c => c.Name)
            };

            return(element);
        }
        private List <FormElementItem> GetForm(NoteTypeCache noteType, int entityId)
        {
            var         form                  = new List <FormElementItem>();
            RockContext rockContext           = new RockContext();
            NoteService noteService           = new NoteService(rockContext);
            var         currentPersonAliasIds = CurrentPerson.Aliases.Select(a => a.Id);
            var         note                  = noteService.Queryable()
                                                .Where(n => n.NoteTypeId == noteType.Id && n.EntityId == entityId && currentPersonAliasIds.Contains(n.CreatedByPersonAliasId ?? 0))
                                                .FirstOrDefault();

            if (note == null)
            {
                note = new Rock.Model.Note
                {
                    NoteTypeId = noteType.Id,
                    EntityId   = entityId,
                    Text       = ""
                };
            }

            var hidden = new FormElementItem
            {
                Type  = FormElementType.Hidden,
                Key   = "entityId",
                Value = entityId.ToString()
            };

            form.Add(hidden);

            var editor = new FormElementItem
            {
                Label         = GetAttributeValue("NoteFieldLabel"),
                HeightRequest = GetAttributeValue("NoteFieldHeight").AsInteger(),
                Type          = FormElementType.Editor,
                Key           = "note",
                Value         = note.Text,
            };

            form.Add(editor);

            var button = new FormElementItem
            {
                Key   = "save",
                Type  = FormElementType.Button,
                Label = "Save"
            };

            form.Add(button);

            return(form);
        }
Beispiel #7
0
        public IActionResult FormElementItem(FormElementItem formElementItem)
        {
            if (HttpContext.Session.GetString("Name") == null)
            {
                return(RedirectToAction("Login", "Admin"));
            }

            var kayıt = itemService.Add(formElementItem);

            TempData["Mesaj"] = kayıt.BasariliMi ? "Kayıt Eklendi." : kayıt.Mesaj;

            ViewModel mymodel = new ViewModel();

            mymodel.FormElements = formElementService.GetAll().Data;
            mymodel.Forms        = formService.GetAll().Data;
            return(View(mymodel));
        }
Beispiel #8
0
        public override FormElementItem Convert(IFieldType fieldType, AttributeCache attribute)
        {
            var height  = 100;
            var options = Helper.GetConfiguredValues(attribute.QualifierValues);

            if (options.ContainsKey("numberofrows") && options["numberofrows"].AsInteger() > 0)
            {
                height = options["numberofrows"].AsInteger() * 20;
            }

            var element = new FormElementItem()
            {
                Type          = FormElementType.Editor,
                HeightRequest = height
            };

            return(element);
        }
        public override FormElementItem Convert(IFieldType fieldType, AttributeCache attribute)
        {
            var dfState               = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.LOCATION_ADDRESS_STATE.AsGuid());
            var statesList            = dfState.DefinedValues.Select(dv => dv.Value).OrderBy(dv => dv).ToList();
            var states                = string.Join(",", statesList);
            var globalAttributesCache = GlobalAttributesCache.Get();
            var defaultState          = globalAttributesCache.OrganizationState;
            var attributes            = new Dictionary <string, string>
            {
                { "States", states },
                { "DefaultState", defaultState }
            };

            var element = new FormElementItem()
            {
                Type       = FormElementType.Address,
                Keyboard   = Keyboard.Text,
                Attributes = attributes
            };

            return(element);
        }
Beispiel #10
0
        public override FormElementItem Convert(IFieldType fieldType, AttributeCache attribute)
        {
            string INCLUDE_INACTIVE_KEY = "includeInactive";



            var element = new FormElementItem()
            {
                Type     = FormElementType.Picker,
                Keyboard = Keyboard.Text,
            };

            var definedTypeValue = attribute.QualifierValues.GetValueOrNull("definedtype");
            var definedType      = DefinedTypeCache.Get(definedTypeValue.AsInteger());

            if (definedType != null)
            {
                var values = definedType.DefinedValues;
                if (!attribute.QualifierValues.GetValueOrNull("includeInactive").AsBoolean())
                {
                    values = values.Where(a => a.IsActive).ToList();
                }

                if (definedTypeValue != null)
                {
                    element.Options = values.ToDictionary(dv => dv.Guid.ToString(), dv => dv.Value);
                }

                var allowmultiple = attribute.QualifierValues.GetValueOrNull("allowmultiple");
                if (allowmultiple != null && allowmultiple.AsBoolean() == true)
                {
                    element.Type = FormElementType.CheckboxList;
                }
            }

            return(element);
        }
Beispiel #11
0
        public override MobileBlock GetMobile(string parameter)
        {
            var form = new List <FormElementItem>();

            var firstName = new FormElementItem
            {
                Type     = FormElementType.Entry,
                Key      = "firstName",
                Label    = "First Name",
                Required = true
            };

            if (CurrentPerson != null)
            {
                firstName.Value = CurrentPerson.NickName;
            }
            form.Add(firstName);

            var lastName = new FormElementItem
            {
                Type     = FormElementType.Entry,
                Key      = "lastName",
                Label    = "Last Name",
                Required = GetAttributeValue("RequireLastName").AsBoolean()
            };

            if (CurrentPerson != null)
            {
                lastName.Value = CurrentPerson.LastName;
            }
            form.Add(lastName);

            var email = new FormElementItem
            {
                Type     = FormElementType.Entry,
                Key      = "email",
                Label    = "Email",
                Required = false,
                Keyboard = Keyboard.Email
            };

            if (CurrentPerson != null)
            {
                email.Value = CurrentPerson.Email;
            }
            form.Add(email);

            if (GetAttributeValue("ShowCampus").AsBoolean())
            {
                var campus = new FormElementItem
                {
                    Type     = FormElementType.Picker,
                    Key      = "campus",
                    Label    = "Campus",
                    Options  = CampusCache.All().ToDictionary(c => c.Id.ToString(), c => c.Name),
                    Required = GetAttributeValue("RequireCampus").AsBoolean()
                };
                if (CurrentPerson != null)
                {
                    campus.Value = CurrentPerson.GetCampus().Id.ToString();
                }

                form.Add(campus);
            }

            if (!string.IsNullOrWhiteSpace(GetAttributeValue("CategorySelection")))
            {
                var categoryGuid = GetAttributeValue("CategorySelection").AsGuid();
                var categoryList = CategoryCache.Read(categoryGuid).Categories.ToDictionary(c => c.Id.ToString(), c => c.Name);

                var category = new FormElementItem
                {
                    Type     = FormElementType.Picker,
                    Key      = "category",
                    Label    = "Category",
                    Options  = categoryList,
                    Required = true
                };
                form.Add(category);
            }

            var request = new FormElementItem
            {
                Type          = FormElementType.Editor,
                Label         = "Request",
                Key           = "request",
                HeightRequest = 100,
                Required      = true
            };

            form.Add(request);

            if (GetAttributeValue("EnableUrgentFlag").AsBoolean())
            {
                var urgent = new FormElementItem
                {
                    Type  = FormElementType.Switch,
                    Key   = "urgent",
                    Label = "Urgent?"
                };
                form.Add(urgent);
            }

            if (GetAttributeValue("DefaultAllowCommentsSetting").AsBoolean())
            {
                var allowComments = new FormElementItem
                {
                    Type  = FormElementType.Switch,
                    Key   = "allowComments",
                    Label = "Allow Encouraging Comments?"
                };
                form.Add(allowComments);
            }

            if (GetAttributeValue("EnablePublicDisplayFlag").AsBoolean())
            {
                var allowPublication = new FormElementItem
                {
                    Type  = FormElementType.Switch,
                    Key   = "allowPublication",
                    Label = "Allow Publication?"
                };
                form.Add(allowPublication);
            }

            var button = new FormElementItem
            {
                Type  = FormElementType.Button,
                Label = "Save Request",
                Key   = "save"
            };

            form.Add(button);

            CustomAttributes.Add("FormElementItems", JsonConvert.SerializeObject(form));
            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.FormBlock",
                Attributes = CustomAttributes
            });
        }
Beispiel #12
0
 public ResultMessage <FormElementItem> Update(FormElementItem data)
 {
     return(repository.Update(data));
 }
Beispiel #13
0
 public ResultMessage <FormElementItem> Add(FormElementItem data)
 {
     return(repository.Add(data));
 }
Beispiel #14
0
        private List <FormElementItem> GetForm(Person person, string parameter)
        {
            var form = new List <FormElementItem>();

            var hidden = new FormElementItem
            {
                Type  = FormElementType.Hidden,
                Key   = "parameter",
                Value = parameter
            };

            form.Add(hidden);

            var title = new FormElementItem
            {
                Label   = "Title",
                Type    = FormElementType.Picker,
                Key     = "title",
                Value   = person.TitleValueId.ToString(),
                Options = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_TITLE)).DefinedValues.ToDictionary(k => k.Id.ToString(), k => k.Value)
            };

            form.Add(title);

            if (string.IsNullOrEmpty(person.FirstName))
            {
                var firstName = new FormElementItem
                {
                    Label    = "First Name",
                    Type     = FormElementType.Entry,
                    Key      = "firstName",
                    Value    = person.FirstName,
                    Required = true
                };
                form.Add(firstName);
            }
            else
            {
                var firstName = new FormElementItem
                {
                    Label = "First Name",
                    Type  = FormElementType.Label,
                    Key   = "firstName",
                    Value = person.FirstName,
                };
                form.Add(firstName);
            }

            var nickName = new FormElementItem
            {
                Label = "Nick Name",
                Type  = FormElementType.Entry,
                Key   = "nickName",
                Value = person.NickName,
            };

            form.Add(nickName);

            var lastName = new FormElementItem
            {
                Label    = "Last Name",
                Type     = FormElementType.Entry,
                Key      = "lastName",
                Value    = person.LastName,
                Required = true
            };

            form.Add(lastName);

            var suffixOptions = new Dictionary <string, string> {
                { "", "" }
            };

            DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_SUFFIX))
            .DefinedValues
            .ForEach(v => suffixOptions.Add(v.Id.ToString(), v.Value));
            var suffix = new FormElementItem
            {
                Label   = "Suffix",
                Type    = FormElementType.Picker,
                Key     = "suffix",
                Value   = person.SuffixValueId.ToString(),
                Options = suffixOptions
            };

            form.Add(suffix);

            var birthdateString = "";

            if (person.BirthDate.HasValue)
            {
                birthdateString = person.BirthDate.Value.ToString("MM/dd/yyyy");
            }


            var birthdate = new FormElementItem
            {
                Label    = "Birthday",
                Type     = FormElementType.DatePicker,
                Key      = "birthdate",
                Value    = birthdateString,
                Required = true
            };

            form.Add(birthdate);

            var gender = new FormElementItem
            {
                Label   = "Gender",
                Type    = FormElementType.Picker,
                Key     = "gender",
                Value   = (( int )person.Gender).ToString(),
                Options = new Dictionary <string, string> {
                    { "1", "Male" }, { "2", "Female" }, { "0", "Unknown" }
                }
            };

            form.Add(gender);

            var contactInfo = new FormElementItem
            {
                Type  = FormElementType.Label,
                Key   = "contactInfo",
                Value = "Contact Info",
            };

            form.Add(contactInfo);

            var mobileNumber      = person.GetPhoneNumber(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE.AsGuid());
            var mobilePhoneNumber = new FormElementItem
            {
                Label    = "Mobile Phone",
                Type     = FormElementType.Entry,
                Key      = "mobilePhone",
                Keyboard = Keyboard.Telephone,
                Value    = mobileNumber != null ? mobileNumber.NumberFormatted : ""
            };

            form.Add(mobilePhoneNumber);

            var homeNumber      = person.GetPhoneNumber(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME.AsGuid());
            var homePhoneNumber = new FormElementItem
            {
                Label    = "Home Phone",
                Type     = FormElementType.Entry,
                Key      = "homePhone",
                Keyboard = Keyboard.Telephone,
                Value    = homeNumber != null ? homeNumber.NumberFormatted : ""
            };

            form.Add(homePhoneNumber);

            var workPhone       = person.GetPhoneNumber(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK.AsGuid());
            var workPhoneNumber = new FormElementItem
            {
                Label    = "Work Phone",
                Type     = FormElementType.Entry,
                Key      = "workPhone",
                Keyboard = Keyboard.Telephone,
                Value    = workPhone != null ? workPhone.NumberFormatted : ""
            };

            form.Add(workPhoneNumber);

            var email = new FormElementItem
            {
                Label    = "Email",
                Type     = FormElementType.Entry,
                Key      = "email",
                Keyboard = Keyboard.Email,
                Value    = person.Email
            };

            form.Add(email);

            var emailPerference = new FormElementItem
            {
                Label   = "Email Preference",
                Type    = FormElementType.Picker,
                Key     = "emailPreference",
                Value   = (( int )person.EmailPreference).ToString(),
                Options = new Dictionary <string, string> {
                    { "0", "Email Allowed" }, { "1", " No Mass Emails" }, { "2", "Do Not Email" }
                }
            };

            form.Add(emailPerference);

            var save = new FormElementItem
            {
                Key   = "save",
                Type  = FormElementType.Button,
                Label = "Save",
                Value = "save"
            };

            form.Add(save);

            var cancel = new FormElementItem
            {
                Key   = "cancel",
                Type  = FormElementType.Button,
                Label = "Cancel",
                Value = "cancel"
            };

            form.Add(cancel);



            return(form);
        }
Beispiel #15
0
        private List <FormElementItem> GetForm(string currentOccurance = "", bool?didNotMeetOverride = null)
        {
            List <FormElementItem> form = new List <FormElementItem>();

            if (group.Schedule != null)
            {
                AttendanceService attendanceService = new AttendanceService(rockContext);
                var occurances = attendanceService.Queryable().Where(a => a.Occurrence.GroupId == group.Id)
                                 .DistinctBy(s => s.StartDateTime)
                                 .Select(s => s.StartDateTime)
                                 .Take(50)
                                 .ToList()
                                 .ToDictionary(s => (s - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds.ToString(),
                                               s => s.ToString("MMM d, yyyy -  h:mmtt"));

                if (group.Schedule.ScheduleType == ScheduleType.Named ||
                    group.Schedule.ScheduleType == ScheduleType.Custom)
                {
                    var prevSchedules = group.Schedule
                                        .GetScheduledStartTimes(Rock.RockDateTime.Today.AddYears(-1), Rock.RockDateTime.Today.AddDays(1))
                                        .OrderByDescending(o => o)
                                        .Take(10)
                                        .ToDictionary(s => (s - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds.ToString(),
                                                      s => s.ToString("MMM d, yyyy -  h:mmtt"));
                    foreach (var prev in prevSchedules)
                    {
                        occurances.AddOrIgnore(prev.Key, prev.Value);
                    }
                }
                else if (group.Schedule.ScheduleType == ScheduleType.Weekly)
                {
                    var schedules = new List <DateTime>();

                    DateTime lastSchedule = Rock.RockDateTime.Today;
                    //Crawl backward to find the last time this occured
                    while (lastSchedule.DayOfWeek != group.Schedule.WeeklyDayOfWeek)
                    {
                        lastSchedule = lastSchedule.AddDays(-1);
                    }
                    lastSchedule = lastSchedule.AddMinutes(group.Schedule.WeeklyTimeOfDay.Value.TotalMinutes);
                    schedules.Add(lastSchedule);
                    for (int i = 1; i < 10; i++)
                    {
                        schedules.Add(lastSchedule.AddDays(i * -7));
                    }

                    foreach (var schedule in schedules)
                    {
                        occurances.AddOrIgnore((schedule - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds.ToString(), schedule.ToString("MMM d, yyyy -  h:mmtt"));
                    }
                }
                if (occurances.Any() && string.IsNullOrWhiteSpace(currentOccurance))
                {
                    currentOccurance = occurances.Last().Key;
                }

                FormElementItem datePicker = new FormElementItem
                {
                    Type         = FormElementType.Picker,
                    Options      = occurances,
                    Value        = currentOccurance,
                    Key          = "schedule",
                    Label        = "Schedule",
                    AutoPostBack = true
                };

                form.Add(datePicker);


                var didNotMeet = false;


                if (!string.IsNullOrWhiteSpace(currentOccurance))
                {
                    //The drop down stores the time in unix time
                    var occurenceDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local)
                                        .AddSeconds(currentOccurance.AsInteger());

                    var attendanceData = new AttendanceService(rockContext)
                                         .Queryable()
                                         .Where(a => a.Occurrence.GroupId == group.Id && a.StartDateTime == occurenceDate)
                                         .ToList();

                    if (didNotMeetOverride == null)
                    {
                        didNotMeet = (attendanceData.Where(a => a.DidAttend == true).Count() <= 0 &&
                                      attendanceData.Where(a => a.Occurrence.DidNotOccur == true).Count() > 0);
                    }
                    else
                    {
                        didNotMeet = didNotMeetOverride.Value;
                    }

                    if (!didNotMeet)
                    {
                        var items = groupMembers
                                    .Where(gm => gm.GroupMemberStatus == GroupMemberStatus.Active)
                                    .OrderBy(gm => gm.Person.LastName)
                                    .ThenBy(gm => gm.Person.NickName)
                                    .Select(m => new
                        {
                            PersonId = m.PersonId.ToString(),
                            FullName = m.ToString(),
                            Attended = (attendanceData.Where(a => a.PersonAlias.PersonId == m.PersonId).Any() &&
                                        (attendanceData.Where(a => a.PersonAlias.PersonId == m.PersonId).FirstOrDefault().DidAttend ?? false))
                        }
                                            )
                                    .ToList();

                        var checkBoxOptions = new Dictionary <string, string>();
                        var selectedPeople  = new List <string>();
                        foreach (var item in items)
                        {
                            checkBoxOptions.Add(item.PersonId, item.FullName);
                            if (item.Attended)
                            {
                                selectedPeople.Add(item.PersonId);
                            }
                        }
                        var checkBoxList = new FormElementItem
                        {
                            Type    = FormElementType.CheckboxList,
                            Key     = "groupMembers",
                            Label   = "Group Members",
                            Options = checkBoxOptions,
                            Value   = string.Join(",", selectedPeople)
                        };

                        form.Add(checkBoxList);
                    }
                }

                var didNotMeetSwitch = new FormElementItem
                {
                    Type         = FormElementType.Switch,
                    Key          = "didNotMeet",
                    Label        = "Did Not Meet",
                    Value        = didNotMeet.ToString(),
                    AutoPostBack = true
                };
                form.Add(didNotMeetSwitch);

                var button = new FormElementItem
                {
                    Label = "Save",
                    Key   = "save",
                    Type  = FormElementType.Button
                };
                form.Add(button);

                var groupId = new FormElementItem
                {
                    Type  = FormElementType.Hidden,
                    Key   = "groupId",
                    Value = group.Id.ToString()
                };
                form.Add(groupId);
            }
            return(form);
        }
Beispiel #16
0
        public IActionResult Post(FormElementItem data)
        {
            var createdFormElementItem = service.Add(data);

            return(CreatedAtAction("Get", new { id = createdFormElementItem.Data.Id }, createdFormElementItem));
        }