-
-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix proper deletion of files/images within Flexible layouts #108
base: master
Are you sure you want to change the base?
Fix proper deletion of files/images within Flexible layouts #108
Conversation
Thanks @chrisneal ! Your approach looks nice. I'll review this tonight. With your current insights, do you think there could be an easier way for developers to get this to work, even if it requires more work on our side ? I'm just asking in case you'd have more ideas after implementing these changes. |
@Nyratas I know it's a pain to integrate for users, though this is the only way I can see it working. We're unable to override the DeleteField Nova route or anything, so we need to handle it after that. The only other thing I can think of would be to create |
I've added those... |
@Nyratas Did you get a chance to look this over? |
Hi @chrisneal, I don't think we should add those fields in the package. Except adding a custom Instead, couldn't we parse the Layouts' |
@Nyratas I don't think it hurts to add them, as they're only helpers and personally I would use them as opposed to having to copy the delete helper everywhere. I think adding magic (like you're suggesting) could cause more confusion, especially if the user wants to do something themselves with the delete callback. |
@chrisneal I don't agree on the "adding magic" part, as it won't change usage habits : you can use the same fields inside a Layout as you would inside a model's I however agree on the fact that we should let the ability to define a custom delete callback. Therefore, when applying the "magic" When there is no user callback defined, we could switch back to default behavior. Something like: // We're somewhere in a loop that's parsing the defined layout File fields...
if(is_callable($field->deleteCallback)) {
$callback = $field->deleteCallback;
$field->delete(function(NovaRequest $request, $model) use ($callback) {
return \Whitecube\NovaFlexibleContent\wrapDeleteFile($callback, $request, $model, $this);
});
} else {
$field->delete(function(NovaRequest $request, $model) {
return \Whitecube\NovaFlexibleContent\defaultDeleteFile($request, $model, $this);
});
} |
Of course this is a quick and dirty example of what I mean. Since the |
Add delete callback logic to collection
@Nyratas I've updated the branch to automatically add the delete callback. I don't particularly like the placement of the code, but it is the best place for it IMO. I've also removed the 2 helper files. |
@Nyratas You had a chance to test this? |
@chrisneal I took a look at your code. I will merge this PR but since I have quite a lot of changes to request, I will add those myself before publishing the release. Thanks for your work ! |
@Nyratas I'd be interested to know what changes you want to make. But glad you're going to merge it. |
@Nyratas FYI, I've found a couple of bugs in my code since we last had a conversation. Any idea when you're planning on creating a release? |
@Nyratas You gonna merge this one soon? |
@Nyratas is there much more to do on this PR (other than rebasing onto the latest changes)? Anything we can assist with? |
@chrisneal @FixSource Thank you for your patience and sorry for the inactivity, we had a very difficult deadline for a client. I think @Nyratas wanted to refactor most of the code in this PR, because I recall he found some tricky problems with it. Hopefully he can get to it soon or explain what should be done to get it in shape to merge. Rest assured we are not forgetting about this and intend to get to it as soon as we can. |
Hey guys, any update on this? |
Anything we can maybe help with to get this merged? |
any update on this? |
I don't have this issue but in meantime... I solved a similar problem in another PR (merged) for by adding to
|
What is the status on this? Can this be rebased and merged in the mean time :) |
@voidgraphics @Nyratas Is there going to be any movement on this issue? I'm happy to fork this and apply this fix if needed, but wanted to check that this isn't going to be imminently addressed first. |
Any information on this issue and the possible merge of the fix? |
Any update when this issue will be fix? |
To get this working:
AvailableFields
trait to resources that use Flexible Layouts.delete
callback on file fields.