Exemplo n.º 1
0
        private void setupCreateNewProperties(T grid, GridViewModel model)
        {
            if (!grid.Definition.AllowCreationOfNew)
            {
                return;
            }

            var endpoint = _endpointService.EndpointForNew(grid.EntityType);

            if (!endpoint.IsAuthorized)
            {
                model.AllowCreateNew = false;
                return;
            }

            model.NewEntityText = StringToken.FromKeyString("CREATE_NEW_" + grid.EntityType.Name.ToUpper()).ToString();
            model.NewEntityUrl  = endpoint.Url;
        }
Exemplo n.º 2
0
        public GridViewModel BuildGridModel(IEnumerable <IGridPolicy> gridPolicies)
        {
            var grid = BuildGrid();

            // TODO -- get an integration test against this
            grid.ApplyPolicies(gridPolicies ?? new IGridPolicy[0]);

            var model = new GridViewModel()
            {
                AllowCreateNew     = grid.Definition.AllowCreationOfNew,
                CanSaveQuery       = grid.Definition.CanSaveQuery,
                FilteredProperties = FilteredProperties(grid),
                GridModel          = buildJqModel(grid),
                GridName           = typeof(T).NameForGrid(),
                GridType           = typeof(T),
                HeaderText         = grid.GetHeader()
            };

            model.AddCriterion(grid.InitialCriteria());

            setupCreateNewProperties(grid, model);

            return(model);
        }
Exemplo n.º 3
0
 public static HtmlTag FiltersFor(this IFubuPage page, GridViewModel model)
 {
     page.Script("grid");
     return(page.Get <FilterTagWriter>().FilterTemplatesFor(model));
 }