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

v8: Pick macro parameters in an infinite editor like content type properties #4318

Closed
bjarnef opened this issue Jan 29, 2019 · 7 comments · Fixed by #6586
Closed

v8: Pick macro parameters in an infinite editor like content type properties #4318

bjarnef opened this issue Jan 29, 2019 · 7 comments · Fixed by #6586

Comments

@bjarnef
Copy link
Contributor

bjarnef commented Jan 29, 2019

In macro parameters the editor is a traditional dropdown. It would be great to change this to a property picker similar to when selecting data type on document types or selecting field types in Umbraco Forms.

image


This item has been added to our backlog AB#3240

@nul800sebastiaan
Copy link
Member

To me it seems like a good idea, but let me get some feedback first. I'll let you know after our next regular meeting.

@nul800sebastiaan
Copy link
Member

We had a chat about this recently and @nielslyngsoe indicated he would get back at you with some feedback! 👍

@bjarnef
Copy link
Contributor Author

bjarnef commented Oct 2, 2019

@nul800sebastiaan @nielslyngsoe I created a quick prototype for this and kept the UI consistent as much as possible like when selecting datatypes on document types.

The top part in the overlay is the new stuff (consistent with datatypes on document types) and the bottom part is the current stuff (should be removed if we go with this).

2019-10-02_23-15-02

@nul800sebastiaan
Copy link
Member

Looks great @bjarnef! I assume this will not show all editor, but only the ones that are available as a macro parameter editor?

@nielslyngsoe
Copy link
Member

@bjarnef looks good, looking forward to the PR, and as Sebastian is asking; I guess the options are the same as before, its just the UI you will be changing, right?

Looks very good to me!

@bjarnef
Copy link
Contributor Author

bjarnef commented Oct 3, 2019

@nul800sebastiaan it only get the same parameter editors as listed in the current dropdown.
I have a branch for it here https://github.com/bjarnef/Umbraco-CMS/tree/dev-v8-temp-macro-parameter-editor

but I can create a PR for this in a few days.

The existing dropdown has a method GetParameterEditors and I have added a new method GetGroupedParameterEditors.
bjarnef@c302d59

Maybe these should return IDictionary<string, IEnumerable<T>> similar to GetGroupedDataTypes instead of HttpResponseMessage, but would can always change this later.

[UmbracoTreeAuthorize(
Constants.Applications.Content, Constants.Applications.Media, Constants.Applications.Members,
Constants.Applications.Settings, Constants.Applications.Packages)]
public IDictionary<string, IEnumerable<DataTypeBasic>> GetGroupedDataTypes()
{
var dataTypes = Services.DataTypeService
.GetAll()
.Select(Mapper.Map<IDataType, DataTypeBasic>)
.ToArray();
var propertyEditors = Current.PropertyEditors.ToArray();
foreach (var dataType in dataTypes)
{
var propertyEditor = propertyEditors.SingleOrDefault(x => x.Alias == dataType.Alias);
if (propertyEditor != null)
dataType.HasPrevalues = propertyEditor.GetConfigurationEditor().Fields.Any(); ;
}
var grouped = dataTypes
.GroupBy(x => x.Group.IsNullOrWhiteSpace() ? "" : x.Group.ToLower())
.ToDictionary(group => group.Key, group => group.OrderBy(d => d.Name).AsEnumerable());
return grouped;
}

As this moment when browsing to a macro it also create to requests to partial views and macro parameter editors (where parameter editors are passed in to the overlay in the current setup). Not sure this is necessary and it instead only request parameter editors in the overlay. We might change the same for partial views, so it only create the request when opening the overlay.

image

@bjarnef
Copy link
Contributor Author

bjarnef commented Oct 3, 2019

At the moment there is this inifinite editor.
https://github.com/umbraco/Umbraco-CMS/tree/v8/dev/src/Umbraco.Web.UI.Client/src/views/macros/infiniteeditors

I have added a new one is this folder https://github.com/umbraco/Umbraco-CMS/tree/v8/dev/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors for "macro parameter editor picker" (similar to how datatypepicker).
This can be re-used (but not sure if there is a use-case where package developers would use this?).

Any suggestion for a good name? For now I have named in "macroparameter", but could also be "macroparameterpicker" or "macroparametereditorpicker"? 🤣

This existing one in macros/infiniteeditors might be specific to macros, so I guess it is fine it is located here for now?

@nul800sebastiaan nul800sebastiaan changed the title v8: Macro editor property picker v8: Pick macro parameters in an infinite editor like content type properties Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants