Пример #1
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            RequireJsOptions.Add(
                "homeUrl",
                Url.Action("Index", "Home", new { area = "" }),
                RequireJsOptionsScope.Global);

            RequireJsOptions.Add(
                "saveThemeUrl",
                Url.Action("SaveTheme", "Home", new { area = "" }),
                RequireJsOptionsScope.Global);

            RequireJsOptions.Add(
                "startTheme",
                Enum.GetName(typeof(BsTheme), GetTheme.Theme),
                RequireJsOptionsScope.Global);

            RequireJsOptions.Add(
                "themeEnum",
                RequireJsHtmlHelpers.ToJsonDictionary <BsTheme>(),
                RequireJsOptionsScope.Global);

            //RequireJsOptions.Add("loggerUrl", Url.Action("LogException", "Error", new { area = string.Empty }), RequireJsOptionsScope.Global);

            //RequireJsOptions.Add("loadLoggerUrl", Url.Action("LogLoadTimes", "Log", new { area = string.Empty }), RequireJsOptionsScope.Global);

            //RequireJsOptions.Add("requestKey", "request-guid", RequireJsOptionsScope.Global);
        }
Пример #2
0
        public ActionResult Index(int?stateId)
        {
            BsGridRepositorySettings <ContributorSearchModel> bsGridSettings = null;

            if (stateId.HasValue)
            {
                var state = _componentState.Get(stateId.Value);

                if (state != null)
                {
                    bsGridSettings = state.ToBsGridRepositorySettings <ContributorSearchModel>();
                }
            }

            if (bsGridSettings == null)
            {
                bsGridSettings = new BsGridRepositorySettings <ContributorSearchModel>()
                {
                    PageSize = 5,
                    Page     = 1
                };
            }

            bsGridSettings.Search = _gridRepository.GetSearchForm(bsGridSettings.Search);

            var gridModel = _gridRepository.ToBsGridViewModel(bsGridSettings);

            var model = new ContributorsViewModel
            {
                Grid    = gridModel,
                Toolbar = new BsToolbarModel <ContributorSearchModel, ContributorNewModel, List <ContributorOrderModel> >
                {
                    Search = bsGridSettings.Search,
                    New    = _gridRepository.GetNewForm(),
                    Order  = _gridRepository.GetOrderForm(true)
                }
            };

            var options = new Dictionary <string, object>
            {
                { "pagerUrl", Url.Action("Pager") },
                { "getRowsUrl", Url.Action("GetRows") },
                { "enableDisableUrl", Url.Action("EnableDisable") },
                { "exportExcelUrl", Url.Action("ExportExcel") },
                { "updateUrl", Url.Action("Update") },
                { "deleteUrl", Url.Action("Delete") },
                { "editComponents", RequireJsHtmlHelpers.ToJsonDictionary <EditComponents>() }
            };

            RequireJsOptions.Add("index", options);

            return(View(model));
        }
Пример #3
0
        public void SerializesPackagesInRequireJSFormat()
        {
            var expected = "var require = {\"baseUrl\":\"\",\"locale\":\"en\",\"urlArgs\":null,\"waitSeconds\":7,\"paths\":{},\"packages\":[{\"name\":\"cart\",\"main\":\"main\"},{\"name\":\"store\",\"main\":\"store\"}],\"shim\":{},\"map\":{}};";

            var config     = new RequireRendererConfiguration();
            var collection = ConfigurationCreators.CreateCollectionWithPackages(
                new RequirePackage("cart", "main"),
                new RequirePackage("store", "store")
                );
            var outputConfig = RequireJsHtmlHelpers.createOutputConfigFrom(collection, config, "en");
            var actual       = Helpers.JavaScriptHelpers.SerializeAsVariable(outputConfig, "require");

            Assert.Equal(expected, actual);
        }
Пример #4
0
 public override void RegisterGlobalOptions()
 {
     RequireJsOptions.Add(
         "homeUrl",
         Url.Action("Index", "Home", new { area = "" }),
         RequireJsOptionsScope.Global);
     RequireJsOptions.Add(
         "adminUrl",
         Url.Action("Index", "Dashboard", new { area = "Admin" }),
         RequireJsOptionsScope.Global);
     RequireJsOptions.Add(
         "statusEnum",
         RequireJsHtmlHelpers.ToJsonDictionary <AjaxRequestStatus>(),
         RequireJsOptionsScope.Global);
 }
Пример #5
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            RequireJsOptions.Add(
                "homeUrl",
                Url.Action("Index", "Home", new { area = "" }),
                RequireJsOptionsScope.Global);

            RequireJsOptions.Add(
                "adminUrl",
                Url.Action("Index", "Dashboard", new { area = "Admin" }),
                RequireJsOptionsScope.Global);

            RequireJsOptions.Add(
                "statusEnum",
                RequireJsHtmlHelpers.ToJsonDictionary <AjaxRequestStatus>(),
                RequireJsOptionsScope.Global);
        }
Пример #6
0
        public ActionResult Index()
        {
            var userData = Session["UserData"] as UserData;

            var gridSettings = new UsersSettings
            {
                PageSize = 5,
                Page     = 1,
                UserData = userData
            };

            var gridModel = _usersRepository.ToBsGridViewModel(gridSettings);

            var model = new UsersPageModel
            {
                Grid    = gridModel,
                Toolbar = new BsToolbarModel <UserSearchModel, UserNewModel>
                {
                    Search = _usersRepository.GetSearchForm(gridSettings),
                    New    = _usersRepository.GetNewForm(gridSettings),
                }
            };

            var options = new Dictionary <string, object>
            {
                { "pagerUrl", Url.Action("Pager") },
                { "getRowsUrl", Url.Action("GetRows") },
                { "enableDisableUrl", Url.Action("EnableDisable") },
                { "deleteUrl", Url.Action("Delete") },
                { "updateComponentListUrl", Url.Action("UpdateComponentList") },
                { "currentCulture", Thread.CurrentThread.CurrentCulture.Name.Split('-')[0] },
                { "autocompleteComponents", RequireJsHtmlHelpers.ToJsonDictionary <UserAutocompleteComponents>() },
                { "userRoles", RequireJsHtmlHelpers.ToJsonDictionary <UserRoles>() }
            };

            RequireJsOptions.Add("Index", options);

            return(View(model));
        }
Пример #7
0
        public override void RegisterGlobalOptions()
        {
            RequireJsOptions.Add(
                "homeUrl",
                Url.Action("Index", "Home", new { area = "" }),
                RequireJsOptionsScope.Global);

            RequireJsOptions.Add(
                "saveThemeUrl",
                Url.Action("SaveTheme", "Home", new { area = "" }),
                RequireJsOptionsScope.Global);

            RequireJsOptions.Add(
                "startTheme",
                Enum.GetName(typeof(BsTheme), GetTheme.Theme),
                RequireJsOptionsScope.Global);

            RequireJsOptions.Add(
                "themeEnum",
                RequireJsHtmlHelpers.ToJsonDictionary <BsTheme>(),
                RequireJsOptionsScope.Global);
        }
Пример #8
0
        public ActionResult Index()
        {
            var model = new GroupEditorModel()
            {
                Developers = new BsEditorTabModel <ContributorRowModel, ContributorSearchModel, ContributorNewModel>
                {
                    Grid = repo.ToBsGridViewModel(new BsGridRepositorySettings <ContributorSearchModel>
                    {
                        Page     = 1,
                        PageSize = 10,
                        Search   = new ContributorSearchModel
                        {
                            RolesFilter = new List <ProjectRole>()
                            {
                                ProjectRole.Developer, ProjectRole.TeamLeader
                            }
                        }
                    }),
                    Search = repo.GetSearchForm(null),
                    New    = repo.GetNewForm()
                },

                Testers = new ContributorsInheritExample
                {
                    Grid = repo.ToBsGridViewModel(new BsGridRepositorySettings <ContributorSearchModel>
                    {
                        Page     = 1,
                        PageSize = 10,
                        Search   = new ContributorSearchModel
                        {
                            RolesFilter = new List <ProjectRole>()
                            {
                                ProjectRole.Tester
                            }
                        }
                    }),
                    Search = repo.GetSearchForm(null)
                },

                BFormsProject = new BsEditorGroupModel <ContributorsGroupRowModel, ContributorsRowFormModel>
                {
                    Items = new List <ContributorsGroupRowModel>()
                    {
                        new ContributorsGroupRowModel
                        {
                            Id            = 1,
                            Name          = "Stefan P.",
                            TabId         = ContributorType.Developer,
                            Contributions = "concept, api design, razor helpers, documentation, c# bug fixing, testing",
                            Form          = new ContributorsRowFormModel()
                            {
                                Contributions = "concept, api design, razor helpers, documentation, c# bug fixing, testing"
                            }
                        },
                        new ContributorsGroupRowModel
                        {
                            Id            = 6,
                            Name          = "Oana M.",
                            TabId         = ContributorType.Developer,
                            Contributions = "UI & UX, css master",
                            Form          = new ContributorsRowFormModel()
                            {
                                Contributions = "UI & UX, css master"
                            }
                        },
                        new ContributorsGroupRowModel
                        {
                            Id            = 3,
                            Name          = "Cezar C.",
                            TabId         = ContributorType.Developer,
                            Contributions = "documentation, razor helpers",
                            Form          = new ContributorsRowFormModel()
                            {
                                Contributions = "documentation, razor helpers"
                            }
                        },
                        new ContributorsGroupRowModel
                        {
                            Id            = 4,
                            Name          = "Marius C.",
                            TabId         = ContributorType.Developer,
                            Contributions = "js framework, datetime picker, automated tests for js",
                            Form          = new ContributorsRowFormModel()
                            {
                                Contributions = "js framework, datetime picker, automated tests for js"
                            }
                        }
                    },
                    Form = new ContributorsRowFormModel()
                },

                RequireJsProject = new BsEditorGroupModel <ContributorsGroupRowModel>
                {
                    Items = new List <ContributorsGroupRowModel>()
                    {
                        new ContributorsGroupRowModel
                        {
                            Id            = 1,
                            Name          = "Stefan P.",
                            Contributions = "concept, api design, razor helpers, documentation, c# bug fixing, testing",
                            TabId         = ContributorType.Developer
                        },
                        new ContributorsGroupRowModel
                        {
                            Id            = 3,
                            Name          = "Cezar C.",
                            Contributions = "documentation, razor helpers",
                            TabId         = ContributorType.Developer
                        }
                    }
                },
                Form = new GroupFormModel()
            };

            var viewModel = new GroupEditorViewModel
            {
                Editor = model
            };

            var options = new
            {
                getTabUrl         = Url.Action("GetTab"),
                save              = Url.Action("Save"),
                advancedSearchUrl = Url.Action("Search"),
                addUrl            = Url.Action("New"),
                contributorType   = RequireJsHtmlHelpers.ToJsonDictionary <ContributorType>(),
                projectRole       = RequireJsHtmlHelpers.ToJsonDictionary <ProjectRole>()
            };

            RequireJsOptions.Add("index", options);

            return(View(viewModel));
        }
Пример #9
0
        public ActionResult Index(int?stateId)
        {
            BsGridRepositorySettings <ContributorSearchModel> bsGridSettings = null;

            //HttpContext.Items["RequestTheme"] = BsTheme.Black;

            if (stateId.HasValue)
            {
                var state = _componentState.Get(stateId.Value);

                if (state != null)
                {
                    bsGridSettings = state.ToBsGridRepositorySettings <ContributorSearchModel>();
                }
            }


            bsGridSettings = new BsGridRepositorySettings <ContributorSearchModel>()
            {
                PageSize = 5,
                Page     = 1,
                //GoTo = BsDirectionType.First
            };

            bsGridSettings.Search = _gridRepository.GetSearchForm(bsGridSettings.Search);

            bsGridSettings.OrderableColumns = new List <BsColumnOrder> {
                new BsColumnOrder
                {
                    Name = "Name",
                    Type = BsOrderType.Descending
                }
            };

            var gridModel = _gridRepository.ToBsGridViewModel(bsGridSettings, x => x.Id);

            var model = new ContributorsViewModel
            {
                Grid    = gridModel,
                Toolbar = new BsToolbarModel <ContributorSearchModel, ContributorNewModel, List <ContributorOrderModel> >
                {
                    Search = bsGridSettings.Search,
                    New    = _gridRepository.GetNewForm(),
                    Order  = _gridRepository.GetOrderForm(true)
                }
            };

            var options = new Dictionary <string, object>
            {
                { "pagerUrl", Url.Action("Pager") },
                { "getRowsUrl", Url.Action("GetRows") },
                { "enableDisableUrl", Url.Action("EnableDisable") },
                { "exportExcelUrl", Url.Action("ExportExcel") },
                { "updateUrl", Url.Action("Update") },
                { "deleteUrl", Url.Action("Delete") },
                { "editComponents", RequireJsHtmlHelpers.ToJsonDictionary <EditComponents>() },
                { "countUrl", Url.Action("Count") }
            };

            RequireJsOptions.Add("index", options);

            return(View(model));
        }