/// <summary>
        /// Shows the status flags
        /// </summary>
        /// <param name="prayerRequest">The prayer request.</param>
        /// <param name="person">The person.</param>
        /// <param name="lFlagged">The l flagged.</param>
        private void ShowStatus(PrayerRequest prayerRequest, Person person, HighlightLabel lFlagged)
        {
            int flagCount = prayerRequest.FlagCount ?? 0;

            if (flagCount > 0)
            {
                lFlagged.Visible = true;
                lFlagged.Text    = string.Format("flagged {0} times", flagCount);
            }

            cbApproved.Enabled = IsUserAuthorized("Approve");
            cbApproved.Checked = prayerRequest.IsApproved ?? false;

            if (person != null &&
                (prayerRequest.IsApproved ?? false) &&
                prayerRequest.ApprovedByPersonAlias != null &&
                prayerRequest.ApprovedByPersonAlias.Person != null)
            {
                lblApprovedByPerson.Visible = true;
                lblApprovedByPerson.Text    = string.Format("approved by {0}", prayerRequest.ApprovedByPersonAlias.Person.FullName);
            }
            else
            {
                lblApprovedByPerson.Visible = false;
            }
        }
示例#2
0
        /// <summary>
        /// Gets the badge label
        /// </summary>
        /// <param name="person">The person.</param>
        /// <returns></returns>
        public override HighlightLabel GetLabel(Person person)
        {
            if (ParentPersonBlock != null)
            {
                // Campus is associated with the family group(s) person belongs to.
                var families = ParentPersonBlock.PersonGroups(Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY);
                if (families != null)
                {
                    var label = new HighlightLabel();
                    label.LabelType = LabelType.Campus;

                    var campusNames = new List <string>();
                    foreach (int campusId in families
                             .Where(g => g.CampusId.HasValue)
                             .Select(g => g.CampusId)
                             .Distinct()
                             .ToList())
                    {
                        campusNames.Add(Rock.Web.Cache.CampusCache.Read(campusId).Name);
                    }

                    label.Text = campusNames.OrderBy(n => n).ToList().AsDelimited(", ");

                    return(label);
                }
            }

            return(null);
        }
        /// <summary>
        /// Shows the status flags
        /// </summary>
        /// <param name="prayerRequest">The prayer request.</param>
        /// <param name="person">The person.</param>
        /// <param name="lFlagged">The l flagged.</param>
        private void ShowStatus(PrayerRequest prayerRequest, Person person, HighlightLabel lFlagged)
        {
            int flagCount = prayerRequest.FlagCount ?? 0;

            if (flagCount > 0)
            {
                lFlagged.Visible = true;
                lFlagged.Text    = string.Format("flagged {0} times", flagCount);
            }

            ShowApproval(prayerRequest);
        }
示例#4
0
        /// <summary>
        /// Gets the badge label
        /// </summary>
        /// <param name="person">The person.</param>
        /// <returns></returns>
        public override HighlightLabel GetLabel(Person person)
        {
            if (Person != null)
            {
                var label = new HighlightLabel();
                label.LabelType = LabelType.Success;
                label.Text      = Person.ConnectionStatusValueId.DefinedValue();
                return(label);
            }

            return(null);
        }
示例#5
0
        /// <summary>
        /// Gets the badge label
        /// </summary>
        /// <param name="person">The person.</param>
        /// <returns></returns>
        public override HighlightLabel GetLabel(Person person)
        {
            if (Person != null)
            {
                // Show record status only if it's not 'Active'
                if (Person.RecordStatusValueId.HasValue)
                {
                    var recordStatusValue = DefinedValueCache.Read(Person.RecordStatusValueId.Value);
                    if (string.Compare(recordStatusValue.Guid.ToString(), Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE, true) != 0)
                    {
                        var recordReasonValue = DefinedValueCache.Read(Person.RecordStatusReasonValueId.Value);
                        var label             = new HighlightLabel();
                        label.LabelType = LabelType.Danger;
                        label.Text      = recordStatusValue.Name;
                        label.ToolTip   = (recordReasonValue != null) ? recordReasonValue.Name : "";
                        return(label);
                    }
                }
            }

            return(null);
        }
示例#6
0
        protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.SetLineSpacing(1, 1.1f);
            }
            if (e.NewElement != null)
            {
                _label      = (HighlightLabel)Element;
                _label.Text = _label.Text.Replace(" ", "\u00A0");
                textHeight  = (int)_label.FontSize;

                if (_label.Dash)
                {
                    Control.PaintFlags |= Android.Graphics.PaintFlags.UnderlineText;
                    Control.PaintFlags |= Android.Graphics.PaintFlags.FakeBoldText;
                }
                else
                {
                    Control.PaintFlags &= ~Android.Graphics.PaintFlags.UnderlineText;
                    Control.PaintFlags &= ~Android.Graphics.PaintFlags.FakeBoldText;
                }

                if (_label.Highlight != null)
                {
                    SpannableString text = new SpannableString(_label.Text);
                    text.SetSpan(new CustomLineSpan(Android.Graphics.Color.ParseColor(_label.Highlight), textHeight), 0, text.Length(), SpanTypes.ExclusiveExclusive);

                    Control.SetText(text, TextView.BufferType.Normal);
                }
                else
                {
                    Control.SetText(Control.Text, TextView.BufferType.Normal);
                }
            }
        }
        /// <summary>
        /// Handles the RowDataBound event of the gGroupMembers control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewRowEventArgs"/> instance containing the event data.</param>
        public void gList_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
        {
            if (e.Row.RowType != DataControlRowType.DataRow)
            {
                return;
            }

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                BenevolenceRequest benevolenceRequest = e.Row.DataItem as BenevolenceRequest;
                if (benevolenceRequest != null)
                {
                    Literal lName = e.Row.FindControl("lName") as Literal;
                    if (lName != null)
                    {
                        if (benevolenceRequest.RequestedByPersonAlias != null)
                        {
                            lName.Text = string.Format("<a href=\"{0}\">{1}</a>", ResolveUrl(string.Format("~/Person/{0}", benevolenceRequest.RequestedByPersonAlias.PersonId)), benevolenceRequest.RequestedByPersonAlias.Person.FullName ?? string.Empty);
                        }
                        else
                        {
                            lName.Text = string.Format("{0} {1}", benevolenceRequest.FirstName, benevolenceRequest.LastName);
                        }
                    }

                    Literal lResults = e.Row.FindControl("lResults") as Literal;
                    if (lResults != null)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.Append("<div class='col-md-12'>");
                        foreach (BenevolenceResult result in benevolenceRequest.BenevolenceResults)
                        {
                            if (result.Amount != null)
                            {
                                stringBuilder.Append(string.Format("<div class='row'>{0} ({1})</div>", result.ResultTypeValue, result.Amount.FormatAsCurrency()));
                            }
                            else
                            {
                                stringBuilder.Append(string.Format("<div class='row'>{0}</div>", result.ResultTypeValue));
                            }
                        }

                        stringBuilder.Append("</div>");
                        lResults.Text = stringBuilder.ToString();
                    }

                    HighlightLabel hlStatus = e.Row.FindControl("hlStatus") as HighlightLabel;
                    if (hlStatus != null)
                    {
                        switch (benevolenceRequest.RequestStatusValue.Value)
                        {
                        case "Approved":
                            hlStatus.Text      = "Approved";
                            hlStatus.LabelType = LabelType.Success;
                            return;

                        case "Denied":
                            hlStatus.Text      = "Denied";
                            hlStatus.LabelType = LabelType.Danger;
                            return;

                        case "Pending":
                            hlStatus.Text      = "Pending";
                            hlStatus.LabelType = LabelType.Default;
                            return;

                        default:
                            hlStatus.Text      = benevolenceRequest.RequestStatusValue.Value;
                            hlStatus.LabelType = LabelType.Info;
                            return;
                        }
                    }
                }
            }
        }
示例#8
0
        public void ShowDetail(int contentItemId, int?contentChannelId)
        {
            bool canEdit = IsUserAuthorized(Authorization.EDIT);

            hfId.Value        = contentItemId.ToString();
            hfChannelId.Value = contentChannelId.HasValue ? contentChannelId.Value.ToString() : string.Empty;

            ContentChannelItem contentItem = GetContentItem();

            if (contentItem != null &&
                contentItem.ContentChannelType != null &&
                contentItem.ContentChannel != null &&
                (canEdit || contentItem.IsAuthorized(Authorization.EDIT, CurrentPerson)))
            {
                ShowApproval(contentItem);

                pnlEditDetails.Visible = true;

                hfId.Value        = contentItem.Id.ToString();
                hfChannelId.Value = contentItem.ContentChannelId.ToString();

                string cssIcon = contentItem.ContentChannel.IconCssClass;
                if (string.IsNullOrWhiteSpace(cssIcon))
                {
                    cssIcon = "fa fa-certificate";
                }
                lIcon.Text = string.Format("<i class='{0}'></i>", cssIcon);

                string title = contentItem.Id > 0 ?
                               ActionTitle.Edit(ContentChannelItem.FriendlyTypeName) :
                               ActionTitle.Add(ContentChannelItem.FriendlyTypeName);
                lTitle.Text = title.FormatAsHtmlTitle();

                hlContentChannel.Text = contentItem.ContentChannel.Name;
                hlStatus.Text         = contentItem.Status.ConvertToString();

                hlStatus.LabelType = LabelType.Default;
                switch (contentItem.Status)
                {
                case ContentChannelItemStatus.Approved: hlStatus.LabelType = LabelType.Success; break;

                case ContentChannelItemStatus.Denied: hlStatus.LabelType = LabelType.Danger; break;

                case ContentChannelItemStatus.PendingApproval: hlStatus.LabelType = LabelType.Warning; break;

                default: hlStatus.LabelType = LabelType.Default; break;
                }

                var statusDetail = new System.Text.StringBuilder();
                if (contentItem.ApprovedByPersonAlias != null && contentItem.ApprovedByPersonAlias.Person != null)
                {
                    statusDetail.AppendFormat("by {0} ", contentItem.ApprovedByPersonAlias.Person.FullName);
                }
                if (contentItem.ApprovedDateTime.HasValue)
                {
                    statusDetail.AppendFormat("on {0} at {1}", contentItem.ApprovedDateTime.Value.ToShortDateString(),
                                              contentItem.ApprovedDateTime.Value.ToShortTimeString());
                }
                hlStatus.ToolTip = statusDetail.ToString();

                tbTitle.Text = contentItem.Title;

                if (contentItem.ContentChannel.ContentControlType == ContentControlType.HtmlEditor)
                {
                    ceContent.Visible   = false;
                    htmlContent.Visible = true;
                    htmlContent.Text    = contentItem.Content;
                    htmlContent.MergeFields.Clear();
                    htmlContent.MergeFields.Add("GlobalAttribute");
                    htmlContent.MergeFields.Add("Rock.Model.ContentChannelItem|Current Item");
                    htmlContent.MergeFields.Add("Rock.Model.Person|Current Person");
                    htmlContent.MergeFields.Add("Campuses");
                    htmlContent.MergeFields.Add("RockVersion");

                    if (!string.IsNullOrWhiteSpace(contentItem.ContentChannel.RootImageDirectory))
                    {
                        htmlContent.DocumentFolderRoot = contentItem.ContentChannel.RootImageDirectory;
                        htmlContent.ImageFolderRoot    = contentItem.ContentChannel.RootImageDirectory;
                    }
                }
                else
                {
                    htmlContent.Visible = false;
                    ceContent.Visible   = true;
                    ceContent.Text      = contentItem.Content;
                    ceContent.MergeFields.Clear();
                    ceContent.MergeFields.Add("GlobalAttribute");
                    ceContent.MergeFields.Add("Rock.Model.ContentChannelItem|Current Item");
                    ceContent.MergeFields.Add("Rock.Model.Person|Current Person");
                    ceContent.MergeFields.Add("Campuses");
                    ceContent.MergeFields.Add("RockVersion");
                }

                if (contentItem.ContentChannelType.IncludeTime)
                {
                    dpStart.Visible   = false;
                    dpExpire.Visible  = false;
                    dtpStart.Visible  = true;
                    dtpExpire.Visible = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange;

                    dtpStart.SelectedDateTime  = contentItem.StartDateTime;
                    dtpStart.Label             = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active";
                    dtpExpire.SelectedDateTime = contentItem.ExpireDateTime;
                }
                else
                {
                    dpStart.Visible   = true;
                    dpExpire.Visible  = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange;
                    dtpStart.Visible  = false;
                    dtpExpire.Visible = false;

                    dpStart.SelectedDate  = contentItem.StartDateTime.Date;
                    dpStart.Label         = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active";
                    dpExpire.SelectedDate = contentItem.ExpireDateTime.HasValue ? contentItem.ExpireDateTime.Value.Date : (DateTime?)null;
                }

                nbPriority.Text    = contentItem.Priority.ToString();
                nbPriority.Visible = !contentItem.ContentChannelType.DisablePriority;

                contentItem.LoadAttributes();
                phAttributes.Controls.Clear();
                Rock.Attribute.Helper.AddEditControls(contentItem, phAttributes, true, BlockValidationGroup);

                phOccurrences.Controls.Clear();
                foreach (var occurrence in contentItem.EventItemOccurrences
                         .Where(o => o.EventItemOccurrence != null)
                         .Select(o => o.EventItemOccurrence))
                {
                    var qryParams = new Dictionary <string, string> {
                        { "EventItemOccurrenceId", occurrence.Id.ToString() }
                    };
                    string url          = LinkedPageUrl("EventOccurrencePage", qryParams);
                    var    hlOccurrence = new HighlightLabel();
                    hlOccurrence.LabelType = LabelType.Info;
                    hlOccurrence.ID        = string.Format("hlOccurrence_{0}", occurrence.Id);
                    hlOccurrence.Text      = string.Format("<a href='{0}'>{1}</a>", url, occurrence.ToString());
                    phOccurrences.Controls.Add(hlOccurrence);
                }
            }
            else
            {
                nbEditModeMessage.Text = EditModeMessage.NotAuthorizedToEdit(ContentChannelItem.FriendlyTypeName);
                pnlEditDetails.Visible = false;
            }
        }
示例#9
0
        public void ShowDetail(int contentItemId, int?contentChannelId)
        {
            bool canEdit = IsUserAuthorized(Authorization.EDIT);

            hfId.Value        = contentItemId.ToString();
            hfChannelId.Value = contentChannelId.HasValue ? contentChannelId.Value.ToString() : string.Empty;

            ContentChannelItem contentItem = GetContentItem();

            if (contentItem == null)
            {
                // this block requires a valid ContentChannel in order to know which channel the ContentChannelItem belongs to, so if ContentChannel wasn't specified, don't show this block
                this.Visible = false;
                return;
            }

            if (contentItem.ContentChannel.IsTaggingEnabled)
            {
                taglTags.EntityTypeId = EntityTypeCache.Read(typeof(ContentChannelItem)).Id;
                taglTags.CategoryGuid = (contentItem.ContentChannel != null && contentItem.ContentChannel.ItemTagCategory != null) ?
                                        contentItem.ContentChannel.ItemTagCategory.Guid : (Guid?)null;
                taglTags.EntityGuid = contentItem.Guid;
                taglTags.DelaySave  = true;
                taglTags.GetTagValues(CurrentPersonId);
                rcwTags.Visible = true;
            }
            else
            {
                rcwTags.Visible = false;
            }

            pdAuditDetails.SetEntity(contentItem, ResolveRockUrl("~"));

            if (contentItem != null &&
                contentItem.ContentChannelType != null &&
                contentItem.ContentChannel != null &&
                (canEdit || contentItem.IsAuthorized(Authorization.EDIT, CurrentPerson)))
            {
                hfIsDirty.Value = "false";

                ShowApproval(contentItem);

                pnlEditDetails.Visible = true;

                // show/hide the delete button
                lbDelete.Visible = (GetAttributeValue("ShowDeleteButton").AsBoolean() && contentItem.Id != 0);

                hfId.Value        = contentItem.Id.ToString();
                hfChannelId.Value = contentItem.ContentChannelId.ToString();

                string cssIcon = contentItem.ContentChannel.IconCssClass;
                if (string.IsNullOrWhiteSpace(cssIcon))
                {
                    cssIcon = "fa fa-certificate";
                }
                lIcon.Text = string.Format("<i class='{0}'></i>", cssIcon);

                string title = contentItem.Id > 0 ?
                               ActionTitle.Edit(ContentChannelItem.FriendlyTypeName) :
                               ActionTitle.Add(ContentChannelItem.FriendlyTypeName);
                lTitle.Text = title.FormatAsHtmlTitle();

                hlContentChannel.Text = contentItem.ContentChannel.Name;

                hlStatus.Visible = contentItem.ContentChannel.RequiresApproval && !contentItem.ContentChannelType.DisableStatus;

                hlStatus.Text = contentItem.Status.ConvertToString();

                hlStatus.LabelType = LabelType.Default;
                switch (contentItem.Status)
                {
                case ContentChannelItemStatus.Approved: hlStatus.LabelType = LabelType.Success; break;

                case ContentChannelItemStatus.Denied: hlStatus.LabelType = LabelType.Danger; break;

                case ContentChannelItemStatus.PendingApproval: hlStatus.LabelType = LabelType.Warning; break;

                default: hlStatus.LabelType = LabelType.Default; break;
                }

                var statusDetail = new System.Text.StringBuilder();
                if (contentItem.ApprovedByPersonAlias != null && contentItem.ApprovedByPersonAlias.Person != null)
                {
                    statusDetail.AppendFormat("by {0} ", contentItem.ApprovedByPersonAlias.Person.FullName);
                }
                if (contentItem.ApprovedDateTime.HasValue)
                {
                    statusDetail.AppendFormat("on {0} at {1}", contentItem.ApprovedDateTime.Value.ToShortDateString(),
                                              contentItem.ApprovedDateTime.Value.ToShortTimeString());
                }
                hlStatus.ToolTip = statusDetail.ToString();

                tbTitle.Text = contentItem.Title;

                htmlContent.Visible = !contentItem.ContentChannelType.DisableContentField;
                htmlContent.Text    = contentItem.Content;
                htmlContent.MergeFields.Clear();
                htmlContent.MergeFields.Add("GlobalAttribute");
                htmlContent.MergeFields.Add("Rock.Model.ContentChannelItem|Current Item");
                htmlContent.MergeFields.Add("Rock.Model.Person|Current Person");
                htmlContent.MergeFields.Add("Campuses");
                htmlContent.MergeFields.Add("RockVersion");

                if (!string.IsNullOrWhiteSpace(contentItem.ContentChannel.RootImageDirectory))
                {
                    htmlContent.DocumentFolderRoot = contentItem.ContentChannel.RootImageDirectory;
                    htmlContent.ImageFolderRoot    = contentItem.ContentChannel.RootImageDirectory;
                }

                htmlContent.StartInCodeEditorMode = contentItem.ContentChannel.ContentControlType == ContentControlType.CodeEditor;

                if (contentItem.ContentChannelType.IncludeTime)
                {
                    dpStart.Visible   = false;
                    dpExpire.Visible  = false;
                    dtpStart.Visible  = contentItem.ContentChannelType.DateRangeType != ContentChannelDateType.NoDates;
                    dtpExpire.Visible = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange;

                    dtpStart.SelectedDateTime  = contentItem.StartDateTime;
                    dtpStart.Label             = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active";
                    dtpExpire.SelectedDateTime = contentItem.ExpireDateTime;
                }
                else
                {
                    dpStart.Visible   = contentItem.ContentChannelType.DateRangeType != ContentChannelDateType.NoDates;
                    dpExpire.Visible  = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange;
                    dtpStart.Visible  = false;
                    dtpExpire.Visible = false;

                    dpStart.SelectedDate  = contentItem.StartDateTime.Date;
                    dpStart.Label         = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active";
                    dpExpire.SelectedDate = contentItem.ExpireDateTime.HasValue ? contentItem.ExpireDateTime.Value.Date : (DateTime?)null;
                }

                nbPriority.Text    = contentItem.Priority.ToString();
                nbPriority.Visible = !contentItem.ContentChannelType.DisablePriority;

                contentItem.LoadAttributes();
                phAttributes.Controls.Clear();
                Rock.Attribute.Helper.AddEditControls(contentItem, phAttributes, true, BlockValidationGroup, 2);

                phOccurrences.Controls.Clear();
                foreach (var occurrence in contentItem.EventItemOccurrences
                         .Where(o => o.EventItemOccurrence != null)
                         .Select(o => o.EventItemOccurrence))
                {
                    var qryParams = new Dictionary <string, string> {
                        { "EventItemOccurrenceId", occurrence.Id.ToString() }
                    };
                    string url          = LinkedPageUrl("EventOccurrencePage", qryParams);
                    var    hlOccurrence = new HighlightLabel();
                    hlOccurrence.LabelType = LabelType.Info;
                    hlOccurrence.ID        = string.Format("hlOccurrence_{0}", occurrence.Id);
                    hlOccurrence.Text      = string.Format("<a href='{0}'><i class='fa fa-calendar-o'></i> {1}</a>", url, occurrence.ToString());
                    phOccurrences.Controls.Add(hlOccurrence);
                }

                bool canHaveChildren = contentItem.Id > 0 && contentItem.ContentChannel.ChildContentChannels.Any();
                bool canHaveParents  = contentItem.Id > 0 && contentItem.ContentChannel.ParentContentChannels.Any();

                pnlChildrenParents.Visible = canHaveChildren || canHaveParents;
                phPills.Visible            = canHaveChildren && canHaveParents;
                if (canHaveChildren && !canHaveParents)
                {
                    lChildrenParentsTitle.Text = "<i class='fa fa-arrow-circle-down'></i> Child Items";
                }

                if (!canHaveChildren && canHaveParents)
                {
                    lChildrenParentsTitle.Text = "<i class='fa fa-arrow-circle-up'></i> Parent Items";
                    divParentItems.AddCssClass("active");
                }

                if (canHaveChildren)
                {
                    BindChildItemsGrid(contentItem);
                }

                if (canHaveParents)
                {
                    BindParentItemsGrid(contentItem);
                }
            }
            else
            {
                nbEditModeMessage.Text = EditModeMessage.NotAuthorizedToEdit(ContentChannelItem.FriendlyTypeName);
                pnlEditDetails.Visible = false;
            }
        }