Drupal 8/9 Views Bulk Operations running in multiple browser tabs - drupal-8

We have a client that is a logistics company who deals in shipping containers of their product. Their business logic is:
Container is shipped, usually from Asia
Container arrives at US port
Container is "released" to the customer
Customer is invoiced for the container contents
The "release" and "invoicing" processes are what the Drupal site performs for them via Views Bulk Operations. That process ended up being a multi-step process. The problem we're having is when a user performs the process on different containers in two different browser tabs. The "second" process overwrites the list of containers selected in the "first" one.
The invoicing process can be done as a separate step, and it originally had the same multi-tab issue, but we solved it by generating a hash key, saving the pertinent data in tempstore using that key, and passing it in the URL as a query arg so the processes wouldn't conflict with each other if performed concurrently in different tabs. But that process works differently in that it starts with an "Add" form, then goes to a VBO action in the second setp, instead of starting with the VBO action like the Release process does.
So the question is: Is there a way to add a query arg to the initial URL that VBO loads when clicking "Apply" on the original view?

Related

What's the best practice to implement "read receipts" on group chats in AWS AppSync and Amplify?

I'm building an Angular 11 web app using AppSync for the backend.
I've mentioned group chat, but basically I have a feature in my app where I have an announcement feature where there's a person creating announcements to a specific audience (can be individual members or groups of members) and whenever the receiving user opens the announcement, it has to mark that announcement as read for that user in their UI and also let the sender know that it has been opened by that particular member.
I have an idea for implementing this:-
Each announcement needs to have a "seenBy" which aggregates the user Ids of the ones who open it.
Each member also has an attribute in their user object named "announcementsRead" which is an array of Ids of the announcements that they have opened.
In the UI when I'm gathering the list of announcements for the user, the ones whose ID don't belong in the member's own announcementsRead array, will be marked as unread.
When they click on it and it is opened, I make 2 updates - a) To the announcement object I simply push the member's user ID to the "seenBy" attribute and push to db. b) to the member's user object, I add the announcement's id to the "announcementRead" attribute and push it to the DB.
This is just something that I came up with.
Please let me know if there are any pitfalls to this approach. Or if there are simpler ways to achieve this functionality.
I have a few concerns as well:-
Let's say that two users are opening an announcement at the same time, and the clients try to update the announcement with the updated seenBy containing the user's ID, what happens when the two requests from two different clients are happening concurrently? It's possible that the first user fetches the object and then the second user fetches it immediately, and by the time the second user has updated the attribute and sent it back to the DB, the first user has already written their updated data. In such a case the second user's write to the DB will overwrite the first user's change. I am not sure of the internal mechanisms of the amplify data store, but I can imagine this happening. Is this possible? If so, how do we ensure that it is prevented?
Is it really necessary for me to maintain the "announcementsRead" attribute in the user? I mean I can imagine generating that list in the UI every time I get the list of announcements by checking if the current user's ID exists in the announcement's "seenBy" and maintaining that list in the UI, that way we can eliminate redundancy of info in the DB and also it would make sense to not accumulate extremely old announcement IDs that may have been deleted. But I'm wondering if having this on the member actually helps in an indispensable way.
Hope my questions are clear.

Generate automatically web service parameters

I have a scenario where I have to pull data from web service using REST web service consumer transformation. For example the endpoint url is http://example/2015/Q1. Here I have to parameterise 2015/Q1 as $$DATES. But I cannot change parameter values manually. I have to design my mapping in a way that it should dynamically keep increasing the dates without doing it manually in all the runs including past to future. Please suggest me a way for the same.
You can have a parent workflow which will dynamically create a script with "pmcmd startworkflow" calls for all the quarters you need. Parent workflow will call the script to invoke the child workflow n number of times. You also need to have a table or file with all the quarters and a flag which will say if that quarter is processed or not. In the child workflow(actual one that you already have) you need to update the flag and mark it as processed. Each run of the child workflow will pick up the first unprocessed quarter and process it.
Hope that helps.

Semantic-UI-React Dropdown Selected Index

I am trying to set a default selected item in a semantic-ui-react dropdown. If I select an item from the dropdown, when I reopen the dropdown it opens on the correct item. However, this item is persisted, and when I refresh the page, the correct items are displayed on the dropdown, but it does not open on the correct item.
Please advise.
Matt, it sounds like you are only using the internal component state. Whatever your components initialize with, they will always start that same way. Your entire React application works this way. If you are expecting your data to be persistent, it needs to be stored somewhere. When you refresh you are starting over again. If the state of your application is not being put elsewhere, you lose that state every single time you refresh because the only copy of state is in your client browser.
Basically you currently only have a frontend application that is not storing data anywhere. Depending on your needs, you could do this in a lot of different ways. A REST API. A GraphQL API. One simple way to accomplish this if you are just creating a simple website would be to use a headless CMS. That will give you a database to store your application data. There are a lot of interesting ones out there that you can explore based on your needs.

Access list data as a group

We have a company program designed to help us get control over data. It has feature to group all the application of one Client. If I want to take a look at them I click on the Client and I see a list of all applications made for him. Take a look at the picture below:
I was wondering if Microsoft Access can do the same? If yes where should I start looking?
I did some internet search and no solution found.
That is built in, and it is called Subdatasheet. You have relationships properly set between Clients and Order, for instance, when you open the Clients table you will see such small "+" allowing to view the Orders of the current client. You may have to set the Subdatasheet Name property of table Clients to "Orders" in this case.
If you want to work with forms, you can build a continuous from for Clients, then one for Orders, then insert the Orders subform in the Footer of the Clients form. Access might tell you you can't do this, just ignore, it works.
In Access that would simply be a continuous form with a filter. Typically opened from a list of clients, setting a filter for the applications of the selected client.
Unless I'm misunderstanding the question.

Emberjs syncing with persistent layer

I have a real time emberjs app. I'm trying to implement a real time notification system, where any updates on one client will be propagated over all the other clients. Hence all the changes happen in real time over all the browsers.
I have Labels extending DS.Model objects. Every time one client creates a new record, the other clients run App.Label.find() which updates the record array correctly. Now the problem is when a client deletes a record and commits the store, App.Label.find() will no remove the record on the other clients. So my question is:
Is there a way you can update your local records from a persistent layer, which will remove all the deleted records?
I got it done by checking for .isDeleted
{{unless "model.isDeleted"}}
show only not deleted models
{{/unless}}