Exemple #1
0
        private void ShowWidigtyEdit(bool setValues)
        {
            var widgityGuid = CurrentEditWidgity.Value;
            var widgity     = Widgities.Where(w => w.Guid == widgityGuid).FirstOrDefault();
            var widgityType = WidgityTypeCache.Get(widgity.WidgityTypeId);

            Literal ltName = new Literal
            {
                Text = string.Format("<h3>{0}</h3>", widgityType.Name)
            };

            pnlMenu.Controls.Add(ltName);

            phAttributesEdit = new PlaceHolder
            {
                ID = this.ID + "_phAttributesEdit"
            };
            pnlMenu.Controls.Add(phAttributesEdit);
            Rock.Attribute.Helper.AddEditControls(widgity, phAttributesEdit, setValues, this.ID + "ValidationGroup");

            if (widgityType.HasItems)
            {
                BuildWidigityItemAttibutes(widgity, setValues);
            }

            HtmlGenericContainer hr = new HtmlGenericContainer("hr");

            pnlMenu.Controls.Add(hr);

            BootstrapButton btnEditSave = new BootstrapButton
            {
                CssClass        = "btn btn-primary",
                Text            = "Save",
                ID              = this.ID + "_btnEditSave",
                ValidationGroup = this.ID + "ValidationGroup"
            };

            pnlMenu.Controls.Add(btnEditSave);
            btnEditSave.Click += BtnEditSave_Click;

            LinkButton btnEditCancel = new LinkButton
            {
                ID               = this.ID + "_btnEditCancel",
                Text             = "Cancel",
                CssClass         = "btn btn-link",
                CausesValidation = false
            };

            pnlMenu.Controls.Add(btnEditCancel);
            btnEditCancel.Click += BtnEditCancel_Click;

            LinkButton btnDeleteWidgity = new LinkButton
            {
                ID               = this.ID + "_btnDeleteWidgity",
                Text             = "Delete",
                CssClass         = "btn btn-delete pull-right",
                CausesValidation = false
            };

            pnlMenu.Controls.Add(btnDeleteWidgity);
            btnDeleteWidgity.Click += BtnDeleteWidgity_Click;
        }
Exemple #2
0
        private void BuildWidigityItemAttibutes(Widgity widgity, bool setValues)
        {
            pnlItems = new Panel();
            pnlMenu.Controls.Add(pnlItems);

            var widgityType = WidgityTypeCache.Get(widgity.WidgityTypeId);

            if (widgityType.HasItems)
            {
                pnlItems.CssClass = "widgityItemControls";
                var widgityItems = WidgityItems[widgity.Guid];
                if (widgityItems.Any())
                {
                    foreach (var widgityItem in widgityItems)
                    {
                        Panel panel = new Panel();
                        pnlItems.Controls.Add(panel);
                        panel.Attributes["data-component-id"] = widgityItem.Guid.ToString();

                        PanelWidget panelWidget = new PanelWidget
                        {
                            ID = string.Format("pnlItem_{0}", widgityItem.Guid),
                        };

                        panel.Controls.Add(panelWidget);

                        if (ExpandedPanels != null && ExpandedPanels.Contains(widgityItem.Guid))
                        {
                            panelWidget.Expanded = true;
                        }

                        if (widgityItem.AttributeValues.Any())
                        {
                            panelWidget.Title = "<a class='btn btn-xs btn-link ui-sortable-handle'><i class='fa fa-bars ui-sortable-handle'></i></a> " +
                                                widgityItem.AttributeValues.FirstOrDefault().Value.ValueFormatted;
                        }
                        else
                        {
                            panelWidget.Title = "<a class='btn btn-xs btn-link ui-sortable-handle'><i class='fa fa-bars ui-sortable-handle'></i></a> ";
                        }

                        HiddenField hiddenField = new HiddenField
                        {
                            ID    = string.Format("hfItem_{0}", widgityItem.Guid),
                            Value = widgityItem.Guid.ToString()
                        };
                        panelWidget.Controls.Add(hiddenField);

                        PlaceHolder phItemAttributes = new PlaceHolder
                        {
                            ID = string.Format("phItem_{0}", widgityItem.Guid)
                        };
                        panelWidget.Controls.Add(phItemAttributes);

                        LinkButton linkButton = new LinkButton()
                        {
                            ID       = string.Format("btnRemove_{0}", widgityItem.Guid),
                            CssClass = "btn btn-danger btn-xs",
                            Text     = "Remove Item"
                        };

                        panelWidget.Controls.Add(linkButton);

                        linkButton.Click += (s, e) => { DeleteWidgityItem(widgityItem.Guid); };

                        Rock.Attribute.Helper.AddEditControls(widgityItem, phItemAttributes, setValues, this.ID + "ValidationGroup");
                    }
                }
                else
                {
                    pnlItems.Controls.Add(new Literal
                    {
                        Text = "<i>No items. Click Add Item to add a new item to this widgity.</i>"
                    });
                }

                LinkButton btnAddButton = new LinkButton
                {
                    ID               = this.ID + "_AddItem",
                    Text             = "Add Item",
                    CssClass         = "btn btn-default btn-xs",
                    CausesValidation = false
                };
                pnlMenu.Controls.Add(btnAddButton);
                btnAddButton.Click += BtnAddButton_Click;
            }
        }
Exemple #3
0
        private void ShowWidgities(bool setValues)
        {
            EnsureChildControls();
            pnlContent.Controls.Clear();

            if (Mode == WidgityMode.Edit)
            {
                pnlMenu.Visible = true;
                ShowEdit(setValues);
            }
            else
            {
                pnlMenu.Visible = false;
                pnlContent.Style["box-shadow"] = "";
                pnlContent.CssClass            = "";
            }

            RockPage rockPage = null;

            if (HttpContext.Current != null)
            {
                rockPage = HttpContext.Current.Handler as RockPage;
            }

            var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(rockPage);

            mergeFields.Add("CurrentPage", PageCache.Get(rockPage.PageId));

            foreach (var widgity in Widgities)
            {
                var panel = new Panel();
                pnlContent.Controls.Add(panel);
                if (Mode == WidgityMode.Edit)
                {
                    if (!CurrentEditWidgity.HasValue || (CurrentEditWidgity.HasValue && CurrentEditWidgity == widgity.Guid))
                    {
                        panel.Attributes["data-component-id"] = widgity.Guid.ToString();
                        panel.CssClass = "widgityContent";

                        Panel pencilPanel = new Panel
                        {
                            CssClass = "widgity-edit"
                        };
                        panel.Controls.Add(pencilPanel);

                        LinkButton link = new LinkButton
                        {
                            ID       = string.Format("lbEdit{0}", widgity.Guid),
                            Text     = "<i class='fa fa-pencil'></i>",
                            CssClass = "widgity-edit-pencil"
                        };
                        link.Click += (s, e) => { EditWidgity(widgity.Guid); };
                        pencilPanel.Controls.Add(link);
                        if (CurrentEditWidgity == widgity.Guid)
                        {
                            panel.AddCssClass("active-edit");
                        }
                    }
                }

                Panel displayPanel = new Panel();
                displayPanel.Style.Add("width", "100%");
                panel.Controls.Add(displayPanel);

                mergeFields["Widgity"]      = widgity;
                mergeFields["WidgityItems"] = WidgityItems[widgity.Guid];
                mergeFields["uniqueid"]     = widgity.Guid.ToString().Split('-').First();
                var widgityType = WidgityTypeCache.Get(widgity.WidgityTypeId);
                var output      = new Literal
                {
                    Text = widgityType.Markdown.ResolveMergeFields(mergeFields, widgityType.EnabledLavaCommands)
                };
                displayPanel.Controls.Add(output);
            }
        }