zioth / dokuwiki_fastwiki

DokuWiki plugin which speeds up user interactions by avoiding page loads, rendering content client-side and pre-loading content.
GNU General Public License v2.0
9 stars 2 forks source link

Conflicts with struct plugin #25

Closed micgro42 closed 6 years ago

micgro42 commented 8 years ago

Hi, unfortunately this plugin causes the struct autocompletion / datepicker to be missing on do=edit-views. I'm not sure if this has to be fixed here or within the struct-plugin.

zioth commented 8 years ago

I don't think edit-views is a standard Doku action. I'm probably just searching for do=edit, and not taking extra characters in the action into account.

zioth commented 7 years ago

My guess was wrong. Where are you seeing this do=edit-views mode?

zioth commented 7 years ago

Any update @micgro42 ?

micgro42 commented 7 years ago

I will check. Thank you for reminding me, that this issue is still open 🙂

zioth commented 7 years ago

@micgro42 I just installed the struct plugin and tried to quickly figure it out, but it's going to take longer. If you let me know how to reproduce the bug, I can take a look.

micgro42 commented 6 years ago

I can confirm that the issue still exists.

Basic steps to reproduce:

It seems that any autocomplete is missing, using the datepicker just seems easier to reproduce initially as we do not have to populate some entries for the autocomplete to fetch.

zioth commented 6 years ago

Thanks! I can now reproduce it.

The issue is that struct does some initialization when the page is loaded, but the fastwiki inline editor isn't initialized until after that. Unfortunately, this is difficult to fix because of the way struct is implemented. Each js file executes inside a jquery load closure. It also has to execute inside a fastwiki event, but the way it's written right now, every JS file would have to be loaded on the page twice, doubling the size of struct's JS. If the code were restructured slightly (for example, to use constructors instead of @includes), it would be easier to fix.

Here's the hacky, JS-doubling fix -- add this to the bottom of struct/script.js:

jQuery(window).on('fastwiki:afterSwitch', function(evt, viewMode, isSectionEdit, prevViewMode) {
    jQuery(function () {
        /* DOKUWIKI:include script/functions.js */

        /* DOKUWIKI:include script/EntryEditor.js */
        EntryEditor(jQuery('#dw__editform, form.bureaucracy__plugin'));

        /* DOKUWIKI:include script/SchemaEditor.js */
        SchemaEditor();

        /* DOKUWIKI:include script/LookupEditor.js */
        jQuery('div.structlookup table').each(LookupEditor);

        /* DOKUWIKI:include script/InlineEditor.js */
        InlineEditor(jQuery('div.structaggregation table'));
            });
    });
zioth commented 6 years ago

After some more testing, it's not so bad. Replace all of script.js with this:

(function() {
    /* DOKUWIKI:include script/functions.js */
    /* DOKUWIKI:include script/EntryEditor.js */
    /* DOKUWIKI:include script/SchemaEditor.js */
    /* DOKUWIKI:include script/LookupEditor.js */
    /* DOKUWIKI:include script/InlineEditor.js */

    function init() {
        EntryEditor(jQuery('#dw__editform, form.bureaucracy__plugin'));
    SchemaEditor();
        jQuery('div.structlookup table').each(LookupEditor);
        InlineEditor(jQuery('div.structaggregation table'));
    }

    jQuery(init);

    jQuery(window).on('fastwiki:afterSwitch', function(evt, viewMode, isSectionEdit, prevViewMode) {
            if (isSectionEdit) {
                init();
            }
    });
});
zioth commented 6 years ago

I've submitted the fix in a struct ticket:

https://github.com/cosmocode/dokuwiki-plugin-struct/issues/351

zioth commented 6 years ago

This fix was merged into the struct plugin on January 2, 2018.