Hi,
Is it possible to get a Datatypes Config settings using AngularJs.
I have a Controller that i would like to get a particular Datatype config settings so i dont have to create a the settings again - basically keeping it all in one place.
I'm a bit unsure if you're thinking about getting settings for an already existing property editor for you in your own?
Or is it simply some configuration settings for you own property editor?
If so then you you can add prevalues using the package.manifest file, which you can then get access to in your controller and view for your editor using model.config.
Here you can see what one of my package.manifest files looks like
{
propertyEditors: [{
alias: "Our.Umbraco.ExtendedTextstring",
name: "Extended Textstring",
icon: "icon-thumbnails",
group: "Pickers",
editor: {
view: "~/App_Plugins/ExtendedTextstring/extendedtextstring.html",
valueType: "JSON"
},
prevalues: {
fields: [
{
label: "Show italic",
description: "Should it be possible to make the text italic?",
key: "showItalic",
view: "boolean"
},
{
label: "Show bold",
description: "Should it be possible to make the text bold?",
key: "showBold",
view: "boolean"
}
]
},
defaultConfig:{
showItalic:"1"
}
}],
javascript: [
'~/App_Plugins/ExtendedTextstring/extendedtextstring.controller.js',
'~/App_Plugins/ExtendedTextstring/extendedtextstring.prevalues.controller.js'
],
"css" : [
"~/App_Plugins/ExtendedTextstring/extendedtextstring.css"
]
}
The "Show italic" and "Show bold" are the prevalues I can refer to in my view and controller for my editor.
You can find more information about how to create you own property editors here
Hi Jonathan, if you could give more of an idea what you are trying to do it may produce a better answer but purely based on the title of your question I would suggest this if you want to get the config settings of another data type definiton
Create a PluginController which extends UmbracoAuthorizedJsonController for the backoffice
Create An angular resource with a method which queries the controller for the config settings of a given datatype
Inject the resource into your property editor controller and call your resource method
I've seen this pattern else where but can't locate any links at the moment sorry.
These are the body contents of the controller in my case which which returns the all the properties of a datatype I needed to my resource
[HttpGet]
public object GetDataTypeById(Guid id)
{
var dtd = Services.DataTypeService.GetDataTypeDefinitionById(id);
return FormatDataType(dtd);
}
protected object FormatDataType(IDataTypeDefinition dtd)
{
if (dtd == null)
throw new HttpResponseException(HttpStatusCode.NotFound);
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
// Force converter before passing prevalues to view
var preValues = Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dtd.Id);
var convertedPreValues = propEditor.PreValueEditor.ConvertDbToEditor(propEditor.DefaultPreValues,
preValues);
return new FormattedDataType()
{
Guid = dtd.Key,
PropertyEditorAlias = dtd.PropertyEditorAlias,
PreValues = convertedPreValues,
View = propEditor.ValueEditor.View
};
}
Get Datatype config settings using AngularJs
Hi, Is it possible to get a Datatypes Config settings using AngularJs. I have a Controller that i would like to get a particular Datatype config settings so i dont have to create a the settings again - basically keeping it all in one place.
Jon
Hi Jonathan
I'm a bit unsure if you're thinking about getting settings for an already existing property editor for you in your own?
Or is it simply some configuration settings for you own property editor?
If so then you you can add prevalues using the package.manifest file, which you can then get access to in your controller and view for your editor using model.config.
Here you can see what one of my package.manifest files looks like
The "Show italic" and "Show bold" are the prevalues I can refer to in my view and controller for my editor.
You can find more information about how to create you own property editors here
I hope this helps and that I have understood your question correctly.
/Jan
Hi Jonathan, if you could give more of an idea what you are trying to do it may produce a better answer but purely based on the title of your question I would suggest this if you want to get the config settings of another data type definiton
I've seen this pattern else where but can't locate any links at the moment sorry.
These are the body contents of the controller in my case which which returns the all the properties of a datatype I needed to my resource
In your case you might only need the prevalues.
is working on a reply...