outl1ne / nova-table-field

Table field for Laravel Nova
MIT License
40 stars 27 forks source link

Nova 4 Support #6

Closed ObaydaAlesawi closed 1 year ago

jcsoriano commented 2 years ago

To the maintainers of this project, thanks for sharing this wonderful package! Just wondering if you have plans on supporting Nova 4 for this package?

Nks commented 2 years ago

Added https://github.com/outl1ne/nova-table-field/pull/8

Waiting for approval.

tmartty commented 1 year ago

To the maintainers of this project, thanks for sharing this wonderful package! Just wondering if you have plans on supporting Nova 4 for this package?

+1

harlekoy commented 1 year ago

If your setup still doesn't work because of lodash not declared as global. You can use my fork instead.

"optimistdigital/nova-table-field": "dev-master",
"repositories": {
    ...
    "nova-table-field": {
        "type": "vcs",
        "url": "https://github.com/harlekoy/nova-table-field"
    }
},
nathan-io commented 1 year ago

Thanks for the tip @harlekoy . Unfortunately this fork still isn't working for in my Laravel 9.47.0 / Nova 4.22.2 project. While I can install the package without issue, I'm seeing console errors and a 404 when I save settings.

The first time I click "Save settings", no API request is made, but there is a console error:

nova-settings:4 ReferenceError: _ is not defined
    at Proxy.finalPayload (nova-table-field:4:31388)
    at we.run (reactivity.esm-bundler.js:185:25)
    at get value [as value] (reactivity.esm-bundler.js:1147:39)
    at Object.get [as finalPayload] (runtime-core.esm-bundler.js:3436:30)
    at Object.get (runtime-core.esm-bundler.js:3109:24)
    at Proxy.fill (nova-table-field:4:29671)
    at nova-settings:4:173325
    at Proxy.forEach (<anonymous>)
    at Proxy.formData (nova-settings:4:173295)
    at we.run (reactivity.esm-bundler.js:185:25)

When I click "Save settings" again, it creates a request and there's another console error:

xhr.js:187          POST https://fge.test/nova-vendor/nova-settings/settings 404
(anonymous) @ xhr.js:187
e.exports @ xhr.js:13
e.exports @ dispatchRequest.js:51
u.request @ Axios.js:108
r.forEach.u.<computed> @ Axios.js:140
(anonymous) @ bind.js:9
updateRequest @ nova-settings:4
(anonymous) @ nova-settings:4
f @ nova-settings:4
(anonymous) @ nova-settings:4
(anonymous) @ nova-settings:4
St @ nova-settings:4
a @ nova-settings:4
(anonymous) @ nova-settings:4
(anonymous) @ nova-settings:4
update @ nova-settings:4
(anonymous) @ nova-settings:4
(anonymous) @ runtime-dom.esm-bundler.js:1482
nn @ runtime-core.esm-bundler.js:155
rn @ runtime-core.esm-bundler.js:164
n @ runtime-dom.esm-bundler.js:370
nova-settings:4 Error: Request failed with status code 404
    at e.exports (createError.js:16:15)
    at e.exports (settle.js:17:12)
    at XMLHttpRequest.y (xhr.js:54:7)

The request that returns 404 is to https://site.test/nova-vendor/nova-settings/settings, but the page I'm using the table field on is https://site.test/admin/nova-settings/retail-sales. Not sure if this makes a difference.


Perhaps a complication is that I'm using this package in conjunction with outl1ne/nova-settings v5.0.8, rather than saving the table data to a model.

Here's my usage:

        \Outl1ne\NovaSettings\NovaSettings::addSettingsFields([
            Panel::make('Category', [
                Table::make('Products', 'retail_sale_products')
                    ->minRows(2)
                    ->minColumns(4)
                    ->maxColumns(4),
                DateTime::make('Products Last Updated', 'retail_sale_products_last_updated'),
            ]),
        ], [
            'retail_sale_products_last_updated' => 'datetime',
            'retail_sale_products' => 'array',
        ], 'Retail Sales');
nathan-io commented 1 year ago

Hi @KasparRosin or @Nembie any plans to release a Nova 4 compatible version?

Nembie commented 1 year ago

Hi @nathan-io , I tried the PR#8 done by @Nks, the only thing I noticed (and the reason it didn't work, i had the same problem as you) it seems to be a misconfiguration in the nova.mix.js file.

Here is my change:

const mix = require('laravel-mix')
const webpack = require('webpack')
const path = require('path')

class NovaExtension {
  name() {
    return 'nova-extension'
  }

  register(name) {
    this.name = name
  }

  webpackPlugins() {
    return new webpack.ProvidePlugin({
      _: 'lodash',
      Errors: 'form-backend-validation',
    })
  }

  webpackConfig(webpackConfig) {
    webpackConfig.externals = {
      vue: 'Vue',
    }

    webpackConfig.resolve.alias = {
      ...(webpackConfig.resolve.alias || {}),
      'laravel-nova': path.join(
        __dirname,
        '../../vendor/laravel/nova/resources/js/mixins/packages.js'
      ),
    }

    webpackConfig.output = {
      uniqueName: this.name,
    }
  }
}

mix.extend('nova', new NovaExtension())

Once the file has been modified everything seems to work correctly but doing other tests would not be bad before the public release :)

nathan-io commented 1 year ago

Hi @allantatter thanks for merging the PR! Could you tag a new release?

allantatter commented 1 year ago

@nathan-io I'm very sorry about the delay. I had problems with testing your changes then and moved myself to other priorities. I turned out nothing was wrong from your part and published a new release now tagged 2.0.0.

Keep in mind that the package namespace was also changed from optimistdigital/nova-table-field to outl1ne/nova-table-field according to our company's brand change that happened a while ago.

https://packagist.org/packages/outl1ne/nova-table-field