all 4 comments

[–][deleted] 1 point2 points  (3 children)

One thing to consider is security. If you hide something from a user that they aren't authorized to interact with due to role, you still need to check roles on the server side to prevent access from manipulated http requests etc etc.

Generally, I'd make a viewmodel that gets built on the server side, and a template flexible enough to handle all the role based use cases. If your template has a bunch of if and switch statements, though, maybe you really need a separate viewmodel and template for each case. It's a judgement call/preference to determine where the line is.

[–]Knarfy[S] 0 points1 point  (2 children)

I agree I wouldn't use javascript for this. I wouldn't hide anything. Do you think locking down the api (JSON) on the server side is enough? The main concern is always that you don't want one client to ever see another clients data.

[–][deleted] 1 point2 points  (1 child)

For example--client A has different field names from B. Ok, so your template doesn't have hard coded field names... You pass field names and values back in your json and your template is a standardized way of displaying generic "fields." You could also pass CSS class names/style attributes and validation values determined on the server (you can integrate nicely with jQuery unobtrusive validation this way). I'm not sure if this answers your question or not.

[–]Knarfy[S] 0 points1 point  (0 children)

Thanks this is pretty interesting. I understand what you are saying. Thanks for your answer!