Example #1
0
        protected override void AddOption(TagHelperContext context, TagHelperOutput output)
        {
            Options.Add("height", MaxHeigth);
            Options.Add(LayuiConsts.Select_Filterable, Filterable);
            Options.Add(LayuiConsts.Select_Single, IsSingle);
            Options.AddIf(IsRequired.HasValue, "layVerify", IsRequired);
            Options.AddIf(MaxSelect > 0, "max", MaxSelect);
            Options.AddIf(Size.HasValue, "size", Size.ToString().ToLower());
            Options.AddIf(IsDisable.HasValue, "disabled", IsDisable);
            Options.AddIf(Data.IsNotNullOrWhiteSpace(), "data", Data);

            Options.Add("model", new Dictionary <string, object> {
                { "icon", "hidden" }
            });
            Options.Add("prop", new Dictionary <string, object> {
                { LayuiConsts.Select_NameField, NameField }, { LayuiConsts.Select_ValueField, ValueField }
            });

            if (HasToolBar)
            {
                Options.Add("toolbar", new Dictionary <string, object> {
                    { "show", true }, { "list", new[] { "ALL", "CLEAR", "REVERSE" } }
                });
            }

            base.AddOption(context, output);
        }
Example #2
0
        protected override void AddOption(TagHelperContext context, TagHelperOutput output)
        {
            Options.Add(LayuiConsts.Grid_PageList, GetJavaScriptString(PageList));
            Options.Add(LayuiConsts.Grid_PageSize, PageSize);
            Options.Add(LayuiConsts.Gird_Page, Page);
            Options.Add(LayuiConsts.ShowHeader, ShowHeader);
            Options.Add(LayuiConsts.Striped, Striped);

            Options.AddIf(Size.HasValue, LayuiConsts.Grid_Size, Size.ToString().ToLower());
            Options.AddIf(Skin.HasValue, LayuiConsts.Grid_Skin, Skin.ToString().ToLower());
            Options.AddIf(ToolBar.IsNotNullOrWhiteSpace(), LayuiConsts.Grid_ToolBar, ToolBar);
            Options.AddIf(Url.IsNotNullOrWhiteSpace(), LayuiConsts.Url, Url);
            Options.AddIf(Data.IsNotNullOrWhiteSpace(), LayuiConsts.Data, GetJavaScriptString(Data));
            Options.AddIf(QueryParams.IsNotNullOrWhiteSpace(), LayuiConsts.QueryParams, GetJavaScriptString(QueryParams));
            Options.AddIf(LayuiTagHelperConfig.GridParseData.IsNotNullOrWhiteSpace(), LayuiConsts.Grid_ParseData, GetJavaScriptString(LayuiTagHelperConfig.GridParseData));
            Options.AddIf(LayuiTagHelperConfig.GridDefaultParam.IsNotNullOrWhiteSpace(), LayuiConsts.Grid_DefaultParam, GetJavaScriptString(LayuiTagHelperConfig.GridDefaultParam));

            Options.Add(LayuiConsts.Grid_Sort, new Dictionary <string, object> {
                { LayuiConsts.Sort_Name, SortName }, { LayuiConsts.Sort_Order, SortOrder }
            });

            output.Attributes.Add(LayuiConsts.Fit, Fit.ToString().ToLower());

            base.AddOption(context, output);
        }
Example #3
0
 protected override void AddOption(TagHelperContext context, TagHelperOutput output)
 {
     Options.AddIf(Max.HasValue, EasyuiConsts.ValidType_Max, Max);
     Options.AddIf(Min.HasValue, EasyuiConsts.ValidType_Min, Min);
     Options.AddIf(Precision.HasValue, EasyuiConsts.ValidType_Precision, Precision);
     base.AddOption(context, output);
 }
Example #4
0
        protected override void AddOption(TagHelperContext context, TagHelperOutput output)
        {
            Options.Add("accept", FIleType.ToString().ToLower());
            Options.Add("auto", IsAtuoUpload);
            Options.AddIf(AcceptMime.IsNotNullOrWhiteSpace(), "acceptMime", AcceptMime);
            Options.AddIf(Url.IsNotNullOrWhiteSpace(), "url", Url);
            Options.AddIf(Field.IsNotNullOrWhiteSpace(), "field", Field);

            base.AddOption(context, output);
        }
Example #5
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            Options.AddIf(Theme.HasValue, "radius", true);
            if (Theme.HasValue)
            {
                Class.Add($"layui-btn-{Theme.ToString().ToLower()}");
            }

            await base.ProcessAsync(context, output);
        }
Example #6
0
        protected override void InitOption(TagHelperContext context, TagHelperOutput output)
        {
            Options.AddIf(DateType.HasValue, "type", DateType.ToString().ToLower());
            Options.AddIf(Format.IsNotNullOrWhiteSpace(), "format", Format);
            Options.AddIf(IsRange, "range", true);

            Options.AddIf(Max.IsNotNullOrWhiteSpace(), "max", Max);
            Options.AddIf(Max.IsNotNullOrWhiteSpace(), "min", Min);
            Options.AddIf(Value.IsNotNullOrWhiteSpace(), "value", Value);

            base.InitOption(context, output);
        }
Example #7
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            Options.AddIf(IsDisable.HasValue, EasyuiConsts.Disabled, IsDisable);
            Options.AddIf(IsPlain.HasValue, EasyuiConsts.Plain, IsPlain);
            output.Attributes.Add("href", "javascript:void(0)");

            if (Icon != IconType.None)
            {
                output.Attributes.Add(EasyuiConsts.Iconcls, $"icon-{Icon.ToString().ToLower()}");
            }

            await base.ProcessAsync(context, output);
        }
Example #8
0
        protected override void AddOption(TagHelperContext context, TagHelperOutput output)
        {
            Options.Add(EasyuiConsts.Page_List, GetJavaScriptString(PageList));
            Options.Add(EasyuiConsts.Page_Size, PageSize);
            Options.Add(EasyuiConsts.Sort_Name, SortName);
            Options.Add(EasyuiConsts.Sort_Order, SortOrder);
            Options.Add(EasyuiConsts.ShowRowNumber, ShowRowNumber);
            Options.Add(EasyuiConsts.ShowPage, ShowPage);
            Options.Add(EasyuiConsts.SingleSelect, SingleSelect);
            Options.Add(EasyuiConsts.ShowHeader, ShowHeader);
            Options.Add(EasyuiConsts.Striped, Striped);

            Options.AddIf(ToolBar.IsNotNullOrWhiteSpace(), EasyuiConsts.ToolBar, ToolBar);
            Options.AddIf(Url.IsNotNullOrWhiteSpace(), EasyuiConsts.Url, Url);
            Options.AddIf(Data.IsNotNullOrWhiteSpace(), EasyuiConsts.Data, GetJavaScriptString(Data));
            Options.AddIf(QueryParams.IsNotNullOrWhiteSpace(), EasyuiConsts.QueryParams, GetJavaScriptString(QueryParams));

            output.Attributes.Add(EasyuiConsts.Fit, Fit.ToString().ToLower());

            base.AddOption(context, output);
        }
Example #9
0
        protected override void AddOption(TagHelperContext context, TagHelperOutput output)
        {
            Options.AddOrUpdate(LayuiConsts.Grid_Col_Sortable, Sortable);
            Options.AddOrUpdate(LayuiConsts.Width, Width);
            Options.AddOrUpdate(LayuiConsts.Grid_Col_Align, Align.ToString().ToLower());
            Options.AddIf(Fixed.HasValue, LayuiConsts.Grid_Col_Fixed, Fixed.ToString().ToLower());

            Options.AddIf(Title.IsNotNullOrWhiteSpace(), LayuiConsts.Title, Title);
            Options.AddIf(Field.IsNotNullOrWhiteSpace(), LayuiConsts.Field, Field.ToCamelCase());
            Options.AddIf(Style.IsNotNullOrWhiteSpace(), LayuiConsts.Grid_Col_Style, Style);
            Options.AddIf(Formatter.IsNotNullOrWhiteSpace(), LayuiConsts.Grid_Col_Formatter, Formatter);
            Options.AddIf(Edit.HasValue, LayuiConsts.Grid_Col_Edit, Edit.ToString().ToLower());
            Options.AddIf(Toolbar.IsNotNullOrWhiteSpace(), LayuiConsts.Grid_Col_Toolbar, Toolbar);

            if (ReplaceField.IsNotNullOrWhiteSpace())
            {
                output.Attributes.Add(LayuiConsts.Item_Replace, ReplaceField);
            }

            base.AddOption(context, output);
        }
Example #10
0
        protected override void AddOption(TagHelperContext context, TagHelperOutput output)
        {
            Options.AddOrUpdate(EasyuiConsts.Grid_Col_Align, Align.ToString().ToLower());
            Options.AddIf(Title.IsNotNullOrWhiteSpace(), EasyuiConsts.Title, Title);
            Options.AddIf(Styler.IsNotNullOrWhiteSpace(), EasyuiConsts.Grid_Col_Styler, Styler);
            Options.AddIf(Editor.IsNotNullOrWhiteSpace(), EasyuiConsts.Grid_Col_Editor, GetJavaScriptString(Editor));

            if (Field.IsNotNullOrWhiteSpace())
            {
                Options.AddOrUpdate(EasyuiConsts.Field, Field.ToCamelCase());
            }
            if (Formatter.IsNotNullOrWhiteSpace())
            {
                Options.AddOrUpdate(EasyuiConsts.Grid_Col_Formatter, GetJavaScriptString(Formatter));
            }

            if (Width != null)
            {
                Options.AddOrUpdate(EasyuiConsts.Width, Width);
            }

            if (IsFrozen)
            {
                output.Attributes.Add(EasyuiConsts.Grid_Col_IsFrozen, IsFrozen);
            }

            if (IsEdit)
            {
                output.Attributes.Add(EasyuiConsts.Grid_Col_IsEdit, IsEdit);
            }

            if (ReplaceField.IsNotNullOrWhiteSpace())
            {
                output.Attributes.Add(EasyuiConsts.Item_Replace, ReplaceField);
            }

            base.AddOption(context, output);
        }
Example #11
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var buttons = new StringBuilder("[");
            var id      = output.Attributes["id"]?.Value;

            if (HasSave)
            {
                buttons.Append($"{{ text:'{SaveButtonName}', iconCls:'icon-ok', handler:function(){{ {OnSave} }} }},");
            }
            if (HasClose)
            {
                buttons.Append($"{{ text:'{CloseButtonName}', iconCls:'icon-cancel', handler:function(){{ {(id != null ? $"$('#{id}').window('close')" : "")} }} }},");
            }


            buttons.Append("]");

            Options.AddIf(OnClose.IsNotNullOrWhiteSpace(), EasyuiConsts.Dialog_OnClose, GetJavaScriptString($"function(){{ {OnClose} }}"));

            Options.AddIf(IsMax, EasyuiConsts.Dialog_IsMax, IsMax);

            Options.Add(EasyuiConsts.Dialog_Buttons, GetJavaScriptString(buttons.ToString()));

            output.Attributes.Add(EasyuiConsts.Dialog_Closed, Closed.ToString().ToCamelCase());

            if (Closed)
            {
                var style = output.Attributes["style"]?.ToString() ?? "";
                if (style.IsNotNullOrWhiteSpace() && !style.EndsWith(";"))
                {
                    style += ";";
                }
                style += "display: none;";
                output.Attributes.SetAttribute("style", style);
            }

            await base.ProcessAsync(context, output);
        }
Example #12
0
        protected override void AddOption(TagHelperContext context, TagHelperOutput output)
        {
            Options.AddIf(IsRequired.HasValue, EasyuiConsts.Required, IsRequired);
            Options.AddIf(IsMultiline.HasValue, EasyuiConsts.Multiline, IsMultiline);
            Options.AddIf(IsDisable.HasValue, EasyuiConsts.Disabled, IsDisable);
            Options.AddIf(IsEdit.HasValue, EasyuiConsts.Editable, IsEdit);

            if (MaxLength > 0)
            {
                ValidTypes.Add($"{EasyuiConsts.ValidType_MaxLength}[{MaxLength}]");
            }

            if (Options.ContainsKey(EasyuiConsts.ValidType))
            {
                var valids = Options[EasyuiConsts.ValidType].ToString().Split(',').Where(x => x.IsNotNullOrWhiteSpace());
                ValidTypes.AddRange(valids);
            }

            if (ValidType.IsNotNullOrWhiteSpace())
            {
                var valids = ValidType.Split(',').Where(x => x.IsNotNullOrWhiteSpace());
                ValidTypes.AddRange(valids);
            }

            if (IsDisable == true)
            {
                Clear = false;
            }
            if (Clear.HasValue)
            {
                output.Attributes.Add(EasyuiConsts.Clear, Clear.ToString().ToCamelCase());
            }

            if (ValidTypes.Any())
            {
                Options.AddOrUpdate(EasyuiConsts.ValidType, GetJavaScriptString(ValidTypes.ToJsonString()));
            }
        }
Example #13
0
        protected override void InitOption(TagHelperContext context, TagHelperOutput output)
        {
            var content = output.Content.GetContent(HtmlEncoder.Default);

            if (Url.IsNotNullOrWhiteSpace())
            {
                Type    = DialogType.Frame;
                content = Url;
            }
            else if (!content.IsNotNullOrWhiteSpace())
            {
                Type = DialogType.Page;
            }

            Options.Add("type", Type);
            Options.AddIf(Title.IsNotNullOrWhiteSpace(), "title", Title);
            Options.AddIf(content.IsNotNullOrWhiteSpace(), LayuiConsts.Dialog_Content, content);
            Options.AddIf(Area.IsNotNullOrWhiteSpace(), "area", Area);
            if (HasSave)
            {
                Options.Add("btn", new[] { SaveButtonName });
                if (OnSave.IsNotNullOrWhiteSpace())
                {
                    Options.Add("yes", GetJavaScriptString($"function(){{ {OnSave} }} }}"));
                }
            }

            Options.AddIf(OnClose.IsNotNullOrWhiteSpace(), LayuiConsts.Dialog_OnClose, GetJavaScriptString($"function(){{ {OnClose} }}"));
            Options.AddIf(OnShow.IsNotNullOrWhiteSpace(), LayuiConsts.Dialog_OnShow, GetJavaScriptString($"function(){{ {OnShow} }}"));
            Options.AddIf(IsMax, LayuiConsts.Dialog_IsMax, IsMax);
            Options.AddIf(ShowMaxMin, LayuiConsts.Dialog_IsMaxMin, true);
            Options.AddIf(MaxWidth > 0, "maxWidth", MaxWidth);
            Options.AddIf(MaxHeight > 0, "maxHeight", MaxHeight);

            base.InitOption(context, output);
        }
Example #14
0
 protected override void AddOption(TagHelperContext context, TagHelperOutput output)
 {
     Options.AddIf(ButtonText.IsNotNullOrWhiteSpace(), EasyuiConsts.Button_Text, ButtonText);
     base.AddOption(context, output);
 }
Example #15
0
 protected override void InitOption(TagHelperContext context, TagHelperOutput output)
 {
     Options.AddIf(IsRadius, "radius", true);
     base.InitOption(context, output);
 }