Add option to autosave draggable tables with ajax

Created on 18 September 2017, almost 7 years ago
Updated 6 June 2024, 21 days ago

Problem/Motivation

In Drupal 7.x-2.x there is a checkbox where you can select Ajax. This will remove the Save button and for easy drag it well save the form.

Proposed resolution

Add same functionality that was in 7.x-2.x into 8.x-1.x

MR35 is the latest working version for 2.1.x

✨ Feature request
Status

Needs review

Version

2.1

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada iStryker

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States loze

    I've dug into this a bit more and have discovered that the error reported in #19 and #30 are not due to this patch.
    This is happening if you have a draggable view with ajax enabled and a views filter

    To reproduce:
    - Install the latest draggable views (unpatched)
    - create a table view page, add the draggable field and enable use ajax
    - Add a views filter
    - save the view
    - visit the view page
    - with the js console open, Drag the table and click "save order" (the order is saved successfully)
    - change the filter (in my case im just changing the published field from yes to any, so it doesn't actually change the rows results)
    - drag the view and click "save order"
    - you will see a 404 error in the console.

    The url the draggable form is calling after you use the filters is /views/ajax, which is returning a 404.
    saving the order before using any filters is calling /your-page-url, which saves correctly

    See the screenshot of my js console.

    Im assuming that this conflict with other ajax forms should be addressed in a separate issue since all this issue is really trying to do is hide the save order submit button and trigger it with javascript.

  • πŸ‡ΊπŸ‡ΈUnited States loze

    I think this is what is going on here https://www.drupal.org/project/drupal/issues/2994868 πŸ› Ajax forms doesn't work properly with ajax views. Active

  • πŸ‡ΊπŸ‡ΈUnited States loze
  • πŸ‡ΊπŸ‡ΈUnited States loze
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States loze

    I think I may have found a workaround. Please try this patch.

  • πŸ‡¨πŸ‡¦Canada liquidcms

    Excite to try out your latest.. but as far as i can tell DVs no longer works (since i have updated from D9.3 to 9.4 since i last looked at this??). I have tried your zip version (without your latest patch) and the clean 2.1.1 version on a simple table view and there is no evidence of a draggable field in the fields list in Views.

  • πŸ‡ΊπŸ‡ΈUnited States loze

    @liquidcms - this patch is for the latest 2.1.x dev. it allows autosaving with ajax for sortable TABLE views only.

    I have tested it both with the latest D9 and D10 and it is working for me, even after other ajax on the view is executed.

    The .zip file I posted a few months ago was just showing that I had gotten draggable DIVs (sort of) working. This patch will not apply to it.

    I intend to revisit that feature once this and some of the other issues in the queue get committed since some of the patches are stepping on each other. This issue is focusing on getting draggable tables to autosave.

  • πŸ‡¨πŸ‡¦Canada liquidcms

    @loze, no problem that this is only for tables stil; but my comment above was that i can't test any of this as DV doesn't seem to work at all any more. There is no field in the views field list to add. Possibly this is broken in 2.1.1 and i need 2.1-dev. Will check that out.

  • πŸ‡¨πŸ‡¦Canada liquidcms

    Nothing from -dev version either. Odd.

  • πŸ‡ΊπŸ‡ΈUnited States loze

    I misunderstood your comment. I thought DV was a typo of DIV, not DraggableView. :)

    That is strange. I see it on a clean install. You don't have a "draggableviews" item in the views field category dropdown?

  • πŸ‡¨πŸ‡¦Canada liquidcms

    correct, no Draggable views category for fields. Same view i was testing this with a few months back.

    I'll try to test out on current vanilla d9 site (D9.3) and see if any issue upgrading that to D9.4.10.

  • πŸ‡¨πŸ‡¦Canada liquidcms

    @loze, been away from this for a while and just having another look.

    so patch in #42 applies to 2.1-dev and is incompatible with your zip above or with the patch in this case: ✨ Support Html List and Unformatted views style plugins. Needs review , correct?

    so no progress on having those 2 features working together?

  • πŸ‡ΊπŸ‡ΈUnited States loze

    The 2 patches probably wont apply together because they both change one or two same lines of code. One needs to be committed first then I can provide a patch for the other feature.

    the .Zip was just to show you my manually patched module with both features working together at the time. It's a little outdated by now though, I wouldn't use it.

  • πŸ‡¨πŸ‡¦Canada liquidcms

    The patch in #42 does not fix the issue in #19 for me.

    I have only this patch and the one from here: πŸ› Undefined draggableviews_structure_parent Closed: duplicate .

    I have:
    - DV 2.1.2
    - set as table with a rendered entity as the only item in the table
    - ajax enabled

    When i refresh the page, checkmark to submit is missing. I have draggable widgets to move the rows. When moved i have a message at the top saving unsaved changes. After a while the message is replaced with a message stating order has been saved. Which then fades away.

    This view, in the header, has a link which opens a user edit form in a modal:

        <div class="col-sm-3">
          <a href="/{{ raw_arguments.null_1 }}/user/{{ raw_arguments.null }}/portal-select" class="use-ajax btn btn-primary btn-block" data-dialog-type="modal" >
            Update list
          </a>
        </div>
    

    if i open this and submit, once the modal is closed, i can see the checkmark widget to save DV order has returned. Making a change still shows the message that i have unsaved changes; but it never goes away.

    There are no js or php errors.

  • πŸ‡ΊπŸ‡ΈUnited States loze

    What is the checkmark widget that you are referring to?

  • πŸ‡¨πŸ‡¦Canada liquidcms

    sorry, possibly some css we have. i mean the "save order" button.

    Went back to your zip file above. :) it is the closest solution i have seen to what we need.

    when other page ajax runs it no longer gets dv js attached, and the save order button shows up again.

    removing/changing this: if ($view->ajaxEnabled()) fixes that. The move now triggers the autosave as before i ran the 2nd ajax on the page but event doesnt fire. I can see that the DV save order button no longer has events attached to it. But don't see where button has js events attached to it.

  • πŸ‡¨πŸ‡¦Canada liquidcms

    i may have found my issue. The data-dialog-type="modal" attrs added to A tag as i showed above is not what is loading the modal, i have custom controller code (/user/1/portal-select) that is doing this. I suspect if i simply reload the view on ajax submit of my form, tyhat it will rebuild correctly and work fine.

  • πŸ‡ΊπŸ‡ΈUnited States loze

    I think we should test if this patch is working for some standard use cases and try to get this feature committed.

    It sounds like you have something fairly advanced going on with your view that involves custom ajax controllers. Any number of things could be going wrong there thats not specifically tied to the patch.

    It also sounds like you have custom css on your submit button that could be overriding this module hiding the submit button when ajax is enabled.

    Hopefully someone else can take a look at this to help move it forward.

  • #42 patch resulted to #19 issue in the latest version.

  • Merge request !35autosave ajax enabled views tables β†’ (Open) created by loze
  • Pipeline finished with Success
    29 days ago
    Total: 235s
    #185391
  • Pipeline finished with Success
    29 days ago
    Total: 261s
    #185441
  • πŸ‡ΊπŸ‡ΈUnited States loze

    My last branch got screwed up this MR35 should work with 2.1.x. Ignore the previous one.

  • πŸ‡ΊπŸ‡ΈUnited States loze
  • Pipeline finished with Success
    29 days ago
    Total: 195s
    #185522
  • Pipeline finished with Success
    26 days ago
    Total: 208s
    #188865
  • Pipeline finished with Canceled
    26 days ago
    Total: 47s
    #188870
  • Pipeline finished with Failed
    26 days ago
    Total: 170s
    #188872
  • Pipeline finished with Failed
    26 days ago
    #188971
  • Pipeline finished with Failed
    26 days ago
    Total: 199s
    #189004
  • Pipeline finished with Failed
    26 days ago
    Total: 551s
    #189053
  • Pipeline finished with Failed
    26 days ago
    Total: 205s
    #189142
  • πŸ‡ΊπŸ‡ΈUnited States loze
  • πŸ‡ΊπŸ‡ΈUnited States loze
  • Pipeline finished with Failed
    25 days ago
    Total: 201s
    #189288
  • πŸ‡ΊπŸ‡ΈUnited States loze

    loze β†’ changed the visibility of the branch 2.1.x to hidden.

  • Pipeline finished with Success
    21 days ago
    Total: 142s
    #193016
  • πŸ‡ΊπŸ‡ΈUnited States loze

    Apologies for all the chatter here, but I think I got all the formatting issues resolved. The pipeline checks pass now.

Production build 0.69.0 2024