interaction design – Should I prevent a user from navigating away from a form while it is being processed?

I’m designing a CRM which has a lot of forms in order to edit everything.
Currently, when you save a form, the Save button transforms into a loading-gif and is disabled (more clicks won’t do anything) and if successful back to the save button with a success message.
It should be mentioned that the user edits detail-information inside the form. So the same form can be edited multiple times consecutively.

Normally, the user doesn’t has to wait more than 1 second until the form is processed and saved. But what if it takes longer?
Currently the user is able to navigate away before the form is saved, if the processing takes a long time. The saving-process is asynchronous, so it still will be saved. But if an error occurs, and the user is on a whole different page, the error message won’t be displayed.

So should I stop the user from navigating away while the form is still processed?
If yes, how? Overlay over the navigation? Over the whole screen? Info-Message that if navigating away, he won’t be notified if there is an error?
If I shouldn’t stop the user, how should I inform him, if the save-process was successfull or failed?

interaction design – Should I prevent a user from navigating away from a form while it is being proccessed?

I’m designing a CRM which has a lot of forms in order to edit everything.
Currently, when you save a form, the Save button transforms into a loading-gif and is disabled (more clicks won’t do anything) and if successful back to the save button with a success message.
It should be mentioned that the user edits detail-information inside the form. So the same form can be edited multiple times consecutively.

Normally, the user doesn’t has to wait more than 1 second until the form is proccessed and saved. But what if it takes longer?
Currently the user is able to navigate away before the form is saved, if the proccessing takes a long time. The saving-process is asynchronous, so it still will be saved. But if an error occurs, and the user is on a whole different page, the error message won’t be displayed.

So should I stop the user from navigating away while the form is still proccessed?
If yes, how? Overlay over the navigation? Over the whole screen? Info-Message that if navigating away, he won’t be notified if there is an error?
If I shouldn’t stop the user, how should I inform him, if the save-proccess was successfull or failed?

javascript – Contact Form 7 Conditional redirect

As per this ticket on WordPress forum, I have added the below code to my contact form for conditional redirect.

<script type="text/javascript">
inputs = event.detail.inputs;
inputs.forEach( function(el) {
    if ( el.name == "menu-52" ) {
        if ( el.value == "Below $10,000" ) {
            location.href = "https://www.facebook.com";
        } else if ( el.value == "Above $10,000" ) {
            location.href = "https://google.co.in";
        }
    }
});
</script>

But this is not working for me on my contact form and there are some errors on the console also.

Can someone please have a look and let me know where I am making mistake?

Thank you.

8 – Is there a way to pass custom data to a form template?

I have been tasked to customize a view, and I have been struggling with its exposed form, because I need to display some informations. Here is how it should look:

tags

These elements act as a checkbox, but the number on the right is the number of nodes that have this tag linked.

So far, I have nothing code related, because I simply don’t know how to handle this. The theme itself would accept an array of array, each of them containing the checkbox’s text, its value, and this number, like so:

tabs: [
    {
      label: "Topics",
      filtersType: "tag",
      filterName: "loremField[]",
      filters: [
        {
          id: "lorem1",
          label: "Loremi",
          items: "5"
        },
        {
          id: "lorem2",
          label: "Loremi",
          items: "15"
        }
    }
]

However, I’m not able to either pass this “items” key to either the form, and I’m not sure at all that I can customize the input from the hook form alter. For a reference, here is the template:

<div class="c-tag-filters">
  {% for item in filters %}
    <div class="c-tag-filters__item">
      <input id="{{item.id}}" name="{{ filters.filterName }}" class="c-tag-filters__item__input" type="checkbox">
      <div class="c-tag-filters__item__content">
        <label for="{{item.id}}">{{item.label}} <span class="c-tag-filters__item__content--nb">{{ item.items }}</span></label>
      </div>
    </div>
  {% endfor %}
</div>

So, how should I proceed in this case?

Thank you in advance

8 – Displaying another entity’s form on a node

I am trying to embed the edit form for a flag on my node (the full page view mode).

After some struggle, I finally figured out how to get the flagging form. But once I have the form, how do I actually get it to display on the page?

function MYMODULE_node_view(array &$build, NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
  if ($node->getType() == 'MY_CONTENT_TYPE') {
    $flag = Drupal::service('flag')->getFlagById('MY_FLAG_ID');
    $flagging_entity = Drupal::service('flag')->getFlagging($flag, $node);
    $form = Drupal::service('entity.manager')
      ->getFormObject('flagging', 'edit')
      ->setEntity($flagging_entity);
    $form_obtained = Drupal::formBuilder()->getForm($form);
    // How do I actually show the form on the node?

I looked at this question on rendering forms (which says use the formBuilder service, which I am already using). I assume I need to put the form in a render array but the documentation is not clear about how to do that.

addEventListener not working on SharePoint list form load

I have a SharePoint list form and I prepopulated certain fields with sharepont user properites. I also decided to use DOM development for form manipulation on the list form. Using the DOM, I was able to successfully disable certain form elements. I also have a checkbox at the beginning of the form that is supposed to hide certain fields when checked. For some reason, my eventlistener on the checkbox isn’t working like it should.

In the developer tool when looking at the SharePoint list form, I get the following error: ‘Unable to get property ‘addEventListener’ of undefined or null reference
The error points to this line:
document.querySelector('input(title="anonymous")').addEventListener('click',getProperties);

(function(){
  getProperties();
})();

document.querySelector('input(title="anonymous")').addEventListener('click',getProperties);

function getProperties(){
        var web = _spPageContextInfo.webAbsoluteUrl;
        var endPointUrl = web + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties";

        axios.get(endPointUrl).then(function(response) {
            var properties = response.data.UserProfileProperties;
            var displayName = response.data.DisplayName;
            var nameAry = displayName.split(" ");
            if (document.querySelector('input(title="Anonymous")') == false) {
                alert("Anonymous Code");
            }

            var fName = document.querySelector('input(title="First Name")');
            fName.value = nameAry(1);
            fName.disabled = true;

            var lName = document.querySelector('input(title="Last Name")')
            lName.value = nameAry(0);
            lName.disabled = true;

            var eMail = document.querySelector('input(title="Email Address")');
            eMail.value = response.data.Email;
            eMail.disabled = true;
            for (var i = 0; i < properties.length; i++) {
                //Office Phone Number
                if (properties(i).Key == "Office") {
                    var oSymbold = document.querySelector('input(title="Office Symbol")')
                    oSymbold.value = properties(i).Value;
                    oSymbold.disabled = true;
                }
            }
        });
        }

Here’s the weird part, I’m able to run the same exact code(slight modifications) in codepen but reading from typicode/json instead of a SharePoint list and it works perfectly. Here’s the codepen

Any idea why it’s not working in SharePoint?

Any assistance you can provide would be much appreciated. I’ve been tackling this for two days.