Jump to content
bernhard

[solved] Weekend Challenge: RockTabulator needs JS Experts :)

Recommended Posts

I've a strange problem where I got stuck developing RockTabulator and I'd really appreciate getting help. I had to refactor quite a bit and the earlier working "rowactions" now don't work any more. See the short screencast demonstrating the problem:

You can install this setup easily by downloading the files here: https://transfer.sh/3YGE7/tabulator.zip (will be available for 14 days)

Please make sure you are not installing it in a sub-folder!!

Then just restore the database from https://transfer.sh/KFjiY/tabulator.zip and login as tabulator/tabulator

The interesting parts of the code are:

https://github.com/BernhardBaumrock/RockTabulator/blob/a868858bdd85d20dba056d6b07c6ecbd0c69c894/rowactions/_rowactions.js#L90-L99

https://github.com/BernhardBaumrock/RockTabulator/tree/a868858bdd85d20dba056d6b07c6ecbd0c69c894#L38

https://github.com/BernhardBaumrock/RockTabulator/blob/a868858bdd85d20dba056d6b07c6ecbd0c69c894/RockTabulatorGrid.js#L122-L139

I wonder why grid.reload() behaves differently in the ajax callback and when using it from the console. And also why the clicks on the trash icons are not intercepted correctly after reloading the grid 😞 

Thx for your help!

Share this post


Link to post
Share on other sites

Downloading now... but quickly looking at the code: Did you try to remove return false, and instead use event.preventDefault() after line 91 in _rowactions.js?

  • Like 1

Share this post


Link to post
Share on other sites

only-23-hours-left.PNG.f36ae3b02cdd9cd0e288bb05eb5f7bc9.PNG

Wow... this should be fun! I removed the cache insert queries, but now it still says 7 hours (using HeidiSQL)... 😐

  • Confused 1

Share this post


Link to post
Share on other sites
1 hour ago, dragan said:

Did you try to remove return false, and instead use event.preventDefault() after line 91 in _rowactions.js?

no, but that should not  be the issue as it works when the grid is freshly loaded https://stackoverflow.com/a/1357151/6370411

58 minutes ago, dragan said:

Wow... this should be fun! I removed the cache insert queries, but now it still says 7 hours (using HeidiSQL)... 😐

😲

hup7u1W.png

That one should be better: https://transfer.sh/KFjiY/tabulator.zip

EiINwTw.png

Thx for having a look!

PS: The second sql file is a regular sql backup while the first one is a PW interal database backup. I know that PW adds some overhead to the backup files with additional checks but I've been wondering for a while now if that is really the best... But that's a different topic 🙂 

Share this post


Link to post
Share on other sites

OK, finally the sql-import is done and I'm in the admin. But under setup/rocktabulator/ I just see "ProcessWire: Process does not exist: Module 'ProcessRockTabulator' is not present or listed as installable"

and under modules it says "no modules found"

Share this post


Link to post
Share on other sites

Please try the second db dump that I linked above (takes 1min on my laptop). Just tried and everything works 🙂 

Share this post


Link to post
Share on other sites

Right, after clearing caches, I can now see your modules installed. Now on to the next challenge:

Folder /tabulator/site/modules/RockTabulator/examples/ does not exist, Folder /tabulator/site/modules/RockTabulator/examples/ is not writable for PHP

It exists, and the examples are there, but apart from the error messages I don't see any files in PW. I'm on Windows w/Laragon. Even trying to create a new file "rt14_test.php" didn't work: not writeable error again.

Share this post


Link to post
Share on other sites

Wow, the 2nd .sql loads really fast... wished I didn't waste time with the other one.

But unfortunately, the "not writable" errors are still there.tabulator-error.thumb.PNG.bcd41ae70193c773588e7b970c927f95.PNG

Share this post


Link to post
Share on other sites

Strange, I'm also on Win10+Laragon... can you access the example directly at /tabulator/setup/rocktabulator/?name=rt12_rowactions ?

Share this post


Link to post
Share on other sites
3 minutes ago, dragan said:

Wow, the 2nd .sql loads really fast... wished I didn't waste time with the other one.

Yeah sorry for that... The default db dump sucks unfortunately...

3 minutes ago, dragan said:

But unfortunately, the "not writable" errors are still

Just remove those lines from the code 🙂 

Share this post


Link to post
Share on other sites

nope: I get "ProcessRockTabulator: No PHP file for rt12_rowactions found - please create it!"

Share this post


Link to post
Share on other sites

OK, I did that, then tried to access the example file directly again, and whoops, get a 403 error. Updated to latest dev, and now even stranger stuff happens. I can't even get to the backend again - just get a 403 EVERYWHERE, incl. frontend. *sigh*

Share this post


Link to post
Share on other sites

Well... restoring an existing installation should not have been the challenge 😞 No idea what's going on. I think the best would be to reinstall everything, clear everything (db, browser cache/cookies)...

You can also try to follow the instructions there: https://github.com/BernhardBaumrock/tabulator.test and install it via GIT (make sure to specify the new-init-method branch)

git clone -b new-init-concept git@github.com:BernhardBaumrock/tabulator.test.git .

 

Share this post


Link to post
Share on other sites

There's other funky stuff going on as well: When trying to access setup/rockfinder2/sandbox/?name=01_cats

I get this:

tabulator-error2.PNG.c4a1f65e2e97bbf788d266192ffddb87.PNG

site/templates/.php ?

Share this post


Link to post
Share on other sites
1 minute ago, dragan said:

which is rubbish, since I have this installation in a subdir: localhost/tabulator/

I guess that's the issue! I'm never using installations in a subdir so there might be some quirks about paths and urls...

Share this post


Link to post
Share on other sites

*grumble*... yeah so now I restarted Laragon and used tabulator.test instead - seems to work now. Sheesh. Please do not use absolute paths/urls, but PW's $config->urls / ->paths instead.

Share this post


Link to post
Share on other sites
4 minutes ago, dragan said:

Please do not use absolute paths/urls, but PW's $config->urls / ->paths instead.

Thx for reminding me about that 🙂 

  • Like 1

Share this post


Link to post
Share on other sites

OK, I really gotta get going soon. I couldn't fix anything in that short period of time, but I noticed something strange:

line 5 of trash.js:

var grid = RockTabulator.getGrid(e.target);

PHPStorm says "unresolved function or method getGrid"

same goes for the next line: it doesn't recognize rowactions. Don't know if it helps...

Share this post


Link to post
Share on other sites

Yep: you should get used to use "use strict" in every JS file, then you would have found this error earlier: 

https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Strict_mode

Now I see this is my console:

jsconsole.thumb.PNG.7c2255b09f257988068d527eb63fbf91.PNG

Also, I see quite a few IDE warnings like these:

panel.js: if(name != 'panel') return;

Quote

Comparison name != 'panel' may cause unexpected type coercion
This inspection reports usages of JavaScript equality operators which may cause unexpected type coercions. It is considered a good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.


 

Share this post


Link to post
Share on other sites

Also:

if(!RockTabulator) {
    console.log('there is no RT here!');
}

RT is not even instantiated / defined in trash.js, so even just hardcoding the tabulator with a DOM-selector won't help...

Share this post


Link to post
Share on other sites

RockTabulator is the global object that is loaded in RockTabulator.js and therefore it's available in all files that are loaded after RockTabulator.js - which is the case for all plugins...

Share this post


Link to post
Share on other sites

Well, in the case of trash.js RT is clearly NOT defined and recognized. Try it out yourself. Consoles don't lie :-)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...