Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions dist/angular-patternfly.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', ["c3ChartDefaul
$scope.config.tooltip = donutTooltip(scope);
};

$scope.config = $.extend(true, c3ChartDefaults.getDefaultDonutConfig(), $scope.config);
$scope.config = angular.merge({}, c3ChartDefaults.getDefaultDonutConfig(), $scope.config);
$scope.updateAll($scope);
}
],
Expand Down Expand Up @@ -867,6 +867,7 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', ["c3ChartDefaul
* <ul style='list-style-type: none'>
* <li>.xData - Array, X values for the data points, first element must be the name of the data
* <li>.yData - Array, Y Values for the data points, first element must be the name of the data
* <li>.total - (optional) The Total amount, used when determining percentages
* </ul>
*
* @param {int=} chartHeight height of the sparkline chart
Expand Down Expand Up @@ -1121,7 +1122,7 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau
$scope.defaultConfig.units = '';

// Override defaults with callers specifications
$scope.config = $.extend(true, angular.copy($scope.defaultConfig), $scope.config);
$scope.config = angular.merge({},$scope.defaultConfig, $scope.config);

// Convert the given data to C3 chart format
$scope.config.data = $scope.getSparklineData($scope.chartData);
Expand All @@ -1130,7 +1131,7 @@ angular.module('patternfly.charts').directive('pfSparklineChart', ["c3ChartDefau

link: function (scope) {
scope.$watch('config', function () {
scope.config = $.extend(true, angular.copy(scope.defaultConfig), scope.config);
scope.config = angular.merge({}, scope.defaultConfig, scope.config);
}, true);
scope.$watch('chartHeight', function () {
scope.config.size.height = scope.chartHeight;
Expand Down Expand Up @@ -1674,7 +1675,7 @@ angular.module('patternfly.filters').directive('pfSimpleFilter',
};

$scope.setupConfig = function () {
$scope.config = $.extend(true, angular.copy(defaultConfig), $scope.config);
$scope.config = angular.merge({}, defaultConfig, $scope.config);

if (!$scope.currentField) {
$scope.currentField = $scope.config.fields[0];
Expand Down Expand Up @@ -2998,7 +2999,7 @@ angular.module('patternfly.views').directive('pfDataList', [
onDblClick: null
};

$scope.config = $.extend(true, angular.copy($scope.defaultConfig), $scope.config);
$scope.config = angular.merge({}, $scope.defaultConfig, $scope.config);
if ($scope.config.selectItems && $scope.config.showSelectBox) {
throw new Error('pfDataList - ' +
'Illegal use of pfDataList directive! ' +
Expand All @@ -3009,7 +3010,7 @@ angular.module('patternfly.views').directive('pfDataList', [

link: function (scope, element, attrs) {
attrs.$observe('config', function () {
scope.config = $.extend(true, angular.copy(scope.defaultConfig), scope.config);
scope.config = angular.merge({}, scope.defaultConfig, scope.config);
if (!scope.config.selectItems) {
scope.config.selectedItems = [];
}
Expand Down Expand Up @@ -3324,7 +3325,7 @@ angular.module('patternfly.views').directive('pfDataTiles', [
onDblClick: null
};

$scope.config = $.extend(true, angular.copy($scope.defaultConfig), $scope.config);
$scope.config = angular.merge({}, $scope.defaultConfig, $scope.config);
if ($scope.config.selectItems && $scope.config.showSelectBox) {
throw new Error('pfDataTiles - ' +
'Illegal use of pfDataTiles directive! ' +
Expand All @@ -3333,7 +3334,7 @@ angular.module('patternfly.views').directive('pfDataTiles', [
}],
link: function (scope, element, attrs) {
attrs.$observe('config', function () {
scope.config = $.extend(true, angular.copy(scope.defaultConfig), scope.config);
scope.config = angular.merge({}, scope.defaultConfig, scope.config);
if (!scope.config.selectItems) {
scope.config.selectedItems = [];
}
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-patternfly.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/charts/donut/donut-pct-chart-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', function (c3Cha
$scope.config.tooltip = donutTooltip(scope);
};

$scope.config = $.extend(true, c3ChartDefaults.getDefaultDonutConfig(), $scope.config);
$scope.config = angular.merge({}, c3ChartDefaults.getDefaultDonutConfig(), $scope.config);
$scope.updateAll($scope);
}
],
Expand Down
5 changes: 3 additions & 2 deletions src/charts/sparkline/sparkline-chart.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* <ul style='list-style-type: none'>
* <li>.xData - Array, X values for the data points, first element must be the name of the data
* <li>.yData - Array, Y Values for the data points, first element must be the name of the data
* <li>.total - (optional) The Total amount, used when determining percentages
* </ul>
*
* @param {int=} chartHeight height of the sparkline chart
Expand Down Expand Up @@ -286,7 +287,7 @@ angular.module('patternfly.charts').directive('pfSparklineChart', function (c3Ch
$scope.defaultConfig.units = '';

// Override defaults with callers specifications
$scope.config = $.extend(true, angular.copy($scope.defaultConfig), $scope.config);
$scope.config = angular.merge({},$scope.defaultConfig, $scope.config);

// Convert the given data to C3 chart format
$scope.config.data = $scope.getSparklineData($scope.chartData);
Expand All @@ -295,7 +296,7 @@ angular.module('patternfly.charts').directive('pfSparklineChart', function (c3Ch

link: function (scope) {
scope.$watch('config', function () {
scope.config = $.extend(true, angular.copy(scope.defaultConfig), scope.config);
scope.config = angular.merge({}, scope.defaultConfig, scope.config);
}, true);
scope.$watch('chartHeight', function () {
scope.config.size.height = scope.chartHeight;
Expand Down
2 changes: 1 addition & 1 deletion src/filters/simple-filter-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ angular.module('patternfly.filters').directive('pfSimpleFilter',
};

$scope.setupConfig = function () {
$scope.config = $.extend(true, angular.copy(defaultConfig), $scope.config);
$scope.config = angular.merge({}, defaultConfig, $scope.config);

if (!$scope.currentField) {
$scope.currentField = $scope.config.fields[0];
Expand Down
4 changes: 2 additions & 2 deletions src/views/datalist/data-list-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ angular.module('patternfly.views').directive('pfDataList', [
onDblClick: null
};

$scope.config = $.extend(true, angular.copy($scope.defaultConfig), $scope.config);
$scope.config = angular.merge({}, $scope.defaultConfig, $scope.config);
if ($scope.config.selectItems && $scope.config.showSelectBox) {
throw new Error('pfDataList - ' +
'Illegal use of pfDataList directive! ' +
Expand All @@ -233,7 +233,7 @@ angular.module('patternfly.views').directive('pfDataList', [

link: function (scope, element, attrs) {
attrs.$observe('config', function () {
scope.config = $.extend(true, angular.copy(scope.defaultConfig), scope.config);
scope.config = angular.merge({}, scope.defaultConfig, scope.config);
if (!scope.config.selectItems) {
scope.config.selectedItems = [];
}
Expand Down
4 changes: 2 additions & 2 deletions src/views/datatiles/data-tiles-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ angular.module('patternfly.views').directive('pfDataTiles', [
onDblClick: null
};

$scope.config = $.extend(true, angular.copy($scope.defaultConfig), $scope.config);
$scope.config = angular.merge({}, $scope.defaultConfig, $scope.config);
if ($scope.config.selectItems && $scope.config.showSelectBox) {
throw new Error('pfDataTiles - ' +
'Illegal use of pfDataTiles directive! ' +
Expand All @@ -228,7 +228,7 @@ angular.module('patternfly.views').directive('pfDataTiles', [
},
link: function (scope, element, attrs) {
attrs.$observe('config', function () {
scope.config = $.extend(true, angular.copy(scope.defaultConfig), scope.config);
scope.config = angular.merge({}, scope.defaultConfig, scope.config);
if (!scope.config.selectItems) {
scope.config.selectedItems = [];
}
Expand Down
4 changes: 2 additions & 2 deletions test/charts/sparkline/sparkline-chart.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('Directive: pfSparklineChart', function() {

expect(isolateScope.config.data.x).toBe("dates");
expect(isolateScope.config.data.columns.length).toBe(2);
expect(isolateScope.config.data.columns[0][1]).toBe($scope.data.xData[1]);
expect(isolateScope.config.data.columns[0][1].toString()).toBe($scope.data.xData[1].toString());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the toString() necessary after these changes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the unit test was checking that the actual javascript objects were the same, after the change:
'+' scope.config = angular.merge({}, scope.defaultConfig, scope.config);
'-' scope.config = $.extend(true, angular.copy(scope.defaultConfig), scope.config);
They don't appear to be, even though their contents are the same. To me the angular.merge and the $.extend cmds should result in new javascript objects, so I'm not sure why/what is different between the commands. In other words, I wouldn't think the 'toString()' would be neccesary.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank makes sense, thanks for the explanation.

expect(isolateScope.config.data.columns[1][1]).toBe('10');

var now = new Date();
Expand All @@ -114,7 +114,7 @@ describe('Directive: pfSparklineChart', function() {

$scope.$digest();

expect(isolateScope.config.data.columns[0][1]).toBe(now);
expect(isolateScope.config.data.columns[0][1].toString()).toBe(now.toString());
expect(isolateScope.config.data.columns[1][1]).toBe('1000');
});

Expand Down