DataPicker context with non-integer "id"s (for use in UIBuilder) #409
andrewmckaskill
started this conversation in
Idea
Replies: 1 comment 1 reply
-
I'll not make a PR yet, but I've put together something that works here: I've got another branch with sufficient test data (incl. UI builder) to see that it all works nicely, but I'm going to compile and try in my main solution. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
DataPicker works great in UIBuilder and the context works on UIBuilder entities with integer keys, but I can't use the ContentmentContext to access data about the current item on entities with Guid keys because DataPicker assumes the id is an integer.
I've had a look and think it's pretty easy, but wanted to run it past you first. Here are the changes that I think are needed (which I can do up in a PR):
In data-picker.js:
The test to check the Id assumes the currentPage.id is an integer. For my UIBuilder pages, it's a Guid in string format. (eg. "11111111-1111-1111-1111-111111111111"). On new pages or subpages it's "00000000-0000-0000-0000-000000000000" rather than a 0.
In DataPickerApiController.cs:
and
Change the signature for the "id" field from an int to a string. It isn't being used in this method, and the ContentmentContentContext it checks if it's parseable to an int anyway, so it shouldn't be a problem.
Finally, add a new ContentmentOtherContext class and Interface that tries to access the Id element and return it as a string (or a generic if you like). Then the IContentmentOtherContext could be injected instead of the IContentmentContentContext.
I'm pretty sure that's all that's needed. Any thoughts?
(I might go ahead and try this locally anyway - just because it would make a massive difference to the project I'm working on having contextual data pickers)
Beta Was this translation helpful? Give feedback.
All reactions