You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/05/12 22:49:23 UTC
[6/7] ambari git commit: AMBARI-11080. Fields in UI are not ordered
even when specifying (category) index in site_properties.js (alexantonenko)
AMBARI-11080. Fields in UI are not ordered even when specifying (category) index in site_properties.js (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/bcfffdb5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bcfffdb5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bcfffdb5
Branch: refs/heads/trunk
Commit: bcfffdb55ad182d8c816b45cd5df3fc7a13f2b74
Parents: f085f59
Author: Alex Antonenko <hi...@gmail.com>
Authored: Tue May 12 21:24:12 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Tue May 12 23:48:37 2015 +0300
----------------------------------------------------------------------
.../configs/service_configs_by_category_view.js | 8 ++-
.../service_configs_by_category_view_test.js | 62 ++++++++++++++++++++
2 files changed, 68 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/bcfffdb5/ambari-web/app/views/common/configs/service_configs_by_category_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/service_configs_by_category_view.js b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
index ab2a498..2e9e6e5 100644
--- a/ambari-web/app/views/common/configs/service_configs_by_category_view.js
+++ b/ambari-web/app/views/common/configs/service_configs_by_category_view.js
@@ -44,9 +44,13 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
* @type {Array}
*/
categoryConfigs: function () {
- var categoryConfigs = this.get('categoryConfigsAll');
+ // sort content type configs, sort the rest of configs based on index and then add content array at the end (as intended)
+ var categoryConfigs = this.get('categoryConfigsAll'),
+ contentOrderedArray = this.orderContentAtLast(categoryConfigs.filterProperty('displayType','content')),
+ contentFreeConfigs = categoryConfigs.filter(function(config) {return config.get('displayType')!=='content';}),
+ indexOrdered = this.sortByIndex(contentFreeConfigs);
- return this.orderContentAtLast(this.sortByIndex(categoryConfigs)).filterProperty('isVisible', true);
+ return indexOrdered.concat(contentOrderedArray).filterProperty('isVisible', true);
}.property('categoryConfigsAll.@each.isVisible').cacheable(),
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/bcfffdb5/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js b/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
index aeae18b..30f1749 100644
--- a/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
+++ b/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js
@@ -521,4 +521,66 @@ describe('App.ServiceConfigsByCategoryView', function () {
});
+ describe('#categoryConfigs', function () {
+ var view,
+ result = [1,2,3,4,5],
+ cases = [
+ {
+ categoryNname: 'TestCategory',
+ serviceConfigs: [
+ Em.Object.create({category: "TestCategory", index: 1, name: "a", isVisible: true, resultId: 1}),
+ Em.Object.create({category: "TestCategory", index: 2, name: "b", isVisible: true, resultId: 2}),
+ Em.Object.create({category: "TestCategory", index: 5, name: "c", isVisible: true, resultId: 5}),
+ Em.Object.create({category: "TestCategory", index: 4, name: "d", isVisible: true, resultId: 4}),
+ Em.Object.create({category: "TestCategory", index: 3, name: "e", isVisible: true, resultId: 3})
+ ],
+ title: 'Order by index with no content type'
+ },
+ {
+ categoryNname: 'TestCategory',
+ serviceConfigs: [
+ Em.Object.create({category: "TestCategory", index: 1, name: "a", isVisible: true, resultId: 1, displayType: 'int'}),
+ Em.Object.create({category: "TestCategory", index: 2, name: "b", isVisible: true, resultId: 4, displayType: 'content'}),
+ Em.Object.create({category: "TestCategory", index: 3, name: "c", isVisible: true, resultId: 2}),
+ Em.Object.create({category: "TestCategory", index: 4, name: "d", isVisible: true, resultId: 5, displayType: 'content'}),
+ Em.Object.create({category: "TestCategory", index: 5, name: "e", isVisible: true, resultId: 3})
+ ],
+ title: 'Order configs by index and display type equal to content'
+ },
+ {
+ categoryNname: 'TestCategory',
+ serviceConfigs: [
+ Em.Object.create({category: "TestCategory", name: "a", isVisible: true, resultId: 1, displayType: 'content'}),
+ Em.Object.create({category: "TestCategory", name: "b", isVisible: true, resultId: 2, displayType: 'content'}),
+ Em.Object.create({category: "TestCategory", name: "c", isVisible: true, resultId: 3, displayType: 'content'}),
+ Em.Object.create({category: "TestCategory", name: "d", isVisible: true, resultId: 4, displayType: 'content'}),
+ Em.Object.create({category: "TestCategory", name: "e", isVisible: true, resultId: 5, displayType: 'content'})
+ ],
+ title: 'Order configs by display type equal to content - so they will be sorted alphabetically'
+ },
+ {
+ categoryNname: 'TestCategory',
+ serviceConfigs: [
+ Em.Object.create({category: "TestCategory", index: 5, name: "a", isVisible: true, resultId: 1, displayType: 'content'}),
+ Em.Object.create({category: "TestCategory", index: 4, name: "b", isVisible: true, resultId: 2, displayType: 'content'}),
+ Em.Object.create({category: "TestCategory", index: 3, name: "c", isVisible: true, resultId: 3, displayType: 'content'}),
+ Em.Object.create({category: "TestCategory", index: 2, name: "d", isVisible: true, resultId: 4, displayType: 'content'}),
+ Em.Object.create({category: "TestCategory", index: 1, name: "e", isVisible: true, resultId: 5, displayType: 'content'})
+ ],
+ title: 'Order configs by display type equal to content - so they will be sorted alphabetically not by index'
+ }
+ ];
+
+ cases.forEach(function (item) {
+ it(item.title, function () {
+ view = App.ServiceConfigsByCategoryView.create({
+ category: {
+ name: item.categoryNname
+ },
+ serviceConfigs: item.serviceConfigs
+ });
+ expect(view.get('categoryConfigs').mapProperty('resultId')).to.deep.equal(result);
+ });
+ });
+ });
});