Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SS4.1.0 BUG: GridFieldOrderableRows no AJAX js loading, wrong AJAX processing #257

Closed
a2nt opened this issue Apr 28, 2018 · 4 comments
Closed

Comments

@a2nt
Copy link

a2nt commented Apr 28, 2018

I have created SS-CMS issue report here about loading JS using AJAX headers which doesn't work: silverstripe/silverstripe-cms#2156

But there's an other issue:
To fix previous one I have tried to pre-load GridFieldExtensions JS+CSS using this config as temporary fix:

SilverStripe\Admin\LeftAndMain:
  extra_requirements_javascript:
    - 'symbiote/silverstripe-gridfieldextensions:javascript/GridFieldExtensions.js'
    - 'symbiote/silverstripe-gridfieldextensions:javascript/tmpl.js'
  extra_requirements_css:
    - 'symbiote/silverstripe-gridfieldextensions:css/GridFieldExtensions.css'

Extension assets were loaded when I have opened: /admin
So I have browsed to a specific page using tree view and re-ordered items:

  1. I have noticed an AJAX request using chrome dev-tools and loading spinner appeared
  2. I have noticed a message "Records reordered."
  3. CMS kept blocked by loading spinner

So I have opened GridFieldExtensions.js, found a line $(".ss-gridfield-orderable tbody").entwine({
and form.addClass('loading'); inside it
Just before adding loading class I have created alert('Loading') and it works ok
Then there goes $.ajax request to check if it works I have created another alert('Success') inside success function and it doesn't works.

As temporary fix I have created done function

$.ajax(....).done(function(){
  self.trigger('reload', self);
  form.removeClass('loading');
});

It works now, but it's just temporary fix.
Guess both bugs are connected and maybe it's just SS4.1.0 bug cuz actually it looks ok on your side

@robbieaverill
Copy link
Contributor

Hi @a2nt

I can't reproduce with CWP 2.0.0-rc3, which includes:

  • SilverStripe core 4.1.0
  • silverstripe/userforms 5.1.0
  • symbiote/silverstripe-gridfieldextensions 3.1.1

I'm testing GridFieldOrderableRows via the "Form Fields" tab for a user defined form page, which uses it to reorder the form fields.

When I drag and drop records I see a loading spinner which goes away after the AJAX has finished processing.

Can you pease provide a working example so I can replicate this issue?

@robbieaverill robbieaverill removed their assignment May 4, 2018
@a2nt
Copy link
Author

a2nt commented May 4, 2018

@robbieaverill looks like the issue comes from colymba/gridfield-bulk-editing-tools 3.0.0-beta4

Causes the issue:

public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $conf = GridFieldConfig_RelationEditor::create(50);
        $conf->addComponent(new GridFieldOrderableRows('SortOrder'));
        $conf->removeComponentsByType('GridFieldDeleteAction');
        $conf->addComponent(new BulkUploader());
        $conf->addComponent(new BulkManager());
        $conf->getComponentByType('Colymba\\BulkUpload\\BulkUploader')->setAutoPublishDataObject(true);

        $fields->addFieldToTab('Root.GalleryImages', GridField::create('GalleryImages', 'GalleryImages', $this->GalleryImages(), $conf));

        return $fields;
    }
}

Works ok:

public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $conf = GridFieldConfig_RelationEditor::create(50);
        $conf->addComponent(new GridFieldOrderableRows('SortOrder'));
        $conf->removeComponentsByType('GridFieldDeleteAction');

        $fields->addFieldToTab('Root.GalleryImages', GridField::create('GalleryImages', 'GalleryImages', $this->GalleryImages(), $conf));

        return $fields;
    }
}

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Jun 1, 2018

@a2nt I have not been able to reproduce this, even using the colymba/gridfield-bulk-editing-tools module. I suspect it might be related #246. Are you still able to reproduce this issue?

I'm going to close this as you've raised silverstripe/silverstripe-gridfield-bulk-editing-tools#176. I assume it'll either be the same as #246 or caused by the other module.

@ScopeyNZ ScopeyNZ closed this as completed Jun 1, 2018
@robbieaverill
Copy link
Contributor

@ScopeyNZ FYI if this issue is related to silverstripe/cwp#141 then I couldn't reproduce this locally, only on CWP. Not sure why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants