Esempio n. 1
0
        /// <summary>
        /// Populates the selection lists for Step Type and Step Status.
        /// </summary>
        /// <param name="filterField">The filter field.</param>
        private void PopulateStepProgramRelatedSelectionLists(FilterField filterField)
        {
            var dataContext = new RockContext();

            var programService = new StepProgramService(dataContext);

            SingleEntityPicker <StepProgram> stepProgramSingleEntityPicker = filterField.ControlsOfTypeRecursive <SingleEntityPicker <StepProgram> >().FirstOrDefault(c => c.HasCssClass("js-step-program-picker"));
            RockCheckBoxList cblStepType    = filterField.ControlsOfTypeRecursive <RockCheckBoxList>().FirstOrDefault(c => c.HasCssClass("js-step-type"));
            RockCheckBoxList _cblStepStatus = filterField.ControlsOfTypeRecursive <RockCheckBoxList>().FirstOrDefault(c => c.HasCssClass("js-step-status"));

            int?stepProgramId = stepProgramSingleEntityPicker.SelectedId;

            StepProgram stepProgram = null;

            if (stepProgramId != null)
            {
                stepProgram = programService.Get(stepProgramId.Value);
            }

            if (stepProgram != null)
            {
                // Step Type list
                cblStepType.Items.Clear();

                var stepTypeService = new StepTypeService(dataContext);

                var stepTypes = stepTypeService.Queryable().Where(x => x.StepProgramId == stepProgramId);

                foreach (var item in stepTypes)
                {
                    cblStepType.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                cblStepType.Visible = cblStepType.Items.Count > 0;

                // Step Status list
                _cblStepStatus.Items.Clear();

                var stepStatusService = new StepStatusService(dataContext);

                var stepStatuses = stepStatusService.Queryable().Where(x => x.StepProgramId == stepProgramId);

                foreach (var item in stepStatuses)
                {
                    _cblStepStatus.Items.Add(new ListItem(item.Name, item.Guid.ToString()));
                }

                _cblStepStatus.Visible = _cblStepStatus.Items.Count > 0;
            }
            else
            {
                cblStepType.Visible    = false;
                _cblStepStatus.Visible = false;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField filterControl)
        {
            var dataContext = new RockContext();

            // Step Program selection
            var stepProgramSingleEntityPicker = new SingleEntityPicker <StepProgram>();

            stepProgramSingleEntityPicker.ID = filterControl.ID + "_StepProgramPicker";
            stepProgramSingleEntityPicker.AddCssClass("js-step-program-picker");
            stepProgramSingleEntityPicker.Label    = "Step Program";
            stepProgramSingleEntityPicker.Help     = "The Program in which the Step was undertaken.";
            stepProgramSingleEntityPicker.Required = true;

            stepProgramSingleEntityPicker.SelectedIndexChanged += StepProgramSingleEntityPicker_SelectedIndexChanged;
            stepProgramSingleEntityPicker.AutoPostBack          = true;

            var programService = new StepProgramService(dataContext);

            var availablePrograms = programService.Queryable()
                                    .Where(x => x.IsActive)
                                    .OrderBy(a => a.Order)
                                    .ThenBy(a => a.Name)
                                    .ToList();

            stepProgramSingleEntityPicker.InitializeListItems(availablePrograms, x => x.Name, allowEmptySelection: true);


            filterControl.Controls.Add(stepProgramSingleEntityPicker);

            // Step Type selection
            var cblStepType = new RockCheckBoxList();

            cblStepType.ID = filterControl.ID + "_cblStepType";
            cblStepType.AddCssClass("js-step-type");
            cblStepType.Label = "Steps";
            cblStepType.Help  = "If selected, specifies the required Steps that have been undertaken.";

            filterControl.Controls.Add(cblStepType);

            // Step Status selection
            var cblStepStatus = new RockCheckBoxList();

            cblStepStatus.ID = filterControl.ID + "_cblStepStatus";
            cblStepStatus.AddCssClass("js-step-status");
            cblStepStatus.Label = "Statuses";
            cblStepStatus.Help  = "If selected, specifies the required Statuses of the Steps.";

            filterControl.Controls.Add(cblStepStatus);

            // Date Started
            var drpStarted = new SlidingDateRangePicker();

            drpStarted.ID = filterControl.ID + "_drpDateStarted";
            drpStarted.AddCssClass("js-date-started");
            drpStarted.Label = "Date Started";
            drpStarted.Help  = "The date range within which the Step was started";

            filterControl.Controls.Add(drpStarted);

            // Date Completed
            var drpCompleted = new SlidingDateRangePicker();

            drpCompleted.ID = filterControl.ID + "_drpDateCompleted";
            drpCompleted.AddCssClass("js-date-completed");
            drpCompleted.Label = "Date Completed";
            drpCompleted.Help  = "The date range within which the Step was completed";

            filterControl.Controls.Add(drpCompleted);

            // Step Campus selection
            var cblStepCampus = new RockCheckBoxList();

            cblStepCampus.ID = filterControl.ID + "_cblStepCampus";
            cblStepCampus.AddCssClass("js-step-campus");
            cblStepCampus.Label = "Campuses";
            cblStepCampus.Help  = "Select the campuses that the steps were completed at. Not selecting a value will select all campuses.";

            filterControl.Controls.Add(cblStepCampus);

            // Populate lists
            PopulateStepProgramRelatedSelectionLists(filterControl);
            PopulateStepCampuses(cblStepCampus);

            return(new Control[] { stepProgramSingleEntityPicker, cblStepType, cblStepStatus, drpStarted, drpCompleted, cblStepCampus });
        }