Esempio n. 1
0
        protected internal virtual PartialViewResult SearchPopup(ControllerBase controller, FindOptions findOptions, FindMode mode, Context context)
        {
            if (!Finder.IsFindable(findOptions.QueryName))
            {
                throw new UnauthorizedAccessException(NormalControlMessage.ViewForType0IsNotAllowed.NiceToString().FormatWith(findOptions.QueryName));
            }

            var desc = DynamicQueryManager.Current.QueryDescription(findOptions.QueryName);

            SetSearchViewableAndCreable(findOptions, desc);
            SetDefaultOrder(findOptions, desc);

            controller.ViewData.Model = context;

            controller.ViewData[ViewDataKeys.FindMode]         = mode;
            controller.ViewData[ViewDataKeys.FindOptions]      = findOptions;
            controller.ViewData[ViewDataKeys.QueryDescription] = desc;

            if (!controller.ViewData.ContainsKey(ViewDataKeys.Title))
            {
                controller.ViewData[ViewDataKeys.Title] = QueryUtils.GetNiceName(findOptions.QueryName);
            }

            return(new PartialViewResult
            {
                ViewName = SearchPopupControlView,
                ViewData = controller.ViewData,
                TempData = controller.TempData
            });
        }
Esempio n. 2
0
        protected internal virtual ViewResult SearchPage(ControllerBase controller, FindOptions findOptions)
        {
            if (!Finder.IsFindable(findOptions.QueryName))
            {
                throw new UnauthorizedAccessException(SearchMessage.Query0IsNotAllowed.NiceToString().FormatWith(findOptions.QueryName));
            }

            QueryDescription description = DynamicQueryManager.Current.QueryDescription(findOptions.QueryName);

            //Finder.SetTokens(findOptions.FilterOptions, description, canAggregate: false);
            SetSearchViewableAndCreable(findOptions, description);
            SetDefaultOrder(findOptions, description);

            controller.ViewData.Model = new Context(null, "");

            controller.ViewData[ViewDataKeys.QueryDescription] = DynamicQueryManager.Current.QueryDescription(findOptions.QueryName);
            controller.ViewData[ViewDataKeys.FindOptions]      = findOptions;

            if (!controller.ViewData.ContainsKey(ViewDataKeys.Title))
            {
                controller.ViewData[ViewDataKeys.Title] = QueryUtils.GetNiceName(findOptions.QueryName);
            }

            return(new ViewResult()
            {
                ViewName = SearchPageView,
                MasterName = null,
                ViewData = controller.ViewData,
                TempData = controller.TempData
            });
        }
Esempio n. 3
0
        internal protected virtual bool OnIsFindable(Type type)
        {
            if (!Finder.IsFindable(type))
            {
                return(false);
            }

            EntitySettings es = EntitySettings.TryGetC(type);

            if (es != null && !es.OnIsFindable())
            {
                return(false);
            }

            if (IsFindable != null)
            {
                foreach (var isCreable in IsFindable.GetInvocationListTyped())
                {
                    if (!isCreable(type))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 4
0
 public QuickLinkExplore(FindOptions findOptions)
 {
     FindOptions = findOptions;
     IsVisible   = Finder.IsFindable(findOptions.QueryName);
     Text        = QueryUtils.GetNiceName(findOptions.QueryName);
     Name        = Finder.ResolveWebQueryName(findOptions.QueryName);
 }
Esempio n. 5
0
        protected internal virtual PartialViewResult Search(ControllerBase controller, QueryRequest request, bool allowSelection, bool navigate, bool showFooter, Context context)
        {
            if (!Finder.IsFindable(request.QueryName))
            {
                throw new UnauthorizedAccessException(NormalControlMessage.ViewForType0IsNotAllowed.NiceToString().FormatWith(request.QueryName));
            }

            QuerySettings    settings = QuerySettings[request.QueryName];
            QueryDescription qd       = DynamicQueryManager.Current.QueryDescription(request.QueryName);

            if (settings.HiddenColumns != null)
            {
                if (settings.HiddenColumns.Any(a => a.Token == null))
                {
                    using (ExecutionMode.Global())
                        ColumnOption.SetColumnTokens(settings.HiddenColumns, qd, canAggregate: false);
                }

                request.Columns.AddRange(settings.HiddenColumns.Select(c => c.ToColumn(qd, isVisible: false)));
            }

            ResultTable queryResult = DynamicQueryManager.Current.ExecuteQuery(request);

            controller.ViewData.Model = context;

            controller.ViewData[ViewDataKeys.AllowSelection] = allowSelection;
            controller.ViewData[ViewDataKeys.Navigate]       = navigate;
            controller.ViewData[ViewDataKeys.ShowFooter]     = showFooter;


            controller.ViewData[ViewDataKeys.QueryDescription] = qd;

            Type   entitiesType = Lite.Extract(qd.Columns.SingleEx(a => a.IsEntity).Type);
            string message      = CollectionElementToken.MultipliedMessage(request.Multiplications, entitiesType);

            if (message.HasText())
            {
                controller.ViewData[ViewDataKeys.MultipliedMessage] = message;
            }

            controller.ViewData[ViewDataKeys.Results]      = queryResult;
            controller.ViewData[ViewDataKeys.QueryRequest] = request;

            controller.ViewData[ViewDataKeys.Formatters]      = queryResult.Columns.Select((c, i) => new { c, i }).ToDictionary(c => c.i, c => settings.GetFormatter(c.c.Column));
            controller.ViewData[ViewDataKeys.EntityFormatter] = settings.EntityFormatter;
            controller.ViewData[ViewDataKeys.RowAttributes]   = settings.RowAttributes;

            return(new PartialViewResult
            {
                ViewName = SearchResultsView,
                ViewData = controller.ViewData,
                TempData = controller.TempData
            });
        }
Esempio n. 6
0
        public static JsTypeInfo ToJsTypeInfo(this Type type, bool isSearch, string prefix)
        {
            var result = new JsTypeInfo()
            {
                name         = Navigator.ResolveWebTypeName(type),
                niceName     = type.NiceName(),
                creable      = Navigator.IsCreable(type, isSearch),
                findable     = Finder.IsFindable(type),
                preConstruct = new JRaw(Constructor.ClientManager.GetPreConstructorScript(new ClientConstructorContext(type, prefix))),
                avoidPopup   = (Navigator.Manager.EntitySettings.TryGetC(type)?.AvoidPopup) ?? false,
            };

            return(result);
        }
Esempio n. 7
0
        internal protected virtual bool OnIsFindable(Type type)
        {
            if (!Finder.IsFindable(type))
            {
                return(false);
            }

            EntitySettings es = EntitySettings.TryGetC(type);

            if (es != null && !es.OnIsFindable())
            {
                return(false);
            }

            return(true);
        }