public ActionResult Create(int listId)
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            var list = listService.GetById(listId);

            WorkContext.Breadcrumbs.Add(T("Manage Lists"), Url.Action("Index", "List", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(list.Name);
            WorkContext.Breadcrumbs.Add(T("Fields"), Url.Action("Index", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(T("Create"));

            var model = new ListFieldModel {
                Title = "", ListId = listId
            };

            var result = new ControlFormResult <ListFieldModel>(model)
            {
                Title                = T("Create Field").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            var listFields = WorkContext.Resolve <IEnumerable <IListField> >();
            var fieldTypes = listFields.Select(x => new { x.FieldType, Type = GetFullTypeName(x.GetType()) }).OrderBy(x => x.FieldType).ToDictionary(x => x.Type, x => x.FieldType);

            result.RegisterExternalDataSource(x => x.FieldType, fieldTypes);

            return(result);
        }
        public ActionResult Manage()
        {
            WorkContext.Breadcrumbs.Add(T("Account"));
            WorkContext.Breadcrumbs.Add(T("Manage"));

            var user  = WorkContext.CurrentUser;
            var model = new UserModel
            {
                UserName = user.UserName,
                Email    = user.Email
            };
            var accountInfo = new ControlFormResult <UserModel>(model)
            {
                Title                = T("Account Info"),
                ReadOnly             = true,
                ShowCancelButton     = false,
                ShowBoxHeader        = false,
                IconHeader           = "fa fa-lg fa-fw fa-user",
                CssClass             = "col-md-4",
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            accountInfo.ExcludeProperty(x => x.SuperUser);
            accountInfo.ExcludeProperty(x => x.IsLockedOut);

            accountInfo.AddAction(addToTop: false).HasText(T("Change Password")).HasUrl(Url.Action("ChangePassword")).HasButtonStyle(ButtonStyle.Primary);

            return(accountInfo);
        }
        public ActionResult Edit(int id)
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            var model    = commentService.GetById(id);
            var listItem = listItemService.GetById(model.ListItemId);
            var list     = listService.GetById(listItem.ListId);

            WorkContext.Breadcrumbs.Add(T("Manage Lists"), Url.Action("Index", "List", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(list.Name);
            WorkContext.Breadcrumbs.Add(T("Comments"), Url.Action("Index", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(T("Edit"));

            var result = new ControlFormResult <ListItemCommentModel>(model)
            {
                Title                = T("Edit List").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            return(result);
        }
        public ActionResult Create()
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý đối tác"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thêm thông tin đối tác"), Url = Url.Action("Index")
            });
            var model = new PartnerModel();

            var result = new ControlFormResult <PartnerModel>(model);

            result.Title                = this.T("Thêm thông tin đối tác");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowCancelButton     = false;
            result.ShowBoxHeader        = false;
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;

            result.RegisterFileUploadOptions("Logo.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            result.AddAction().HasText(this.T("Thêm mới")).HasUrl(this.Url.Action("Create")).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);
            return(result);
        }
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin dòng sản phẩm"), Url = Url.Action("Index")
            });
            var model = new ProductsGroupModel();

            if (id > 0)
            {
                model = this.service.GetById(id);
            }

            var result = new ControlFormResult <ProductsGroupModel>(model);

            result.Title                = this.T("Thông tin dòng sản phẩm");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowBoxHeader        = false;
            result.CancelButtonText     = T("Back");
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;
            result.RegisterFileUploadOptions("ImageUrl.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });
            result.RegisterFileUploadOptions("HomeImageUrl.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });
            return(result);
        }
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý cửa hàng phân phối"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin cửa hàng phân phối"), Url = Url.Action("Index")
            });
            var model = new StoreBranchModel();

            if (id > 0)
            {
                model = this.service.GetById(id);
            }

            var result = new ControlFormResult <StoreBranchModel>(model);

            result.Title                = this.T("Thông tin cửa hàng phân phối");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowCancelButton     = false;
            result.ShowBoxHeader        = false;
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;

            result.RegisterFileUploadOptions("LogoUrl.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            result.AddAction().HasText(this.T("Clear")).HasUrl(this.Url.Action("Edit", RouteData.Values.Merge(new { id = 0 }))).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);
            return(result);
        }
 protected override void OnEditing(ControlFormResult <QueuedEmailModel> controlForm)
 {
     controlForm.Title            = T("View Message");
     controlForm.ShowSubmitButton = false;
     controlForm.ReadOnly         = true;
     controlForm.CancelButtonText = T("Close");
 }
        public ActionResult Edit(Guid id)
        {
            if (!CheckPermission(NewsletterPermissions.ManageNewsletters))
            {
                return(new HttpUnauthorizedResult());
            }

            NewsletterModel model = newsletterService.GetById(id);

            WorkContext.Breadcrumbs.Add(T("Newsletters"), Url.Action("Index", new { area = Constants.Areas.Newsletters }));
            WorkContext.Breadcrumbs.Add(model.Title);
            WorkContext.Breadcrumbs.Add(T("Edit"));

            var result = new ControlFormResult <NewsletterModel>(model)
            {
                Title                = T("Edit Newsletter").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.AddAction(true, true, false).HasText(T("Save & Continue")).HasName("SaveAndContinue").HasButtonStyle(ButtonStyle.Info);

            return(result);
        }
        public override string SelfGenerateControlUI <TModel>(ControlFormResult <TModel> controlForm, WorkContext workContext, HtmlHelper htmlHelper)
        {
            var id         = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(Name);
            var attributes = new RouteValueDictionary();

            var cssClass = (controlForm.FormProvider.ControlCssClass + " " + CssClass).Trim();

            if (!string.IsNullOrEmpty(cssClass))
            {
                attributes.Add("class", cssClass);
            }

            if (MaxLength > 0)
            {
                attributes.Add("maxlength", MaxLength);
            }

            attributes.Add("id", id);
            attributes.Add("name", Name);
            attributes.Add("value", Value);
            attributes.Add("type", "text");
            attributes.Add("readonly", "readonly");
            attributes.Add("style", "width: 100%;");

            if (ReadOnly || controlForm.ReadOnly)
            {
                return(htmlHelper.TextBox(Name, Value, (IDictionary <string, object>)attributes).ToHtmlString());
            }

            var tagBuilder = new TagBuilder("input");

            tagBuilder.MergeAttributes(attributes);

            return(string.Format("{0}<button class=\"control-slug-trigger\" type=\"button\" onclick=\"var $this = $(this).prev(); $this.attr('readonly') ? $this.removeAttr('readonly') : $this.attr('readonly', 'readonly');\"></button>", tagBuilder.ToString(TagRenderMode.SelfClosing)));
        }
        public ActionResult CreateItem(int menuId)
        {
            if (!CheckPermission(MenusPermissions.ManageMenus))
            {
                return(new HttpUnauthorizedResult());
            }

            var model = new MenuItemModel
            {
                MenuId  = menuId,
                Enabled = true
            };

            var result = new ControlFormResult <MenuItemModel>(model)
            {
                Title                = T("Create Menu Item").Text,
                UpdateActionName     = "UpdateItem",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            var menuItems = GetMenuItems(menuItemService.GetMenuItems(menuId));

            result.RegisterExternalDataSource(x => x.ParentId, menuItems.ToDictionary(x => x.Id, x => x.Text.Replace("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", "\xA0\xA0\xA0\xA0\xA0")));

            return(result);
        }
        public ActionResult Translate(Guid id, string cultureCode)
        {
            if (!CheckPermission(NewsletterPermissions.ManageNewsletters))
            {
                return(new HttpUnauthorizedResult());
            }

            NewsletterModel model = newsletterService.GetByLanguage(id, cultureCode);

            WorkContext.Breadcrumbs.Add(T("Newsletters"), Url.Action("Index", new { area = Constants.Areas.Newsletters }));
            if (model != null)
            {
                WorkContext.Breadcrumbs.Add(model.Title);
            }

            WorkContext.Breadcrumbs.Add(T("Translate"));
            WorkContext.Breadcrumbs.Add(cultureCode);

            var showSaveAndContinue = false;

            if (model == null)
            {
                model                     = newsletterService.GetById(id);
                model.Id                  = Guid.Empty;
                model.CultureCode         = cultureCode;
                model.RefId               = id;
                ViewData.ModelState["Id"] = new ModelState {
                    Value = new ValueProviderResult(Guid.Empty, Guid.Empty.ToString(), null)
                };
            }
            else
            {
                ViewData.ModelState["Id"] = new ModelState {
                    Value = new ValueProviderResult(model.Id, model.Id.ToString(), null)
                };
                showSaveAndContinue = true;
            }

            var result = new ControlFormResult <NewsletterModel>(model)
            {
                Title                = T("Translate Newsletter").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.AssignGridLayout(x => x.Id, 0, 0);
            result.AssignGridLayout(x => x.CultureCode, 0, 0);
            result.AssignGridLayout(x => x.RefId, 0, 0);
            result.AssignGridLayout(x => x.Title, 0, 0);
            result.AssignGridLayout(x => x.BodyContent, 0, 1, 2);

            if (showSaveAndContinue)
            {
                result.AddAction(true, true, false).HasText(T("Save & Continue")).HasName("SaveAndContinue").HasButtonStyle(ButtonStyle.Info);
            }

            return(result);
        }
        public ActionResult Create()
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            WorkContext.Breadcrumbs.Add(T("Manage Lists"), Url.Action("Index", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(T("Create"));

            var model = new ListModel
            {
                Enabled  = true,
                PageSize = 10
            };

            var result = new ControlFormResult <ListModel>(model)
            {
                Title                = T("Create List").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.ExcludeProperty(x => x.Sorting);
            result.ExcludeProperty(x => x.CssClass);
            result.ExcludeProperty(x => x.SummaryTemplate);
            result.ExcludeProperty(x => x.DetailTemplate);

            return(result);
        }
        public ActionResult InstallerModuleFileZip()
        {
            var result = new ControlFormResult
            {
                Title                = T("Installer module").Text,
                FormActionUrl        = Url.Action("SaveModule"),
                CssClass             = "form-edit-page",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml,
                FormMethod           = FormMethod.Post,
                IsAjaxSupported      = false
            };


            result.AddProperty("AssemblyName", new ControlTextAttribute
            {
                Required          = true,
                MaxLength         = 255,
                LabelText         = "Assembly Name",
                ContainerCssClass = "col-md-6",
                ContainerRowIndex = 0
            }, string.Empty);

            result.AddProperty("UploadedFile", new ControlFileUploadAttribute
            {
                EnableFineUploader = false,
                LabelText          = T("Hãy nén module định dạng .zip"),
                ContainerCssClass  = "col-md-6",
                ContainerRowIndex  = 2,
                AllowedExtensions  = "*.zip",
            }, string.Empty);

            return(result);
        }
        public ActionResult Create()
        {
            if (!CheckPermission(DashboardPermissions.ManageModuleSettings))
            {
                return(new HttpUnauthorizedResult());
            }

            WorkContext.Breadcrumbs.Add(T("Extension Modules"), Url.Action("Index", new { area = Constants.Areas.Dashboard }));
            WorkContext.Breadcrumbs.Add(T("Module Informations"));

            var model  = new ShellFeatureModel();
            var result = new ControlFormResult <ShellFeatureModel>(model)
            {
                Title                = T("Module Informations").Text,
                UpdateActionName     = "Update",
                CssClass             = "form-edit-page",
                ShowSubmitButton     = true,
                ShowCloseButton      = true,
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            return(result);
        }
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý thông tin liên hệ"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin liên hệ"), Url = Url.Action("Index")
            });
            var model = new EmailsModel();

            if (id > 0)
            {
                var service = WorkContext.Resolve <IEmailsService>();
                model = service.GetById(id);
            }
            var result = new ControlFormResult <EmailsModel>(model);

            result.Title                = this.T("Thông tin liên hệ");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowCancelButton     = false;
            result.ShowBoxHeader        = false;
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;

            result.AddAction().HasText(this.T("Clear")).HasUrl(this.Url.Action("Edit", RouteData.Values.Merge(new { id = 0 }))).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);
            return(result);
        }
Exemple #16
0
        public virtual ActionResult ChangePassword()
        {
            WorkContext.Breadcrumbs.Add(T("Account"));
            WorkContext.Breadcrumbs.Add(T("Change Password"));

            var model = new ChangePasswordModel
            {
                Email    = WorkContext.CurrentUser.Email,
                UserName = WorkContext.CurrentUser.UserName
            };

            var result = new ControlFormResult <ChangePasswordModel>(model)
            {
                Title                = T("Change Password").Text,
                UpdateActionName     = "ChangePassword",
                SubmitButtonText     = T("Change Password"),
                CancelButtonUrl      = Url.Action("Manage"),
                ShowBoxHeader        = false,
                IconHeader           = "fa fa-lg fa-fw fa-user",
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml,
            };

            result.MakeReadOnlyProperty(x => x.Email);
            result.MakeReadOnlyProperty(x => x.UserName);

            return(result);
        }
Exemple #17
0
        public ActionResult Create()
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý chuyên mục"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thêm thông tin chuyên mục"), Url = Url.Action("Index")
            });
            var model = new CategoriesModel();

            var result = new ControlFormResult <CategoriesModel>(model);

            result.Title                = this.T("Thêm thông  chuyên mục");
            result.FormMethod           = FormMethod.Post;
            result.UpdateActionName     = "Update";
            result.ShowCancelButton     = false;
            result.ShowBoxHeader        = false;
            result.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            result.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;

            result.RegisterExternalDataSource(x => x.ParentId, BindCategories());

            result.AddAction().HasText(this.T("Thêm mới")).HasUrl(this.Url.Action("Create")).HasButtonStyle(ButtonStyle.Success);
            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);

            return(result);
        }
Exemple #18
0
        public ActionResult Create()
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                return(new HttpUnauthorizedResult());
            }

            var result = new ControlFormResult <LanguageModel>(new LanguageModel {
                Active = true
            })
            {
                Title                = T("Create Language"),
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.RegisterFileUploadOptions("ImageFlag.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            var cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);

            result.RegisterExternalDataSource(x => x.CultureCode, cultures.ToList().OrderBy(x => x.DisplayName).ToDictionary(k => k.Name, v => v.DisplayName));

            var themeManager = WorkContext.Resolve <IThemeManager>();

            result.RegisterExternalDataSource(x => x.Theme, themeManager.GetInstalledThemes());

            result.ExcludeProperty(x => x.CultureCode2);

            return(result);
        }
Exemple #19
0
        public ActionResult Create(int listId)
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            var list = listService.GetById(listId);

            WorkContext.Breadcrumbs.Add(T("Manage Lists"), Url.Action("Index", "List", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(list.Name);
            WorkContext.Breadcrumbs.Add(T("Categories"), Url.Action("Index", new { area = Constants.Areas.Lists }));
            WorkContext.Breadcrumbs.Add(T("Create"));

            var model = new ListCategoryModel
            {
                ListId = listId
            };

            var result = new ControlFormResult <ListCategoryModel>(model)
            {
                Title                = T("Create Category").Text,
                UpdateActionName     = "Update",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            var dataSource = listCategoryService.GetCategories(listId).Select(x => new { Key = x.Id.ToString(), Value = FormatCategoryText(x.Name, x.ParentId, listCategoryService.GetCategories(listId), "\xA0\xA0\xA0\xA0\xA0") }).ToList();

            dataSource.Insert(0, new { Key = "", Value = "" });
            result.RegisterExternalDataSource(x => x.ParentId, dataSource.ToDictionary(x => x.Key, x => x.Value));

            return(result);
        }
        public ActionResult Translations(Guid id)
        {
            if (!CheckPermission(PagesPermissions.ManagePages))
            {
                return(new HttpUnauthorizedResult());
            }

            var model = new TranslationModel {
                Id = id
            };

            var result = new ControlFormResult <TranslationModel>(model)
            {
                Title                = T("Select Language").Text,
                UpdateActionName     = "Translations",
                SubmitButtonText     = T("OK"),
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            var languages = languageManager.GetActiveLanguages(Constants.ThemeDefault, false);

            result.RegisterExternalDataSource(x => x.CultureCode, languages.ToDictionary(k => k.CultureCode, v => v.Name));

            return(result);
        }
        public virtual ActionResult ChangePassword(int userId)
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                throw new NotAuthorizedException();
            }

            var user = membershipService.GetUser(userId);

            var model = new ChangePasswordModel
            {
                UserName = user.UserName,
                Email    = user.Email
            };

            var retult = new ControlFormResult <ChangePasswordModel>(model)
            {
                Title                = T("Change Password").Text,
                ShowBoxHeader        = false,
                IconHeader           = "fa fa-lg fa-fw fa-user",
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            retult.ExcludeProperty(x => x.OldPassword);

            return(retult);
        }
        protected override void OnCreating(ControlFormResult <UserModel> controlForm)
        {
            controlForm.AddProperty("Password", new ControlTextAttribute
            {
                Type              = ControlText.Password,
                MaxLength         = 128,
                Required          = true,
                LabelText         = "Password",
                ContainerCssClass = "col-xs-6 col-md-6",
                ContainerRowIndex = 1
            });
            controlForm.AddProperty("ConfirmPassword", new ControlTextAttribute
            {
                Type              = ControlText.Password,
                MaxLength         = 128,
                Required          = true,
                EqualTo           = "Password",
                LabelText         = "Confirm Password",
                ContainerCssClass = "col-xs-6 col-md-6",
                ContainerRowIndex = 1
            });

            var callbackUrl = Request.QueryString["callbackUrl"];

            if (!string.IsNullOrEmpty(callbackUrl))
            {
                controlForm.AddHiddenValue("CallbackUrl", callbackUrl);
            }

            controlForm.ShowBoxHeader        = false;
            controlForm.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            controlForm.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;
        }
Exemple #23
0
        private string GenerateCheckBox <TModel>(ControlFormResult <TModel> controlForm, HtmlHelper htmlHelper) where TModel : class
        {
            if (PropertyType != typeof(bool) && PropertyType != typeof(bool?))
            {
                throw new NotSupportedException("Cannot apply control choice for non-Boolean property as checkbox.");
            }

            var attributes = new RouteValueDictionary();

            if (Required)
            {
                attributes.Add("data-val", "true");
                attributes.Add("data-val-required", Constants.Messages.Validation.Required);
            }

            if (!string.IsNullOrEmpty(DataBind))
            {
                attributes.Add("data-bind", DataBind);
            }

            if (!string.IsNullOrEmpty(OnSelectedIndexChanged))
            {
                attributes.Add("onchange", OnSelectedIndexChanged);
            }

            if (ReadOnly || controlForm.ReadOnly)
            {
                attributes.Add("disabled", "disabled");
            }

            var sbCheckBox = new StringBuilder();

            sbCheckBox.AppendFormat("<div class=\"checkbox\"><label class=\"{0}\">", CssClass);

            if (!string.IsNullOrEmpty(PrependText))
            {
                sbCheckBox.Append(PrependText);
                sbCheckBox.Append("&nbsp;");
            }

            var checkBox = htmlHelper.CheckBox(Name, Convert.ToBoolean(Value), attributes);

            sbCheckBox.Append(checkBox);

            if (!string.IsNullOrEmpty(AppendText))
            {
                sbCheckBox.Append("&nbsp;");
                sbCheckBox.Append(AppendText);
            }

            sbCheckBox.Append("</label></div>");

            if (!string.IsNullOrEmpty(HelpText))
            {
                sbCheckBox.AppendFormat("<span class=\"help-block\">{0}</span>", HelpText);
            }

            return(sbCheckBox.ToString());
        }
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý đơn hàng"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Xem thông tin đơn hàng"), Url = Url.Action("Index")
            });
            var model = new OrdersModel();

            if (id > 0)
            {
                model = this.service.GetById(id);
            }

            var result = new ControlFormResult <OrdersModel>(model)
            {
                Title                = this.T("Xem thông tin đơn hàng"),
                FormMethod           = FormMethod.Post,
                UpdateActionName     = "Update",
                ShowCancelButton     = false,
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.MakeReadOnlyProperty(x => x.OrderCode);
            result.MakeReadOnlyProperty(x => x.FullName);
            result.MakeReadOnlyProperty(x => x.PhoneNumber);
            result.MakeReadOnlyProperty(x => x.Email);
            result.MakeReadOnlyProperty(x => x.PaymentType);
            result.MakeReadOnlyProperty(x => x.PaymentCode);
            result.RegisterExternalDataSource(x => x.PaymentType, y => BindPaymentTypes());

            var result2 = new ControlGridFormResult <OrderDetailsInfo>
            {
                Title                = T("Danh sách sản phẩm"),
                CssClass             = "table table-bordered table-striped",
                IsAjaxSupported      = true,
                FetchAjaxSource      = GetProducts,
                DefaultPageSize      = WorkContext.DefaultPageSize,
                EnablePaginate       = true,
                UpdateActionName     = "Update",
                GridWrapperStartHtml = Constants.Grid.GridWrapperStartHtml,
                GridWrapperEndHtml   = Constants.Grid.GridWrapperEndHtml,
                ClientId             = TableName
            };

            result2.AddCustomVar(Extensions.Constants.OrderId, id);
            result2.AddColumn(x => x.ProductName, T("Tên sản phẩm"));
            result2.AddColumn(x => x.Capacity, T("Thể tích"));
            result2.AddColumn(x => x.Quantity, T("Số lượng"));
            result2.AddColumn(x => x.Price, T("Giá"));
            result2.AddColumn(x => (x.Price * x.Quantity), T("Thành tiền"));

            result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);

            return(new ControlFormsResult(result, result2));
        }
        protected override void OnEditing(ControlFormResult <PageTagModel> controlForm)
        {
            base.OnEditing(controlForm);
            controlForm.CssClass = "form-vertical";

            controlForm.ShowBoxHeader        = false;
            controlForm.FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml;
            controlForm.FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml;
        }
Exemple #26
0
        public override string SelfGenerateControlUI <TModel>(ControlFormResult <TModel> controlForm, WorkContext workContext, HtmlHelper htmlHelper)
        {
            var scriptRegister = new ScriptRegister(workContext);
            var clientId       = controlForm.ViewData.TemplateInfo.GetFullHtmlFieldId(Name);

            scriptRegister.IncludeInline(string.Format("$('#{0}').simplecolorpicker({{ picker: {1}, theme: '{2}' }});", clientId, Picker.ToString().ToLowerInvariant(), Theme));

            return(base.SelfGenerateControlUI(controlForm, workContext, htmlHelper));
        }
Exemple #27
0
 protected override void OnEditing(ControlFormResult <SlideModel> controlForm)
 {
     controlForm.RegisterExternalDataSource(x => x.SlideDirection, "left", "right", "top", "bottom", "fade");
     controlForm.RegisterFileUploadOptions("BackgroundUrl.FileName", new ControlFileUploadOptions
     {
         AllowedExtensions = "jpg,jpeg,png,gif"
     });
     base.OnEditing(controlForm);
 }
        public override string SelfGenerateControlUI <TModel>(ControlFormResult <TModel> controlForm, WorkContext workContext, HtmlHelper htmlHelper)
        {
            var attrs = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(DataBind))
            {
                attrs.Add("data-bind", DataBind);
            }
            return(htmlHelper.Hidden(Name, Value, attrs).ToHtmlString());
        }
Exemple #29
0
        protected override void OnEditing(ControlFormResult <MessageTemplateModel> controlForm)
        {
            var allTokens = new List <string>();

            foreach (var tokens in tokenProviders.Select(provider => provider.GetAvailableTokens(controlForm.FormModel.Name)).Where(tokens => tokens != null))
            {
                allTokens.AddRange(tokens);
            }

            controlForm.FormModel.Tokens = string.Join(" ", allTokens.Distinct().OrderBy(x => x));
        }
        public ActionResult EditPermissions(int roleId)
        {
            var permissions    = permissionProviders.Value.SelectMany(x => x.GetPermissions()).ToList();
            var allPermissions = permissionService.GetRecords();

            foreach (var permission in permissions)
            {
                if (allPermissions.All(x => x.Name != permission.Name))
                {
                    var newPermission = new Domain.Permission
                    {
                        Name        = permission.Name,
                        Category    = string.IsNullOrEmpty(permission.Category) ? "Miscellaneous" : permission.Category,
                        Description = permission.Description
                    };
                    permissionService.Insert(newPermission);
                    allPermissions.Add(newPermission);
                }
            }

            var role            = roleService.GetById(roleId);
            var rolePermissions = membershipService.GetPermissionsForRole(role.Id);

            var model = new UpdatePermissionsModel
            {
                RoleId      = roleId,
                Permissions = rolePermissions.Select(x => x.Id).ToArray()
            };

            var retult = new ControlFormResult <UpdatePermissionsModel>(model)
            {
                Title                = T("Edit Role Permissions"),
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            var selectListItems = new List <ExtendedSelectListItem>();

            foreach (var categoryGroup in allPermissions.OrderBy(x => x.Category, new PermissionComparer(StringComparer.InvariantCultureIgnoreCase)).GroupBy(x => x.Category))
            {
                selectListItems.AddRange(categoryGroup.OrderBy(x => x.Description)
                                         .Select(permission => new ExtendedSelectListItem
                {
                    Category = permission.Category,
                    Text     = permission.Description,
                    Value    = permission.Id.ToString()
                }));
            }

            retult.RegisterExternalDataSource(x => x.Permissions, selectListItems);
            return(retult);
        }