public static void Create(AdaptiveOpenUrlAction action, HtmlTag tag, AdaptiveRenderContext renderContext)
        {
            tag.Attr("id", AdaptiveCardRenderer.GenerateRandomId());
            tag.Attr("data-ac-url", action.Url);

            tag.Attributes.Add("onclick", "window.blazorAdaptiveCards.openUrl(this.getAttribute('data-ac-url'), this)");
        }
Esempio n. 2
0
        public static void Create(AdaptiveShowCardAction action, HtmlTag tag, AdaptiveRenderContext renderContext)
        {
            tag.Attr("id", AdaptiveCardRenderer.GenerateRandomId());

            var targetId = AdaptiveCardRenderer.GenerateRandomId();

            tag.Attr("data-ac-showCardId", targetId);

            tag.Attributes.Add("onclick",
                               $"document.getElementById('{targetId}').style.display === 'none' ? document.getElementById('{targetId}').style.display = '' : document.getElementById('{targetId}').style.display = 'none';");
        }
        /// <summary>
        /// Creates the specified submit action.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="renderContext">The render context.</param>
        public static void Create(AdaptiveSubmitAction action, HtmlTag tag, AdaptiveRenderContext renderContext)
        {
            var id = AdaptiveCardRenderer.GenerateRandomId();

            tag.Attr("id", id);
            tag.Attr("data-ac-submitData", JsonConvert.SerializeObject(action.Data, Formatting.None));

            if (action.AdditionalProperties.ContainsKey("name"))
            {
                tag.Attributes.Add("data-name", action.AdditionalProperties["name"].ToString());
            }
            else
            {
                tag.Attributes.Add("data-name", "Submit");
            }

            tag.Attributes.Add("onclick", "window.blazorAdaptiveCards.submitData(this, id)");
        }
Esempio n. 4
0
        public static void Create(AdaptiveToggleVisibilityAction action, HtmlTag tag, AdaptiveRenderContext renderContext)
        {
            var targetElements = string.Empty;

            if (action.TargetElements?.Any() != true)
            {
                return;
            }

            foreach (var targetElement in action.TargetElements)
            {
                if (!string.IsNullOrWhiteSpace(targetElements))
                {
                    targetElements += ",";
                }

                string targetElementId           = null;
                var    targetElementToggleAction = "Toggle";

                if (targetElement != null)
                {
                    targetElementId = targetElement.ElementId;

                    if (targetElement.IsVisible.HasValue)
                    {
                        targetElementToggleAction = targetElement.IsVisible.Value.ToString();
                    }
                }

                targetElements += targetElementId + ":" + targetElementToggleAction;
            }

            tag.Attr("data-ac-targetelements", targetElements);
            var toggleId = AdaptiveCardRenderer.GenerateRandomId();

            tag.Attr("id", toggleId);
            tag.Attributes.Add("onclick",
                               $"blazorAdaptiveCards.toggleVisibility('{toggleId}')");
        }