Easy admin conditional fields - symfony

Stack is symf 5 and EA 3.
I have a problem with showing different data for one AssociationField.
I want to show different values of that field for different roles. Something that query builder do in Symfony forms. Any help?

You probably need to create a switch statement in the CRUD Controller which will render that field differently based on what is the current user role. Remember, that one user can have multiple roles by default, so You need to specify which role index should it take to statement as a parameter.
But the true question is: Do You really need that functionality? If so, You probably should consider giving Your user class additionally a configuration array, where You will store the config of the preferred way for data presentation.
You do not tell much about the background of Your problem, so I hope my answer address it correctly.

Related

2sxc News app: Show more then 1 category and role related categories

We are using the 2sxc module version 9.32.1 and the news-pro app version 3.1.
I am trying to make a view where I can show the items of 2 categories, but it seems I can only select one? And when I enable the function: Select more then one item, it will only show items for the first category selected.
How can I achieve this?
And I really want to connect user roles to the categories, and only show them when you are in then user role, how would I go about this?
I expect a list where I can show multiple category items.
and I expect a field with category where I can connect a user role to it.
I Sorency - it's best to put each question into a separate stack-overflow question, to keep things clean for future users who are looking for one. So I'll answer the initial question with multiple categories.
There are two ways to do this - one uses Visual Query, the other code. I will just give a general guide here:
With Visual Query https://2sxc.org/en/Learn/Visual-Query-Designer
1. First make sure you understand what it does, as I assume you haven't worked with it yet.
1. Look at how the first filter works - there you can either add more parameters (to allow multiple categories) or create a second stream with the additional filter, and then merge the results. So your query then has one list for the matches of the first parameter, and another match for the second parameter - and in the end it merges them together.
With Code you would do it in the razor file (CSHTML). There you would need to learn some LINQ and then work with the DataSource objects. This is much more technical, so I suggest you stick with the visual query for now.

How can I allow the Current User to have permissions/views tied to their Direct Reports and Manager relationships?

In a handful of circumstances, I'd like to allow the Current User to be able view a list of records filtered by Owners of each record that are Direct Reports that they manage or even by the Manager they report to via our global directory.
I'm comfortable making a new Datasource for CurrentUser in a Directory model. However, I'm tripping over myself trying to find the best way to match an Ownership (email) field from a record, with an array of the direct reports associated with the current user.
A specific example would be on the Travel Approval template. The table on the Dashboard page has a filter for "My Requests | All" and I'd love to add a third option for "Direct Report Requests".
My assumption is that I would adjust the onClick event to filter results accordingly:
widget.datasource.query.pageIndex = 1;
widget.datasource.query.filters.Owner._equals = app.user.email;
widget.datasource.query.filters.Owner._in = null;
widget.datasource.load();
updateUrlForDashboard();
That's one small example, but more importantly, I'd like to get a better understanding of how best to reference/store those additional relationships about the Current User.
Ideally, a current user is able to have greater ability to manage (approve/deny/comment on) resources tied to their Direct Reports and generate records that provide a similar level of control to the Users that Manage them.
I'm not sure if that's best handle by some use of Roles or another approach. Any advice on how best to plan out that kind of setup would be much appreciated.
funny thing ... I had the same question a couple of months ago. I think you will find Pavel's solution on this very interesting. You can find it here.

Drupal 7 - Functionality for multi-select of nodes and then action to send email to a manually entered email address

I have a webform setup along with a rule that creates a new content type called 'Idea' with most of the submitted data (so that comments can be made on node of type 'Idea')
The webform is for new ideas for the business and depending on the idea it then needs emailed to the correct person in the business so they can respond.
I know a way of doing this would be to create a drop-down list in the webform and assign an email address to that record (eg. IT > (email would go to > it.dave#company.com) but they don't want it to be in the control of the user in case they select the wrong person for the webform submission to go to, they want to be able to manage this themselves manually.
What is the best way to approach this?
I was thinking, is there some sort of multi-select option where you could select one or multiple nodes from the content page and then manually enter an email address, hit a submit button, which emails them.
They want to be able to enter the email part manually and not choose from a list as it may end up going to a large range of different people, not one of a pre-determined list.
I was possibly thinking if rules or workflow or workbench might help but never used the last 2 before, but if someone knows of a way that might be best to approach this it would be appreciated.
Step 1
Use the Rules module to create a Rules Component, which includes whatever Rules Conditions you might need (if any), and with a Rules Action to Send an eMail, for each of those fields you want to be updated.
Step 2
Create a view of the group of nodes for which those eMails should be generated. Then transform that view into a view that uses Views Bulk Operations, and use the technique documented in "How to use Rules to create a custom bulk operation for a VBO view?". In doing so, you'll then be able to use the Rules Component from Step 1.
Tutorial
To get the idea, have a look at the video about Using Rules components with VBO" which uses a Rules Component with (only) 1 parameter. If you want even more, then also watch the subsequent "Using Rules components with more than one parameter" video.
Attention: to process like 100.000 entities at once is quite a challenge (memory requirements, etc). Therefor you might want to also watch the video about "More details about VBO settings" ... Before you are tempted to use VBO for processing them all at once ...

Multiple tag pools for a document type

We have a document base that needs the metadata to be structured in order to facilitate search, but due to the nature of the information, it will be impossible to use constraints. Tagging seems like an interesting option: it keeps the metadata structured, but allows users to create new values on the fly.
The problem with this solution is that each property needs to have a specific pool of tags. Imagine a document with two properties:
Entity
Process
In theory, we could put this information into metadata fields with constraints (database backed even), but the users want to be able to create values on the fly. Tags seem interesting, but we don't want to mix tags from the Entity list with tags from the Process list. Each tag should have its own "pool".
Has anyone done something like this in Alfresco? It seems like we'd have to tear apart the tagging system and basically rewrite it, but maybe it's easier than that.
If your only issue with tag is related to on the fly creation then you should look into "Categories". In Categories only admin user can create required Category structure.Then normal user will be able to use them to categories docs.
I your case I guess you require something like this
Entity
Entity1
Entity2
Entity3
....
Process
Process1
Process2
Process3
.....
If yes, you should b able to use categories.

Designing a web form with default and custom values

The web form I'm working on right now is the electronic version of a contract. The users want to have default values for a large number of the fields to keep wording consistent. However, they also want to be able to enter a custom value or select multiple values for some of the fields. I'm finding that the presentation layer is bleeding into the backend quite heavily and wondering if anyone has some tips on how to go about designing an application like this?
EDIT: I wanted to try and keep from going into the specifics because there is a large amount of business logic in it. But basically I have a form with about 20 fields in it. 3 of the fields have select boxes with multiple options in them. These are the default values I was talking about. But the user also wants to be able to add a "one off" type value to the select. This represents a specific term in the contract that isn't used enough to be valuable as a default. My issue is that I'm storing the default values in the database because the users want to be able to add and remove these defaults at will. Its not just a standard data capture screen.
tblRecord (RecordID, SomeFieldID, CustomText)
tlkpSomeField (SomeFieldID, SomeFieldText)
It sucks, but that is actually a pretty common solution. You can use the CustomText only when the Record shows that SomeFieldID is null. Your data layer will abstract all of that away, so it will be clean. You can also store your default value as the first value in the tlkp table.
tlkpSomeField
1 Default Value
2 value1
3 value2
4 ....
If I understand you correctly, without knowing you or your domain, you have problems with storing both default and chosen value, you sort of get redundant data in the database.
It feels wierd to store the default flag with the chosen item with the freetext when lots of it is just user stuff. Sort of.
My thoughts/recommendations are:
Default value doesn't have any business value so don't store it as users' choice. Just store what the user chose/freetext.
Or does it Mean something that the user chose default? Then there is business value to it and you should store the value/text the user chose and a tick that it happened to be the default value.
Or I might have misunderstood you totally...

Resources