Comments (23)
Hi guys,
Just to clarify, "hard to read" not meaning it's not good code, it is, meaning it's hard to keep a mental model in one's head of all the moving parts and track each variables actual value etc.
If you have not developed a Nova plugin and have not got a handle on the inner workings is quite daunting.
Thanks again for a great tool.
from nova-flexible-content.
Looks like something related is happening when you use a Trix field. Getting 404s when adding images to a Flexible layout containing a Trix field.
Flexible::make('Content')
->addLayout('Simple content section', 'wysiwyg', [
Text::make('Title'),
Trix::make('Content')->withFiles('local')->alwaysShow()
]),
A normal Trix upload will post to (eg):
/nova-api/blocks/trix-attachment/content
whereas within a Flexible field, it's posting to:
/nova-api/blocks/trix-attachment/4dd76ad5528575d4__content
and getting a 404 response.
from nova-flexible-content.
Hi all,
Just checking for an update on this, I find it hard to believe on such a great tool this has not been fixed, unless we are doing something wrong. Basically one cannot remove and image without deleting the whole layout and that leaves the assets on disk.
I am looking into it, but code is quite complex. Did anyone sort this?
from nova-flexible-content.
Yup, the issue lies here in FieldDestroyController
in the handle
method. As @Nyratas pointed out - when Nova tries to find the field by attribute it fails, because the field does not exist in the root.
$field = $resource->updateFields($request)
->whereInstanceOf(File::class)
->findFieldByAttribute($request->field, function () {
abort(404);
});
One of the solutions could be to overwrite the updateFields
method on the resource by returning a custom FieldCollection
instance which uses a different way to find fields by attribute. This could all be part of the package, you could just include a trait in your resource.
I might give it a go in the coming days.
On second inspection - overriding the availableFields
method on the resource and applying a custom instance of the collection should do the trick.
from nova-flexible-content.
I looked at that issue quickly, the only solution I can think of is to have a FlexibleFile
/FlexibleImage
field that emulates the same behavior as the original File
field but will allow us to change the controller actions called by the vue component. The issue with that solution is that we'll have to track and maintain the same level of functionality than the original Nova field, it's not frequently updated but still.
Does that makes sense or do you have any other idea? I could work on a PR in a few days, let me know!
from nova-flexible-content.
+1 Is this already fixed? I have the same issue and can't remove any images.
from nova-flexible-content.
Any progress on this?
from nova-flexible-content.
I guess it's a complicated fix so does it make sense to update the docs to say that you can use a Trix field but not with images?
from nova-flexible-content.
Does anyone have a solution for bypassing this issue?
from nova-flexible-content.
@ajarti i tried so fix it myself but like you said the code is complex and hard to read.
i'm already looking for another package.
from nova-flexible-content.
@Nyratas Is there maybe a way we can also intercept this delete request in a middleware similar to what we have done for media library fields?
from nova-flexible-content.
@voidgraphics We could give it a try, but once again, that's a dirty workaround and I'm not sure we'll be able to fix it that way since it involves altering the behavior of an original Nova Controller.
For everyone's information, the file's delete route uses the resource's identifier and its field's attribute as parameters. This way, the controller will be able to find the file by resolving the field on the resource. If the file field is used inside a Flexible Content, the Nova Controller won't be able to find it (because it is not a root field of the resource) and returns an error. Believe me, this is not an easy issue.
@wimurk I agree, the code may sometimes be quite complex. Knowing it has multiple complex responsibilities in an environment that has not been built for its behavior, this may cause complex workarounds. However, it is not "hard to read" (in my opinion). Each method is documented, we use a clear naming convention, avoid method complexity as much as possible and do our best to implement SOLID principles wherever we can. I'm sure there's still room for enhancement, of course. Feel free to suggest code style changes if needed.
from nova-flexible-content.
So what I've tried to do was to flatten the array of available fields on DELETE requests - but then I have an issue because the query does not go through for updating in the database.
I somehow get over the "findFieldByAttribute" method by flattening the array of fields - but then it stops for me. If anyone can help I'd be happy to share my code and what I've done so far.
I don't even want to get started on nested flexible content etc.
from nova-flexible-content.
@slovenianGooner can you create a merge request so we can pull from that branch.
from nova-flexible-content.
from nova-flexible-content.
Any updates on this?
from nova-flexible-content.
it looks like these commits were launched in v0.2.6, but the problem persists.
from nova-flexible-content.
@paperscissors this problem exists since the beginning and there has not been an attempt to fix this since. Nova's file fields still need to be "root" fields for this to work, which is not the case when they're used inside Flexible fields.
from nova-flexible-content.
any update about the issue ?
from nova-flexible-content.
Just ran into this. Seems like no progress is being made.
If possible you can disable downloads and deletions. In my case this works fine but Nova really needs to sort out its fields system:
->deletable(false)
->disableDownload()
from nova-flexible-content.
Still persists
from nova-flexible-content.
Still persists
from nova-flexible-content.
Still persists
from nova-flexible-content.
Related Issues (20)
- BelongsTo relationship issue HOT 2
- Z-index incompatibility with the most recent version of Laravel Nova HOT 11
- Delete layout error <danger-button> HOT 2
- Dependent Fields not working HOT 4
- Call to undefined method preventsAccessingMissingAttributes() HOT 3
- "Add layout" dropdown overflow HOT 1
- Not working with replicate function HOT 4
- Dark mode issues HOT 2
- Float-left class not working HOT 1
- Nested flexible layout width HOT 1
- Flexible Content Layouts Truncated When Insufficient Form Content Present HOT 1
- Compatiblity issue with spatie/laravel-medialibrary ^11.4.2
- Resource Details view fails to load in Nova 4.32.13 and up HOT 19
- Laravel 11 Support
- Button cover by card
- The flexible-search-menu does not work. HOT 1
- Regression: Delete button is broken HOT 4
- Can't update models with any flexible field HOT 7
- Flexible isn't opening on Detail and Edit page with Nova v3.3 and Laravel 10
- Flexible not work with DependOn
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nova-flexible-content.