Skip to content

Commit beba1a4

Browse files
committed
merge 3.0-pinned-containers
1 parent e96e19a commit beba1a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+29501
-1254
lines changed

DEVELOPER.md

+64-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44

55
Thanks for considering contributions to the ui-grid project. This doc will give you a jump start on the development standards we use.
66

7+
# Running Dev Server
8+
Grunt task dev will run jshint, compile less, run fontella, run unit tests, run protractor tests, and start a local
9+
webserver on port 9003. A watch is started to rerun all the tasks if any source file changes.
10+
11+
<br>
12+
```
13+
grunt dev
14+
```
15+
<br>
16+
http://localhost:9003/docs/#/tutorial to browse each tutorial.
17+
18+
<br/>options
19+
<br/> no-e2e - eliminate protractor tests
20+
<br/> angular=n.n.n - specify a specify angular version to run unit tests against
21+
22+
```
23+
grunt dev --no-e2e --angular=1.2.16
24+
```
25+
726
# Code Structure
827
The development goal of ui-grid (ng-grid 3.0) is a fast, testable, and extensible grid component.
928

@@ -22,7 +41,7 @@ Everything else should be added as new angular modules unless the grid team agre
2241
* feature folder is added below src
2342
* One js file per feature
2443
* no global variables
25-
* public events are registered in grid.events (more on that later)
44+
* public methods and events are registered in grid.api (more on that later)
2645
* design and code the angular way. What do we main by that? Dependency injection, small directives, emphasis the model, not the DOM, tests!
2746
* feature.js contains an enclosure:
2847

@@ -155,7 +174,7 @@ column and row builders (see below). See ui.grid.edit unit tests on how to easi
155174
compile: function () {
156175
return {
157176
pre: function ($scope, $elm, $attrs, uiGridCtrl) {
158-
uiGridCtrl.grid.events.registerEventsFromObject(uiGridFeatureConstants.publicEvents);
177+
uiGridCtrl.grid.api.registerEventsFromObject(uiGridFeatureConstants.publicEvents);
159178
uiGridCtrl.grid.registerColumnBuilder(uiGridFeatureService.featureColumnBuilder);
160179
uiGridCtrl.grid.registerRowBuilder(uiGridFeatureService.featureRowBuilder);
161180
uiGridCtrl.grid.RowsProcessor(uiGridFeatureService.featureRowsProcessor);
@@ -227,14 +246,13 @@ RowsProcessor allows your feature to affect the entire rows collections. Gives
227246
uiGridCtrl.grid.RowsProcessor(uiGridFeatureService.featureRowsProcessor);
228247
```
229248
230-
## Public Events
231-
The grid provides public events via the GridEvents object. This object allows you to register your feature's public
232-
events and raise/consume events. It guarantees that your events are specific to a grid instance. Internally, angular
249+
## Public Methods and Events
250+
The grid provides public api via the GridApi object. This object allows you to register your feature's public
251+
api methods and events. It guarantees that your events are specific to a grid instance. Internally, angular
233252
scope $broadcast and $on are used.
234253
```javascript
235-
//preferred method is to use a publicEvents map from constants
236-
module.constant('uiGridFeatureConstants', {
237-
publicEvents: {
254+
//preferred method is to use a map so ide's can pick up on the signatures
255+
var publicEvents = {
238256
featureName : {
239257
event1 : function(scope, function(newRowCol, oldRowCol)){},
240258
event2 : function(scope, function(){}){}
@@ -243,13 +261,48 @@ scope $broadcast and $on are used.
243261
});
244262

245263
//from feature directive pre-link
246-
uiGridCtrl.grid.events.registerEventsFromObject(uiGridFeatureConstants.publicEvents);
264+
uiGridCtrl.grid.api.registerEventsFromObject(publicEvents);
265+
266+
//more stringy registration
267+
uiGridCtrl.grid.api.registerEvents('featureName', 'eventName');
247268

248269
//raise event
249-
uiGridCtrl.grid.events.featureName.event1(newRowCol, oldRowCol);
270+
uiGridCtrl.grid.api.featureName.raise.event1(newRowCol, oldRowCol);
250271

251272
//subscribe to event. You must provide a scope object so the listener will be destroyed when scope is destroyed
252-
uiGridCtrl.grid.events.featureName.on.event1($scope, function(newRowCol, oldRowCol){});
273+
//function's this variable will be grid.api
274+
uiGridCtrl.grid.api.featureName.on.event1($scope, function(newRowCol, oldRowCol){});
275+
276+
//register methods
277+
var methods = {
278+
featureName : {
279+
methodName1 : function(yourVar1, yourVar2){
280+
//whatever you method needs to do
281+
},
282+
methodName2 : function(var2){
283+
//do something else
284+
}
285+
}
286+
}
287+
288+
uiGridCtrl.grid.api.registerMethodsFromObject(uiGridFeatureConstants.publicEvents);
289+
290+
//way of the string
291+
uiGridCtrl.grid.api.registerMethod('featureName', 'methodName', function(yourVar){//do something});
292+
293+
//external use
294+
$scope.gridOptions.onRegisterApi = function(gridApi){
295+
296+
//subscribe to event
297+
gridApi.feature.on.event1($scope,function(scope, function(newRowCol, oldRowCol)){
298+
var self = this; //grid.api
299+
var msg = 'row selected ' + row.isSelected;
300+
$log.log(msg);
301+
});
302+
303+
//call method
304+
gridApi.featureName.methodName1('abc','123');
305+
};
253306

254307
```
255308

Gruntfile.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,9 @@ module.exports = function(grunt) {
326326
// },
327327
rebuild: {
328328
files: util.testFiles.unit,
329-
tasks: ['jshint:src_test', 'jscs', 'karmangular:run', 'concat', 'uglify', 'ngdocs'],
330-
options: {
331-
// livereload: true
332-
}
329+
// NOTE(c0bra): turn back on after render containers works
330+
// tasks: ['jshint:src_test', 'jscs', 'karmangular:run', 'concat', 'uglify', 'ngdocs'],
331+
tasks: ['jshint:src_test', 'jscs', 'concat', 'uglify', 'ngdocs'],
333332
},
334333
protractor: {
335334
files: ['.tmp/doc-scenarios/**/*.spec.js', 'test/e2e/**/*.spec.js'],
@@ -563,7 +562,9 @@ module.exports = function(grunt) {
563562

564563
var tasks = ['before-test', 'after-test', 'connect', 'autotest:unit', 'autotest:e2e', 'watch'];
565564
if (e2e === false) {
566-
tasks = ['before-test', 'after-test', 'connect', 'autotest:unit', 'watch'];
565+
// NOTE(c0bra): turn back on after render containers works
566+
// tasks = ['before-test', 'after-test', 'connect', 'autotest:unit', 'watch'];
567+
tasks = ['before-test', 'after-test', 'connect', 'watch'];
567568
}
568569

569570
grunt.task.run(tasks);

TODO.md

+63-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,71 @@
22

33
# CURRENT
44

5-
1. [TODO] - header-cell and thus .ui-grid-vertical-bar not filling the full vertical space when a column has filtering disabled but its neighbors DON'T.
5+
# Pinning
6+
7+
1. [TODO] - Add tests for new getBorderSize() and closestElm() methods in gridUtil
8+
1. [BUG] - With multiple columns left-pinned, they are wrapping as it appears the render container is 1px too small
9+
1. [BUG] - Column menu not in right place when grid is horizontally scrolled
10+
1. [BUG/MINOR] - If you pin one column and then use the scrollbar to scroll quickly scroll down, the body container will scroll correctly but the pinned container will be missing some rows, visibly.
11+
- Also it seems like the scroll amount can get out of sync by a few pixels.
12+
1. Right-pinned container needs to have a vertical-scrollbar, if visible then the body should hide its own scrollbar, however we determine to handle that.
13+
14+
15+
# Render containers
16+
17+
*** [NOTE] *** - I turned off test running (karmangular, etc) for render container development
18+
19+
1. [TODO] - headerHeight when vertical scrollbar renders doesn't include the border width.
20+
- Somehow need a way to re-run buildStyles after any header height updates...
21+
1. [TODO] - Render container header viewport (and maybe main viewport) are too wide. Also the vertical scrollbar is too high. If the header is present the scrollbar needs
22+
to size down...
23+
24+
1. [NOTE] - refreshCanvas() needs to QUEUE a refresh. It cannot directly call one. We need to debounce it somehow. Otherwise every render container refresh call will
25+
make the grid refresh itself WAY too much. Can we just use $timeout() and $timeout.cancel() with no delay?
26+
- Maybe make a `queueRefresh` method that GridRenderContainer can call...
27+
28+
1. [NOTE] - On grid init we need to redrawInPlace all containers, or rather update the scrollTop and scrollLeft of all registered container to '0' pixels.
29+
1. [BUG] - The pinning menu actions ARE putting the columns into the renderContainer caches, but it's not immediately updating (re-rendering) the grid. If I then scroll I
30+
see the column is gone, but it's also still accounts for the column's width when setting the canvas width (so two separate bugs).
31+
- NOTE - The viewport width adjustment needs to subtract the pinned viewports' dimensions from the main viewport
32+
- NOTE - Is the canvasWidth updating running in uiGridHeader BEFORE the visible/renderContainer updates which columns are in the body container?
33+
- NOTE - The main viewport and main header will need their left/right dimensions updated as well as their width/height. The header isn't being updated at all!
34+
- NOTE - We'd need to subtract the cumulative horizontal-pinned containers width from the top-panel and offset the header's left position based on the left container
35+
36+
1. [TODO] - Horizontal-pinned container will need their OWN header... sigh.
37+
- Their repeater will need to be based on their render container
38+
39+
1. [IDEA] - Should grid have an `addRenderContainer` method? Rather than just popping them in to the renderContainers properties with no validation?
40+
1. [NOTE] - We can add headerHeight back into the left/right-pinned containers if we don't want a scrollbar at the bottom (we probably don't).
41+
1. [NOTE] - We probably need getAdjustedViewportWidth/Height() methods, the idea being that the normal methods return the full width/height and the others return the adjusted value.
42+
The pinned containers will need the FULL value so they can fill out the body's width or height based on which side they're pinned to, and then the viewport will use the adjusted
43+
value to render smaller to make room for the other one.
44+
1. [TODO] - Main viewport will need top/left CSS positioning values to adjust for the left/top-pinned containers (right?)
45+
1. [TODO] - Make viewports generic, so they can be sized to their contents no matter what they are, so they can listen for scroll events. Also need to give the a
46+
viewports controller that child elements (rows, columns) can communicate with to handle column resizing, etc.
47+
- Render containers need to have max and min width/height values, and they need to be able to take percentages (i.e. make the left pinned container 30% of the total grid
48+
width).
49+
- Need to somehow keep pinned viewports from listening to scroll events that they should ignore, like left/right-pinned containers shouldn't scroll left/right when the
50+
body scrolls, but it DOES need to listen to vertical scroll events.
51+
- I guess we can just add attributes like `bind-scroll-vertical` + `bind-scroll-horizontal` to make them both fire those events and listen for them... That ought to be
52+
the RIGHT thing (yay).
53+
- Create a registry of functions that alter the grid viewport's dimensions. For instance, a left-pinned render container will need to substract its own width from the width
54+
of the main (body) viewport. Basically the body's viewport has to resize around any other viewport inside the main render area, the scrollbar-box or whatever you want to call it.
55+
- Almost done, just need to split the functionality out so there are "normal" methods and "adjusted" methods.
56+
- Need to flesh out update() method in ui-grid-render-container to update the renderContainer canvas/viewport styles.
57+
- i.e. canvas width = sum of columnCache widths, canvas height = sum of rowCache heights
58+
59+
** uiGridRenderContainer **
60+
- Needs to register to the specific renderContainer to get its rows and columns
61+
- Needs to find its canvas, and its viewport. Or maybe the render container IS a viewport. That's probably easier
62+
- Needs to get its canvas height
63+
64+
1. [TODO] - uiGridRow needs to take render container so it knows which column cache to look in
65+
1. [TODO] - Within column resizer we need to only account for columns within OUR render container, which means we need to be able to access the contain details from its
66+
controller, which will be above us.
67+
668

7-
1. [PERF] - Try to improve horizontal scroll performance with cellTemplates
869
1. [TODO] - remove gridBorderWidth on column menu top-left, top-right
9-
1. [TODO] - Try using a $cacheFactory for the cellValueGetterCache.
1070
1. [TODO] - Move row filtering to feature module.
1171

1272
1. [IDEA] - Look at using Istanbul for code coverage reporting.

0 commit comments

Comments
 (0)