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);
        }
        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("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 #4
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);
        }
        public virtual ActionResult ResetPassword(string resetToken)
        {
            if (membershipSettings.EnablePasswordReset)
            {
                return(new HttpUnauthorizedResult());
            }

            if (string.IsNullOrEmpty(resetToken))
            {
                return(RedirectToAction("Login"));
            }

            var localAccount = service.GetLocalAccount(resetToken);

            if (localAccount == null)
            {
                return(RedirectToAction("Login"));
            }

            if (!localAccount.PasswordVerificationTokenExpirationDate.HasValue || DateTime.UtcNow > localAccount.PasswordVerificationTokenExpirationDate.Value)
            {
                return(RedirectToAction("Login"));
            }

            WorkContext.Breadcrumbs.Add(T("Account"));
            WorkContext.Breadcrumbs.Add(T("Reset Password"));

            var model = new ResetPasswordModel {
                ResetToken = resetToken
            };

            var result = new ControlFormResult <ResetPasswordModel>(model)
            {
                Title            = T("Reset Password"),
                UpdateActionName = "ResetPassword",
                ShowCancelButton = false,
                ShowBoxHeader    = false,
                //IconHeader = "fa fa-lg fa-fw fa-user",
                //CssClass = "col-md-4",
                //FormWrapperStartHtml = CMSConstants.Form.FormWrapperStartHtml,
                //FormWrapperEndHtml = CMSConstants.Form.FormWrapperEndHtml
                IsFormCenter  = true,
                CssFormCenter = "col-md-4"
            };

            result.AddAction(addToTop: false).HasText(T("Login")).HasUrl(Url.Action("Login")).HasButtonStyle(ButtonStyle.Default);
            if (membershipSettings.AllowForgotPassword)
            {
                result.AddAction(addToTop: false).HasText(T("Forgot Password")).HasUrl(Url.Action("Recovery")).HasButtonStyle(ButtonStyle.Default);
            }

            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(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 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 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));
        }
Exemple #10
0
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý banner"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin banner"), Url = Url.Action("Index")
            });
            var model = new SlidersModel();

            if (id > 0)
            {
                var service = WorkContext.Resolve <ISlidersService>();
                var item    = service.GetById(id);
                if (item != null)
                {
                    model.Type = item.Type;
                    var list      = service.GetRecords(x => x.Type == item.Type);
                    var listModel = list.Select(image => new UploadImageModel {
                        ImageUrl = image.ImageUrl, Caption = image.Caption, SortOrder = image.SortOrder
                    }).ToList();
                    model.UploadPhotos = listModel;
                }
            }

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

            result.Title                = this.T("Thông tin banner");
            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.CategoryId, BindCategories());
            result.RegisterExternalDataSource(x => x.Type, y => BindSliderType());

            result.AddAction().HasText(this.T("Thêm mới")).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);
        }
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý bài viết"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin bài viết"), Url = Url.Action("Index")
            });
            var model = new ArticlesModel();

            if (id > 0)
            {
                var service = WorkContext.Resolve <IArticlesService>();
                model = service.GetById(id);
            }

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

            result.Title                = this.T("Thông tin bài viết");
            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("BannerUrl.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });

            result.RegisterFileUploadOptions("Image.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);

            result.RegisterExternalDataSource(x => x.CategoryId, y => BindCategories());

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

            HistoricPageModel model = historicPageService.GetById(id);

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

            var menuItem = menuItemService.GetMenuItemByRefId(id);

            if (menuItem != null)
            {
                model.ShowOnMenuId = menuItem.MenuId;
            }

            var result = new ControlFormResult <HistoricPageModel>(model)
            {
                Title                = T("Edit Page").Text,
                UpdateActionName     = "Update",
                CssClass             = "form-edit-page",
                ReadOnly             = true,
                CancelButtonText     = T("Close"),
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            result.AddAction(true)
            .HasText(T("Restore Version"))
            .HasName("RestoreVersion")
            .HasButtonStyle(ButtonStyle.Warning)
            .HasConfirmMessage(T("Are you sure you want to restore this version of the page?").Text);

            var themes = extensionManager.AvailableExtensions().Where(x => DefaultExtensionTypes.IsTheme(x.ExtensionType) && descriptor.Features.Any(f => f.Name == x.Id)).ToDictionary(k => k.Id, v => v.Name);

            result.RegisterExternalDataSource(x => x.Theme, themes);
            result.RegisterExternalDataSource(x => x.ShowOnMenuId, menuService.GetRecords().ToDictionary(k => k.Id, v => v.Name));

            // Page tags
            var tags = pageTagService.GetRecords();

            if (tags.Count > 0)
            {
                result.AddHiddenValue("RichtextCustomTags", JsonConvert.SerializeObject(tags.Select(x => new[] { x.Name, "[%" + x.Name + "%]" })));
            }

            return(result);
        }
        public virtual ActionResult Register()
        {
            if (!membershipSettings.AllowRegisterUser)
            {
                return(new HttpUnauthorizedResult());
            }

            var model = new RegisterModel();

            ActionResult viewResult;

            if (FindView("Register", model, out viewResult))
            {
                return(viewResult);
            }

            var result = new ControlFormResult <RegisterModel>(model)
            {
                Title            = T("Sign Up").Text,
                UpdateActionName = "Register",
                ShowCancelButton = false,
                SubmitButtonText = T("Sign Up").Text,
                CssClass         = "register-form col-md-4",
                ShowBoxHeader    = false,
                //IconHeader = "fa fa-lg fa-fw fa-user",
                //FormWrapperStartHtml = CMSConstants.Form.FormWrapperStartHtml,
                //FormWrapperEndHtml = CMSConstants.Form.FormWrapperEndHtml,
                IsFormCenter  = true,
                CssFormCenter = "col-md-4"
            };

            result.AddAction(addToTop: false).HasText(T("Login")).HasUrl(Url.Action("Login")).HasButtonStyle(ButtonStyle.Default);

            if (membershipSettings.AllowForgotPassword)
            {
                result.AddAction(addToTop: false).HasText(T("Forgot password?")).HasUrl(Url.Action("Recovery")).HasButtonStyle(ButtonStyle.Default);
            }

            return(result);
        }
        public virtual ActionResult Recovery()
        {
            if (!membershipSettings.AllowForgotPassword)
            {
                return(new HttpUnauthorizedResult());
            }

            WorkContext.Breadcrumbs.Add(T("Account"));
            WorkContext.Breadcrumbs.Add(T("Recovery"));

            var model  = new PasswordRecoveryModel();
            var result = new ControlFormResult <PasswordRecoveryModel>(model)
            {
                Title            = T("Find Your Password"),
                Description      = T("Please enter your email address below. You will receive a link to reset your password."),
                UpdateActionName = "Recovery",
                ShowCancelButton = false,
                SubmitButtonText = T("Recovery"),
                CssClass         = "forgot-password-form col-md-4",
                ShowBoxHeader    = false,
                //IconHeader = "fa fa-lg fa-fw fa-user",
                //FormWrapperStartHtml = CMSConstants.Form.FormWrapperStartHtml,
                //FormWrapperEndHtml = CMSConstants.Form.FormWrapperEndHtml,
                IsFormCenter  = true,
                CssFormCenter = "col-md-4"
            };

            result.AddAction(addToTop: false).HasText(T("Login")).HasUrl(Url.Action("Login")).HasButtonStyle(ButtonStyle.Default);

            if (membershipSettings.AllowRegisterUser)
            {
                result.AddAction(addToTop: false).HasText(T("Register")).HasUrl(Url.Action("Register")).HasButtonStyle(ButtonStyle.Default);
            }

            return(result);
        }
        public ActionResult Translate(int id, string cultureCode)
        {
            if (!CheckPermission(PagesPermissions.ManagePages))
            {
                return(new HttpUnauthorizedResult());
            }

            PageModel model = pageService.GetPageByLanguage(id, cultureCode);

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

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

            var showSaveAndContinue = false;

            if (model == null)
            {
                model                     = pageService.GetById(id);
                model.Id                  = 0;
                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 <PageModel>(model)
            {
                Title                = T("Translate Page").Text,
                UpdateActionName     = "Update",
                CssClass             = "form-edit-page",
                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.MetaKeywords, 1, 0);
            result.AssignGridLayout(x => x.IsEnabled, 0, 1);
            result.AssignGridLayout(x => x.MetaDescription, 1, 1);
            result.AssignGridLayout(x => x.BodyContent, 0, 2, 2);

            result.ExcludeProperty(x => x.Slug);
            result.AddHiddenValue("Slug", model.Slug);

            result.ExcludeProperty(x => x.Theme);
            result.AddHiddenValue("Theme", model.Theme);

            result.ExcludeProperty(x => x.CssClass);
            result.AddHiddenValue("CssClass", model.CssClass);

            result.ExcludeProperty(x => x.ShowOnMenuId);
            if (model.ShowOnMenuId.HasValue)
            {
                result.AddHiddenValue("ShowOnMenuId", model.ShowOnMenuId.Value.ToString());
            }

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

            // Page tags
            var tags = pageTagService.GetRecords();

            if (tags.Count > 0)
            {
                result.AddHiddenValue("RichtextCustomTags", JsonConvert.SerializeObject(tags.Select(x => new[] { x.Name, "[%" + x.Name + "%]" })));
            }

            return(result);
        }
        public ActionResult Edit(int id, int cateId, int articlesId)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý ảnh bài viết"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin ảnh bài viết"), Url = Url.Action("Index")
            });
            var model = new ImagesModel {
                CategoryId = cateId, ArticlesId = articlesId
            };
            var service = WorkContext.Resolve <IImagesService>();

            if (id > 0)
            {
                var item = service.GetById(id);
                if (item != null)
                {
                    model.CategoryId   = item.CategoryId;
                    model.ArticlesId   = item.ArticlesId;
                    model.ListCategory = Utilities.ParseListInt(item.ListCategory);
                    if (item.ArticlesId > 0)
                    {
                        var list      = service.GetRecords(x => x.ArticlesId == item.ArticlesId && x.CategoryId == 0);
                        var listModel = list.Select(image => new UploadImageModel {
                            ImageUrl = image.FilePath, Caption = image.Caption, SortOrder = image.SortOrder
                        }).ToList();
                        model.UploadPhotos = listModel;
                    }
                    else
                    {
                        var list      = service.GetRecords(x => x.CategoryId == item.CategoryId && x.ArticlesId == 0);
                        var listModel = list.Select(image => new UploadImageModel {
                            ImageUrl = image.FilePath, Caption = image.Caption, SortOrder = image.SortOrder
                        }).ToList();
                        model.UploadPhotos = listModel;
                    }
                }
            }

            if (cateId > 0)
            {
                var list = service.GetRecords(x => x.CategoryId == cateId);
                foreach (var imageInfo in list)
                {
                    if (!string.IsNullOrEmpty(imageInfo.ListCategory))
                    {
                        model.ListCategory = Utilities.ParseListInt(imageInfo.ListCategory);
                    }
                }
                var listModel = list.Select(image => new UploadImageModel {
                    ImageUrl = image.FilePath, Caption = image.Caption, SortOrder = image.SortOrder
                }).ToList();
                model.UploadPhotos = listModel;
            }

            if (articlesId > 0)
            {
                var list      = service.GetRecords(x => x.ArticlesId == articlesId);
                var listModel = list.Select(image => new UploadImageModel {
                    ImageUrl = image.FilePath, Caption = image.Caption, SortOrder = image.SortOrder
                }).ToList();
                model.UploadPhotos = listModel;
            }

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

            result.Title                = this.T("Thông tin ảnh 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;

            if (articlesId > 0)
            {
                result.MakeReadOnlyProperty(x => x.CategoryId);
                result.MakeReadOnlyProperty(x => x.ListCategory);
            }

            result.RegisterExternalDataSource(x => x.CategoryId, BindCategories());
            result.RegisterExternalDataSource(x => x.ListCategory, BindCategories());

            result.AddAction().HasText(this.T("Back to Articles")).HasUrl(this.Url.Action("Index", "AdminArticles")).HasButtonStyle(ButtonStyle.Danger);
            result.AddAction().HasText(this.T("Back to Categories")).HasUrl(this.Url.Action("Index", "AdminCategories")).HasButtonStyle(ButtonStyle.Danger);
            //if (CheckPermission(ImagesPermissions.ManagerImages, T("Can't access the dashboard panel.")))
            //{
            //    result.AddAction().HasText(this.T("Back")).HasUrl(this.Url.Action("Index")).HasButtonStyle(ButtonStyle.Danger);
            //}

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

            PageModel model = pageService.GetById(id);

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

            var menuItem = menuItemService.GetMenuItemByRefId(id);

            if (menuItem != null)
            {
                model.ShowOnMenuId = menuItem.MenuId;
            }

            var result = new ControlFormResult <PageModel>(model)
            {
                Title                = T("Edit Page").Text,
                UpdateActionName     = "Update",
                CssClass             = "form-edit-page",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

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

            result.AddAction(addToTop: false)
            .HasText(T("Preview"))
            .HasClientId("btnPreview")
            .HasButtonStyle(ButtonStyle.Info);

            var themes = extensionManager.AvailableExtensions().Where(x => DefaultExtensionTypes.IsTheme(x.ExtensionType) && descriptor.Features.Any(f => f.Name == x.Id)).ToDictionary(k => k.Id, v => v.Name);

            result.RegisterExternalDataSource(x => x.Theme, themes);
            result.RegisterExternalDataSource(x => x.ShowOnMenuId, menuService.GetRecords().ToDictionary(k => k.Id, v => v.Name));

            // Page tags
            var tags = pageTagService.GetRecords();

            if (tags.Count > 0)
            {
                result.AddHiddenValue("RichtextCustomTags", JsonConvert.SerializeObject(tags.Select(x => new[] { x.Name, "[%" + x.Name + "%]" })));
            }

            var scriptRegister = new ScriptRegister(WorkContext);

            scriptRegister.IncludeInline(Constants.Scripts.JQueryFormExtension);
            scriptRegister.IncludeInline(Constants.Scripts.JQueryFormParams);

            var sbScript = new StringBuilder(256);

            sbScript.Append("$(document).ready(function(){");
            sbScript.Append("$('#btnPreview').click(function(e){");
            sbScript.Append("var data = $('form').formParams();");
            sbScript.Append("var bodyContent = $('#idContentoEdit0').contents().find('body').html();");
            sbScript.Append("data.BodyContent = bodyContent;");
            sbScript.AppendFormat("$.form('{0}',", Url.Action("Preview"));
            sbScript.Append("data");
            sbScript.Append(").attr('target', '_blank').submit().remove(); return false;");
            sbScript.Append("});})");

            scriptRegister.IncludeInline(sbScript.ToString());

            return(result);
        }
        public virtual ActionResult Login()
        {
            var model = new LoginModel
            {
                ReturnUrl = Request.QueryString["ReturnUrl"]
            };

            ActionResult viewResult;

            if (FindView("Login", model, out viewResult))
            {
                return(viewResult);
            }

            var result = new ControlFormResult <LoginModel>(model)
            {
                Title                 = T("Login to your account").Text,
                UpdateActionName      = "Login",
                ShowCancelButton      = false,
                SubmitButtonText      = T("Login").Text,
                CssClass              = "login-form col-md-4",
                ClientId              = "fLogin",
                ShowValidationSummary = true,
                ShowBoxHeader         = false,
                IconHeader            = "fa fa-lg fa-fw fa-user",
                FormWrapperStartHtml  = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml    = Constants.Form.FormWrapperEndHtml,
                IsFormCenter          = true,
                CssFormCenter         = "col-md-4"
            };

            //if (membershipSettings.AllowRegisterUser)
            //{
            //    result.AddAction(addToTop: false).HasText(T("Register")).HasUrl(Url.Action("Register")).HasButtonStyle(ButtonStyle.Default).HasClientId("btnRegister");
            //}

            //if (membershipSettings.AllowForgotPassword)
            //{
            //    result.AddAction(addToTop: false).HasText(T("Forgot password?")).HasUrl(Url.Action("Recovery")).HasButtonStyle(ButtonStyle.Default).HasClientId("btnFindPassword");
            //}

            var providers = WorkContext.Resolve <IEnumerable <IAuthenticationClientProvider> >();

            var clients = (from provider in providers
                           let resolvedProvider = (IAuthenticationClientProvider)WorkContext.Resolve(provider.GetType())
                                                  where resolvedProvider.IsValid()
                                                  select resolvedProvider).ToList();

            if (clients.Count > 0)
            {
                var action = result.AddAction();
                action.HasHtmlBuilder(() =>
                {
                    var sb = new StringBuilder();
                    sb.Append("<fieldset class=\"oauth-login-form\">");
                    sb.AppendFormat("<legend>{0}</legend>", T("Sign In using"));

                    foreach (var client in clients)
                    {
                        sb.AppendFormat("<a title=\"{0}\" class=\"btn-oauth btn-oauth-{1}\" href=\"{2}\">{0}</a>", client.Name, client.ProviderName, client.GetLoginUrl(Url, model.ReturnUrl));
                    }

                    sb.Append("</fieldset>");
                    return(sb.ToString());
                });
            }

            ViewBag.BodyCssClass = "login-page";

            return(result);
        }
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý đối tác"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Sửa thông tin đối tác"), Url = Url.Action("Index")
            });

            var          service   = WorkContext.Resolve <IPartnerService>();
            var          records   = service.GetRecords(x => x.Id == id || x.RefId == id);
            PartnerModel model     = records.First(x => x.Id == id);
            var          modelType = model.GetType();

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

            result.Title            = this.T("Sửa thông tin đối tác");
            result.FormMethod       = FormMethod.Post;
            result.Layout           = ControlFormLayout.Tab;
            result.UpdateActionName = "Update";
            result.ShowCancelButton = false;
            result.ShowBoxHeader    = false;

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

            var mainTab           = result.AddTabbedLayout("Thông tin chính");
            var mainGroup         = mainTab.AddGroup();
            var allFields         = modelType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            var controlAttributes = new Dictionary <string, ControlFormAttribute>();

            foreach (var propertyInfo in allFields)
            {
                var controlAttribute = propertyInfo.GetCustomAttribute <ControlFormAttribute>(true);
                if (controlAttribute == null)
                {
                    continue;
                }
                mainGroup.Add(propertyInfo.Name);
                controlAttribute.PropertyInfo = propertyInfo;
                controlAttribute.PropertyType = propertyInfo.PropertyType;
                controlAttributes.Add(propertyInfo.Name, controlAttribute);
            }

            var languageManager = WorkContext.Resolve <ILanguageManager>();
            var languages       = languageManager.GetActiveLanguages(Constants.ThemeDefault, false);
            var listHidden      = new List <string>
            {
                "Id", "SortOrder", "Logo", "PhoneNumber", "Email", "Website"
            };

            if (languages.Count > 0)
            {
                foreach (var language in languages)
                {
                    var languageTab       = result.AddTabbedLayout(language.Name);
                    var languageGroup     = languageTab.AddGroup();
                    var widgetForLanguage = records.FirstOrDefault(x => x.LanguageCode == language.CultureCode) ?? model;

                    foreach (var controlAttribute in controlAttributes)
                    {
                        if (listHidden.Contains(controlAttribute.Key))
                        {
                            continue;
                        }

                        var key   = controlAttribute.Key + "." + language.CultureCode;
                        var value = controlAttribute.Value.PropertyInfo.GetValue(widgetForLanguage);
                        result.AddProperty(key, controlAttribute.Value.ShallowCopy(), value);
                        languageGroup.Add(key);
                    }
                }
            }

            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 #20
0
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý chuyên mục"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Sửa thông tin chuyên mục"), Url = Url.Action("Index")
            });

            var             service   = WorkContext.Resolve <ICategoriesService>();
            var             records   = service.GetRecords(x => x.Id == id || x.RefId == id);
            CategoriesModel model     = records.First(x => x.Id == id);
            var             modelType = model.GetType();

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

            result.Title            = this.T("Sửa thông chuyên mục");
            result.FormMethod       = FormMethod.Post;
            result.Layout           = ControlFormLayout.Tab;
            result.UpdateActionName = "Update";
            result.ShowCancelButton = false;
            result.ShowBoxHeader    = false;

            result.ExcludeProperty(x => x.Alias);
            result.ExcludeProperty(x => x.Name);
            result.ExcludeProperty(x => x.ShortName);
            result.ExcludeProperty(x => x.Url);
            result.ExcludeProperty(x => x.Tags);
            result.ExcludeProperty(x => x.Notes);
            result.ExcludeProperty(x => x.Description);
            result.ExcludeProperty(x => x.Tags);

            var mainTab           = result.AddTabbedLayout("Thông tin chính");
            var mainGroup         = mainTab.AddGroup();
            var allFields         = modelType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            var controlAttributes = new Dictionary <string, ControlFormAttribute>();

            foreach (var propertyInfo in allFields)
            {
                var controlAttribute = propertyInfo.GetCustomAttribute <ControlFormAttribute>(true);
                if (controlAttribute == null)
                {
                    continue;
                }
                mainGroup.Add(propertyInfo.Name);
                controlAttribute.PropertyInfo = propertyInfo;
                controlAttribute.PropertyType = propertyInfo.PropertyType;
                controlAttributes.Add(propertyInfo.Name, controlAttribute);
            }

            var languageManager = WorkContext.Resolve <ILanguageManager>();
            var languages       = languageManager.GetActiveLanguages(Constants.ThemeDefault, false);
            var listHidden      = new List <string>
            {
                "Id", "OrderBy", "MenuOrderBy", "ParentId",
                "HasChilden", "IsHome", "IsActived",
                "IsDeleted", "IsDisplayMenu", "IsDisplayFooter"
            };

            if (languages.Count > 0)
            {
                foreach (var language in languages)
                {
                    var languageTab       = result.AddTabbedLayout(language.Name);
                    var languageGroup     = languageTab.AddGroup();
                    var widgetForLanguage = records.FirstOrDefault(x => x.LanguageCode == language.CultureCode) ?? model;

                    foreach (var controlAttribute in controlAttributes)
                    {
                        if (listHidden.Contains(controlAttribute.Key))
                        {
                            continue;
                        }

                        var key   = controlAttribute.Key + "." + language.CultureCode;
                        var value = controlAttribute.Value.PropertyInfo.GetValue(widgetForLanguage);
                        result.AddProperty(key, controlAttribute.Value.ShallowCopy(), value);
                        languageGroup.Add(key);
                    }
                }
            }
            result.RegisterExternalDataSource(x => x.ParentId, BindCategories());

            result.AddAction().HasText(T("Add Images")).HasUrl(Url.Action("Edit", "AdminImages", new { id = 0, cateId = model.Id, articlesId = 0 })).HasButtonStyle(ButtonStyle.Info);
            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);
        }
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý tuyển dụng"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Sửa thông tin tuyển dụng"), Url = Url.Action("Index")
            });

            var records            = service.GetRecords(x => x.Id == id || x.RefId == id);
            RecruitmentModel model = records.First(x => x.Id == id);
            var modelType          = model.GetType();

            if (string.IsNullOrEmpty(model.Contents) || model.Contents.Trim() == "<br />")
            {
                var viewRenderer = new ViewRenderer {
                    Context = ControllerContext
                };
                var viewTemplate = viewRenderer.RenderPartialView(string.Format(Extensions.Constants.ViewRecruitmentTemplate, WorkContext.CurrentCulture), null);
                model.Contents = viewTemplate;
            }

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

            result.Title            = this.T("Sửa thông tin tuyển dụng");
            result.FormMethod       = FormMethod.Post;
            result.Layout           = ControlFormLayout.Tab;
            result.UpdateActionName = "Update";
            result.ShowCancelButton = false;
            result.ShowBoxHeader    = false;

            result.ExcludeProperty(x => x.Alias);
            result.ExcludeProperty(x => x.Contents);
            result.ExcludeProperty(x => x.Position);
            result.ExcludeProperty(x => x.Summary);
            result.ExcludeProperty(x => x.Title);
            result.ExcludeProperty(x => x.TimeWork);

            var mainTab           = result.AddTabbedLayout("Thông tin chính");
            var mainGroup         = mainTab.AddGroup();
            var allFields         = modelType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
            var controlAttributes = new Dictionary <string, ControlFormAttribute>();

            foreach (var propertyInfo in allFields)
            {
                var controlAttribute = propertyInfo.GetCustomAttribute <ControlFormAttribute>(true);
                if (controlAttribute == null)
                {
                    continue;
                }
                mainGroup.Add(propertyInfo.Name);
                controlAttribute.PropertyInfo = propertyInfo;
                controlAttribute.PropertyType = propertyInfo.PropertyType;
                controlAttributes.Add(propertyInfo.Name, controlAttribute);
            }

            var languageManager = WorkContext.Resolve <ILanguageManager>();
            var languages       = languageManager.GetActiveLanguages(Constants.ThemeDefault, false);
            var listHidden      = new List <string>
            {
                "Id", "CategoryId", "IsDeleted", "FinishDate"
            };

            if (languages.Count > 0)
            {
                foreach (var language in languages)
                {
                    var languageTab       = result.AddTabbedLayout(language.Name);
                    var languageGroup     = languageTab.AddGroup();
                    var widgetForLanguage = records.FirstOrDefault(x => x.LanguageCode == language.CultureCode) ?? model;

                    foreach (var controlAttribute in controlAttributes)
                    {
                        if (listHidden.Contains(controlAttribute.Key))
                        {
                            continue;
                        }

                        var key   = controlAttribute.Key + "." + language.CultureCode;
                        var value = controlAttribute.Value.PropertyInfo.GetValue(widgetForLanguage);
                        result.AddProperty(key, controlAttribute.Value.ShallowCopy(), value);
                        languageGroup.Add(key);
                    }
                }
            }
            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);

            result.RegisterExternalDataSource(x => x.CategoryId, y => BindCategories());

            return(result);
        }
        private ActionResult UserProfile(int userId, bool editMode = false)
        {
            var result = new ControlFormResult
            {
                UpdateActionName = "UpdateProfile",
                SubmitButtonText = T("Save").Text,
                ReadOnly         = !editMode
            };

            string title;
            bool   onlyPublicProperties = false;

            if (editMode)
            {
                if (userId == WorkContext.CurrentUser.Id)
                {
                    title = T("Edit My Profile");
                }
                else if (WorkContext.CurrentUser.SuperUser || CheckPermission(StandardPermissions.FullAccess))
                {
                    title = T("Edit Profile");
                }
                else
                {
                    return(new HttpUnauthorizedResult());
                }
            }
            else
            {
                if (userId == WorkContext.CurrentUser.Id)
                {
                    title = T("My Profile");

                    result.AddAction(addToTop: false)
                    .HasText(T("Edit"))
                    .HasUrl(Url.Action("EditMyProfile"))
                    .HasButtonStyle(ButtonStyle.Primary);
                }
                else if (WorkContext.CurrentUser.SuperUser || CheckPermission(StandardPermissions.FullAccess))
                {
                    var user = service.GetUser(userId);
                    title = string.Format(T("Profile for '{0}'", user.UserName));

                    result.AddAction(addToTop: false)
                    .HasText(T("Edit"))
                    .HasUrl(Url.Action("EditProfile", RouteData.Values.Merge(new { userId })))
                    .HasButtonStyle(ButtonStyle.Primary);
                }
                else
                {
                    var user = service.GetUser(userId);
                    title = string.Format(T("Profile for '{0}'", user.UserName));
                    onlyPublicProperties = true;
                }

                result.CancelButtonText = T("Close");
            }

            result.Title = title;

            result.AddHiddenValue("UserId", userId.ToString());

            bool hasProperties = false;

            foreach (var provider in userProfileProviders.Value)
            {
                var newGroup = result.AddGroupedLayout(provider.Category);

                foreach (var field in provider.GetFields(WorkContext, userId, onlyPublicProperties))
                {
                    hasProperties = true;

                    result.AddProperty(field.Name, field, field.Value);
                    newGroup.Add(field.Name);
                }
            }

            if (!hasProperties)
            {
                return(new ContentViewResult
                {
                    Title = title,
                    BodyContent = T("There is no profile available to view.")
                });
            }

            return(result);
        }
Exemple #23
0
        public ActionResult AddOrEditSublayer(string tag, string id)
        {
            var model = new SublayerModel {
                Id = id, Tag = tag
            };

            var result = new ControlFormResult <SublayerModel>(model)
            {
                Title            = T("Sublayer"),
                UpdateActionName = "UpdateSublayer"
            };

            if (string.Equals(tag, "img", StringComparison.InvariantCultureIgnoreCase))
            {
                result.ExcludeProperty(x => x.HtmlContent);
                result.ExcludeProperty(x => x.FontFamily);
                result.ExcludeProperty(x => x.FontSize);
                result.ExcludeProperty(x => x.Color);
            }
            else
            {
                result.ExcludeProperty(x => x.ImageSource);
            }

            if (!string.IsNullOrEmpty(id))
            {
                var script = new StringBuilder();

                script.AppendLine(@"function colorToHex(color) {
                    if(!color) return '';
                    if (color.substr(0, 1) === '#') {
                        return color;
                    }
                    var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color); if(!digits) return color;

                    var red = parseInt(digits[2]);
                    var green = parseInt(digits[3]);
                    var blue = parseInt(digits[4]);

                    var rgb = blue | (green << 8) | (red << 16);
                    return digits[1] + '#' + rgb.toString(16);
                };");
                script.AppendLine(@"function getStyleValue(style, name){
                    var split = style.split(';');
                    for(var i = 0; i < split.length; i++){
                        if(split[i].indexOf(name + ':') == 0){
                            return $.trim(split[i].replace(name + ':', ''));
                        }
                    }
                    return '';
                }");

                script.AppendFormat("var element = $('#{0}', window.parent.document);", id);
                script.Append("var elementStyle = element.prop('style');");
                script.Append("var style = element.attr('style');");
                script.Append("$('#Top').val(element.css('top'));");
                script.Append("$('#Left').val(element.css('left'));");
                script.Append("$('#BackgroundColor').val(colorToHex(elementStyle[$.camelCase('backround-color')]));");
                script.Append("$('#SlideDirection').val(getStyleValue(style, 'slidedirection'));");
                script.Append("$('#SlideOutDirection').val(getStyleValue(style, 'slideoutdirection'));");
                script.Append("$('#DurationIn').val(getStyleValue(style, 'durationin'));");
                script.Append("$('#DurationOut').val(getStyleValue(style, 'durationout'));");
                script.Append("$('#EasingIn').val(getStyleValue(style, 'easingin'));");
                script.Append("$('#EasingOut').val(getStyleValue(style, 'easingout'));");
                script.Append("$('#RotateIn').val(getStyleValue(style, 'rotatein'));");
                script.Append("$('#RotateOut').val(getStyleValue(style, 'rotateout'));");

                if (string.Equals(tag, "img", StringComparison.InvariantCultureIgnoreCase))
                {
                    script.Append("$('#ImageSource').val(element.attr('src'));");
                    script.Append("$('#ImageSource_UploadList').html(element.attr('src'));");
                }
                else
                {
                    script.Append("$('#HtmlContent').val(element.html());");
                    script.Append("$('#FontFamily').val(elementStyle[$.camelCase('font-family')]);");
                    script.Append("$('#FontSize').val(elementStyle[$.camelCase('font-size')]);");
                    script.Append("$('#Color').val(colorToHex(elementStyle[$.camelCase('color')]));");
                }
                var scriptRegister = new ScriptRegister(WorkContext);
                scriptRegister.IncludeInline(script.ToString());

                result.AddAction(true)
                .HasName("Delete")
                .HasButtonStyle(ButtonStyle.Danger)
                .HasText(T("Delete"))
                .HasIconCssClass("cx-icon cx-icon-remove")
                .HasValue(id);
            }

            result.RegisterExternalDataSource(x => x.SlideDirection, "left", "right", "top", "bottom", "fade");
            result.RegisterExternalDataSource(x => x.SlideOutDirection, "left", "right", "top", "bottom", "fade");

            var easings = new[] { "linear", "swing", "easeInQuad", "easeOutQuad", "easeInOutQuad", "easeInCubic", "easeOutCubic", "easeInOutCubic", "easeInQuart", "easeOutQuart", "easeInOutQuart", "easeInQuint", "easeOutQuint", "easeInOutQuint", "easeInExpo", "easeOutExpo", "easeInOutExpo", "easeInSine", "easeOutSine", "easeInOutSine", "easeInCirc", "easeOutCirc", "easeInOutCirc", "easeInElastic", "easeOutElastic", "easeInOutElastic", "easeInBack", "easeOutBack", "easeInOutBack", "easeInBounce", "easeOutBounce", "easeInOutBounce" };

            result.RegisterExternalDataSource(x => x.EasingIn, easings);
            result.RegisterExternalDataSource(x => x.EasingOut, easings);

            return(result);
        }