public virtual async Task <ModalContext> OpenModal <TModal>(Action <ModalContext> configureContext, IDictionary <string, object> attributes = null)
        {
            ModalContext modalContext = new ModalContext()
            {
                ModalType = typeof(TModal)
            };

            configureContext(modalContext);

            RenderFragment renderFragment = (builder) =>
            {
                builder.OpenComponent(0, typeof(TModal));

                int i = 1;
                if (attributes != null)
                {
                    foreach (var kvp in attributes)
                    {
                        builder.AddAttribute(i++, kvp.Key, kvp.Value);
                    }
                }

                builder.CloseComponent();
            };

            modalContext.RenderFragment = renderFragment;

            await ModalStack.Push(modalContext);

            return(modalContext);
        }
Пример #2
0
        public InfoModal(ModalContext modalContext)
        {
            Assure.ArgumentNotNull(modalContext, nameof(modalContext));

            _modalContext = modalContext;

            InitializeComponent();
        }
Пример #3
0
        public ProductDetailsModal(ModalContext modalContext)
        {
            Assure.ArgumentNotNull(modalContext, nameof(modalContext));

            _modalContext = modalContext;

            InitializeComponent();
        }
Пример #4
0
        public PromoCodeEntryModal(ModalContext modalContext)
        {
            Assure.ArgumentNotNull(modalContext, nameof(modalContext));

            _modalContext = modalContext;

            InitializeComponent();
        }
        public InactivityConfirmationModalModel(ModalContext modalContext, int countdownSeconds, Action onCountdownRunOut)
        {
            Assure.ArgumentNotNull(modalContext, nameof(modalContext));
            Assure.ArgumentNotNull(onCountdownRunOut, nameof(onCountdownRunOut));

            ModalContext       = modalContext;
            _countdownSeconds  = countdownSeconds;
            _onCountdownRunOut = onCountdownRunOut;
        }
Пример #6
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var modalContext = new ModalContext();

            //modal context typeof itself, but this time a modalContext parameter is passed
            //probably context.Items is a shared tagHelper memory space or something


            context.Items.Add(typeof(ModalTagHelper), modalContext);

            await output.GetChildContentAsync();

            var template =
                $@"<div class='modal-dialog' role='document'>
    <div class='modal-content'>
      <div class='modal-header'>
        <button type = 'button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
        <h4 class='modal-title' id='{context.UniqueId}Label'>{Title}</h4>
      </div>
        <div class='modal-body'>";

            output.TagName = "div";
            output.Attributes.SetAttribute("role", "dialog");
            output.Attributes.SetAttribute("id", Id);
            output.Attributes.SetAttribute("aria-labelledby", $"{context.UniqueId}Label");
            output.Attributes.SetAttribute("tabindex", "-1");
            var classNames = "modal fade";

            if (output.Attributes.ContainsName("class"))
            {
                classNames = string.Format("{0} {1}", output.Attributes["class"].Value, classNames);
            }
            output.Attributes.SetAttribute("class", classNames);
            output.Content.AppendHtml(template);
            if (modalContext.Body != null)
            {
                output.Content.AppendHtml(modalContext.Body);
            }
            output.Content.AppendHtml("</div>");
            if (modalContext.Footer != null)
            {
                output.Content.AppendHtml("<div class='modal-footer'>");
                output.Content.AppendHtml(modalContext.Footer);
                output.Content.AppendHtml("</div>");
            }

            output.Content.AppendHtml("</div></div>");
        }