Skip to content
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

LayerSwitcher: Using attribute table seems to crash Hajk whenever the layer contains a date/dateTime field using QGIS Server #1540

Open
eri-blan opened this issue Aug 21, 2024 · 1 comment

Comments

@eri-blan
Copy link

eri-blan commented Aug 21, 2024

Describe the bug
When activating the setting to enable the attribute table, the Hajk client crashes (becomes completely white) when clicking on the attribute table button if the layer contains a dateTime/date field, for instance Date in Oracle or timestamp in PostgreSQL.
image

The dateTime/date field seems to look something like this in the response from QGIS Server:

(GetFeature)

"DATUM": "2022-04-28T00:00:00.000"

(DescribeFeatureType)

  {
                    "alias": "Dating",
                    "localType": "date",
                    "name": "DATUM",
                    "nillable": "true",
                    "type": "date"
  }

I have tried altering the settings below for the layer in QGIS, but to no effect on the attribute table working or not. MUI seems to only accept Date() objects after all. Perhaps valueGetter can be used to convert the dateTime/date strings somehow?
Link to MUI docs
image

To Reproduce
Activate the functionality in Admin for a layer containing any number of dateTime fields. Click on the attribute table icon.

The following type of error will display:

ERROR MUI: datecolumn type only acceptsDateobjects as values. UsevalueGetterto transform the value into aDateobject. Row ID: 0, field: "DATUM". Error: MUI:datecolumn type only acceptsDateobjects as values. UsevalueGetterto transform the value into aDate object. Row ID: 0, field: "DATUM". at throwIfNotDateObject (http://localhost:3000/static/js/bundle.js:67040:11) at Object.gridDateFormatter [as valueFormatter] (http://localhost:3000/static/js/bundle.js:67052:3) at Object.getCellParams (http://localhost:3000/static/js/bundle.js:87296:38) at http://localhost:3000/static/js/bundle.js:70224:41 at applySelector (http://localhost:3000/static/js/bundle.js:90112:10) at useGridSelector (http://localhost:3000/static/js/bundle.js:90132:20) at http://localhost:3000/static/js/bundle.js:70219:107 at renderWithHooks (http://localhost:3000/static/js/bundle.js:151795:22) at updateForwardRef (http://localhost:3000/static/js/bundle.js:154364:24) at beginWork (http://localhost:3000/static/js/bundle.js:156411:20)

Expected behavior
The attribute table shows up as expected.

Additional context
Tested using Oracle and PostgreSQL. Using QGIS/QGIS Server 3.34. I have not tested it with for instance Geoserver. Hajk version 3.14 RC1.

@eri-blan eri-blan changed the title LayerSwitcher: Attribute table seems to crash whenever the layer contains a dateTime field using QGIS Server LayerSwitcher: Attribute table seems to crash whenever the layer contains a date/dateTime field using QGIS Server Aug 21, 2024
@eri-blan eri-blan changed the title LayerSwitcher: Attribute table seems to crash whenever the layer contains a date/dateTime field using QGIS Server LayerSwitcher: Using attribute table seems to crash Hajk whenever the layer contains a date/dateTime field using QGIS Server Aug 21, 2024
@jacobwod
Copy link
Member

jacobwod commented Aug 22, 2024

Hi @eri-blan. The clear description you provide got me thinking and I think the solution could be as simple as adding rows 631-633, as in the screenshot below:

            ...(c.localType === "date" && {
              valueGetter: (value) => value && new Date(value),
            }),

Skärmavbild 2024-08-22 kl  08 19 28

Unfortunately I don't have the time right now to fire it up and test. But I'm giving away it for free – with no guarantees. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants