- 07 Dec, 2015 8 commits
-
-
Sean Hammond authored
-
Sean Hammond authored
Move the public method vm.render() out of AnnotationController, making it a private function and renaming it to updateViewModel(). This function is not part of the view model (it's never called by the templates, only by code in annotation.js and tests) and its tests don't need to be part of the annotation controller/directive tests. Move it out. All the function does is copy some fields from the domain model to the view model, the opposite of what the updateDomainModel() function does, so rename it to updateViewModel() and put it next to updateDomainModel(), clarifying its role.
-
Sean Hammond authored
Private functions first, then public methods, and each section in alphabetical order. This also means that all `on*()` event listener functions are together (except for vm.onKeydown()). Also always use the `function foo() {}` form instead of mixing it with `var foo = function() {}`.
-
Sean Hammond authored
-
Sean Hammond authored
Public properties first, then private ones, then event listeners and watchers, then initialization logic, and each group in alphabetical order. Also added/improved some docstrings.
-
Sean Hammond authored
It isn't necessary.
-
Sean Hammond authored
Collect all AnnotationController init code together in an init() function. Previously it was spread around at the top, middle and bottom of the AnnotationController() function, some of it even hiding between method definitions. Now it's all in one place.
-
Nick Stenning authored
Remove USER_CHANGED event from AnnotationController
-
- 04 Dec, 2015 11 commits
-
-
Nick Stenning authored
Add groups report to admin dashboard
-
Sean Hammond authored
When the user logs out or logs in we throw away all the AnnotationController instances and create new ones. So everything it needs to do "when the user logs in" (or out) AnnotationController can do on Initialization, it doesn't need the event.
-
Robert Knight authored
Refactor saving highlights in AnnotationController
-
Sean Hammond authored
-
Sean Hammond authored
Remove the global variable `annotation` from annotation-test.js. This paves the way for having different helper functions for creating different kinds of annotation and passing them in to the directive initialization. Some describe()s still use their own global annotation objects, these should be factored out as well.
-
Sean Hammond authored
Simply having no content does not make an annotation a highlight (it also has to not be a page note or reply).
-
Sean Hammond authored
-
Sean Hammond authored
-
Sean Hammond authored
Clarify the logic a little.
-
Sean Hammond authored
-
Sean Hammond authored
-
- 03 Dec, 2015 21 commits
-
-
Sean Hammond authored
-
Sean Hammond authored
* Rename local variable `highlight` to `newlyCreatedByHighlightButton` and add a docstring - clarify what this piece of state actually means. * Fix `vm.isHighlight()`: It now returns `false` for new annotations that the user hasn't entered any text or tags for yet (instead of `true`). * Move the code for saving new highlights to the server into a `saveNewHighlight()` function that's called on AnnotationController instantiation instead of having it in a `$watch()` function that's called every time the local variable `model` changes. Also use the presence of `model.id` to avoid re-saving highlights that have already been saved - instead of abusing the `highlight` (now `newlyCreatedByHighlightButton`) variable and confusing what it represents. * Don't automatically open the annotation editor on Annotationcontroller instantiation if the annotation is a highlight. This fixes this bug: 1. Create a new highlight while logged out 2. Log in 3. Your highlight is saved to the server, but also the annotation editor is open on your highlight. The intention is that highlights are simply saved to the server, not opened for editing. _Annotations_ created while logged out, on the other hand, are _not_ saved to the server on login but _are_ opened for editing on login.
-
Robert Knight authored
Refactor annotation controller tests
-
Sean Hammond authored
-
Sean Hammond authored
-
Sean Hammond authored
-
Sean Hammond authored
-
Sean Hammond authored
-
Sean Hammond authored
-
Sean Hammond authored
Remove gloval `controller` variable from AnnotationController tests.
-
Sean Hammond authored
Move the tests for annotation.js's top-level function out of the 'AnnotationController' describe() - these functions aren't part of AnnotationController and their tests don't need all the setup in this describe().
-
Sean Hammond authored
Wrap the annotation directive tests in a new top-level describe that's for the entire file annotation.js, not just AnnotationController or the annotation directive.
-
Robert Knight authored
Refactor annotation controller, part 1
-
Sean Hammond authored
Move scope.feature() from the annotation directive to vm.feature() in the AnnotationController. Just trying to move as much as possible out of the directive's scope and link function into the controller, if we're gonna use a directive controller here try to just use it instead of randomly using the link function and scope for some things and the controller for others.
-
Sean Hammond authored
It doesn't appear to be possible for model to be null.
-
Sean Hammond authored
-
Sean Hammond authored
Move the DOM event listener function that saves an annotation on Ctrl+Enter into AnnotationController. This is just for the sake of keeping all the code in one place (in AnnotationController, not in the directive's link function) and putting code where it can be tested more easily. Note that the controller's save() function was previously called with scope.$evalAsync() and we're now just calling it synchronously. This seems to be fine.
-
Sean Hammond authored
Remove AnnotationController's vm.preview as it doesn't appear to be used.
-
Sean Hammond authored
Replace AnnotationController's vm.editing boolean with a vm.editing() method. This removes some duplicated state, as both vm.editing and vm.action were recording whether or not the annotation was being edited.
-
Sean Hammond authored
Move scope.share() from the annotation directive to vm.share() in the AnnotationController. Just trying to move as much as possible out of the directive's scope and link function into the controller, if we're gonna use a directive controller here try to just use it instead of randomly using the link function and scope for some things and the controller for others.
-
Sean Hammond authored
It does not change after directive linking, there's no reason to $observe() it.
-