예제 #1
0
        public PartialViewResult KanbanFilter(int id, bool showStatusFilter)
        {
            #region Считываем данные из кук если они там есть

            List <int>    userIds;
            List <int>    projectIds;
            List <int>    colorIds;
            List <int>    statusIds;
            TasksSortType sortType;
            _FilterUtility.GetCurrentFilter(id, out userIds, out projectIds, out colorIds, out sortType, out statusIds, null);

            #endregion

            #region Подготавливаем данные для представления

            var userData  = Utility.Boards.GetAllExecutorsOnBoard(id);
            var usersView = new DropdownCheckList
            {
                SelectList = userData.Select(x => new SelectListItem
                {
                    Selected = userIds == null || userIds.Contains(x.Id),
                    Text     = x.Nick,
                    Value    = x.Id.ToString()
                }).ToList(),
                Label = "Все исполнители",
                Title = "Исполнители",
                Name  = "Users"
            };

            List <IProject>   projectsData = Utility.Projects.GetByBoard(id);
            DropdownCheckList projectsView = new DropdownCheckList
            {
                SelectList = projectsData.Select(x => new SelectListItem
                {
                    Selected = projectIds == null || projectIds.Contains(x.Id),
                    Text     = x.Name,
                    Value    = x.Id.ToString()
                }).ToList(),
                Label = "Все проекты",
                Title = "Проекты",
                Name  = "Projects"
            };

            var statusesData = Utility.Statuses.GetByBoard(id);
            var statusView   = new DropdownCheckList
            {
                SelectList = statusesData.Select(x => new SelectListItem
                {
                    Selected = statusIds == null || statusIds.Contains(x.Id),
                    Text     = x.Name,
                    Value    = x.Id.ToString()
                }).ToList(),
                Label = "Все статусы",
                Title = "Статусы",
                Name  = "Statuses"
            };

            var colorsData = Utility.Boards.GetColors(id);
            var colorsView = new DropdownCheckList
            {
                SelectList = colorsData.Select(x => new SelectListItem
                {
                    Selected = colorIds == null || colorIds.Contains(x.Id),
                    Text     = x.Name,
                    Value    = x.Id.ToString()
                }).ToList(),
                Label = "Все приоритеты",
                Title = "Приоритеты",
                Name  = "Colors"
            };

            var sortTypeView = new List <SelectListItem>();
            foreach (TasksSortType item in Enum.GetValues(typeof(TasksSortType)))
            {
                if (!showStatusFilter && item == TasksSortType.ByStatus)
                {
                    continue;
                }

                sortTypeView.Add(new SelectListItem
                {
                    Text     = item.GetAlias(),
                    Value    = ((int)item).ToString(),
                    Selected = item == sortType
                });
            }

            #endregion

            ViewData.Add("Users", usersView);
            ViewData.Add("Projects", projectsView);
            ViewData.Add("Colors", colorsView);
            ViewData.Add("SortTypeView", sortTypeView);
            ViewData.Add("StatusesView", statusView);
            return(PartialView("KanbanFilter"));
        }
예제 #2
0
        public PartialViewResult Filter(int id)
        {
            #region Считываем данные из кук если они там есть
            List <int>    userIds;
            List <int>    projectIds;
            List <int>    colorIds;
            List <int>    statusIds;
            TasksSortType sortType;
            _FilterUtility.GetCurrentFilter(id, out userIds, out projectIds, out colorIds, out sortType, out statusIds, null);
            EventType eventTypes = GetEventTypes(null);
            #endregion

            #region Подготавливаем данные для представления
            var userData  = Utility.Boards.GetAllExecutorsOnBoard(id);
            var usersView = new DropdownCheckList
            {
                SelectList = userData.Select(x => new SelectListItem
                {
                    Selected = userIds == null || userIds.Contains(x.Id),
                    Text     = x.Nick,
                    Value    = x.Id.ToString()
                }).ToList(),
                Label = "Все инициаторы действий",
                Title = "Инициаторы действий",
                Name  = "Users"
            };

            var projectsData = Utility.Projects.GetByBoard(id);
            var projectsView = new DropdownCheckList
            {
                SelectList = projectsData.Select(x => new SelectListItem
                {
                    Selected = projectIds == null || projectIds.Contains(x.Id),
                    Text     = x.Name,
                    Value    = x.Id.ToString()
                }).ToList(),
                Label = "Все проекты",
                Title = "Проекты",
                Name  = "Projects"
            };


            var eventTypeView = new List <SelectListItem>();
            foreach (EventType item in Enum.GetValues(typeof(EventType)))
            {
                if ((item & EventType.All) == EventType.All)
                {
                    continue;
                }

                eventTypeView.Add(new SelectListItem
                {
                    Text     = item.GetAlias(),
                    Value    = ((int)item).ToString(),
                    Selected = (item & eventTypes) == item
                });
            }

            var eventTypeViewCheckList = new DropdownCheckList
            {
                SelectList = eventTypeView,
                Label      = "Все события",
                Title      = "События",
                Name       = "EventTypes"
            };

            #endregion

            ViewData.Add("Users", usersView);
            ViewData.Add("Projects", projectsView);

            ViewData.Add("EventTypes", eventTypeViewCheckList);

            return(PartialView("Filter"));
        }