GithubHelp home page GithubHelp logo

Comments (21)

Piedone avatar Piedone commented on June 2, 2024

Can you elaborate a bit Mike, what would you be most interested in? I suppose just adding an example with such a content type being created from migrations wouldn't help much.

from orchard-training-demo-module.

devlife avatar devlife commented on June 2, 2024

Yes! I have an OC site which is a decoupled CMS. All content types/items have been created via the admin UI. Using your (amazing) training module I'm trying to convert all content types to C#, creating custom editors, etc. I have a content type which has a few taxonomy fields. What I would like to know how to do is how to create taxonomies and reference them in C# like this:

image

The Tags taxonomy in the screen shot uses the new "tags" functionality while the Branching Strategy is just a standard taxonomy.

from orchard-training-demo-module.

Piedone avatar Piedone commented on June 2, 2024

In the O1 version of our Helpful Extensions module, we have a content type code generation feature. Wouldn't this be something you're looking for?

from orchard-training-demo-module.

devlife avatar devlife commented on June 2, 2024

That does sound very interesting! At this point, though I'm more interested in the knowledge than an automation step. Although I suppose seeing the output of that would provide a lot of knowledge.

from orchard-training-demo-module.

devlife avatar devlife commented on June 2, 2024

Oh I see now. So that's how I would add the field. I would then use a recipe to create the custom taxonomy and associate it with the content type?

from orchard-training-demo-module.

Piedone avatar Piedone commented on June 2, 2024

That would be one way, yes. There's not much unique in adding a specific field apart from its own settings. If we have code generation then that can be much easier. Then adding the Taxonomy itself can happen just with recipes as that's a lot more data usually than what you want to keep in C# (but if it's just a 5-term Taxonomy you also could very well add the terms from code, with IContentManager.

from orchard-training-demo-module.

Piedone avatar Piedone commented on June 2, 2024

I've implemented the migration code generation feature in this branch (I wanted to do it for a while anyway): Lombiq/Helpful-Extensions#5 Could you please check it out if it helps you?

from orchard-training-demo-module.

devlife avatar devlife commented on June 2, 2024

Oh this looks great! How do I run it? Add a nuget package reference and hit a url?

from orchard-training-demo-module.

Piedone avatar Piedone commented on June 2, 2024

Not yet since it's just in a branch. I'll work on it a bit some more, so, for now, checkout its branch from the repo and add it as source to your solution just as your own modules. Here's how to use it: https://github.com/Lombiq/Helpful-Extensions/pull/5/files#diff-1e290ac8433d555bce009b162cb869d0

from orchard-training-demo-module.

devlife avatar devlife commented on June 2, 2024

I gave it a try but am getting an exception:

image

System.InvalidCastException: Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JValue'.
   at Lombiq.HelpfulExtensions.Extensions.CodeGeneration.CodeGenerationDisplayDriver.<Edit>g__AddSettingsWithout|0_2[T](JObject settings, Int32 indentationDepth, <>c__DisplayClass0_1& ) in C:\Users\mikep\src\cc\CloudConstruct\AppMgmt\src\Helpful-Extensions\Extensions\CodeGeneration\CodeGenerationDisplayDriver.cs:line 38
   at Lombiq.HelpfulExtensions.Extensions.CodeGeneration.CodeGenerationDisplayDriver.<>c__DisplayClass0_0.<Edit>b__1() in C:\Users\mikep\src\cc\CloudConstruct\AppMgmt\src\Helpful-Extensions\Extensions\CodeGeneration\CodeGenerationDisplayDriver.cs:line 101
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Lombiq.HelpfulExtensions.Extensions.CodeGeneration.ContentTypeMigrationsViewModel.get_MigrationCode() in C:\Users\mikep\src\cc\CloudConstruct\AppMgmt\src\Helpful-Extensions\Extensions\CodeGeneration\ContentTypeMigrationsViewModel.cs:line 8
   at AspNetCore._Areas_Lombiq_HelpfulExtensions_Views_ContentTypeMigrations_Edit.ExecuteAsync() in C:\Users\mikep\src\cc\CloudConstruct\AppMgmt\src\Helpful-Extensions\Views\ContentTypeMigrations.Edit.cshtml:line 12

Let me know if I can provide any further information or if you'd like me to try anything else.

I enabled the module/feature and went to edit one of my content types.

Note that it does work for some other content types. I think it's failing on ListPart.

from orchard-training-demo-module.

Piedone avatar Piedone commented on June 2, 2024

Indeed, that was a bug with arrays in part settings, thank you for finding it! I've pushed a fix, could you check it out?

from orchard-training-demo-module.

devlife avatar devlife commented on June 2, 2024

Woot making progress! That type is fixed but I found another bug:

image

image

I'm not sure but I think it might be due to the content type having a text field which has a default value of N/A:

{
            "FieldName": "TextField",
            "Name": "NotificationGroup",
            "Settings": {
                "ContentPartFieldSettings": {
                    "DisplayName": "Notification Group",
                    "Editor": "PredefinedList",
                    "Position": "2"
                },
                "TextFieldSettings": {
                    "Hint": "The notification group assigned in the availability test alert"
                },
                "TextFieldPredefinedListEditorSettings": {
                    "Options": [{
                        "name": "N/A",
                        "value": ""
                    }, {
                        "name": "Monitoring Readers",
                        "value": "MonitoringReaders"
                    }],
                    "Editor": 1
                }
            }
        }

I could be wrong about that though.

from orchard-training-demo-module.

Piedone avatar Piedone commented on June 2, 2024

That was something I thought nobody will ever need :D.

This indeed happens because of TextFieldPredefinedListEditorSettings. Unfortunately, the JToken containing the Options array doesn't contain any information about the type of items in it (which is ListValueOption). So it's not possible to figure out (in a generic way) how what to instantiate, and thus I don't think we can generate the proper code for it.

So I've opted with something that would still generate the rest of the code but let you know it can't do anything here:

image

It's a bit meh but I don't see a better way. The information we need is simply not there. And I don't want to cheat by tying the code to TextFieldPredefinedListEditorSettings and other such settings that need specific support (and their property names are also wrong in the JObject).

Code's in the branch if you'd like to check it out.

from orchard-training-demo-module.

devlife avatar devlife commented on June 2, 2024

Oh hmm that's interesting. How are the property names wrong in the JObject?
Anyhow I think that is definitely reasonable! I'll pull down the update in the morning and give it a try. This is gonna save me a lot of time and be very educational!

from orchard-training-demo-module.

devlife avatar devlife commented on June 2, 2024

Woohoo this is phenomenal! It brings up so many new things that I need to learn. IE. how to create these content types with a setting for a TaxonomyContentItemId

    .WithField("NotificationGroupRecipients", field => field
        .OfType("TaxonomyField")
        .WithDisplayName("Notification Group Recipients")
        .WithPosition("3")
        .WithSettings(new TaxonomyFieldSettings
        {
            TaxonomyContentItemId = "4k0acdf1frk1432kpjby4z3f5j"
        })
    )

I need to make more progress through the training demo! Thanks a ton for doing this. It also gives me a bunch of ideas for other parts of the CMS such as generating the file name and path where you can overwrite templates:

image

Anyhow thanks again!

from orchard-training-demo-module.

Piedone avatar Piedone commented on June 2, 2024

What I mean by property names being wrong is that the property names indicated in the JObject ("name" and "value") are not the actual names of the properties of the C# class. Rather, these are just specified for the JSON so I think it's impossible to figure out the property name from them (I mean in a generic way since these names can be overridden by anything).

Anyway, glad you like it! Any other suggestions for the feature?

from orchard-training-demo-module.

devlife avatar devlife commented on June 2, 2024

Ah I see. That makes sense.

Along with the file name and file path for overriding templates, the same thing could definitely be done for Drivers! Even if it just spits out a shell that could be helpful. i could see the case being made for just using snippets but i would argue that both would be valuable.

from orchard-training-demo-module.

Piedone avatar Piedone commented on June 2, 2024

Do you know the Orchard 1 Shape Tracing feature? It's like Chrome DevTools, you point to an element and it shows you which shape drives it, and you can create overrides with all alternates right away. I think something like that would be the best for template generation.

For drivers I think snippets are a more suitable approach. We have such for O1 in the Dojo Library which we'll eventually upgrade for OC.

from orchard-training-demo-module.

Piedone avatar Piedone commented on June 2, 2024

I created an issue for your template idea here: Lombiq/Helpful-Extensions#6

from orchard-training-demo-module.

devlife avatar devlife commented on June 2, 2024

Nice! Thanks so much. If you agree, I think I'll close this issue. Thanks for all the help.

from orchard-training-demo-module.

Piedone avatar Piedone commented on June 2, 2024

With pleasure!

from orchard-training-demo-module.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.