getgrav / grav-plugin-admin

Grav Admin Plugin
http://getgrav.org
MIT License
355 stars 227 forks source link

Can not move a page to a folder #1690

Open ulab opened 5 years ago

ulab commented 5 years ago

While editing a page, the Move button allows me to select a folder as target, but the page isn't moved there.

I can move a page into the folder using it's Advanced => Parent select box though.

rhukster commented 5 years ago

we're actually reworking the whole parent/move field, so we'll definitely look at this issue during this process. Thanks.

TheHackmeister commented 4 years ago

I ran into this issue too. Just thought I'd mention the issue only happens if the drop down selection is outside of the "window" that pops up. If you scroll such that the selection falls within the white box, you can select, hit continue and the page will actually move.

I'm pretty sure the logic to exit the move page shadow box is incorrectly getting called when a selection from the dropdown is made. Hope it helps!

adrianw commented 3 years ago

Is this still a live issue? I'm currently have issues moving modules using the current latest version (1.10.17), getting forbidden errors using either the move icon at the top or changing parent.

rhukster commented 3 years ago

I know matias was going to look at this. He's on vacation this week though and will be back next week.

adrianw commented 3 years ago

I know matias was going to look at this. He's on vacation this week though and will be back next week.

Thanks for the update, I think the issue lies actually with the flex-objects plugin, or maybe admins usage of flexobjects, if I disable 'Directories Pages (Admin) ' in flex objects and go back to old style Pages I can then move pages/modules without issue, so at least I have a work around in the meantime.

rhukster commented 3 years ago

thanks for that info.

chronopoulos commented 12 months ago

i had the same issue with Grav v1.7.42.3, Admin v1.10.42. @adrianw your workaround worked for me, thanks

SpuGG commented 3 weeks ago

I have the same problem with Grav v1.7.46 - Admin v1.10.46 and @adrianw's workaround still works.

SpuGG commented 3 weeks ago

Update, it SOMETIMES works. I have 2 sites I'm playing with (just to learn Grav) and they have different plugins.

In the one with the Editorial Theme (B), I have these plugins: image

On my first test site (A), it just uses Quark and I have these plugins: image

It works on site A, but not on B. On site A, it works as expected but on Site B, it will not allow me to select the folder in the dialog box when I try to move pages. So it's possible that the problem lies somewhere else. I will try to play around with turning off various plugins to see if I can isolate the problem (but it will probably take me a few days). If there's any updates, I'll post them here.

SpuGG commented 3 weeks ago

I had a few more cycles so quickly looked at the dev console to see if I could gleam any more information.

It appears that on line 8726 that item is null.

      var item = element[0]._item;
      var column = value.column;
      var data = item[this.config.childKey] || this.data;
      var active = external_jQuery_default()(column).find(".".concat(this.config.className.active));

When you take a look at element[0] it is just the selected folder (e.g. on mouse click): <li class="fjs-item fjs-has-children fjs-item-dir" data-fjs-item="blog"><a href="" tabindex="-1"><span title="Blog"><i class="fa fa-folder"></i>Blog</span><span class="info-container"><span class="badge">8</span><i class="fa fa-caret-right"></i></span></a></li> but it has no _item child. In the working version (Site A), this is not a problem and I can see element[0]._item directly populated.

When I set a breakpoint at line 8855

      var list = external_jQuery_default()('<ul />');
      var items = data.map(function (item) {
        return _this5.createItem(item);
      });
      var fragments = items.reduce(function (fragment, current) {
        fragment.appendChild(current[0] || current);
        return fragment;
      }, document.createDocumentFragment());

It seems to disappear between the var items and var fragments. Inspecting the _this5.createItem() call shows that indeed it attaches what looks like the right object to listItems[0]._item but somehow it disappears in items afterwards.

Actually upon closer inspection, it IS there, but the behaviour is bizarre. Can anyone explain this?

JSON.stringify(items)
'[{"0":{"_item":{"name":"Nested Page","value":"/blog/nested/nested-page","item-key":"nested-page","filename":"nested-page","extension":".md","type":"dir","modified":1724609969,"size":0,"symlink":false,"has-children":false}},"length":1}]'
JSON.stringify(items[0])
'{"0":{"_item":{"name":"Nested Page","value":"/blog/nested/nested-page","item-key":"nested-page","filename":"nested-page","extension":".md","type":"dir","modified":1724609969,"size":0,"symlink":false,"has-children":false}},"length":1}'
JSON.stringify(items[0]._item)

(Context: I JSON.stringify-ed when I was on the var fragments line, so it shouldn't have started the reduce yet.)

So if we can figure out WHY it seems to be the right structure but also not the right structure (e.g. there's a hidden _item property???), then maybe it'll be easier to solve this. This is just odd. Maybe someone can provide a hint here...

Okay, I also tried attaching the object again to another property _backup, but again it does not show up on the object (yet it shows up in JSON.stringify().

JSON.stringify(items[0])
'{"0":{"_item":{"name":"<root>","value":"/","item-key":"","filename":".","extension":"","type":"root","modified":1724350895,"size":0,"symlink":false,"has-children":false},"_backup":{"name":"<root>","value":"/","item-key":"","filename":".","extension":"","type":"root","modified":1724350895,"size":0,"symlink":false,"has-children":false}},"length":1}'
JSON.stringify(items[0]._backup)
undefined