Example #1
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);
        }
        public override ActionResult BuildEditor(Controller controller, WorkContext workContext, ControlFormResult <IWidget> form)
        {
            form.RegisterExternalDataSource("Theme", new Dictionary <string, string>
            {
                { "theme-default", "Default" },
                { "theme-bar", "Bar" },
                { "theme-dark", "Dark" },
                { "theme-light", "Light" },
            });

            form.RegisterExternalDataSource("Effect", new Dictionary <string, string>
            {
                { "random", "Random" },
                { "sliceDown", "Slice Down" },
                { "sliceDownLeft", "Slice Down Left" },
                { "sliceUp", "Slice Up" },
                { "sliceUpLeft", "Slice Up Left" },
                { "sliceUpDown", "Slice Up Down" },
                { "sliceUpDownLeft", "Slice Up Down Left" },
                { "fold", "Fold" },
                { "fade", "Fade" },
                { "slideInRight", "Slide In Right" },
                { "slideInLeft", "Slide In Left" },
                { "boxRandom", "Box Random" },
                { "boxRain", "Box Rain" },
                { "boxRainReverse", "Box Rain Reverse" },
                { "boxRainGrow", "Box Rain Grow" },
                { "boxRainGrowReverse", "Box Rain Grow Reverse" },
            });

            return(base.BuildEditor(controller, workContext, form));
        }
        public override ActionResult BuildEditor(Controller controller, WorkContext workContext, ControlFormResult <IWidget> controlForm)
        {
            var sliderService = workContext.Resolve <ISliderService>();
            var sliders       = sliderService.GetRecords();

            controlForm.RegisterExternalDataSource("SliderId", sliders.ToSelectList(v => v.Id.ToString(), t => t.Name));

            controlForm.RegisterExternalDataSource("Skin", "defaultskin", "fullwidth", "glass", "borderlessdark", "borderlesslight", "darkskin", "lightskin", "minimal");

            return(base.BuildEditor(controller, workContext, controlForm));
        }
        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);
        }
Example #5
0
        public ActionResult Create()
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý bài viết"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thêm thông tin bài viết"), Url = Url.Action("Index")
            });
            var model = new ArticlesModel();

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

            result.Title                = this.T("Thêm 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("Image.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);

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

            return(result);
        }
Example #6
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);
        }
Example #7
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);
        }
Example #8
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("Thông tin chuyên mục"), Url = Url.Action("Index")
            });
            var model = new CategoriesModel();

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

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

            result.Title                = this.T("Thông tin 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, y => BindCategoriesParent());

            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(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);
        }
Example #10
0
        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 override ActionResult BuildEditor(Controller controller, WorkContext workContext, ControlFormResult <IWidget> form)
        {
            var mediaService = workContext.Resolve <IMediaService>();

            form.RegisterExternalDataSource("PhotosFolder", mediaService.GetMediaFolders());

            var oldCaptions = new List <FileCaption>();

            if (Captions != null)
            {
                oldCaptions.AddRange(Captions);
                Captions.Clear();
            }
            else
            {
                Captions = new List <FileCaption>();
            }

            if (!string.IsNullOrEmpty(PhotosFolder))
            {
                var files = mediaService.GetMediaFiles(PhotosFolder).Where(IsPhotoFile).OrderBy(x => x.Name);
                Captions.AddRange(files.Select(file => oldCaptions.FirstOrDefault(x => x.FileName == file.Name)
                                               ?? new FileCaption {
                    FileName = file.Name
                }));
            }
            else
            {
                form.ExcludeProperty("Captions");
            }

            return(base.BuildEditor(controller, workContext, form));
        }
Example #12
0
        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 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));
        }
Example #14
0
        public override ActionResult BuildEditor(Controller controller, WorkContext workContext, ControlFormResult <IWidget> form)
        {
            var menuService = workContext.Resolve <IMenuService>();
            var menus       = menuService.GetRecords().OrderBy(x => x.Name).ToDictionary(x => x.Id, x => x.Name);

            form.RegisterExternalDataSource("MenuId", menus);

            return(form);
        }
Example #15
0
        public override void BindControlField(ControlFormResult controlForm, object value)
        {
            var attribute = new ControlGridAttribute(0, MaxPhotos)
            {
                PropertyName     = Name,
                LabelText        = Title,
                PropertyType     = typeof(List <PictureTooltip>),
                ShowLabelControl = false,
                EnabledScroll    = true
            };

            controlForm.RegisterExternalDataSource(Name + ".Button", "moregold", "moregrey", "moreblack", "moredarkblue", "moreblue", "morelightblue", "morelightblue2", "morewatergreen", "morelightgreen", "moregreen", "moreyellow", "moreorange", "morered", "morepurple", "moreviolet", "morelightviolet", "morefucsia");
            controlForm.RegisterExternalDataSource(Name + ".Background", "bgblack", "bgwhite");
            controlForm.RegisterExternalDataSource(Name + ".Round", "roundBgW", "roundBgB");
            controlForm.RegisterExternalDataSource(Name + ".AnimationType", "ltr-slide", "rtl-slide", "btt-slide", "ttb-slide");

            controlForm.AddProperty(Name, attribute, value);
        }
Example #16
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);
 }
Example #17
0
        public ActionResult Create()
        {
            if (!CheckPermission(PagesPermissions.ManagePages))
            {
                return(new HttpUnauthorizedResult());
            }

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

            var model = new PageModel {
                IsEnabled = true, Title = ""
            };

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

            //result.AddAction(true, false, false).HasText(T("Preview")).HasUrl(Url.Action("Preview")).HasButtonStyle(ButtonStyle.Default);

            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);
        }
Example #18
0
        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);
        }
        public ActionResult Create(int?pageId)
        {
            if (!CheckPermission(WidgetPermissions.ManageWidgets))
            {
                return(new HttpUnauthorizedResult());
            }

            WorkContext.Breadcrumbs.Add(T("Widgets"), Url.Action("Index"));
            WorkContext.Breadcrumbs.Add(T("Create"));

            var model = new WidgetModel {
                Title = "", PageId = pageId
            };

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

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

            var widgets = WorkContext.Resolve <IEnumerable <IWidget> >();

            var widgetTypes = widgets.Select(x => new { x.Name, Type = GetFullTypeName(x.GetType()) }).OrderBy(x => x.Name).ToDictionary(x => x.Type, x => x.Name);

            result.RegisterExternalDataSource(x => x.WidgetType, widgetTypes);

            var zoneService = WorkContext.Resolve <IZoneService>();
            var zones       = zoneService.GetRecords().ToDictionary(x => x.Id, x => x.Name);

            result.RegisterExternalDataSource(x => x.ZoneId, zones);

            return(result);
        }
        public ActionResult Edit(int id)
        {
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Quản lý sản phẩm"), Url = "#"
            });
            WorkContext.Breadcrumbs.Add(new Breadcrumb {
                Text = T("Thông tin sản phẩm"), Url = Url.Action("Index")
            });
            var model = new ProductModel();

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

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

            result.Title                = this.T("Thông tin sản phẩm");
            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("Image.FileName", new ControlFileUploadOptions
            {
                AllowedExtensions = "jpg,jpeg,png,gif"
            });
            result.MakeReadOnlyProperty(x => x.CategoryId);

            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());
            result.RegisterExternalDataSource(x => x.GroupId, y => BindProductGroup());
            result.RegisterExternalDataSource(x => x.Type, y => BindProductTypes());

            return(result);
        }
Example #21
0
        void ISettings.OnEditing(ControlFormResult <ISettings> controlForm, WorkContext workContext)
        {
            var        indexingService = workContext.Resolve <IIndexingService>();
            IndexEntry indexEntry;

            try
            {
                indexEntry = indexingService.GetIndexEntry("Search");
            }
            catch (Exception)
            {
                indexEntry = null;
            }

            if (indexEntry == null)
            {
                controlForm.RegisterExternalDataSource("SearchedFields", "title", "body");
            }
            else
            {
                controlForm.RegisterExternalDataSource("SearchedFields", indexEntry.Fields);
            }
        }
        public override ActionResult BuildEditor(Controller controller, WorkContext workContext, ControlFormResult <IWidget> form)
        {
            var listService = workContext.Resolve <IListService>();
            var list        = listService.GetRecords().OrderBy(x => x.Name).ToDictionary(x => x.Id, x => x.Name);

            form.RegisterExternalDataSource("ListId", list);

            form.RegisterCascadingDropDownDataSource("CategoryId", new ControlCascadingDropDownOptions
            {
                SourceUrl = controller.Url.Action("EditorCallback"),
                Command   = "GetCategories"
            });

            return(form);
        }
Example #23
0
        public ActionResult EditItem(int id)
        {
            if (!CheckPermission(MenusPermissions.ManageMenus))
            {
                return(new HttpUnauthorizedResult());
            }

            var menuItem = menuItemService.GetById(id);

            MenuItemModel model = menuItem;

            WorkContext.Breadcrumbs.Add(T("Menus"), Url.Action("Index", new { area = Constants.Areas.Menus }));
            WorkContext.Breadcrumbs.Add(T("Items"), Url.Action("MenuItems", new { area = Constants.Areas.Menus, menuId = menuItem.MenuId }));
            WorkContext.Breadcrumbs.Add(T("Edit"));

            if (string.IsNullOrEmpty(model.Url))
            {
                model.Url = "/";
            }

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

            var items = menuItemService.GetMenuItems(model.MenuId);

            if (model.ParentId.HasValue)
            {
                items = items.Where(x => x.Id != model.Id && x.ParentId != model.ParentId.Value).ToList();
            }
            else
            {
                items = items.Where(x => x.Id != model.Id).ToList();
            }
            var menuItems = GetMenuItems(items);

            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);
        }
Example #24
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);
        }
Example #25
0
        public ActionResult Edit(int id)
        {
            if (!CheckPermission(ListsPermissions.ManageLists))
            {
                return(new HttpUnauthorizedResult());
            }

            var model = listService.GetById(id);

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

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

            var sortByFields = new Dictionary <object, string>
            {
                { "Position asc", "Position (Ascending)" },
                { "Position desc", "Position (Descending)" },
                { "Title asc", "Title (Ascending)" },
                { "Title desc", "Title (Descending)" },
                { "Slug asc", "Slug (Ascending)" },
                { "Slug desc", "Slug (Descending)" },
                { "Url asc", "Url (Ascending)" },
                { "Url desc", "Url (Descending)" },
                { "CreatedDate asc", "Created Date (Ascending)" },
                { "CreatedDate desc", "Created Date (Descending)" },
                { "ModifiedDate asc", "Modified Date (Ascending)" },
                { "ModifiedDate desc", "Modified Date (Descending)" },
            };

            result.RegisterExternalDataSource(x => x.Sorting, sortByFields);
            return(result);
        }
Example #26
0
        public ActionResult Edit(int id)
        {
            if (!CheckPermission(StandardPermissions.FullAccess))
            {
                return(new HttpUnauthorizedResult());
            }

            LanguageModel model = languageService.GetById(id);

            model.CultureCode2 = model.CultureCode;

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

            if (model.CultureCode == siteSettings.DefaultLanguage)
            {
                result.ExcludeProperty(x => x.Active);
                result.AddHiddenValue("Active", "true");
            }

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

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

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

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

            return(result);
        }
Example #27
0
        public virtual ActionResult EditRoles(int userId)
        {
            var user  = membershipService.GetUser(userId);
            var model = new UpdateRolesModel
            {
                UserId = userId,
                Roles  = membershipService.GetRolesForUser(user.Id).Select(x => x.Id).ToArray()
            };

            var retult = new ControlFormResult <UpdateRolesModel>(model)
            {
                Title                = T("Update User Roles").Text,
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            var roles = roleService.GetRecords().ToDictionary(k => k.Id, v => v.Name);

            retult.RegisterExternalDataSource(x => x.Roles, roles);

            return(retult);
        }
Example #28
0
        void ISettings.OnEditing(ControlFormResult <ISettings> controlForm, WorkContext workContext)
        {
            var languageManager = workContext.Resolve <ILanguageManager>();

            controlForm.RegisterExternalDataSource("DefaultLanguage", languageManager.GetActiveLanguages(Constants.ThemeDefault, false).ToDictionary(k => k.CultureCode, v => v.Name));
        }
Example #29
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);
        }
Example #30
0
        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);
        }