Jump to content

Admin Actions


adrian

Recommended Posts

1 hour ago, matjazp said:

I'm testing in Chrome. It's looking good in uikit and reno theme.

Right, I see the problem now looking at it with the default theme. 

I can take a look tomorrow to see if I can get it working there as well.

Link to comment
Share on other sites

Hi @matjazp - I just tested the default theme on Safari, FF, and Chrome and it looks fine here.

The css I added to fix the position of the links (and also the space between the text above the tabs) is:

html.AdminThemeDefault li#AdminActionsList ul.WireTabs {
    margin-top: 3em;
}

https://github.com/adrianbj/ProcessAdminActions/blob/d95cafe225c958db38e015ebe5df329ed9e826db/ProcessAdminActions.css#L5-L7

Would you mind taking a look to see if that is being applied please. Maybe it needs an !important added to it.

I'll sort out that undefined index notice

Link to comment
Share on other sites

6 hours ago, adrian said:

Would you mind taking a look to see if that is being applied please.

It's not applied because AdminThemeDefault class is set on body, not on html. This is what I have now and it's working here:

.Inputfields .InputfieldMarkup .InputfieldContent {
    margin-top: 0;
}

div#links {
    margin-left: calc(100% - 250px);
    text-align: right;
    position: relative;
    top: 35px;
    z-index: 103;
}
.AdminThemeDefault div#links {
      top: .5em;
}

#AdminActionsList {
    background: none;
}
.AdminThemeDefault #AdminActionsList {
    margin-top: 1em;
}

Mind z-index on div#links.

6 hours ago, adrian said:

Also curious why you aren't seeing the icons I recently added to all of the actions

Because there is no $info['icon'], see the php notice in my second screenshot:

array (6)
title => "Copy Content to Other Field" (27) description => "This action copies the content from one field to another field on all pages that use the selected template." (107) notes => "This can be useful if you decide you need to split one field into two to allow different settings on different templates. It also makes it easy to move content from one field type to another one that is incompatible." (216) author => "Adrian Jones" (12) authorLinks => array (3) roles => array (1)

in ...\ProcessAdminActions\ProcessAdminActions.module:388

  • Like 1
Link to comment
Share on other sites

1 hour ago, matjazp said:

It's not applied because AdminThemeDefault class is set on body, not on html.

Interesting - turns out that AOS actually adds AdminThemeDefault to html which is why it was working for me here. @tpr - is this something that can or should be changed?

Anyway, thanks for helping to debug this - I have updated the CSS with part of what you provided above, but it had a problem with UiKit, so it's a combined version that seems to work with both themes and with AOS on and off. Please let me know if it looks ok at your end.

I think if you save the module settings page it should fix the icons. Can you please confirm.

 

Link to comment
Share on other sites

Just now, tpr said:

Unfortunately the default admin theme doesn't have this class on the html while others do so aos adds that to normalize things (for styling and toglle features).

No problem at all - it was an easy fix at my end for AdminActions - just a bit of initial confusion ?

Link to comment
Share on other sites

  • 6 months later...

This is a very useful set of tools.

But I have a problem and I am looking for which tool will help to solve it.

Is there such a function as copying one field of a repeater to another field of a repeater on the same page?

For example, the situation is as follows:
-I have a repeater field for which I want to change the template without losing the values.
-I make a new repeater field with a different name, but with the same fields and add it to the page template.
-I need to copy all the values from the first field of the repeater to the second.

It’s like the "Page Table to Repeater/Repeater Matrix" function or "Copy Repeater Items To Other Page" function.

Sorry if I'm off topic.

Link to comment
Share on other sites

  • 1 month later...

Tip: How to "rename" an image field when the name you want to rename it to already exists

I ran into a situation when I had two single-file image fields.  Let's call them A and B.

I didn't like the field name of 'A' and I wanted to give it a new name of 'B', but that field name was already being used in OTHER templates and had content populated.

Therefore we need a clever way to rename A into B.

With non-image fields this isn't a problem, but with an image field, there's files involved, so it gets a little more complicated.

Admin Actions can handle this using the "Copy Content to Other Field" action.

Set Source to 'A' and Destination to 'B'.

The way it seems to be programmed is that it won't actually make a copy of the file (which is good because I don't want to duplicate the image), but instead it seems to copy the name of the file to the destination image field.

Once the action has been run, if you view the a page using the template you applied to the action to, you will see that the image exists in both fields.  DO NOT TOUCH THEM because whether you delete from A or B, it will delete in both fields.

So now to complete this renaming, edit your template file and remove field "A".  It will remove the field, but it will NOT remove the image, which is good.

The end result is you now have image field 'B' with the contents from 'A', without having had to duplicate the image (meaning any references to that image will still be intact and not 404) and without ProcessWire having deleted the image when you removed "A" from your template.

?

  • Like 3
Link to comment
Share on other sites

  • 4 months later...

Hi @adrian,

Within an admin action we have the option to return true or false depending on if the action succeeded or failed (and I assume success or failure is up to the action author depending on what the overall objective of the action is).

If an action returns true then a database restore link is shown.

2019-10-28_164148.png.1843493f3a34219d3efa4b67abf0634a.png

But it seems that if the action returns false then the link to restore the database is not shown.

2019-10-28_163817.png.746477704efacb5380a8381372e9d78f.png

I'm not sure if no backup is made or it's just the restore link that's missing - maybe the former because when I manually visited the /restore/ URL segment and clicked the Restore button then the restore didn't work. Is it possible to get a backup and a link to restore it when an action returns false?

Also, maybe the background colour of the failure message could be a pale red because it's hard to see links against the dark red (there's actually a link to the logs in the failure message above).

BTW, the module readme doesn't make it entirely clear that an action should return false on the fail state, as only the failureMessage is mentioned:

Quote

At the end of the executeAction() method you can populate $this->successMessage, or $this->failureMessage which will be returned after the action has finished.

 

  • Like 2
Link to comment
Share on other sites

6 hours ago, Robin S said:

The actual action I noticed this on works with an external database so it's not easily shareable but attached is a demo action that shows the issue. Thanks for taking a look at this.

Thanks - from what I can tell, the backup is being created successfully - it's just not linked to. The new version just committed now returns this with the restore link included and the error color changed to match the PW uikit color and also make links white and underlined so they are visible.

You mentioned above that the restore didn't work though, so please test the new version and let me know.

image.png.2d83be3a839a0e7a5665ed55765fed33.png

  • Like 4
Link to comment
Share on other sites

  • 2 months later...
15 hours ago, Knubbi said:

Thanks for the awesome module!

I want to Search&Replace text in content. How to limit/exclude specific language versions of content, please?

Hi @Knubbi - can you please test the attached version of that action?

If it works as expected for you, I'll commit it to the module repo.

 

FieldSetOrSearchAndReplace.action.php

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Hey @adrian,

What do you think about the idea of adding a link to the "Restore" page somewhere within the main interface? I know it's accessible via the flyout menu but it's easy (for me at least) to overlook or forget this and there have been a few times where I've started to worry that I don't have the ability to restore a backup when an action fails due to an error or I've navigated away from the success screen which includes the restore link. Then after a moment I remember where the link is and breathe a sigh of relief. ?

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

I just tried copying repeater items from one page to another and got this error:

ProcessWire\WireException
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '24' for key 'PRIMARY' search►

any idea how to fix?

 .../core/FieldtypeMulti.php:305

295:                }    
296:    
297:                try {
298:                    $query = $database->prepare(rtrim($sql, ", "));    
299:                    $result = $query->execute();
300:                } catch(\Exception $e) {
301:                    if($useTransaction) $database->rollBack();
302:                    if($this->wire('config')->allowExceptions) throw $e; // throw original
303:                    $msg = $e->getMessage();
304:                    if($this->wire('config')->debug && $this->wire('config')->advanced) $msg .= "\n$sql";
305:                    throw new WireException($msg); // throw WireException
306:                }
307:                
308:            } else {
309:                $result = true;

 

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
×
×
  • Create New...