@@ -130,26 +130,17 @@ _becomes_
130130- api internal controller
131131- globbing for angular routing
132132- Home controller index action is blank
133-
134- ---
135-
136- # ifCan Directive
137-
138- The frankenstein if-else:
139-
140- ![ inline] ( ui-sref.png )
141-
142- ^ would love to hear if someone knows a better way to do this
133+ - Now lets move on to partials (next)
143134
144135---
145136
146137# Angular Partials
147138
148- In ` deals/index.nghaml ` :
139+ ` deals/index.nghaml `
149140
150141![ inline] ( ng-include.png )
151142
152- In ` deals/bar_table.nghaml ` :
143+ ` deals/bar_table.nghaml `
153144
154145![ inline] ( ng-include-2.png )
155146
@@ -162,7 +153,7 @@ In `deals/bar_table.nghaml`:
162153
163154# Angular Partials
164155
165- In case wrapping the partial causes issues:
156+ In case wrapping the partial causes issues
166157
167158![ inline] ( ng-include-replace.png )
168159
@@ -184,7 +175,7 @@ In case wrapping the partial causes issues:
184175- parent state
185176- ui-view template
186177- data permissions (will go over this in a minute)
187- - lets jump back to front-end permissions
178+ - how do i link to these states? (next)
188179
189180---
190181
@@ -198,61 +189,81 @@ New and Show routes:
198189- one with no params, the other with a required dealkey param
199190- both Will trigger state changes, change URL, not reload browser
200191- you can also pass arbitrary params to routes and handle them on a case-by-case basis
201- - now lets go over permissions (next)
192+ - how about transitioning states in a controller? (next)
202193
203194---
204195
205196# Angular Routing
206197
207- ##in ` deals/router.js.coffee ` :
198+ <br >
199+
200+ ![ inline] ( controller-route-go.png )
201+
202+ ^ inject state service and call state.go with the state and optional params
203+ - now lets go over permissions (next)
204+
205+ ---
206+
207+ # Route Authorization
208+
209+ ` deals/router.js.coffee `
208210
209211![ inline] ( route-permissions.png )
210212
211- ##in ` shared/permissions.constant.js.coffee ` :
213+ ` shared/permissions.constant.js.coffee `
212214
213215![ inline] ( permissions-constant.png )
214216
215217^ So, remember that data-permission hash?
216218- Make sure you have all permissions in the constant file
217- - if you don't, don't worry, you'll be reminded (next)
219+ - so lets say we wanted to change readDeals in the router to manageDeals (next)
218220
219221---
220222
221- # Angular Routing
223+ # Route Authorization
222224
223225![ inline] ( missing-permission.png )
224226
225227^ Auth will fail, and you'll get this console error message
226- - Now lets get into some small implementation details about permissions
228+ - Now lets say we added manageDeals to the permissions constant, that's it right? Wrong (next)
227229
228230---
229231
230- # Angular Routing
231-
232- <br >
232+ # Route Authorization
233233
234- ![ inline] ( permissions-can .png)
234+ ![ inline] ( missing-permission-service .png)
235235
236- ^ Heres the basic method that does 90% of the work
237- - There's a lot of technical details that you're interested
238- - checks against manage first, since that encompasses all actions of a feature/resource
239- - maybe feature is the wrong variable name here
240- - but basically it ends up here, checking against the users cancan abilities
241- - you can also do custom checking like this (next)
236+ ^ Auth will still fail, and you'll get this console error message
237+ - Now we add manageDeals to the permissions service here (next)
242238
243239---
244240
245- # Angular Routing
241+ # Route Authorization
246242
247243<br >
248244
249245![ inline] ( custom-permission-check.png )
250246
251247^ This is part of a switch statement in the main canAccess method
252- - See here you can use that can method, or do something custom
248+ - See here you can use a ' can' method, or do something custom
253249- you can modify this file and allow custom attributes or something other than key potentially
254250- checking role or pub key to only allow user to see their own pub content
255- - and here is where the permission service gets called (next)
251+ - you can also do custom checking like this
252+
253+ ---
254+
255+ # Route Authorization
256+
257+ <br >
258+
259+ ![ inline] ( permissions-can.png )
260+
261+ ^ Heres the basic method that does 90% of the work
262+ - There's a lot of technical details that you can look up if you're interested
263+ - checks against manage first, since that encompasses all actions of a feature/resource
264+ - maybe feature is the wrong variable name here
265+ - but basically it ends up here, checking against the users cancan abilities
266+ - and here is where the permission service gets called during routing (next)
256267
257268---
258269
@@ -262,14 +273,28 @@ New and Show routes:
262273
263274^ lots of stuff here again, but it's not super important to understand
264275- check if logged in, unless state is login (doesn't exist yet)
276+ - should probably just return if state is login
265277- basically the parent publisher stuff might be important
266278- if there is a parent you must be able to see parent
267279- make sure you can also access curent
268280- if unauthorized, go to a pseudo 404 page
269281- prevent default if you are not logged in
270282- get current user (pseudo log in)
271283- set user in session, recurse
272- - one last thing I'd like to mention
284+ - okay cool, now how about using auth/permissions on the front-end? (next)
285+
286+ ---
287+
288+ # ifCan Directive
289+
290+ The frankenstein if-else
291+
292+ ![ inline] ( ui-sref.png )
293+
294+ ^ would love to hear if someone knows a better way to do this
295+ - One last thing
296+ - what if you need data that is required before the page loads?
297+ - the page jitters and snaps after resource is loaded. Here's a solution (next)
273298
274299---
275300
@@ -278,7 +303,7 @@ New and Show routes:
278303![ inline] ( pre-resolve.png )
279304
280305^ Router resolving is a very cool concept
281- - It takes code from this:
306+ - It takes code from this (next)
282307
283308---
284309
@@ -287,25 +312,26 @@ New and Show routes:
287312![ inline] ( post-resolve.png )
288313
289314^ ...to this
315+ - now where does this magical deal object coming from? (next)
290316
291317---
292318
293319# Router Resolving
294320
295321![ inline] ( route-resolve.png )
296322
297- ^ ...and this
323+ ^ here!
298324- Use route resolves for data that is required before the page loads
299- - prevents things like stuff showing up then snapping around once data is loaded
300325- will cause initial page load to take longer so...
301326- we need to establish a pattern showing that the page is loading
302327- but it also gets rid of lots of prepareData calls and jittery pages
328+ - Now here are a few gotchas I came across while doing this (next)
303329
304330---
305331
306332# Gotchas and Interestings
307333
308- Coffeescript + Inline-Edit:
334+ Coffeescript + Inline-Edit
309335
310336![ inline] ( inline-edit-method.png )
311337![ inline] ( inline-edit-method-2.png )
@@ -353,9 +379,9 @@ Camelizing and Decamelizing $http requests
353379- str-directive-name?
354380- Plan for separating front-end from back-end
355381- Better handling duplication like metrics-related stuff
356- - auto-camelize and decamelize http requests
357382- relying on cancan abilities JSON
358- - plan for future refactor?
383+ - plan for future refactorings?
384+ - feature flagged angular routing?
359385
360386---
361387
0 commit comments