Skip to content

Commit f5fa33f

Browse files
Fix for regression from angular-dashboard-framework/angular-dashboard-framework@816ab40 which broke `categories` feature.
1 parent ec38c84 commit f5fa33f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/scripts/dashboard.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,17 @@ angular.module('adf')
253253
*/
254254
function createCategories(widgets){
255255
var categories = {};
256-
angular.forEach(widgets, function(widget){
256+
angular.forEach(widgets, function(widget, key){
257257
var category = widget.category;
258258
// if the widget has no category use a default one
259259
if (!category){
260260
category = 'Miscellaneous';
261261
}
262262
// push widget to category array
263-
if (!categories[category]){
264-
categories[category] = [];
263+
if (angular.isUndefined(categories[category])){
264+
categories[category] = {widgets: {}};
265265
}
266-
categories[category].push(widget);
266+
categories[category].widgets[key] = widget;
267267
});
268268
return categories;
269269
}

src/templates/widget-add.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ <h4 class="modal-title" ng-bind="translate('ADF_WIDGET_ADD_HEADER')">Add new wid
88
<uib-accordion ng-init="categorized = createCategories(widgets)">
99
<uib-accordion-group heading="{{category.name}}" ng-repeat="category in categorized | adfOrderByObjectKey: 'name'">
1010
<dl class="dl-horizontal">
11-
<dt ng-repeat-start="widget in category | adfOrderByObjectKey: 'key'">
12-
<a href="" ng-click="addWidget(key)">
11+
<dt ng-repeat-start="widget in category.widgets | adfOrderByObjectKey: 'key'">
12+
<a href="" ng-click="addWidget(widget.key)">
1313
{{widget.title}}
1414
</a>
1515
</dt>

test/unit/dashboardSpec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ describe('Dashboard Directive tests', function () {
340340

341341
// create categories and test
342342
var categories = scope.createCategories(widgets);
343-
expect(categories.a.length).toBe(2);
344-
expect(categories.b.length).toBe(1);
345-
expect(categories.Miscellaneous.length).toBe(1);
343+
expect(Object.keys(categories.a.widgets).length).toBe(2);
344+
expect(Object.keys(categories.b.widgets).length).toBe(1);
345+
expect(Object.keys(categories.Miscellaneous.widgets).length).toBe(1);
346346
});
347347

348348
it('should close add widget dialog', function(){

0 commit comments

Comments
 (0)