Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/22/11 21:01:58 (13 years ago)
Author:
dhohl
Message:

#1499 The filter form does not lost any inputs after reloading the page; date filter is possible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/FilterController.cs

    r6245 r6247  
    2020        /// </summary>
    2121        /// <returns></returns>
    22         public ActionResult GetRuns()
     22        public void GetRuns()
    2323        {
    2424            FilterModel qm = new FilterModel();
     
    3232            Response.Write("Found <" + ids.Count() + "> Runs.");
    3333
    34             return View("Index", qm); // name of usercontrol
     34          //  return View("Index", qm); // name of usercontrol
    3535        }
    3636
     
    5151        /// <param name="collection"></param>
    5252        /// <returns></returns>
    53         public ActionResult AddFilterAnd(FormCollection collection)
     53        public ActionResult AddFilterAnd(string submitButton, FormCollection collection)
    5454        {
    5555            FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]);
    5656
    57 
    58             // Add Filter
    59             String idKey = null;
    60             String parentIdKey = null;
    61 
    62             foreach (string key in collection.AllKeys)
    63             {
    64                 if (key.StartsWith(FilterModel.ComboboxName))
    65                 {
    66                     idKey = key;
    67                 }
    68                 if (key.StartsWith(FilterModel.ParentIdName))
    69                 {
    70                     parentIdKey = key;
    71                 }
    72             }
    73 
    74             Guid parentId = new Guid(collection.Get(parentIdKey));
    75             string filterTypeName = collection.Get(idKey);
    76             fm.AddFilter(filterTypeName, parentId);
    77 
     57            Response.Write("Submit:" + submitButton);
     58           
     59            //update model with form data
    7860            UpdateModel(collection, fm);
    7961
     62            if (submitButton.StartsWith("+"))
     63            {
     64                string stringid = submitButton.Substring(2);
     65                AddNewFilter(collection, fm, stringid);
     66            }
     67            else if (submitButton.StartsWith("-"))
     68            {
     69                string stringid = submitButton.Substring(2);
     70                DeleteFilter(new Guid(stringid));
     71            }
     72            else if (submitButton.Equals("runs"))
     73            {
     74                GetRuns();
     75            }
     76            else if (submitButton.Equals("or"))
     77            {
     78                AddFilterOr( fm);
     79            }
     80           
    8081            // Set Content
    8182            Session["Content"] = fm.Content;
    8283
    8384            return View("Index", fm);
     85                       
     86        }
     87
     88        private void AddNewFilter(FormCollection collection, FilterModel fm, String idKey)
     89        {
     90            // Add Filter
     91            //String idKey = null;
     92            String parentIdKey = idKey;
     93
     94            //foreach (string key in collection.AllKeys)
     95            //{
     96            //    //if (key.StartsWith(FilterModel.ComboboxName))
     97            //    //{
     98            //    //    idKey = key;
     99            //    //}
     100            //    if (key.StartsWith(FilterModel.ParentIdName))
     101            //    {
     102            //        parentIdKey = key;
     103            //    }
     104            //}
     105
     106            Guid parentId = new Guid(parentIdKey);
     107            string filterTypeName = collection.Get(FilterModel.ComboboxName+ "." + idKey);
     108            fm.AddFilter(filterTypeName, parentId);
     109
     110            //UpdateModel(collection, fm);
     111
     112            //// Set Content
     113            //Session["Content"] = fm.Content;
     114
     115            //return View("Index", fm);
    84116        }
    85117
     
    111143                {
    112144                    int idx = key.IndexOf(".");
    113                     string id = key.Substring(0, idx);
    114                     string type = key.Substring(idx + 1);
    115 
    116                     Guid fid = new Guid(id);
    117 
    118                     if (postValues.ContainsKey(fid))
     145                    if (idx != -1)
    119146                    {
    120                         Dictionary<string, string> d = postValues[fid];
    121                         d.Add(type, collection.Get(key));
    122                     }
    123                     else
    124                     {
    125                         Dictionary<string, string> d = new Dictionary<string, string>();
    126                         d.Add(type, collection.Get(key));
    127                         postValues.Add(fid, d);
     147                        string id = key.Substring(0, idx);
     148                        string type = key.Substring(idx + 1);
     149
     150                        Guid fid = new Guid(id);
     151
     152                        if (postValues.ContainsKey(fid))
     153                        {
     154                            Dictionary<string, string> d = postValues[fid];
     155                            d.Add(type, collection.Get(key));
     156                        }
     157                        else
     158                        {
     159                            Dictionary<string, string> d = new Dictionary<string, string>();
     160                            d.Add(type, collection.Get(key));
     161                            postValues.Add(fid, d);
     162                        }
    128163                    }
    129164                }
     
    140175        /// <param name="id"></param>
    141176        /// <returns></returns>
    142         public ActionResult DeleteFilter(Guid id)
     177        public void DeleteFilter(Guid id)
    143178        {
    144179            // Get Content from Session
    145180            FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]);
    146181
     182            //throw new Exception();
     183
    147184            // Remove Filter
    148185            bool filterRemoved = fm.RemoveFilter(id);
    149186
     187
     188            //UpdateModel(collection, fm);
    150189            // TODO Model muss auch beim löschen upgeadatet werden UpdateModel(collection, fm);
    151190
    152191            // Set Content
    153             Session["Content"] = fm.Content;
    154 
    155             return View("Index", fm);
     192            //Session["Content"] = fm.Content;
     193
     194            //return View("Index", fm);
    156195        }
    157196
     
    163202        /// </summary>
    164203        /// <returns></returns>
    165         public ActionResult AddFilterOr()
    166         {
    167             FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]);
    168 
     204        public void AddFilterOr(FilterModel fm)
     205        {
     206           
    169207            List<Filter> orFilters = fm.Content.Filters.ToList<Filter>(); ;
    170208
     
    177215            Session["Content"] = fm.Content;
    178216
    179             return View("Index", fm);
     217            //return View("Index", fm);
    180218        }
    181219
Note: See TracChangeset for help on using the changeset viewer.