Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2017-11-08 12:54:26

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Add the ability to alterate admin UI messages

As said before, I worked on an experimental plugin to test the flexibility of the upcoming Skin package.
This plugin allow to export a page, form or style on saving.
It is easy to use callback events to add this kind of feature but I can’t find a way to inform the user that the template export failed or succeeded.
Shouldn’t we have a hook to alterate UI messages?
I guess the problem would be to ensure the message is correctly strutured (string or array using the right status), but there should be a way to achieve that… What do you think?

Last edited by NicolasGraph (2017-11-08 12:55:03)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#2 2017-11-08 15:48:53

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

Re: Add the ability to alterate admin UI messages

Mmmm, interesting.

If we get the callback structure right (and I haven’t forgotten about consistent callbacks) then this could be a good candidate for either appending or amending or replacing the admin messages.

It’s especially more relevant if we start permitting pre- and post- action callbacks, as you might want to abort prior to save and supply a dfifferent type of status message (warning, for example).

Any bright ideas on implementation, anyone? Without offering too much chance of breaking anything?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2017-11-08 16:26:04

etc
Developer
Registered: 2010-11-11
Posts: 5,192
Website GitHub

Re: Add the ability to alterate admin UI messages

I’m testing the client-side announce (introduced for multiple files upload) portability to the whole admin side. One of its benefits would be the possibility to merge multiple categorized messages or to replace the existing ones with a new one. But even now you can send a custom message via pagetop() function, or am I missing something?

Offline

#4 2017-11-08 16:32:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

Re: Add the ability to alterate admin UI messages

Yes, if you’re building an entire admin-side page, you can use pagetop() but if you’re hooking into a save routine or something more granular in our API (e.g. form.create) then I think you’re at the mercy of the messages the page itself throws.

Looking forward to trying out the announce changes.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2017-11-08 16:45:15

etc
Developer
Registered: 2010-11-11
Posts: 5,192
Website GitHub

Re: Add the ability to alterate admin UI messages

Can’t you use app_mode=async and

send_script_response(announce($message));

like we do to update partials?

Offline

#6 2017-11-08 17:48:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

Re: Add the ability to alterate admin UI messages

etc wrote #307721:

Can’t you use app_mode=async and send_script_response(announce($message));... like we do to update partials?

Maybe. Never tried it. Nicolas?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2017-11-09 08:43:34

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Add the ability to alterate admin UI messages

etc wrote #307721:

Can’t you use app_mode=async and

send_script_response(announce($message));...

like we do to update partials?

I will take a look at this and come back if I have questions (I’m not familiar with these functions), or if it work… Thanks.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#8 2017-11-09 09:49:34

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Add the ability to alterate admin UI messages

I tried this:

namespace Oui {

    class Message
    {
        public function __construct()
        {
            register_callback(array($this, 'sendMessage'), 'page_saved');
        }

        public function sendMessage($event, $step)
        {
            send_script_response(announce(array('ERROR!', E_ERROR)));

            return;
        }
    }

    new Message();
}

but on page saving it shows that:

;

<script>
$(document).ready(function ()
                {
                    $("#messagepane").html("<span class=\"messageflash error\" role=\"alert\" aria-live=\"assertive\"><span class=\"ui-icon ui-icon-alert\"><\/span> ERROR!&#160;<a class=\"close\" role=\"button\" title=\"Close\" aria-label=\"Close\" href=\"#close\">&#215;<\/a><\/span>");
                });
</script>
<noscript>
<span class="messageflash error" role="alert" aria-live="assertive"><span class="ui-icon ui-icon-alert"></span> ERROR!&#160;<a class="close" role="button" title="Close" aria-label="Close" href="#close">&#215;</a></span>
</noscript>;
<!DOCTYPE html>
…

I guess I’m missing something…

Last edited by NicolasGraph (2017-11-09 11:06:16)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#9 2017-11-09 10:23:32

etc
Developer
Registered: 2010-11-11
Posts: 5,192
Website GitHub

Re: Add the ability to alterate admin UI messages

Try to post to the page saving URL with app_mode=async parameter.

Offline

#10 2017-11-09 10:56:01

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Add the ability to alterate admin UI messages

etc wrote #307733:

Try to post to the page saving URL with app_mode=async parameter.

I changed the event to page_updated which, I think, is send in async mode. Shouldn’t It work?
As far as I tried, nothing happens. I mean nothing more than the update.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#11 2017-11-09 10:58:06

etc
Developer
Registered: 2010-11-11
Posts: 5,192
Website GitHub

Re: Add the ability to alterate admin UI messages

What is the server response, still the same?

Offline

#12 2017-11-09 11:03:07

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Add the ability to alterate admin UI messages

etc wrote #307737:

What is the server response, still the same?

No, the page is updated normally; nothing more.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

Board footer

Powered by FluxBB