Skip to content

Commit 1e31fb9

Browse files
Walden Rainesehelms
Walden Raines
authored andcommittedJun 5, 2013
Systems: adding scaffolding for nutupane bulk actions.
1 parent b351354 commit 1e31fb9

File tree

9 files changed

+1117
-16
lines changed

9 files changed

+1117
-16
lines changed
 

‎app/assets/javascripts/common/experimental/katello_experimental.js

+39-4
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,54 @@
1919
* Base module that defines the Katello module namespace and includes any thirdparty
2020
* modules used by the application.
2121
*/
22-
var Katello = angular.module('Katello', ['alchemy', 'alch-templates', 'ngSanitize', 'infinite-scroll']);
22+
var Katello = angular.module('Katello', ['alchemy', 'alch-templates', 'ngSanitize', 'infinite-scroll', 'ui.compat']);
2323

2424
/**
2525
* @ngdoc config
2626
* @name Katello.config
2727
*
2828
* @requires $httpProvider
29-
* @requires $locationProvider
29+
* @requires $stateProvider
3030
*
3131
* @description
3232
* Used for establishing application wide configuration such as adding the Rails CSRF token
33-
* to every request.
33+
* to every request and setting up the ui state machine.
3434
*/
35-
Katello.config(['$httpProvider', '$locationProvider', function($httpProvider, $locationProvider){
35+
Katello.config(['$httpProvider', '$stateProvider', function($httpProvider, $stateProvider){
3636
$httpProvider.defaults.headers.common['X-CSRF-TOKEN'] = $('meta[name=csrf-token]').attr('content');
37+
38+
$stateProvider.state('systems', {
39+
views: {
40+
'@': {
41+
controller: 'SystemsController'
42+
}
43+
}
44+
});
45+
46+
$stateProvider.state('systems.alter-content', {
47+
views: {
48+
'@': {
49+
controller: 'SystemsBulkActionController',
50+
templateUrl: 'views/systems/alter-content-bulk.html'
51+
}
52+
}
53+
});
54+
55+
$stateProvider.state('systems.alter-system-groups', {
56+
views: {
57+
'@': {
58+
controller: 'SystemsBulkActionController',
59+
templateUrl: 'views/systems/alter-systems-group-bulk.html'
60+
}
61+
}
62+
});
63+
64+
$stateProvider.state('systems.bulk-delete', {
65+
views: {
66+
'@': {
67+
controller: 'SystemsBulkActionController',
68+
templateUrl: 'views/systems/systems-delete-bulk.html'
69+
}
70+
}
71+
});
3772
}]);

‎app/assets/javascripts/common/vendor.js

+1
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@
3737
//= require "ui_alchemy/alchemy/alchemy"
3838
//= require "ui_alchemy/alchemy-tables/alchemy-tables"
3939
//= require "ui_alchemy/alchemy-header/alchemy-header"
40+
//= require "angular-ui-states"

‎app/assets/javascripts/systems/systems.controller.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@
2020
* @requires $location
2121
* @requires $compile
2222
* @requires $http
23+
* @requires $state
2324
*
2425
* @description
2526
* Provides the functionality specific to Systems for use with the Nutupane UI pattern.
2627
* Defines the columns to display and the transform function for how to generate each row
2728
* within the table.
2829
*/
2930
angular.module('Katello').controller('SystemsController',
30-
['$scope', 'Nutupane', '$location', '$compile', '$filter', '$http',
31-
function($scope, Nutupane, $location, $compile, $filter, $http) {
31+
['$scope', 'Nutupane', '$location', '$compile', '$filter', '$http', '$state',
32+
function($scope, Nutupane, $location, $compile, $filter, $http, $state) {
3233

3334
var columns = [{
3435
id: 'name',
@@ -138,6 +139,15 @@ angular.module('Katello').controller('SystemsController',
138139
});
139140
};
140141

142+
/**
143+
* Fill the right pane with the specified state.
144+
* @param state the state to fill the right pane with.
145+
*/
146+
$scope.fillRightPaneWithState = function(state) {
147+
$scope.table.openRightPane();
148+
$state.transitionTo(state);
149+
};
150+
141151
Nutupane.default_item_url = function(id) {
142152
return KT.routes.edit_system_path(id);
143153
};
@@ -149,3 +159,11 @@ angular.module('Katello').controller('SystemsController',
149159
});
150160
}]
151161
);
162+
163+
angular.module('Katello').controller('SystemsBulkActionController',
164+
['$scope',
165+
function($scope) {
166+
// To be used for all bulk actions rather than have a separate controller
167+
// for each.
168+
}]
169+
);

‎app/assets/javascripts/widgets/nutupane.js

+22-8
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ angular.module('Katello').factory('Nutupane', ['$location', '$http', 'current_or
6666
data: {},
6767
offset: 0,
6868
visible: true,
69+
collapsed: false,
6970
detailsVisible: false,
71+
newPaneVisible: false,
7072
total: 0,
7173
search_string: $location.search().search,
7274
loading_more: false
@@ -178,13 +180,12 @@ angular.module('Katello').factory('Nutupane', ['$location', '$http', 'current_or
178180
*/
179181
Nutupane.table.setDetailsVisibility = function(visibility) {
180182
var table = Nutupane.table;
181-
182183
if (visibility) {
183184
// Remove all columns except name and replace them with the details pane
184185
table.data.columns = shownColums;
186+
table.openRightPane();
185187
} else {
186-
// Restore the former columns
187-
table.data.columns = allColumns;
188+
table.closeRightPane();
188189
}
189190

190191
table.detailsVisible = visibility;
@@ -203,13 +204,27 @@ angular.module('Katello').factory('Nutupane', ['$location', '$http', 'current_or
203204
Nutupane.table.newPaneVisible = visibility;
204205
};
205206

206-
Nutupane.table.close_item = function () {
207+
Nutupane.table.close_item = function() {
207208
Nutupane.table.setDetailsVisibility(false);
208-
// Restore the former columns
209-
Nutupane.table.data.columns = allColumns;
210209
$location.search('item', '');
211210
};
212211

212+
/**
213+
* Open the right pane by removing all but the name column.
214+
*/
215+
Nutupane.table.openRightPane = function() {
216+
Nutupane.table.collapsed = true;
217+
Nutupane.table.data.columns = nameColumn;
218+
};
219+
220+
/**
221+
* Close the right pane by restoring the table columns.
222+
*/
223+
Nutupane.table.closeRightPane = function() {
224+
Nutupane.table.collapsed = false;
225+
Nutupane.table.data.columns = allColumns;
226+
};
227+
213228
Nutupane.table.select_item = function(url, id){
214229
var item,
215230
table = Nutupane.table;
@@ -241,8 +256,7 @@ angular.module('Katello').factory('Nutupane', ['$location', '$http', 'current_or
241256
table.active_item.selected = true;
242257
rowSelect = false;
243258
}
244-
245-
table.active_item.html = response.data;
259+
Nutupane.table.active_item.html = response.data;
246260
Nutupane.table.setDetailsVisibility(true);
247261
});
248262
};

‎app/views/systems/index_nutupane.html.haml

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77
%div{ 'alch-table-toolbar' => 'table' }
88
%button.primary{'ng-click' => 'createNewSystem()'}
99
= _("Create New System")
10-
%button{'ng-click' => 'removeSelectedSystems()', 'ng-show' => 'table.num_selected > 0'}
10+
%button{'ng-click' => 'fillRightPaneWithState("systems.alter-content")', 'ng-disabled' => 'table.num_selected == 0'}
11+
= _("Alter Content")
12+
%button{'ng-click' => 'fillRightPaneWithState("systems.alter-system-groups")', 'ng-disabled' => 'table.num_selected == 0'}
13+
= _("Alter System Group(s)")
14+
%button{'ng-click' => 'fillRightPaneWithState("systems.bulk-delete")', 'ng-disabled' => 'table.num_selected == 0'}
1115
= _("Delete")
12-
%table#nutupane-table.table.stable.stripe-row{ 'alch-table' => 'table', 'row-select' => 'true', 'ng-class' => '{ "table-mask" : table.working, "details-visible": table.detailsVisible}' }
16+
%table#nutupane-table.table.stable.stripe-row{ 'alch-table' => 'table', 'row-select' => 'true', 'ng-class' => '{ "table-mask" : table.working, "details-visible": table.collapsed}' }
1317
%div#nutupane-new-item.nutupane-pane{'ng-show' => 'table.newPaneVisible', 'ng-cloak' => true}
1418
%a.fr{ 'ng-click' => 'table.setNewItemVisibility(false)' }
1519
= 'x'
1620
%div.nutupane-pane-content
1721
%span.nutupane-details.panel.nutupane-pane#nutupane-details{ 'nutupane-details'=>'table.detailsVisible', 'model'=>'table', 'ng-class' => '{ "nutupane-details-open" : model.detailsVisible }' }
22+
%span.nutupane-details.panel.nutupane-pane{ 'ui-view' => true, 'ng-class' => '{ "nutupane-details-open" : table.collapsed }' }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<form>
2+
This will be the form to alter system content.
3+
</form>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<form>
2+
This will be the form to add/remove systems to system groups.
3+
</form>
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<form>
2+
This will be the form to bulk delete systems.
3+
</form>
4+

0 commit comments

Comments
 (0)