How to hide general ui elements in frappe framework / erpnext - erpnext

What is the best approach to hide general ui options from certain desk users with lower permission roles? I would for example like to block the create workspace feature (and hide the button) for a certain user role:
Ideally I would like to also hide certain options from the following pane for certain user roles.
What would be the best approach for this. I am thinking of writing some javascript code to manipulate the dom here, but I am wondering what the best way would be to inject something like this and if it is possible to selectively inject that code in frappe framework via a custom app.

Related

Calling pop up from different pages .jsf

Does anyone know how I can get the same pop up via a button located on different pages (.JSF)?
That is, there is a button "add file" which then opens a pop up with a form where the user adds information about the file. As the pop up is always the same I was thinking of using declarative components. However, I do not understand how.
You can create a taskflow which will contain your page with upload form, and then reuse it on other pages as af:region. Check out this great post with an example how to do it.
I might think about three different ways to achieve this:
1) As #Pregrad said, you can create a Bounded Task Flow and expose this BTF as region (or dynamic region) in every page you need it as a popUp window (recommended if you are using transactions)
2) You can create page templates, put the af:popUp in them and apply the template for each page (recommended if you already have templates, and you need the popUp for each page on your application)
3) You can put the af:popUp component on each page you need it, and then call it programmatically. This approach may be would give you more control on the popUp behaviour but would require you to handle it manually.
The approach you should use does really depend on your needs.

Internal state in backbonejs application

I am creating an application and trying to figure out best way to deal with navigation in it. User can choose different view settings (which content to show and options to filter it). Part of settings is stored in backend in user preferences model. Another part is stored in url and managed by router. But there is more settings I want to keep. The reason: I want to be able to refresh content therefore I need to keep settings somewhere, not update content on user actions and forget how I came to this state. My question is: what is the best place for such settings? Collection object? View object? My own controller?
P.S. to make it more clear, I'm working on rss reader application. And I want, for example, to show last week posts from certain feeds which are starred etc.
Save it in the URL. Thats the only place you can really rely on. If you need more then routes use query parameter like in a classic web application and use them in the view.

How to design a flexible admin panel with Symfony 2 bundles?

I want to create an admin bundle, that somehow detects other bundles and tries to add them to the menu and to the same RBAC context.
Eg:
AdminBundle defines a route /admin/dashboard, that requires authentication and authorization. There you can see 3 items in the menu, eg: dashboard, config (some config stored in the db), and users (CRUD for users, found in the UserBundle)
Then someone adds a ProductBundle, which deals with CRUD for e-commerce products or something. Somehow, without modifying any code in AdminBundle, we have now a new item 'products', available in the menu in /admin/dashboard
Later on, the products CRUD is no longer needed, so we just delete the ProductBundle, and it automagically disappears from the admin dashboard menu.
How would you go about implementing something like this? Is there any native support for a plugin-like design like this in symfony 2?
I don't know about a full plugin solution but my approach would be:
There is one "master backend" call it MasterAdminBundle for the sake of conversation. This bundle contains a base.html.twig which just helps define the navigation bar of the Administration area and a {% block content %}. It also has some kind of MenuService which displays the menu. I'd have my other bundles register with this service an AdminMenu subclass by way of using the Tag System just as a Voter can register with the Security Context (see here).
In the base.html.twig I'd then likely use an Embedded Controller to render the menu.
Now with this sort of framework in place your other bundles can stay encapsulated by keeping their own admin routes and interfaces:
ProductController would now also have ProductAdminController where you can use a route prefix #Route("/admin") on the class definition. Any routes could then render templates from within the bundle since templates are held under the controller name. Acme\ProductBundle\Resources\views\ProductAdmin\edit_products.html.twig as long as they extend the base.html.twig from MasterAdminBundle and put their content into the content block.
For other things like a dashboard that you wanted to plug other bundles into I'd likely just keep going the same way, create a service in the MasterAdminBundle and use tags to load other classes into it with the data required.
Hope that makes sense, maybe others will have a better solution to this, I'm interested to hear also since this is something I'm trying to tackle at the moment also.

In what way a User url can be created with GWT

I have this web app which is a directory of users from a database, the web app works just fine with all the widgets/components that allow user search and show results in gwt panels. However I am thinking to add a way a User can have a user like:
mygwtapp.com/user123
And gwt app will show the appropriate view for the user?
Any ideas?
The standard way to do this in GWT is using the history mechanism:
http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsHistory.html
Basically, instead of:
mygwtapp.com/user123
You can do something like this:
mygwtapp.com/gwtapp.html#user123
Once you understand the basics, you can use activities and places (a simple framework on top of gwt's history api). But this is a bit more complicated and probably unnecessary for your needs.
http://code.google.com/webtoolkit/doc/latest/DevGuideMvpActivitiesAndPlaces.html

Creating a Calendar in Symfony

I'm using symfony 1.4 for my web project.
I have the following problem (or opportunity): I need to create a calendar where the "common" user has only the ability to see (or read) the date and time of the events and the "admin" user can edit, add and remove new events. So it's basically a google calendar type of thing where I have to different permissions, read and read, write, delete.
Also I need to be able to fully customize a calendar style so that It matches my css.
How would your approach this problem? I've been trying to find the best plugin for this endeavor but I haven't found one that with a good documentation
Thanks in advance!
I recommend FullCalendar jQuery plugin. It gives you very nice JavaScript calendar with drag&drop support. You can use your own CSS style.
On the server side create symfony actions that will return data to FullCalendar API. Just serialize the data to JSON Event Object.
Of course you should use symfony security component to restrict read/write access. Show only those events that users should be able to see. And don't let them access write actions if they don't have write permission.
To manage event data you can either create backend admin module or display your own form when user click on calendar (like Google Calendar does). If you like the second approach then you have to handle it in JavaScript.
I would suggest to build 2 applications for that.
frontend (read/see)
backend (admin)
Just go with the normal symfony approach.. define your models, generate frontend (inkl. modules). There you can adjust you templates and css.
Practicle open book where you can choose the topics you need
Then use the admin-generator to get the backend application. You can customize behaviours and styling of course.