bastion 4.3.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/bastion/bastion-bootstrap.js +0 -1
- data/app/assets/javascripts/bastion/bastion.js +0 -1
- data/app/assets/javascripts/bastion/components/bst-on-enter.directive.js +1 -0
- data/app/assets/javascripts/bastion/components/nutupane.factory.js +95 -61
- data/app/assets/javascripts/bastion/layouts/partials/table.html +63 -21
- data/app/assets/javascripts/bastion/utils/round-up.filter.js +20 -0
- data/app/assets/stylesheets/bastion/nutupane.scss +0 -4
- data/app/assets/stylesheets/bastion/overrides.scss +5 -0
- data/app/assets/stylesheets/bastion/tables.scss +8 -0
- data/app/views/bastion/layouts/assets.html.erb +1 -0
- data/bower.json +0 -4
- data/grunt/karma.js +0 -1
- data/lib/bastion/version.rb +1 -1
- data/test/components/nutupane.factory.test.js +114 -48
- data/test/utils/round-up.filter.test.js +14 -0
- metadata +5 -11
- data/app/assets/javascripts/bastion/components/bst-container-scroll.directive.js +0 -74
- data/app/assets/javascripts/bastion/components/nutupane-table.directive.js +0 -69
- data/app/assets/javascripts/bastion/layouts/details-nutupane.html +0 -89
- data/app/assets/javascripts/bastion/layouts/nutupane.html +0 -93
- data/test/components/bst-container-scroll.directive.test.js +0 -63
- data/test/components/bst-nutupane-table.directive.test.js +0 -55
- data/vendor/assets/javascripts/bastion/ngInfiniteScroll/ng-infinite-scroll.js +0 -186
@@ -4,12 +4,15 @@ describe('Factory: Nutupane', function() {
|
|
4
4
|
$rootScope,
|
5
5
|
Resource,
|
6
6
|
TableCache,
|
7
|
+
entriesPerPage,
|
7
8
|
expectedResult,
|
8
9
|
Nutupane;
|
9
10
|
|
10
11
|
beforeEach(module('Bastion.components'));
|
11
12
|
|
12
13
|
beforeEach(module(function ($provide) {
|
14
|
+
entriesPerPage = 20;
|
15
|
+
|
13
16
|
TableCache = {
|
14
17
|
getTable: function () {
|
15
18
|
},
|
@@ -19,20 +22,24 @@ describe('Factory: Nutupane', function() {
|
|
19
22
|
}
|
20
23
|
};
|
21
24
|
|
25
|
+
$provide.value('entriesPerPage', entriesPerPage);
|
22
26
|
$provide.value('TableCache', TableCache);
|
23
27
|
}));
|
24
28
|
|
25
29
|
beforeEach(module(function() {
|
26
|
-
expectedResult = [{id: 2, value: "value2"}, {id:3, value: "value3"}
|
30
|
+
expectedResult = [{id: 2, value: "value2"}, {id:3, value: "value3"},
|
31
|
+
{id: 4, value: "value4"}, {id:5, value: "value5"}];
|
27
32
|
Resource = {
|
28
33
|
queryPaged: function(params, callback) {
|
29
|
-
var result = {results: expectedResult};
|
34
|
+
var result = {page: 1, results: expectedResult, subtotal: 8, per_page: 2};
|
30
35
|
if (callback) {
|
31
36
|
callback(result);
|
32
37
|
}
|
33
38
|
return result;
|
34
39
|
},
|
35
40
|
customAction: function() {},
|
41
|
+
page: 1,
|
42
|
+
per_page: 2,
|
36
43
|
total: 10,
|
37
44
|
subtotal: 8,
|
38
45
|
offset: 5,
|
@@ -66,15 +73,58 @@ describe('Factory: Nutupane', function() {
|
|
66
73
|
});
|
67
74
|
|
68
75
|
it("providing a method to fetch records for the table", function() {
|
69
|
-
var expected = nutupane.table.rows.concat(expectedResult);
|
70
|
-
|
71
76
|
spyOn(Resource, 'queryPaged').and.callThrough();
|
72
77
|
nutupane.query();
|
73
78
|
|
74
79
|
expect(Resource.queryPaged).toHaveBeenCalled();
|
75
80
|
expect(nutupane.table.rows.length).toBe(4);
|
76
81
|
angular.forEach(nutupane.table.rows, function(value, index) {
|
77
|
-
expect(value).toBe(
|
82
|
+
expect(value).toBe(expectedResult[index]);
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
86
|
+
describe("sets query string params of the table's properties", function () {
|
87
|
+
beforeEach(function () {
|
88
|
+
spyOn($location, 'search').and.callThrough();
|
89
|
+
});
|
90
|
+
|
91
|
+
it("if paged", function () {
|
92
|
+
nutupane.table.params.paged = true;
|
93
|
+
nutupane.load();
|
94
|
+
expect($location.search).toHaveBeenCalledWith('page', 1);
|
95
|
+
expect($location.search).toHaveBeenCalledWith('per_page', 20);
|
96
|
+
});
|
97
|
+
|
98
|
+
it("but does not include page information if not paged", function () {
|
99
|
+
nutupane.table.params.paged = false;
|
100
|
+
nutupane.load();
|
101
|
+
expect($location.search).not.toHaveBeenCalledWith('page', jasmine.any);
|
102
|
+
expect($location.search).not.toHaveBeenCalledWith('per_page', jasmine.any);
|
103
|
+
});
|
104
|
+
|
105
|
+
it("by including a search if there is one", function () {
|
106
|
+
nutupane.table.searchTerm = 'hello!';
|
107
|
+
nutupane.load();
|
108
|
+
expect($location.search).toHaveBeenCalledWith('search', 'hello!');
|
109
|
+
});
|
110
|
+
|
111
|
+
it("by not including a search if there isn't one", function () {
|
112
|
+
nutupane.load();
|
113
|
+
expect($location.search).not.toHaveBeenCalledWith('search', jasmine.any);
|
114
|
+
});
|
115
|
+
|
116
|
+
it("by including the sort properties if provided", function () {
|
117
|
+
nutupane.table.params['sort_by'] = 'name';
|
118
|
+
nutupane.table.params['sort_order'] = 'asc';
|
119
|
+
nutupane.load();
|
120
|
+
expect($location.search).toHaveBeenCalledWith('sortBy', 'name');
|
121
|
+
expect($location.search).toHaveBeenCalledWith('sortOrder', 'asc');
|
122
|
+
});
|
123
|
+
|
124
|
+
it("by not including the sort properties if provided", function () {
|
125
|
+
nutupane.load();
|
126
|
+
expect($location.search).not.toHaveBeenCalledWith('sortBy', jasmine.any);
|
127
|
+
expect($location.search).not.toHaveBeenCalledWith('sortOrder', jasmine.any);
|
78
128
|
});
|
79
129
|
});
|
80
130
|
|
@@ -97,7 +147,6 @@ describe('Factory: Nutupane', function() {
|
|
97
147
|
|
98
148
|
it("providing a method to perform a search", function() {
|
99
149
|
spyOn(Resource, 'queryPaged');
|
100
|
-
nutupane.table.closeItem = function() {};
|
101
150
|
|
102
151
|
nutupane.table.search();
|
103
152
|
|
@@ -106,7 +155,6 @@ describe('Factory: Nutupane', function() {
|
|
106
155
|
|
107
156
|
it("refusing to perform a search if the table is currently fetching", function() {
|
108
157
|
spyOn(Resource, 'queryPaged');
|
109
|
-
nutupane.table.closeItem = function() {};
|
110
158
|
nutupane.table.working = true;
|
111
159
|
|
112
160
|
nutupane.table.search();
|
@@ -116,7 +164,7 @@ describe('Factory: Nutupane', function() {
|
|
116
164
|
|
117
165
|
it("setting the search parameter in the URL when performing a search", function() {
|
118
166
|
spyOn(Resource, 'queryPaged');
|
119
|
-
|
167
|
+
|
120
168
|
nutupane.table.working = true;
|
121
169
|
|
122
170
|
nutupane.table.search("Find Me");
|
@@ -133,13 +181,8 @@ describe('Factory: Nutupane', function() {
|
|
133
181
|
expect(nutupane.table.searchCompleted).toBe(true);
|
134
182
|
});
|
135
183
|
|
136
|
-
it("enforcing the user of this factory to define a closeItem function", function() {
|
137
|
-
expect(nutupane.table.closeItem).toThrow();
|
138
|
-
});
|
139
|
-
|
140
184
|
it("updates a single occurrence of a row within the list of rows.", function() {
|
141
185
|
var newRow = {id:0, value:"new value", anotherValue: "value"};
|
142
|
-
nutupane.query();
|
143
186
|
nutupane.table.replaceRow(newRow);
|
144
187
|
expect(nutupane.table.rows[0]).toBe(newRow);
|
145
188
|
});
|
@@ -162,29 +205,70 @@ describe('Factory: Nutupane', function() {
|
|
162
205
|
expect(nutupane.table.numSelected).toBe(0);
|
163
206
|
});
|
164
207
|
|
165
|
-
it("
|
166
|
-
nutupane.table.
|
167
|
-
|
208
|
+
it("provides a way to tell if on the first page", function () {
|
209
|
+
nutupane.table.firstPage();
|
210
|
+
expect(nutupane.table.onFirstPage()).toBe(true);
|
211
|
+
});
|
168
212
|
|
169
|
-
|
213
|
+
it("provides a way to tell if on the last page", function () {
|
214
|
+
spyOn(nutupane, 'load');
|
215
|
+
nutupane.table.lastPage();
|
216
|
+
expect(nutupane.table.onLastPage()).toBe(true);
|
217
|
+
expect(nutupane.load).toHaveBeenCalled();
|
218
|
+
});
|
170
219
|
|
171
|
-
|
220
|
+
it("provides a way to get the page end based on offset", function () {
|
221
|
+
expect(nutupane.table.getPageEnd()).toBe(6);
|
172
222
|
});
|
173
223
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
224
|
+
describe("provides page navigation", function () {
|
225
|
+
beforeEach(function () {
|
226
|
+
spyOn(nutupane.table, 'changePage').and.callThrough();
|
227
|
+
spyOn(nutupane, 'load');
|
228
|
+
});
|
178
229
|
|
179
|
-
|
230
|
+
afterEach(function () {
|
231
|
+
expect(nutupane.load).toHaveBeenCalled();
|
232
|
+
});
|
233
|
+
|
234
|
+
it("to the first page", function () {
|
235
|
+
nutupane.table.firstPage();
|
236
|
+
expect(nutupane.table.changePage).toHaveBeenCalledWith(1);
|
237
|
+
});
|
238
|
+
|
239
|
+
it("to the previous page", function () {
|
240
|
+
nutupane.table.params.page = 3;
|
241
|
+
nutupane.table.previousPage();
|
242
|
+
expect(nutupane.table.changePage).toHaveBeenCalledWith(2);
|
243
|
+
});
|
244
|
+
|
245
|
+
it("to the next page", function () {
|
246
|
+
nutupane.table.params.page = 3;
|
247
|
+
nutupane.table.nextPage();
|
248
|
+
expect(nutupane.table.changePage).toHaveBeenCalledWith(4);
|
249
|
+
});
|
250
|
+
|
251
|
+
it("to the last page", function () {
|
252
|
+
nutupane.table.lastPage();
|
253
|
+
expect(nutupane.table.changePage).toHaveBeenCalledWith(4);
|
254
|
+
});
|
255
|
+
|
256
|
+
it("to an arbitrary page", function () {
|
257
|
+
nutupane.table.changePage(3);
|
258
|
+
expect(nutupane.table.resource.page).toBe(3);
|
259
|
+
expect(nutupane.table.params.page).toBe(3);
|
260
|
+
});
|
180
261
|
});
|
181
262
|
|
182
|
-
it("
|
183
|
-
|
184
|
-
nutupane.table.
|
185
|
-
|
263
|
+
it("sets the array of page sizes that includes the default setting from rails", function () {
|
264
|
+
expect(nutupane.table.pageSizes).toBeDefined();
|
265
|
+
expect(nutupane.table.pageSizes).toContain(entriesPerPage);
|
266
|
+
});
|
186
267
|
|
187
|
-
|
268
|
+
it("provides a way to update the page size", function () {
|
269
|
+
spyOn(nutupane, "query");
|
270
|
+
nutupane.table.updatePageSize();
|
271
|
+
expect(nutupane.query).toHaveBeenCalled();
|
188
272
|
});
|
189
273
|
|
190
274
|
it("provides a way to add an individual row", function() {
|
@@ -294,7 +378,7 @@ describe('Factory: Nutupane', function() {
|
|
294
378
|
|
295
379
|
describe("provides a way to sort the table", function() {
|
296
380
|
it ("defaults the sort to ascending if the previous sort does not match the new sort.", function() {
|
297
|
-
var expectedParams = {sort_by: 'name', sort_order: 'ASC', search: '', page: 1};
|
381
|
+
var expectedParams = {sort_by: 'name', sort_order: 'ASC', search: '', paged: true, page: 1, per_page: entriesPerPage};
|
298
382
|
nutupane.table.resource.sort = {};
|
299
383
|
|
300
384
|
spyOn(Resource, 'queryPaged');
|
@@ -304,7 +388,7 @@ describe('Factory: Nutupane', function() {
|
|
304
388
|
});
|
305
389
|
|
306
390
|
it("toggles the sort order if already sorting by that column", function() {
|
307
|
-
var expectedParams = {sort_by: 'name', sort_order: 'DESC', search: '', page: 1};
|
391
|
+
var expectedParams = {sort_by: 'name', sort_order: 'DESC', search: '', paged: true, page: 1, per_page: entriesPerPage};
|
308
392
|
nutupane.table.resource.sort = {
|
309
393
|
by: 'name',
|
310
394
|
order: 'ASC'
|
@@ -329,23 +413,6 @@ describe('Factory: Nutupane', function() {
|
|
329
413
|
nutupane.table.sortBy({id: "name"});
|
330
414
|
expect(nutupane.query).toHaveBeenCalled();
|
331
415
|
});
|
332
|
-
|
333
|
-
describe("watches $locationChangeStart", function () {
|
334
|
-
beforeEach(function () {
|
335
|
-
nutupane.table.closeItem = function() {};
|
336
|
-
spyOn(nutupane.table, 'closeItem');
|
337
|
-
});
|
338
|
-
|
339
|
-
it("and closes the item pane if the url matches the org switcher url", function () {
|
340
|
-
$rootScope.$emit("$locationChangeStart", '/organizations/1-Default%20Organization/select');
|
341
|
-
expect(nutupane.table.closeItem).toHaveBeenCalled();
|
342
|
-
});
|
343
|
-
|
344
|
-
it("and does nothing if the URL does not match the org switcher url", function () {
|
345
|
-
$rootScope.$emit("$locationChangeStart", '/some-other-url/select');
|
346
|
-
expect(nutupane.table.closeItem).not.toHaveBeenCalled();
|
347
|
-
});
|
348
|
-
});
|
349
416
|
});
|
350
417
|
});
|
351
418
|
|
@@ -353,7 +420,6 @@ describe('Factory: Nutupane', function() {
|
|
353
420
|
beforeEach(function() {
|
354
421
|
nutupane = new Nutupane(Resource, {}, 'customAction');
|
355
422
|
nutupane.table.working = false;
|
356
|
-
nutupane.table.closeItem = function () {};
|
357
423
|
nutupane.table.allSelected = function () {};
|
358
424
|
nutupane.table.selectAll = function () {};
|
359
425
|
});
|
@@ -0,0 +1,14 @@
|
|
1
|
+
describe('Filter:roundUp', function() {
|
2
|
+
var roundUpFilter;
|
3
|
+
|
4
|
+
beforeEach(module('Bastion.utils'));
|
5
|
+
|
6
|
+
beforeEach(inject(function($filter) {
|
7
|
+
roundUpFilter = $filter('roundUp')
|
8
|
+
}));
|
9
|
+
|
10
|
+
it("should round up a value", function() {
|
11
|
+
expect(roundUpFilter('730.5')).toEqual(731);
|
12
|
+
expect(roundUpFilter('730.2')).toEqual(731);
|
13
|
+
});
|
14
|
+
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bastion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric D Helms
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-03-
|
12
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: angular-rails-templates
|
@@ -63,7 +63,6 @@ files:
|
|
63
63
|
- app/assets/javascripts/bastion/components/bst-alerts.directive.js
|
64
64
|
- app/assets/javascripts/bastion/components/bst-bookmark.directive.js
|
65
65
|
- app/assets/javascripts/bastion/components/bst-bookmark.factory.js
|
66
|
-
- app/assets/javascripts/bastion/components/bst-container-scroll.directive.js
|
67
66
|
- app/assets/javascripts/bastion/components/bst-dropdown.directive.js
|
68
67
|
- app/assets/javascripts/bastion/components/bst-edit.directive.js
|
69
68
|
- app/assets/javascripts/bastion/components/bst-flyout.directive.js
|
@@ -84,7 +83,6 @@ files:
|
|
84
83
|
- app/assets/javascripts/bastion/components/formatters/key-value-to-string.filter.js
|
85
84
|
- app/assets/javascripts/bastion/components/formatters/unlimitedFilter.filter.js
|
86
85
|
- app/assets/javascripts/bastion/components/global-notification.service.js
|
87
|
-
- app/assets/javascripts/bastion/components/nutupane-table.directive.js
|
88
86
|
- app/assets/javascripts/bastion/components/nutupane.factory.js
|
89
87
|
- app/assets/javascripts/bastion/components/page-title.directive.js
|
90
88
|
- app/assets/javascripts/bastion/components/page-title.service.js
|
@@ -139,10 +137,8 @@ files:
|
|
139
137
|
- app/assets/javascripts/bastion/i18n/translations.js
|
140
138
|
- app/assets/javascripts/bastion/i18n/zanata.xml
|
141
139
|
- app/assets/javascripts/bastion/layouts/404.html
|
142
|
-
- app/assets/javascripts/bastion/layouts/details-nutupane.html
|
143
140
|
- app/assets/javascripts/bastion/layouts/details-page-with-breadcrumbs.html
|
144
141
|
- app/assets/javascripts/bastion/layouts/full-page-details.html
|
145
|
-
- app/assets/javascripts/bastion/layouts/nutupane.html
|
146
142
|
- app/assets/javascripts/bastion/layouts/panel.html
|
147
143
|
- app/assets/javascripts/bastion/layouts/partials/full-row-breadcrumbs.html
|
148
144
|
- app/assets/javascripts/bastion/layouts/partials/messages-container.html
|
@@ -157,6 +153,7 @@ files:
|
|
157
153
|
- app/assets/javascripts/bastion/routing.module.js
|
158
154
|
- app/assets/javascripts/bastion/utils/bastion-resource.factory.js
|
159
155
|
- app/assets/javascripts/bastion/utils/form-utils.service.js
|
156
|
+
- app/assets/javascripts/bastion/utils/round-up.filter.js
|
160
157
|
- app/assets/javascripts/bastion/utils/stop-event.directive.js
|
161
158
|
- app/assets/javascripts/bastion/utils/urlencode.filter.js
|
162
159
|
- app/assets/javascripts/bastion/utils/utils.module.js
|
@@ -197,7 +194,6 @@ files:
|
|
197
194
|
- test/components/bst-alerts.directive.test.js
|
198
195
|
- test/components/bst-bookmark.directive.test.js
|
199
196
|
- test/components/bst-bookmark.factory.test.js
|
200
|
-
- test/components/bst-container-scroll.directive.test.js
|
201
197
|
- test/components/bst-dropdown.directive.test.js
|
202
198
|
- test/components/bst-edit.directive.test.js
|
203
199
|
- test/components/bst-flyout.directive.test.js
|
@@ -206,7 +202,6 @@ files:
|
|
206
202
|
- test/components/bst-global-notification.directive.test.js
|
207
203
|
- test/components/bst-menu.directive.test.js
|
208
204
|
- test/components/bst-modal.directive.test.js
|
209
|
-
- test/components/bst-nutupane-table.directive.test.js
|
210
205
|
- test/components/bst-table.directive.test.js
|
211
206
|
- test/components/formatters/array-to-string.filter.test.js
|
212
207
|
- test/components/formatters/boolean-to-yes-no.filter.test.js
|
@@ -228,6 +223,7 @@ files:
|
|
228
223
|
- test/test-mocks.module.js
|
229
224
|
- test/utils/bastion-resource.factory.test.js
|
230
225
|
- test/utils/form-utils.service.test.js
|
226
|
+
- test/utils/round-up.filter.test.js
|
231
227
|
- test/utils/stop-event.directive.test.js
|
232
228
|
- test/utils/urlencode.filter.test.js
|
233
229
|
- vendor/assets/javascripts/bastion/angular-animate/angular-animate.js
|
@@ -1742,7 +1738,6 @@ files:
|
|
1742
1738
|
- vendor/assets/javascripts/bastion/angular-uuid4/angular-uuid4.js
|
1743
1739
|
- vendor/assets/javascripts/bastion/angular/angular.js
|
1744
1740
|
- vendor/assets/javascripts/bastion/json3/json3.js
|
1745
|
-
- vendor/assets/javascripts/bastion/ngInfiniteScroll/ng-infinite-scroll.js
|
1746
1741
|
- vendor/assets/javascripts/bastion/ngUpload/ng-upload.js
|
1747
1742
|
homepage: http://www.github.com/Katello/bastion
|
1748
1743
|
licenses: []
|
@@ -1774,7 +1769,6 @@ test_files:
|
|
1774
1769
|
- test/components/bst-form-group.directive.test.js
|
1775
1770
|
- test/components/bst-table.directive.test.js
|
1776
1771
|
- test/components/page-title.directive.test.js
|
1777
|
-
- test/components/bst-nutupane-table.directive.test.js
|
1778
1772
|
- test/components/bst-menu.directive.test.js
|
1779
1773
|
- test/components/bst-alerts.directive.test.js
|
1780
1774
|
- test/components/nutupane.factory.test.js
|
@@ -1787,7 +1781,6 @@ test_files:
|
|
1787
1781
|
- test/components/page-title.service.test.js
|
1788
1782
|
- test/components/bst-bookmark.factory.test.js
|
1789
1783
|
- test/components/bst-alert.directive.test.js
|
1790
|
-
- test/components/bst-container-scroll.directive.test.js
|
1791
1784
|
- test/components/bst-bookmark.directive.test.js
|
1792
1785
|
- test/components/bst-global-notification.directive.test.js
|
1793
1786
|
- test/components/bst-flyout.directive.test.js
|
@@ -1807,3 +1800,4 @@ test_files:
|
|
1807
1800
|
- test/utils/stop-event.directive.test.js
|
1808
1801
|
- test/utils/bastion-resource.factory.test.js
|
1809
1802
|
- test/utils/urlencode.filter.test.js
|
1803
|
+
- test/utils/round-up.filter.test.js
|
@@ -1,74 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @ngdoc directive
|
3
|
-
* @name Bastion.components.directive:bstContainerScroll
|
4
|
-
* @restrict A
|
5
|
-
*
|
6
|
-
* @requires $window
|
7
|
-
* @requires $timeout
|
8
|
-
*
|
9
|
-
* @description
|
10
|
-
* The container scroll directive should be applied to a wrapping div around an element that
|
11
|
-
* you wish to have scrolling capabilities that is outside the standard browser flow.
|
12
|
-
*
|
13
|
-
* @example
|
14
|
-
* <pre>
|
15
|
-
<div bst-container-scroll></div>
|
16
|
-
</pre>
|
17
|
-
*/
|
18
|
-
angular.module('Bastion.components').directive('bstContainerScroll', ['$window', '$timeout', function ($window, $timeout) {
|
19
|
-
function getScrollBarWidth() {
|
20
|
-
var $outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'),
|
21
|
-
widthWithScroll = $('<div>').css({width: '100%'}).appendTo($outer).outerWidth();
|
22
|
-
|
23
|
-
$outer.remove();
|
24
|
-
|
25
|
-
return 100 - widthWithScroll;
|
26
|
-
}
|
27
|
-
|
28
|
-
return {
|
29
|
-
restrict: 'A',
|
30
|
-
compile: function (tElement) {
|
31
|
-
tElement.addClass("container-scroll-wrapper");
|
32
|
-
|
33
|
-
return function (scope, element) {
|
34
|
-
var windowElement = angular.element($window),
|
35
|
-
bottomPadding = parseInt(element.css('padding-bottom').replace('px', ''), 10),
|
36
|
-
addScroll, newElementHeight;
|
37
|
-
|
38
|
-
addScroll = function () {
|
39
|
-
var windowHeight = windowElement.height(),
|
40
|
-
offset = element.offset().top,
|
41
|
-
hasScrollbar;
|
42
|
-
|
43
|
-
if (bottomPadding) {
|
44
|
-
offset = offset + bottomPadding;
|
45
|
-
}
|
46
|
-
|
47
|
-
newElementHeight = windowHeight - offset;
|
48
|
-
|
49
|
-
if (newElementHeight <= 100) {
|
50
|
-
newElementHeight = 300;
|
51
|
-
}
|
52
|
-
|
53
|
-
element.outerHeight(newElementHeight);
|
54
|
-
element.height(newElementHeight);
|
55
|
-
|
56
|
-
// Normalize to 100% width before adding the scrollbar width
|
57
|
-
element.css('width', '100%');
|
58
|
-
|
59
|
-
hasScrollbar = element.children().height() > element.height();
|
60
|
-
|
61
|
-
// Set the container width based on the width of the scroll bar
|
62
|
-
if (hasScrollbar) {
|
63
|
-
element.width(element.width() + getScrollBarWidth());
|
64
|
-
}
|
65
|
-
};
|
66
|
-
|
67
|
-
windowElement.bind('resize', addScroll);
|
68
|
-
$timeout(function () {
|
69
|
-
windowElement.trigger('resize');
|
70
|
-
}, 0);
|
71
|
-
};
|
72
|
-
}
|
73
|
-
};
|
74
|
-
}]);
|
@@ -1,69 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @ngdoc directive
|
3
|
-
* @name Bastion.components.directive:nutupaneTable
|
4
|
-
* @restrict A
|
5
|
-
*
|
6
|
-
* @require $compile
|
7
|
-
*
|
8
|
-
* @description
|
9
|
-
*
|
10
|
-
* @example
|
11
|
-
*/
|
12
|
-
angular.module('Bastion.components').directive('nutupaneTable', ['$compile', '$window', function ($compile, $window) {
|
13
|
-
return {
|
14
|
-
restrict: 'A',
|
15
|
-
link: function (scope, element) {
|
16
|
-
var originalTable, clonedTable, clonedThs,
|
17
|
-
bstTableName = element.attr('bst-table'),
|
18
|
-
windowElement = angular.element($window);
|
19
|
-
|
20
|
-
function buildTable() {
|
21
|
-
var rowSelect;
|
22
|
-
|
23
|
-
element.find('.cloned-nutupane-table').remove();
|
24
|
-
|
25
|
-
originalTable = element.find('table');
|
26
|
-
clonedTable = originalTable.clone();
|
27
|
-
|
28
|
-
if (!bstTableName) {
|
29
|
-
bstTableName = element.find('[bst-table]').attr('bst-table');
|
30
|
-
}
|
31
|
-
|
32
|
-
clonedTable.attr('ng-show', bstTableName + '.rows.length > 0');
|
33
|
-
clonedTable.removeAttr("nutupane-table");
|
34
|
-
clonedTable.addClass("cloned-nutupane-table");
|
35
|
-
clonedTable.find('tbody').remove();
|
36
|
-
|
37
|
-
originalTable.find('thead').hide();
|
38
|
-
|
39
|
-
element.prepend(clonedTable);
|
40
|
-
$compile(element.find('.cloned-nutupane-table'))(scope);
|
41
|
-
|
42
|
-
// Need to remove duplicate row-select created by second $compile
|
43
|
-
rowSelect = element.find(".row-select")[0];
|
44
|
-
if (rowSelect) {
|
45
|
-
angular.element(rowSelect).remove();
|
46
|
-
}
|
47
|
-
|
48
|
-
// Compile each cloned th individually with original th scope
|
49
|
-
// so sort will work.
|
50
|
-
clonedThs = element.find('.cloned-nutupane-table th');
|
51
|
-
angular.forEach(originalTable.find('th'), function (th, index) {
|
52
|
-
$compile(clonedThs[index])(angular.element(th).scope());
|
53
|
-
});
|
54
|
-
}
|
55
|
-
|
56
|
-
scope.$on("$stateChangeSuccess", function (event, newState, newParams, oldState) {
|
57
|
-
// Only clone the table if the collapsed value changed or it's the first time.
|
58
|
-
if (newState.collapsed !== oldState.collapsed || !oldState.name) {
|
59
|
-
buildTable();
|
60
|
-
} else {
|
61
|
-
element.find("table:not(.cloned-nutupane-table)").find('thead').hide();
|
62
|
-
}
|
63
|
-
});
|
64
|
-
|
65
|
-
buildTable();
|
66
|
-
windowElement.trigger('resize');
|
67
|
-
}
|
68
|
-
};
|
69
|
-
}]);
|
@@ -1,89 +0,0 @@
|
|
1
|
-
<section>
|
2
|
-
<div data-block="messages" bst-alerts success-messages="successMessages" error-messages="errorMessages"></div>
|
3
|
-
|
4
|
-
<h4>
|
5
|
-
<span data-block="header"></span>
|
6
|
-
</h4>
|
7
|
-
|
8
|
-
<div>
|
9
|
-
<span data-block="filters"></span>
|
10
|
-
</div>
|
11
|
-
|
12
|
-
<div class="row nutupane-details-bar">
|
13
|
-
<div class="col-sm-4">
|
14
|
-
<div data-block="search">
|
15
|
-
<form role="form" class="search-pf has-button">
|
16
|
-
<div class="form-group has-clear">
|
17
|
-
<div class="search-pf-input-group">
|
18
|
-
<span data-block="search-filter"></span>
|
19
|
-
|
20
|
-
<input type="text"
|
21
|
-
class="form-control"
|
22
|
-
placeholder="{{ 'Search...' | translate }}"
|
23
|
-
ng-model="detailsTable.searchTerm"
|
24
|
-
bst-on-enter="detailsTable.search(detailsTable.searchTerm)"
|
25
|
-
ng-trim="false"
|
26
|
-
uib-typeahead="item.label for item in detailsTable.autocomplete($viewValue)"
|
27
|
-
typeahead-template-url="components/views/autocomplete-scoped-search.html"/>
|
28
|
-
|
29
|
-
<button type="button" class="clear" aria-hidden="true" ng-show="detailsTable.searchTerm" ng-click='detailsTable.clearSearch()'>
|
30
|
-
<span class="pficon pficon-close"></span>
|
31
|
-
</button>
|
32
|
-
</div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div class="form-group">
|
36
|
-
<button class="btn btn-default" type="button" ng-click="detailsTable.search(detailsTable.searchTerm)" >
|
37
|
-
<span class="fa fa-search"></span>
|
38
|
-
</button>
|
39
|
-
</div>
|
40
|
-
</form>
|
41
|
-
</div>
|
42
|
-
</div>
|
43
|
-
|
44
|
-
<div class="col-sm-3">
|
45
|
-
<span class="nutupane-info" data-block="result-count" translate>Showing {{ detailsTable.rows.length }} of {{ detailsTable.resource.subtotal }} ({{ detailsTable.resource.total }} Total)</span>
|
46
|
-
</div>
|
47
|
-
|
48
|
-
<div class="col-sm-4 fr">
|
49
|
-
<div class="fr">
|
50
|
-
<span class="nutupane-info fl" data-block="selection-summary">
|
51
|
-
<span translate>{{ detailsTable.numSelected }} Selected</span>
|
52
|
-
</span>
|
53
|
-
|
54
|
-
<span class="fl">
|
55
|
-
<span data-block="actions"></span>
|
56
|
-
</span>
|
57
|
-
</div>
|
58
|
-
</div>
|
59
|
-
</div>
|
60
|
-
|
61
|
-
<div class="nutupane nutupane-details-table" bst-table="detailsTable" nutupane-table>
|
62
|
-
<div class="loading-mask loading-mask-collapsed" ng-show="detailsTable.refreshing">
|
63
|
-
<i class="fa fa-spinner fa-spin"></i>
|
64
|
-
<span ng-hide="$root.$state.current.collapsed">{{ "Loading..." | translate }}</span>
|
65
|
-
</div>
|
66
|
-
|
67
|
-
<div bst-container-scroll data="detailsTable.rows">
|
68
|
-
|
69
|
-
<div class="nutupane-select-all" ng-show="detailsTable.selectAllResultsEnabled && detailsTable.allSelected() && !detailsTable.allResultsSelected">
|
70
|
-
<span translate>All {{ detailsTable.rows.length }} items on this page are selected.</span>
|
71
|
-
<a ng-click="detailsTable.selectAllResults(true)" translate>Select all {{ detailsTable.resource.subtotal }}.</a>
|
72
|
-
</div>
|
73
|
-
|
74
|
-
<div class="nutupane-select-all-selected" ng-show="detailsTable.selectAllResultsEnabled && detailsTable.allResultsSelected">
|
75
|
-
<span translate>{{ detailsTable.allResultsSelectCount() }} results are selected.</span>
|
76
|
-
<a ng-click="detailsTable.selectAllResults(false)" translate>Deselect all</a>
|
77
|
-
</div>
|
78
|
-
|
79
|
-
<p bst-alert="info" ng-show="detailsTable.rows.length === 0 && !detailsTable.working">
|
80
|
-
<span data-block="no-rows-message"></span>
|
81
|
-
</p>
|
82
|
-
|
83
|
-
<div infinite-scroll="detailsTable.nextPage()" infinite-scroll-container="'.nutupane-details-table .container-scroll-wrapper'" infinite-scroll-listen-for-event="nutupane:loaded">
|
84
|
-
<div ng-show="detailsTable.rows.length > 0" data-block="table"></div>
|
85
|
-
</div>
|
86
|
-
</div>
|
87
|
-
</div>
|
88
|
-
|
89
|
-
</section>
|