FLEX-34852 Introducing ComplexSortField to specify that a sort field name is actually a chain of properties separated by a dot (e.g. "address.name"). This was necessary because, as Alex H pointed out, one can add a property with a dot onto a dynamic object, and developers should still be able to sort by it using the existing algorithm.
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/bf6d0693 Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/bf6d0693 Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/bf6d0693 Branch: refs/heads/develop Commit: bf6d0693c842091a3e8f97c267e6ddad5ab7d940 Parents: 7cd1b3b Author: Mihai Chira <[email protected]> Authored: Sun Jun 7 12:58:11 2015 +0200 Committer: Mihai Chira <[email protected]> Committed: Sun Jun 7 12:58:11 2015 +0200 ---------------------------------------------------------------------- .../src/mx/collections/ComplexSortField.as | 37 ++++++++++++++++++++ .../framework/tests/FLEX_34852_Tests.as | 4 +-- 2 files changed, 39 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/bf6d0693/frameworks/projects/framework/src/mx/collections/ComplexSortField.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/src/mx/collections/ComplexSortField.as b/frameworks/projects/framework/src/mx/collections/ComplexSortField.as new file mode 100644 index 0000000..6c9a27b --- /dev/null +++ b/frameworks/projects/framework/src/mx/collections/ComplexSortField.as @@ -0,0 +1,37 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package mx.collections { + import mx.utils.ObjectUtil; + + public class ComplexSortField extends SortField + { + + private var _nameParts:Array; + + public function ComplexSortField(name:String = null, + caseInsensitive:Boolean = false, + descending:Boolean = false, + numeric:Object = null) + { + super(name, caseInsensitive, descending, numeric); + _nameParts = name.split("."); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/bf6d0693/frameworks/projects/framework/tests/FLEX_34852_Tests.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/tests/FLEX_34852_Tests.as b/frameworks/projects/framework/tests/FLEX_34852_Tests.as index 3a66221..4a9b1ee 100644 --- a/frameworks/projects/framework/tests/FLEX_34852_Tests.as +++ b/frameworks/projects/framework/tests/FLEX_34852_Tests.as @@ -19,10 +19,10 @@ package { import mx.collections.ArrayList; + import mx.collections.ComplexSortField; import mx.collections.IList; import mx.collections.ListCollectionView; import mx.collections.Sort; - import mx.collections.SortField; import org.flexunit.asserts.assertEquals; @@ -49,7 +49,7 @@ package { _sut.addAll(from4To0); //values["address.street"]: Street4, Street3, Street2, Street1, Street0 const sortByIndexAscending:Sort = new Sort(); - sortByIndexAscending.fields = [new SortField("address.street", false, false, false)]; + sortByIndexAscending.fields = [new ComplexSortField("address.street", false, false, false)]; _sut.sort = sortByIndexAscending; //when
