Setting a min and max value of required items for a macro multi url custom property
Hi,
I have been making a custom property for a social media macro block where I want to have a multi url picker that has a minimum requirement of 2 url and a maximum of 4 urls and I have gotten it to work to the point where I can add urls, but there is no limit or any minimum requirement since I cant seem to get the config to work as I want it to.
The only error I seem to be getting in inspect mode from console is:
TypeError: Cannot read property 'minCount' of undefined
at MacroUrlPickerMinMax.js?cdv=1806545781:47
at Scope.$digest (angular.js?cdv=1806545781:19208)
at ChildScope.$apply (angular.js?cdv=1806545781:19568)
at HTMLButtonElement.
When looking in the backoffice section where I edit my macro properties the console shows no config or default config for some reason:
Been at this for 6 hours now and still am no closer to making this work. The end goal for this is to be able to limit how many items are needed and how many items are allowed to be added by an editor, if anybody has any advice it would be much appreciated! :)
I have a feeling it's to do with PreValues and the DefaultConfig setting for your custom editor.
PreValues are used to provide a configuration option for the editor when it is viewed as a DataType
And can be read inside the angularJS controller from $scope.model.config.aliasOfPreValue
DefaultConfig: is an option to provide values for those PreValues when the editor is used in a situation where you can't set them via the backoffice UI, eg in a Macro Parameter etc
Anyway your custom Url Picker Package Manifest defines only 1 PreValue called 'maxCount'
It defined as a 'boolean' via it's view, and then you are trying to set the defaultconfiguration - for this boolean property - when there is a UI for someone to provide the value (eg in a new DataType) - but instead of setting a default boolean value for this option, you are setting two properties, one called 'Default' and one called 'maxCount' and the 'Boolean' view for a checkbox isn't going to know how to interpret that!
But maybe you are not trying to set the defaultconfig value of the configuration option?
If you are instead trying to set the defaultconfig for the editor as a whole, then your defaultConfig: definition needs to be outside of the preValues configuration:
You can see the DefaultConfig for the ImagePosition is 'outside' of the preValues configuration...
I think you'll need to have a PreValue field entry for each property you want people to be able to configure or that you want to set in the editor's default configuration.
The built in Multi Url Picker can be made to work as a Macro Parameter, 'as of' V8.7... an example of the configuration to make it work, is in this PR that fixed a bug that made it possible:
Than you for your lenghtly reply and sorry for not responding earlier! I managed to make it appear as a property to be used for macros with a min / max value set (would just allow for checkboxes to be ticked if you wanted one or the other with a hard coded value).
Although I could never get it to actually enforce the min or max value with any validation or anything..so atm I think im more confused as to where that is controlled and how.
So, what did you end up with as your manifest file?
As the short version of what I'm explaining above based on the manifest file you had original posted - is you have defaultConfig in the wrong place! :-P
so wondering if you worked that out, and it's still not working, or whether that's not clear from my overly verbose explanation!
Setting a min and max value of required items for a macro multi url custom property
Hi,
I have been making a custom property for a social media macro block where I want to have a multi url picker that has a minimum requirement of 2 url and a maximum of 4 urls and I have gotten it to work to the point where I can add urls, but there is no limit or any minimum requirement since I cant seem to get the config to work as I want it to.
Here is my manifest code:
The only error I seem to be getting in inspect mode from console is:
TypeError: Cannot read property 'minCount' of undefined at MacroUrlPickerMinMax.js?cdv=1806545781:47 at Scope.$digest (angular.js?cdv=1806545781:19208) at ChildScope.$apply (angular.js?cdv=1806545781:19568) at HTMLButtonElement.
This is referencing to a part in my .js file:
When looking in the backoffice section where I edit my macro properties the console shows no config or default config for some reason:
Been at this for 6 hours now and still am no closer to making this work. The end goal for this is to be able to limit how many items are needed and how many items are allowed to be added by an editor, if anybody has any advice it would be much appreciated! :)
Hi Isaiah
I have a feeling it's to do with PreValues and the DefaultConfig setting for your custom editor.
PreValues are used to provide a configuration option for the editor when it is viewed as a DataType
And can be read inside the angularJS controller from
$scope.model.config.aliasOfPreValue
DefaultConfig: is an option to provide values for those PreValues when the editor is used in a situation where you can't set them via the backoffice UI, eg in a Macro Parameter etc
Anyway your custom Url Picker Package Manifest defines only 1 PreValue called 'maxCount'
It defined as a 'boolean' via it's view, and then you are trying to set the defaultconfiguration - for this boolean property - when there is a UI for someone to provide the value (eg in a new DataType) - but instead of setting a default boolean value for this option, you are setting two properties, one called 'Default' and one called 'maxCount' and the 'Boolean' view for a checkbox isn't going to know how to interpret that!
But maybe you are not trying to set the defaultconfig value of the configuration option?
If you are instead trying to set the defaultconfig for the editor as a whole, then your defaultConfig: definition needs to be outside of the preValues configuration:
Have a look at this example in the docs;
https://our.umbraco.com/Documentation/Extending/Macro-Parameter-Editors/#using-defaultconfig
You can see the DefaultConfig for the ImagePosition is 'outside' of the preValues configuration...
I think you'll need to have a PreValue field entry for each property you want people to be able to configure or that you want to set in the editor's default configuration.
The built in Multi Url Picker can be made to work as a Macro Parameter, 'as of' V8.7... an example of the configuration to make it work, is in this PR that fixed a bug that made it possible:
https://github.com/umbraco/Umbraco-CMS/pull/8144
regards
marc
Hi Mark,
Than you for your lenghtly reply and sorry for not responding earlier! I managed to make it appear as a property to be used for macros with a min / max value set (would just allow for checkboxes to be ticked if you wanted one or the other with a hard coded value). Although I could never get it to actually enforce the min or max value with any validation or anything..so atm I think im more confused as to where that is controlled and how.
Thank you for your help!
HI Isaiah
So, what did you end up with as your manifest file?
As the short version of what I'm explaining above based on the manifest file you had original posted - is you have defaultConfig in the wrong place! :-P
so wondering if you worked that out, and it's still not working, or whether that's not clear from my overly verbose explanation!
regards
Marc
is working on a reply...