Inheritance: ViewBase
Exemplo n.º 1
0
        public override object GetData()
        {
            var columns = new List <Column>();

            columns.AddRange(GetSelectedColumns(ColumnListView));
            columns.AddRange(GetSelectedColumns(ColumnListViewAdvanced));

            return(Handler.SerializeColumnXml(columns));
        }
Exemplo n.º 2
0
 protected override IEnumerable <string> GetFieldList()
 {
     Handlers.ListView listDefinition = this.ViewDefinition as Handlers.ListView;
     return(listDefinition.GetColumnList());
 }
Exemplo n.º 3
0
        public override void SetData(object data)
        {
            _columnIndexList = new List <int>();

            var index            = 1;
            var unusedCols       = new List <Column>();
            var advancedCols     = new List <Column>();
            var colXml           = data as string;
            var colEnum          = Handler.PrepareColumnList(colXml);
            var fieldTitles      = new List <string>();
            var duplicatedTitles = new List <string>();

            _columns = colEnum != null?colEnum.ToList() : new List <Column>();

            _columnsAdvanced = new List <Column>();

            var ind = 1;

            foreach (var column in _columns)
            {
                column.Selected = true;

                //use the display name of the field instead of the value saved in the view
                var afs = AvailableFields.FirstOrDefault(af => af.FullName == column.FullName);
                if (afs != null)
                {
                    column.Title = afs.DisplayName;
                }

                //default index for the selected columns)
                if (this.Field.Content.IsNew)
                {
                    column.Index = ind++;
                }

                //add index numbers for selected columns
                _columnIndexList.Add(index++);
            }

            foreach (var fs in AvailableFields)
            {
                if (fieldTitles.Contains(fs.DisplayName))
                {
                    duplicatedTitles.Add(fs.DisplayName);
                }
                else
                {
                    fieldTitles.Add(fs.DisplayName);
                }

                if (_columns.Any(c => c.BindingName == fs.BindingName))
                {
                    continue;
                }

                //add index numbers for remaining columns
                _columnIndexList.Add(index++);

                var col = new Column
                {
                    Title       = (string.IsNullOrEmpty(fs.DisplayName) ? fs.Name : fs.DisplayName),
                    FullName    = fs.FullName,
                    BindingName = fs.BindingName,
                    Index       = 1,
                    Selected    = false
                };

                if (_advancedFieldNames.Contains(fs.BindingName))
                {
                    advancedCols.Add(col);
                }
                else
                {
                    unusedCols.Add(col);
                }
            }

            unusedCols.Sort(CompareColumns);
            advancedCols.Sort(CompareColumns);

            //default column indexes: 1,2,3,...
            ind = _columns.Count + 1;
            foreach (var col in unusedCols)
            {
                col.Index = ind++;
            }

            foreach (var col in advancedCols)
            {
                col.Index = ind++;
            }

            _columns.AddRange(unusedCols);
            _columnsAdvanced.AddRange(advancedCols);

            foreach (var dupTitle in duplicatedTitles)
            {
                foreach (var column in _columns.Where(cc => cc.Title == dupTitle))
                {
                    var fs = this.AvailableFields.FirstOrDefault(af => af.FullName == column.FullName);
                    if (fs == null)
                    {
                        continue;
                    }

                    column.Title = column.Title + string.Format(" ({0})", ContentRepository.Content.Create(fs.Owner).DisplayName);
                }

                foreach (var column in _columnsAdvanced.Where(cc => cc.Title == dupTitle))
                {
                    var fs = this.AvailableFields.FirstOrDefault(af => af.FullName == column.FullName);
                    if (fs == null)
                    {
                        continue;
                    }

                    column.Title = column.Title + string.Format(" ({0})", ContentRepository.Content.Create(fs.Owner).DisplayName);
                }
            }
        }