Question :
Let say i have an application form that allow me to apply for few service.
for example services are :
Service A
Service B
Service C
Condition :
one application form only allow one user to add few service
Parent file is "application form"
Child file is "service 1", service 2, Service 3
user have 2 button to select either to click on "save" / "Cancel" at Application form(parent file)
My form allow to be save anytime.
My question, if user already add the child document, but user click on "cancel" function. Means it want to delete document(child) that been select on the time key in. How to differentiate it.
A few approaches come to mind.
The first is to only allow creration of child documents in read mode. That splits the separation between creating the parents and the children.
The second is to have child documents get a "Draft" flag when initially created. If they save, clear the draft flag. If they cancel, remove drafts.
The third is similar. Capture which children exist when they first edit the document, then in the cancel process, remove them.
Steps 2 and 3 still have the problem that edits to an existing child will still be held. A fourth option is to load the children into Java objects that wrap the underlying Notes document. Creation will create the Java object, not the Notes Document. Save will then create or update the backend Notes documents. This way you're able to handle parent and child as a single transaction and this will be the most complete option. (DominoDocument datasource is effectively a Java class that's a wrapper of the backend Notes Document, so it's effectively the same thing, but covering multiple documents instead of one).
Related
I have an add contact Modal and an add company Modal. When the user wants to add a contact they click the corresponding button which opens said Modal. Typically, they would fill out the information needed on this form. One of them being a Company they belong to. If the company does not exist in the system, they then have an add company button which when pressed opens another Modal on top of the contact one.
Again, the user enters the information for the company and once done, would tap save. This would then trigger a fetch which POSTS the information to my Spring Boot backend which in turn sends back a JSON object version of the company which has come from the database.
I then check it and if it comes back valid, it sets out an alert telling the user it was successful and closes the company Modal.
At this point, the user should be able to type the company name into the contact company autocomplete and find the company they've added.
However, at this point, that is not happening. The re-fetch is not triggered at all despite me thinking that when the Contact Modal is re-rendered it would trigger the re-fetch.
I've tried clearing the contactList within the return() function but this causes a Too many re-renders error.
My question is, how would I trigger a re-fetch from within the contact list once it has returned from the company modal?
My initial thought would be to not have more than one modal open at the same time. Feel free to disagree but that doesn't seem like that's how modals are intended to work. As an alternative, you could have an "Other" option and have a set of text fields conditionally appear. Upon completing the form, have a boolean variable (or however you want to do it) be passed into your backend that kicks of the business logic that creates a new company before adding the contact. Or add all that logic to your add contact SQL procedure to avoid making (a risky) two db calls for one action.
Refetch Problem
Without looking at your code, it's possible that if you're using the useEffect hook, you aren't passing any dependencies to "listen" for certain variables that have been changed. After the data comes back from that POST call, you should add code that updates the array populating the select company dropdown field (eg .then() callback)--assuming it is a dropdown and an array. This change in state should re-render the component but, for a better user experience, you may want to do it in a way that it doesn't blank out the rest of your fields.
You are probably using useEffect which makes the loop.
Try to connect refetch with an event - click or submit, within try/catch - via 2 way binding eventHandler prop that calls praticular function.
Also you can change the state, and refectch the results after the new loading of the page. Hope it helps, even as a hint!
Right now I'm building a team based project with Node.js/MySQL/React and have been stuck at a ToDo list part. I would like to know what is the recommended or fastest way how to save data or options to database automatically and without any submit button on each row.
Todo item
You could do a single POST when adding a new row, and whenever you change the options you could do a PUT request, but as a general design rule I'd advise against it : you want to be able to review all your changes before committing them to the database, plus this requires a lot more requests, hence more controllers rather than just having one.
Looking at your screenshot why don't you have a single submit button at the bottom of the table ?
My website contains posts something like blog posts, a registered user can post things and any other registered user can view them, here when showing individual post I kept an follow button for to the viewer so if the viewer clicked it and follow the author(post owner). Now the problem is every time when a viewer clicked and see individual post I need to check whether viewer is already following that author or not so that I have to choose follow or following button to display. In my angularjs controller I have json array of authors(following authors). How can i check the individual post author existing in following authors in controller or is there any chance to perform this on view? O am using angularjs 1.x
Anyway you have to set a flag for the buttons choice (true for follow button and false for following button).
To set the scope of this variable you need to implement the logic in JS (Since its an array collection). Now in HTML you can show the follow or following button by using ng-show and ng-hide. (ng-show="isFollow")
I need some direction on how to procede in this scenario. Using and Asp.Net page with JQuery, user generates dynamic elements representing data of his process' tasks:
-Basically, at the left, right and bottom of the page, there are several accordion with a sort of draggable items
-In the middle of the page, there is a 'PLUS' button
-Where user hits '+', a new 'CARD' is dynamically generated in the middle of the page. This card is a main div, with some droppable divs inside it
-This card represents the user task, and the inner divs are the properties of the current task
-The user drags the options from the lateral accordions and drops them on the droppable areas/div of the card/main div.
-Done! The 'task characterization' of the task is done.
-The process is repeated, adding more cards as required.
All this operation is client-side: until this moment, there is no needed to invoke server operations.
Until now, and this is where my question is laid: when the user is done, he hits a 'SAVE' button.
How can I go from a dynamic set of HTML controls on the client to, lets say, a IEnumerable of a custom class type containing the user data to proceed with data operations?
These are some of my ideas:
Idea #1:
1. On Page_Load, instantiate a list of 'TaskData'
2. When user hits Save, using Jquery, select all elements of the card class
3. Loop through all card
4. Select and loop all elements of the card, reading data of the droppable areas
5. Pass data to server (using webservice or page_methods)
Idea #2:
On Page_Load, instantiate a list of 'TaskData'
At each 'drop' event, call a specific page_method, eg: setPropertyX(string value), setPropertyY(string value), and so on, avoiding callbacks. This way, on the Save method, I would have the objects to be populated progressively.
Idea #3:
At each 'drop' event, store values on array variables
...
Idea #4:
Use browser' localstorage/sessionstorage, or browser DB (new area to me)
So, as you can see, I'm pretty stuck at this. Suggestions are welcome :-)
I'm trying to figure out how I can make a custom directive which will combine:
reference list select field
create button which will show a reference entity creation view
and on creation save. reload reference list entities, so i can choose a newly created entity.
It can be easily done using completely custom code, but i want to make it using ng-admin templates and directives.
It's also quite common functionality, but i'm having a hard time integrating it into ng-admin.
So in case there is no required field in list, i will not loose data i already entered by navigating to create new entity on another page.
Add two fields:
one of type referenced_list to display related entries
one virtual field with an empty label and a custom template, using a create button with prefilled default values for the related entry (e.g. <ma-create-button entity-name="comments" default-values="{ post_id: entry.values.id }" size="xs"></ma-create-button>)
Check https://github.com/marmelab/ng-admin-demo/blob/3a0944acbcb12dc20dc8a4a860c6c9f8da9c1645/js/customers/config.js#L81-L101 for an example.