/// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="formular">Das zugehörige Formular</param>
 /// <param name="id">Die ID</param>
 public ControlFormularItemButton(ControlPanelFormular formular, string id = null)
     : base(formular, id)
 {
     Init();
 }
Exemple #2
0
        /// <summary>
        /// In HTML konvertieren
        /// </summary>
        /// <returns>Das Control als HTML</returns>
        public override IHtmlNode ToHtml()
        {
            var classes = new List <string>();

            classes.Add(Class);
            classes.Add("post");

            var profile = new ControlAvatar(Page)
            {
                User  = User,
                Image = Image
            };

            var timespan = string.Empty;
            var days     = (DateTime.Now - Timestamp).Days;

            if (days == 1)
            {
                timespan = "vor ein Tag";
            }
            else if (days < 1)
            {
                var hours = (DateTime.Now - Timestamp).Hours;
                if (hours == 1)
                {
                    timespan = "vor einer Stunde";
                }
                else if (hours < 1)
                {
                    var minutes = (DateTime.Now - Timestamp).Minutes;

                    if (minutes == 1)
                    {
                        timespan = "vor einer Minute";
                    }
                    else if (minutes < 1)
                    {
                        timespan = "gerade ebend";
                    }
                    else
                    {
                        timespan = "vor " + minutes + " Minuten";
                    }
                }
                else
                {
                    timespan = "vor " + hours + " Stunden";
                }
            }
            else
            {
                timespan = "vor " + days + " Tagen";
            }

            var date = new ControlText(Page)
            {
                Text    = timespan,
                Tooltip = "Am " + Timestamp.ToShortDateString() + " um " + Timestamp.ToShortTimeString() + " Uhr",
                Format  = TypesTextFormat.Span,
                Color   = TypesTextColor.Muted
            };

            var headerText = new HtmlElementP
                             (
                new ControlText(Page)
            {
                Text = Action, Color = TypesTextColor.Info, Format = TypesTextFormat.Span
            }.ToHtml(),
                date.ToHtml()
                             );

            var setting = new ControlDropdownMenu(Page)
            {
                Icon   = "fas fa-cog",
                Layout = TypesLayoutButton.Light,
                HorizontalAlignment = TypesHorizontalAlignment.Right,
                Size = TypesSize.Small
            };

            setting.Add(new ControlLink(Page)
            {
                Text = "Löschen", Icon = "fas fa-trash-alt", Color = TypesTextColor.Danger, Url = Page.GetUrl()
            });

            var header = new HtmlElementDiv(setting.ToHtml(), profile.ToHtml(), headerText)
            {
                Class = "header"
            };

            var body = new HtmlElementDiv(new HtmlText(Post))
            {
                Class = string.Join(" ", classes.Where(x => !string.IsNullOrWhiteSpace(x)))
            };

            var likeText = "Gefällt mir" + (Likes > 0 ? " (" + Likes + ")" : string.Empty);
            var like     = new ControlButtonLink(Page)
            {
                Icon = "fas fa-thumbs-up", Text = likeText, Url = Page.GetUrl(), Size = TypesSize.Small, Layout = TypesLayoutButton.Light, Outline = true, Color = TypesTextColor.Primary
            };
            //var comment = new ControlButtonLink(Page) { Icon = "fas fa-comment", Text = "Antworten", Url = Page.GetUrl(), Size = TypesSize.Small, Layout = TypesLayoutButton.Light, Color = TypesTextColor.Primary };

            var option = new HtmlElementDiv(like.ToHtml())
            {
                Class = "options"
            };

            var html = new HtmlList(header, body, option);

            //if (Comments.Count > 0)
            //{
            //    html.Elements.Add(new HtmlElementHr());
            //}
            html.Elements.AddRange(from x in Comments select x.ToHtml());

            var form = new ControlPanelFormular(Page)
            {
                Name = !string.IsNullOrWhiteSpace(Name)? Name : "form",
                EnableCancelButton = false
            };

            form.SubmitButton.Icon                = "fas fa-paper-plane";
            form.SubmitButton.Text                = "Antworten";
            form.SubmitButton.Outline             = true;
            form.SubmitButton.Size                = TypesSize.Small;
            form.SubmitButton.HorizontalAlignment = TypesHorizontalAlignment.Default;

            form.Add(new ControlFormularItemTextBox(form)
            {
                Format = TypesEditTextFormat.Multiline, Placeholder = "Kommentieren..."
            });

            html.Elements.Add(form.ToHtml());

            return(html);
        }
 /// <summary>
 /// Konstruktor
 /// </summary>
 /// <param name="formular">Das zugehörige Formular</param>
 /// <param name="id">Die ID</param>
 public ControlFormularItemStaticText(ControlPanelFormular formular, string id = null)
     : base(formular, id)
 {
     Init();
 }