Beispiel #1
0
 public static MvcHtmlString UploadButtonControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, string buttonTextKey, string defaultButtonText, string inputCss = null, string inputType = null)
 {
     //helper.RegisterScript("~/scripts/fileuploader.js", true);
     helper.RegisterWebReference("fileuploader");
     return(GetControlGroup(widget, id, textKey, defaultText,
                            string.Format("   <a class=\"btn {1}\" id=\"{0}\" >{2}</a>",
                                          widget.GetId(id), inputCss, HttpUtility.HtmlEncode(widget.GetText(buttonTextKey, defaultButtonText)))));
 }
Beispiel #2
0
        public static MvcHtmlString DefinitionListItem(this HtmlHelper helper, Models.IClientControl widget, string labelKey, string defaultLabel, string id, string dataColumn, IEnumerable <SelectListItem> selectList, string inputCss = null, SelectListItem blankItem = null, string separator = null, string labelCss = null, string textCss = null)
        {
            var list = selectList.ToList(); //todo: minor little hack...

            if (blankItem != null)
            {
                list.Insert(0, blankItem);
            }
            return(new MvcHtmlString(string.Format("<dt class=\"{2}\" title=\"{0}\">{0}{4}</dt><dd class=\"{3}\">{1}</dd>", HttpUtility.HtmlEncode(widget.GetText(labelKey, defaultLabel)), helper.DropDownList(id, list, new { @class = inputCss, data_column = dataColumn }).ToString(), labelCss, textCss, separator)));
        }
Beispiel #3
0
        public static MvcHtmlString TextEditorControl(this HtmlHelper helper, Models.IClientControl clientControl, string id, string dataColumn, bool required = false, string labelText = null)
        {
            var model = new Models.DataControl(dataColumn, Services.Portal.CurrentPortal.GetAttribute("Core", "TextEditor", "Core/CKTextEditor"));

            model.ClientId  = clientControl.GetId(id);
            model.Required  = required;
            model.LabelText = labelText;
            helper.RenderPartial("Controls/" + model.Path, model);
            return(null);
        }
Beispiel #4
0
        public static MvcHtmlString RoleControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, Dictionary <string, string> dataAttributes, bool required, List <string> selectedRoles = null, string inputCss = null)
        {
            selectedRoles = selectedRoles == null ? new List <string>() : selectedRoles;
            var items = Services.Account.GetRoles().Select(r => new SelectListItem()
            {
                Value = r.Id, Text = r.Name, Selected = selectedRoles.Contains(r.Id)
            }).ToList();

            return(MultiSelectControlGroup(helper, widget, id, textKey, defaultText, dataAttributes, required, items, inputCss));
        }
Beispiel #5
0
        public static MvcHtmlString DropDownControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, string dataColumn, IEnumerable <SelectListItem> selectList, string inputCss = null, SelectListItem blankItem = null)
        {
            var list = selectList.ToList(); //todo: minor little hack...

            if (blankItem != null)
            {
                list.Insert(0, blankItem);
            }
            return(GetControlGroup(widget, id, textKey, defaultText, helper.DropDownList(widget.GetId(id), list, new { @class = inputCss, data_column = dataColumn }).ToString()));
        }
Beispiel #6
0
        //public static MvcHtmlString LabelControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, string dataColumn, string css = null)
        //{
        //    return GetControlGroup(widget, id, textKey, defaultText,
        //                        string.Format("<label class=\"{2}\" id=\"{0}\" {1}></label>",
        //                            widget.GetId(id), GetDataAttributeMarkup(GetDataAttributeDict(dataColumn)), css));
        //}

        public static MvcHtmlString InputControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, string dataColumn = null, string inputCss = null, string inputType = null, bool readOnly = false, bool required = false, string dataType = null, string valueMatchControl = null, bool disableAutoComplete = false)
        {
            if (!string.IsNullOrEmpty(valueMatchControl))
            {
                valueMatchControl = widget.GetId(valueMatchControl); //todo: right place for this?
            }
            if (dataType == "datetime")                              //todo: auto do this?
            {
                helper.RegisterWebReferenceGroup("timepicker");
            }

            return(InputControlGroup(helper, widget, id, textKey, defaultText, GetDataAttributeDict(dataColumn, dataType: dataType, valueMatchControl: valueMatchControl), required, inputCss, inputType, readOnly, disableAutoComplete));
        }
Beispiel #7
0
 private static MvcHtmlString GetControlGroup(Models.IClientControl widget, string id, string textKey, string defaultText, string controlMarkup, string controlsCss = "")
 {
     return(new MvcHtmlString(string.Format(
                                  "<div class=\"control-group\">" +
                                  "<label class=\"control-label\" for=\"{0}\">{1}</label>" +
                                  "<div class=\"controls {2}\">" +
                                  "   {3}" +
                                  "</div>" +
                                  "</div>",
                                  widget.GetId(id),
                                  HttpUtility.HtmlEncode(widget.GetText(textKey, defaultText)),
                                  controlsCss,
                                  controlMarkup)));
 }
Beispiel #8
0
        public static void RegisterControlPresenter(this HtmlHelper helper, Models.IClientControl model, string clientType, string instanceName, Dictionary <string, object> properties = null)
        {
            properties = properties == null ? new Dictionary <string, object>() : properties;
            RegisterCoreScripts(helper);

            if (!string.IsNullOrEmpty(model.ScriptPath))
            {
                HtmlExtensions.RegisterScript(helper, model.ScriptPath + clientType + ".js", true);
            }

            properties["id"] = model.ClientId;  //todo: not necessary now... same as ns?
            properties["ns"] = model.ClientId;

            //Properties["user"] = Services.Account.GetClientUser();
            //var ser = new System.Web.Script.Serialization.JavaScriptSerializer();   //no binders for date conversions...
            HtmlExtensions.RegisterDocumentReadyScript(helper, model.ClientId + "Presenter", string.Format("videre.widgets.register('{0}', {1}, {2});", model.ClientId, clientType, properties.ToJson(ignoreType: "client")));
        }
Beispiel #9
0
 public static MvcHtmlString AuthorizedControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, string dataColumn)
 {
     return(helper.DropDownControlGroup(widget, id, textKey, defaultText, dataColumn, new List <SelectListItem>()
     {
         new SelectListItem()
         {
             Text = widget.GetPortalText("None.Text", "None"), Value = ""
         },
         new SelectListItem()
         {
             Text = widget.GetPortalText("Authenticated.Text", "Authenticated"), Value = "true"
         },
         new SelectListItem()
         {
             Text = widget.GetPortalText("NotAuthenticated.Text", "Not Authenticated"), Value = "false"
         }
     }));
 }
Beispiel #10
0
        public static MvcHtmlString MultiSelectControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, Dictionary <string, string> dataAttributes, bool required, List <SelectListItem> items, string inputCss = null)
        {
            var clientId = widget.GetId(id);

            helper.RegisterWebReferenceGroup("multiselect");
            //helper.RegisterScript("~/scripts/multiselect/jquery.multiselect.min.js", true);
            //helper.RegisterStylesheet("~/scripts/multiselect/jquery.multiselect.css", true);

            //todo: localize text (Select Options)
            //helper.RegisterDocumentReadyScript("multiselect-init", string.Format("$('select[data-controltype=\"multiselect\"]').multiselect({{ selectedList: 3 }});", clientId));

            var options = new System.Text.StringBuilder();

            foreach (var item in items)
            {
                options.AppendLine(string.Format("<option {0} value=\"{1}\">{2}</option>", item.Selected ? "selected=\"selected\" " : "", item.Value, HttpUtility.HtmlEncode(item.Text)));
            }

            return(GetControlGroup(widget, id, textKey, defaultText,
                                   string.Format("   <select class=\"{2}\" id=\"{0}\" {1}  multiple=\"multiple\" {4}>{3}</select>",
                                                 clientId, GetDataAttributeMarkup(dataAttributes), inputCss, options.ToString(), required ? "required=\"required\"" : "")));
        }
Beispiel #11
0
 public static void RegisterControlPresenter(this HtmlHelper helper, Models.IClientControl model, string clientType, Dictionary <string, object> properties = null)
 {
     RegisterControlPresenter(helper, model, clientType, model.ClientId, properties);
 }
Beispiel #12
0
 public static MvcHtmlString RenderClientControl(this HtmlHelper helper, Models.IClientControl clientControl, string id, Models.Chart model)
 {
     model.ClientId = clientControl.GetId(id);
     helper.RenderPartial("Controls/" + model.Path, model);
     return(null);
 }
Beispiel #13
0
 public static MvcHtmlString MultiSelectControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, string dataColumn, bool required, List <SelectListItem> items, string inputCss = null)
 {
     return(MultiSelectControlGroup(helper, widget, id, textKey, defaultText, GetDataAttributeDict(dataColumn, "multiselect"), required, items, inputCss));
 }
Beispiel #14
0
 public static MvcHtmlString RoleControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, string dataColumn, List <string> selectedRoles = null, string inputCss = null, bool required = false)
 {
     return(RoleControlGroup(helper, widget, id, textKey, defaultText, GetDataAttributeDict(dataColumn, "multiselect"), required, selectedRoles, inputCss));
 }
Beispiel #15
0
 public static MvcHtmlString DefinitionListItem(this HtmlHelper helper, Models.IClientControl widget, string labelKey, string defaultLabel, string text, string separator = null, string labelCss = null, string textCss = null)
 {
     return(new MvcHtmlString(string.Format("<dt class=\"{2}\" title=\"{0}\">{0}{4}</dt><dd class=\"{3}\">{1}</dd>", HttpUtility.HtmlEncode(widget.GetText(labelKey, defaultLabel)), text, labelCss, textCss, separator)));
 }
Beispiel #16
0
 public static MvcHtmlString TextAreaControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, Dictionary <string, string> dataAttributes, bool required, string inputCss = "", int rows = 3, bool readOnly = false)
 {
     return(GetControlGroup(widget, id, textKey, defaultText,
                            string.Format("<textarea type=\"text\" class=\"{2}\" id=\"{0}\" {1} rows=\"{3}\" {4} {5}></textarea>",
                                          widget.GetId(id), GetDataAttributeMarkup(dataAttributes), inputCss, rows, required ? "required=\"required\"" : "", readOnly ? "readonly=\"readonly\"" : "")));
 }
Beispiel #17
0
 public static MvcHtmlString TextAreaControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, string dataColumn, string controlType = "", string inputCss = "", int rows = 3, bool required = false, bool readOnly = false)
 {
     return(TextAreaControlGroup(helper, widget, id, textKey, defaultText, GetDataAttributeDict(dataColumn, controlType), required, inputCss, rows, readOnly));
 }
Beispiel #18
0
        public static MvcHtmlString InputFileBrowserControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, Dictionary <string, string> dataAttributes, string inputCss = null, string mimeType = "", bool required = false)
        {
            //ONLY REGISTER ONCE AND AT END?!?!
            helper.RenderWidget("Core/Admin/FileBrowser", new Dictionary <string, object>()
            {
                { "MimeType", mimeType }
            }, true);

            return(GetControlGroup(widget, id, textKey, defaultText,
                                   string.Format("   <input type=\"text\" class=\"{2}\" id=\"{0}\" {1} {3}/>" +
                                                 "   <a class=\"btn\" data-action=\"filebrowser\" data-control=\"{0}\" ><i class=\"icon-picture\"></i></a>",
                                                 widget.GetId(id), GetDataAttributeMarkup(dataAttributes), inputCss, required ? "required=\"required\"" : ""), "input-append"));
        }
Beispiel #19
0
 public static MvcHtmlString InputFileBrowserControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, string dataColumn, string inputCss = null, string mimeType = "", bool required = false)
 {
     return(InputFileBrowserControlGroup(helper, widget, id, textKey, defaultText, GetDataAttributeDict(dataColumn), inputCss, mimeType));
 }
Beispiel #20
0
 public static MvcHtmlString InputControlGroup(this HtmlHelper helper, Models.IClientControl widget, string id, string textKey, string defaultText, Dictionary <string, string> dataAttributes, bool required, string inputCss = null, string inputType = null, bool readOnly = false, bool disableAutoComplete = false)
 {
     return(GetControlGroup(widget, id, textKey, defaultText,
                            string.Format("<input type=\"{3}\" class=\"{2}\" id=\"{0}\" name=\"{0}\" {1} {4} {5} {6}/>",
                                          widget.GetId(id), GetDataAttributeMarkup(dataAttributes), inputCss, string.IsNullOrEmpty(inputType) ? "text" : inputType, readOnly ? "readonly=\"readonly\"" : "", required ? "required=\"required\"" : "", disableAutoComplete ? "autocomplete=\"off\"" : "")));
 }