Exemple #1
0
        public static bool StartContainer(this IHtmlHelper helper, string tag, string identifier, object attrs = null, string tabVariable = null)
        {
            var access = proc.Process(helper, identifier.ToLower(), "Container");

            if (access.Read)
            {
                dynamic other       = new ExpandoObject();
                string  stringified = attrs == null ? "" : RazorUtils.ToAttributeString(attrs);
                if (attrs == null || !attrs.HasProperty("id"))
                {
                    other.id = identifier;
                }
                if (tabVariable != null)
                {
                    other.calc__show_if = $"{tabVariable}=='{identifier}'";
                    other.@class        = "tab-page";
                }

                if (other != null)
                {
                    stringified += RazorUtils.ToAttributeStringDynamic(other);
                }
                stringified += " #" + identifier;
                helper.ViewContext.Writer.Write(string.Format("<{0} {1}>\n", tag, stringified));
            }

            return(access.Read);
        }
Exemple #2
0
        public static IHtmlContent ChartBlock(
            this IHtmlHelper helper,
            ChartTypes type,
            string item,
            int size              = 4,
            string loadedField    = "true",
            object attrs          = null,
            object componentAttrs = null,
            string classes        = null)
        {
            var acc = proc.Process(helper, "chart_block_" + item, "DashboardItem__" + type.ToString());

            if (!acc.Read)
            {
                return(null);
            }
            else
            {
                var model = new DashboardBlockModel
                {
                    Attributes = attrs != null?RazorUtils.ToAttributeString(attrs) : null,
                                     ComponentAttrs = componentAttrs != null?RazorUtils.ToAttributeString(componentAttrs) : null,
                                                          Selector      = GetTypeSelector(type),
                                                          Size          = size,
                                                          SingleItem    = true,
                                                          DataField     = item,
                                                          IsLoadedField = loadedField
                };
                return(helper.GetComponent("Components/DashboardBlock", model));
            }
        }
        public CellWriter SelectCell <T, TValue>(
            IHtmlHelper <T> helper,
            Expression <Func <T, TValue> > exp,
            Lister source,
            string displayMember,
            string valueMember,
            bool required,
            bool multi,
            bool nullable,
            object cellAttributes,
            object inputAttr,
            string classes,
            string readOnlyProp,
            string rowIndex)
        {
            var writer = base.SelectCell(helper, exp, source, displayMember, valueMember, required, multi, cellAttributes, inputAttr, classes, nullable, rowIndex);

            writer.ColumnModel.Attributes = RazorUtils.ToAttributeString(cellAttributes);
            ((SelectNgInput)writer.InputModel).Nullable = nullable;
            writer.Accessibility = proc.ProcessCell(helper, exp, InputControls.Select);
            writer.Initialize(null, null, cellAttributes, inputAttr, classes);

            helper.AddSource(source);
            if (!writer.Accessibility.Write)
            {
                if (readOnlyProp != null)
                {
                    writer.InputModel.MemberName = readOnlyProp;
                }
            }
            writer.InputModel.RowIndex = rowIndex;
            return(writer);
        }
Exemple #4
0
        public virtual void Initialize(string placeHolder = null, string width = null, object attrs = null, object inputAttr = null, string classes = "")
        {
            ColumnModel.Attributes = RazorUtils.ToAttributeString(attrs);
            ColumnModel.Width      = width == null ? "" : $"style='width:{width}'";

            InputModel.PlaceHolder     = placeHolder ?? TextProvider.Column(ColumnId);
            InputModel.Classes         = classes;
            InputModel.AttributeObject = inputAttr;
        }
        public CellWriter AutoCompleteSelectCell <T, TValue>(IHtmlHelper <T> helper, Expression <Func <T, TValue> > exp, Lister source, string displayMember, string valueMember, bool required, bool multi, bool nullable, object cellAttributes, object inputAttr, string classes)
        {
            var writer = base.SelectCell(helper, exp, source, displayMember, valueMember, required, multi, cellAttributes, inputAttr, classes, false, null);

            writer.ColumnModel.Attributes = RazorUtils.ToAttributeString(cellAttributes);
            ((SelectNgInput)writer.InputModel).Nullable = nullable;
            writer.Accessibility = proc.ProcessCell(helper, exp, InputControls.Select);
            writer.Initialize(null, null, cellAttributes, inputAttr, classes);
            return(writer);
        }
 public virtual CellWriter HeaderCell(IHtmlHelper helper, string textId, string size, bool isColumn, object cellAttributes, bool sorting)
 {
     using (var writer = new CellWriter(helper))
     {
         writer.ColumnModel.MemberName = textId;
         writer.ColumnModel.Sorting    = sorting;
         writer.ColumnModel.Attributes = cellAttributes == null ? "" : RazorUtils.ToAttributeString(cellAttributes);
         writer.InputModel.PlaceHolder = isColumn ? RazorConfig.LocaleTextProvider.Column(textId) : RazorConfig.LocaleTextProvider.Word(textId);
         return(writer);
     }
 }
Exemple #7
0
        public virtual void SetOptions(int size, string alternateLabel = null, string placeHolder = null, object attrs = null, object inputAttr = null, string classes = "", string grClasses = "")
        {
            GroupModel.Label         = alternateLabel ?? GroupModel.Label;
            GroupModel.Size          = size == -1 ? Helper.GetTheme().DefaultControlGroupSize : size;
            GroupModel.Attributes    = RazorUtils.ToAttributeString(attrs);
            GroupModel.GroupCssClass = grClasses;

            InputModel.PlaceHolder     = placeHolder ?? GroupModel.Label;
            InputModel.Classes         = classes;
            InputModel.AttributeObject = inputAttr;
        }
 public static void WriteContainerStart(ViewContext con, string tag, object attr, dynamic otherAttr = null)
 {
     if (tag != null)
     {
         string attrs = RazorUtils.ToAttributeString(attr);
         if (otherAttr != null)
         {
             attrs += RazorUtils.ToAttributeStringDynamic(otherAttr);
         }
         con.Writer.Write(string.Format("<{0} {1}>\n", tag, attrs));
     }
 }
Exemple #9
0
        protected override void WriteOpeningTag(object attr)
        {
            string attrs = RazorUtils.ToAttributeString(attr);

            Helper.ViewContext.Writer.Write(string.Format("<{0} #{1}=\"ngForm\" {2}>\n", TagName, FormName, attrs));
            if (ModelName != null)
            {
                currentNgModel = Helper.GetModelName();
                Helper.SetNgModel(ModelName);
            }

            currentNgForm = Helper.GetFormName();
            Helper.SetNgForm(FormName);
        }
Exemple #10
0
        public virtual IHtmlContent ComponentSelectorFromOther(IHtmlHelper helper, string id, string def = null, object attr = null)
        {
            string res = "";

            var acc = proc.Process(helper, id, "ComponentSelector");

            par.Process(helper, id, PageParameterTypes.Embedded, def);
            if (!acc.Read)
            {
                return(null);
            }
            string componentPath = helper.GetViewParams().GetFromOther(id, def);
            var    nameService   = helper.GetService <IUIFileNameService>();

            id = id != "none" ? "#" + id : null;

            if (!string.IsNullOrEmpty(componentPath))
            {
                componentPath = nameService.GetComponentSelector(componentPath.GetAfterLast("/"));
                string attrString = attr == null ? "" : RazorUtils.ToAttributeString(attr);
                res = $"<{componentPath} {id} [IsEmbedded]='true'{attrString}></{componentPath}>";
            }
            return(new HtmlString(res));
        }
Exemple #11
0
        public static IHtmlContent DashboardItem(
            this IHtmlHelper helper,
            ChartTypes type,
            string id,
            string listName       = null,
            string[] lists        = null,
            bool combine          = false,
            int size              = 4,
            string isLoadedField  = null,
            object attrs          = null,
            object componentAttrs = null,
            string classes        = null
            )
        {
            var acc = proc.Process(helper, id, "DashboardItem__" + type.ToString());

            if (!acc.Read)
            {
                return(null);
            }
            else
            {
                var model = new DashboardBlockModel
                {
                    Attributes = attrs != null?RazorUtils.ToAttributeString(attrs) : null,
                                     ComponentAttrs = componentAttrs != null?RazorUtils.ToAttributeString(componentAttrs) : null,
                                                          Selector      = GetTypeSelector(type),
                                                          Size          = size,
                                                          IsLoadedField = isLoadedField
                };

                List <string> listsArray = new List <string>();

                if (listName != null)
                {
                    model.DataField = $"GetPagedList('{listName}').list";
                    if (combine)
                    {
                        model.DataField = null;
                        model.Series    = $"GetPagedList('{listName}').list";
                    }
                    if (model.IsLoadedField == null)
                    {
                        model.IsLoadedField = $"GetIsLoaded('{listName}')";
                    }
                    helper.AddSource(Lister.Make(listName), id);
                }
                else if (lists != null)
                {
                    List <string> fieldArray = new List <string>();
                    foreach (var l in lists)
                    {
                        fieldArray.Add(l);
                        listsArray.Add("GetFirst('" + l + "')");
                        helper.AddSource(Lister.Make(l), id);
                    }
                    model.Series = "[" + string.Join(",", listsArray) + "]";
                    if (model.IsLoadedField == null)
                    {
                        model.IsLoadedField = "GetAllIsLoaded(['" + string.Join("','", fieldArray) + "'])";
                    }
                }

                return(helper.GetComponent("Components/DashboardBlock", model));
            }
        }