Jump to content

ProcessModule Modal before Save


Pete
 Share

Recommended Posts

I'm building a ProcessModule to handle pages that store a version number.

Everything is pretty straightforward apart from the last part. What I want to happen is that when the Save button is clicked instead of saving straight away a modal window pops up asking if the changes made were minor or major, and depending on which button is clicked (minor or major) the minor or major version number is incremented.

Since the minor and major version fields are hidden in the editor, I'm not even sure how to save those (making them hidden doesn't make them a hidden field - they simply don't get rendered) but I suspect some AJAX to append them to the end of the form might work.

My bigger problem is I've no idea how to launch and interact with this modal on page save.

My brain seems to be drawing a blank on every aspect of this one, but I suspect there would be other uses for such modals on page save.

Any suggestions would be greatly appreciated :)

Link to comment
Share on other sites

Pete,

If I get you correctly, there's various approaches to this:

  1. Bind the save button event using jQuery to maybe return the dreaded false!
  2. Disable the save button similar to how PW disables page delete until you confirm by selecting the checkbox (the move to trash button). In your case, for selecting major or minor, I would use radio buttons instead.
  3. If you don't have to use a modal, could be like the drop down box used in Batcher actions.

I think #2 is easiest. If I trace the code in PW that achieves that I'll post here.

Edit:

The more I think about this, the more I think a modal is not the better approach. Depending on the level of activity of the editors, opening a modal every time I want to save a record simply to click other buttons (minor/major) would eventually get on my nerves. I think I'd go for radio buttons + disable save combo....Having said that, I've been using modals myself :-)

About saving the incremented hidden fields, are those hidden fields part of the form? If they are, they will be sent in the $post even if hidden. I'm probably not getting that bit. If not, I would probably append them to the form as the page is rendered (jQuery?). Just thinking out loud here...

Edited by kongondo
Link to comment
Share on other sites

The main reason for the modal is we want to make it something that people HAVE to do before the page will save (otherwise they might not) but we want it to increment by one on the major or minor field depending on what they click. I figured making it a modal would give more scope to expand it if we needed to.

Basically I'm trying to make version numbers idiot-proof so that one or the other always increments on save, but it's down to the user whether it was major or minor edit.

I try not to do anything particularly straightforward :)

I guess an easy first step in the meantime is to have both fields be visible in the editor and just have a confirmation box popup asking the user if they updated the version number so they remember to check it. It's not as foolproof, but it would be a start.

Link to comment
Share on other sites

But you can enforce that easily with the radio buttons (also similar to when changing a page's template in PW). If they do not select a radio button and click save, then you could pop-up a modal saying "you must select a minor or major" version before save. The page would not save until they did since no $post would be sent :-)

Link to comment
Share on other sites

But the major and minor fields on the page would already have the last major or minor version numbers in them so I guess I'd just have to do a quick AJAX query to see if the values had been changed at all.

Or actually I could just grab the initial values with JS on page load and see if either has changed on page save.

I could also use some more JS to make sure they only increment the minor version by 1 and if the major version is incremented the minor versions is set to 0, but then if they mess it up you need an "undo" button.

My head hurts.

Maybe I should just give them the ability to type whatever number in the boxes and urge them to just do it correctly :)

Link to comment
Share on other sites

What I would do, is replace the Save button with two separate buttons: "Save (Major)" and "Save (Minor)". Accent/highlight these as you see fit. The click action of either one would be caught by javascript, where you can then add a hidden field to the page to set the value of major or minor. Then submit the form. The module would hook into the save process to do the actual incrementing of the field value.

  1. The action is clear either way.
  2. There are no number fields for them to screw up (which they would, somehow)
  3. No annoying modal box gets in the way.
  • Like 4
Link to comment
Share on other sites

There will be a guide, but we'll have to do some checks too to make sure.

Major in this case is a change to one of the steps in an article that basically alters the workflow. Minor is spelling corrections or rewording something.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...