Merge pull request #961 from umbraco/temp-U4-7551
U4-7551 New Content type editor dialog to select an editor for a prop…
This commit is contained in:
@@ -114,28 +114,17 @@ function dataTypeResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
"GetAll")),
|
||||
"Failed to retrieve data");
|
||||
},
|
||||
|
||||
getAllUserConfigured: function () {
|
||||
|
||||
|
||||
getGroupedDataTypes: function () {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"dataTypeApiBaseUrl",
|
||||
"GetAllUserConfigured")),
|
||||
"GetGroupedDataTypes")),
|
||||
"Failed to retrieve data");
|
||||
},
|
||||
|
||||
getAllUserPropertyEditors: function () {
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"dataTypeApiBaseUrl",
|
||||
"GetAllUserPropertyEditors")),
|
||||
"Failed to retrieve data");
|
||||
},
|
||||
|
||||
getAllTypesAndEditors : function(){
|
||||
getGroupedPropertyEditors : function(){
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
|
||||
@@ -21,14 +21,14 @@
|
||||
{
|
||||
active: true,
|
||||
id: 1,
|
||||
label: "Default",
|
||||
label: "Available Editors",
|
||||
alias: "Default",
|
||||
typesAndEditors: []
|
||||
},
|
||||
{
|
||||
active: false,
|
||||
id: 2,
|
||||
label: "Reuse",
|
||||
label: "Re-use",
|
||||
alias: "Reuse",
|
||||
userConfigured: []
|
||||
}
|
||||
@@ -38,17 +38,18 @@
|
||||
vm.showDetailsOverlay = showDetailsOverlay;
|
||||
vm.hideDetailsOverlay = hideDetailsOverlay;
|
||||
vm.pickEditor = pickEditor;
|
||||
vm.pickDataType = pickDataType;
|
||||
|
||||
function activate() {
|
||||
|
||||
getAllUserConfiguredDataTypes();
|
||||
getAllTypesAndEditors();
|
||||
getGroupedDataTypes();
|
||||
getGroupedPropertyEditors();
|
||||
|
||||
}
|
||||
|
||||
function getAllTypesAndEditors() {
|
||||
function getGroupedPropertyEditors() {
|
||||
|
||||
dataTypeResource.getAllTypesAndEditors().then(function(data){
|
||||
dataTypeResource.getGroupedPropertyEditors().then(function(data){
|
||||
vm.tabs[0].typesAndEditors = data;
|
||||
vm.tabsLoaded = vm.tabsLoaded + 1;
|
||||
checkIfTabContentIsLoaded();
|
||||
@@ -56,9 +57,9 @@
|
||||
|
||||
}
|
||||
|
||||
function getAllUserConfiguredDataTypes() {
|
||||
function getGroupedDataTypes() {
|
||||
|
||||
dataTypeResource.getAllUserConfigured().then(function(data){
|
||||
dataTypeResource.getGroupedDataTypes().then(function (data) {
|
||||
vm.tabs[1].userConfigured = data;
|
||||
vm.tabsLoaded = vm.tabsLoaded + 1;
|
||||
checkIfTabContentIsLoaded();
|
||||
@@ -93,58 +94,51 @@
|
||||
|
||||
function pickEditor(editor) {
|
||||
|
||||
if(editor.id === null) {
|
||||
var parentId = -1;
|
||||
|
||||
// add scaffold in data type root
|
||||
var parentId = -1;
|
||||
dataTypeResource.getScaffold(parentId).then(function(dataType) {
|
||||
|
||||
dataTypeResource.getScaffold(parentId).then(function(dataType) {
|
||||
// set alias
|
||||
dataType.selectedEditor = editor.alias;
|
||||
|
||||
// set alias
|
||||
dataType.selectedEditor = editor.alias;
|
||||
// set name
|
||||
var nameArray = [];
|
||||
|
||||
// set name
|
||||
var nameArray = [];
|
||||
if($scope.model.contentTypeName) {
|
||||
nameArray.push($scope.model.contentTypeName);
|
||||
}
|
||||
|
||||
if($scope.model.contentTypeName) {
|
||||
nameArray.push($scope.model.contentTypeName);
|
||||
}
|
||||
if($scope.model.property.label) {
|
||||
nameArray.push($scope.model.property.label);
|
||||
}
|
||||
|
||||
if($scope.model.property.label) {
|
||||
nameArray.push($scope.model.property.label);
|
||||
}
|
||||
if(editor.name) {
|
||||
nameArray.push(editor.name);
|
||||
}
|
||||
|
||||
if(editor.name) {
|
||||
nameArray.push(editor.name);
|
||||
}
|
||||
// make name
|
||||
dataType.name = nameArray.join(" - ");
|
||||
|
||||
// make name
|
||||
dataType.name = nameArray.join(" - ");
|
||||
// get pre values
|
||||
dataTypeResource.getPreValues(dataType.selectedEditor).then(function(preValues) {
|
||||
|
||||
// get pre values
|
||||
dataTypeResource.getPreValues(dataType.selectedEditor).then(function(preValues) {
|
||||
dataType.preValues = preValues;
|
||||
|
||||
dataType.preValues = preValues;
|
||||
|
||||
openEditorSettingsOverlay(dataType, true);
|
||||
|
||||
});
|
||||
openEditorSettingsOverlay(dataType, true);
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
});
|
||||
|
||||
dataTypeResource.getById(editor.id).then(function(dataType) {
|
||||
}
|
||||
|
||||
contentTypeResource.getPropertyTypeScaffold(dataType.id).then(function(propertyType) {
|
||||
function pickDataType(selectedDataType) {
|
||||
|
||||
submitOverlay(dataType, propertyType, false);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
dataTypeResource.getById(selectedDataType.id).then(function(dataType) {
|
||||
contentTypeResource.getPropertyTypeScaffold(dataType.id).then(function(propertyType) {
|
||||
submitOverlay(dataType, propertyType, false);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -42,15 +42,25 @@
|
||||
</div>
|
||||
|
||||
<div ng-if="tab.alias==='Reuse'">
|
||||
<h5>Your configurations</h5>
|
||||
<ul class="umb-card-grid" ng-mouseleave="vm.hideDetailsOverlay()">
|
||||
<li ng-repeat="configuredDataType in tab.userConfigured | orderBy:'name' | filter: vm.searchTerm" ng-mouseover="vm.showDetailsOverlay(configuredDataType)">
|
||||
<a href="" ng-click="vm.pickEditor(configuredDataType)">
|
||||
<i class="{{ configuredDataType.icon }}" ng-class="{'icon-autofill': configuredDataType.icon == null}"></i>
|
||||
{{ configuredDataType.name }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div ng-repeat="(key,value) in tab.userConfigured">
|
||||
|
||||
<div ng-if="(value | filter:vm.searchTerm).length > 0">
|
||||
<h5>{{key}}</h5>
|
||||
|
||||
<ul class="umb-card-grid" ng-mouseleave="vm.hideDetailsOverlay()">
|
||||
<li ng-repeat="dataType in value | orderBy:'name' | filter: vm.searchTerm" ng-mouseover="vm.showDetailsOverlay(dataType)">
|
||||
<a href="" ng-click="vm.pickDataType(dataType)">
|
||||
<i class="{{ dataType.icon }}" ng-class="{'icon-autofill': dataType.icon == null}"></i>
|
||||
{{ dataType.name }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</umb-tab>
|
||||
|
||||
@@ -286,31 +286,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content json for all data types added by the user
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// Permission is granted to this method if the user has access to any of these sections: Content, media, settings, developer, members
|
||||
/// </remarks>
|
||||
[UmbracoApplicationAuthorize(
|
||||
Constants.Applications.Content, Constants.Applications.Media, Constants.Applications.Members,
|
||||
Constants.Applications.Settings, Constants.Applications.Developer)]
|
||||
public IEnumerable<DataTypeBasic> GetAllUserConfigured()
|
||||
{
|
||||
//find all user configured for re-reference
|
||||
return Services.DataTypeService
|
||||
.GetAllDataTypeDefinitions()
|
||||
//TODO: This is pretty nasty :(
|
||||
.Where(x => x.Id > 1045)
|
||||
.Select(Mapper.Map<IDataTypeDefinition, DataTypeBasic>).Where(x => x.IsSystemDataType == false);
|
||||
|
||||
//find all custom editors added by non-core manifests
|
||||
|
||||
//find the rest
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content json for all user added property editors
|
||||
/// Returns all data types grouped by their property editor group
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
@@ -319,17 +295,29 @@ namespace Umbraco.Web.Editors
|
||||
[UmbracoTreeAuthorize(
|
||||
Constants.Applications.Content, Constants.Applications.Media, Constants.Applications.Members,
|
||||
Constants.Applications.Settings, Constants.Applications.Developer)]
|
||||
public IEnumerable<PropertyEditorBasic> GetAllUserPropertyEditors()
|
||||
public IDictionary<string, IEnumerable<DataTypeBasic>> GetGroupedDataTypes()
|
||||
{
|
||||
return PropertyEditorResolver.Current.PropertyEditors
|
||||
.OrderBy(x => x.Name)
|
||||
.Where(x => x.ValueEditor.View.IndexOf("app_plugins", StringComparison.InvariantCultureIgnoreCase) >= 0)
|
||||
.Select(Mapper.Map<PropertyEditorBasic>);
|
||||
var dataTypes = Services.DataTypeService
|
||||
.GetAllDataTypeDefinitions()
|
||||
.Select(Mapper.Map<IDataTypeDefinition, DataTypeBasic>);
|
||||
|
||||
var propertyEditors = PropertyEditorResolver.Current.PropertyEditors.ToArray();
|
||||
|
||||
foreach (var dataType in dataTypes)
|
||||
{
|
||||
var propertyEditor = propertyEditors.Single(x => x.Alias == dataType.Alias);
|
||||
dataType.HasPrevalues = propertyEditor.PreValueEditor.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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all configured data types and all potential data types that could exist based on unused property editors grouped
|
||||
/// by their property editor defined group.
|
||||
/// Returns all property editors grouped
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
@@ -340,44 +328,20 @@ namespace Umbraco.Web.Editors
|
||||
Constants.Applications.Settings, Constants.Applications.Developer)]
|
||||
public IDictionary<string, IEnumerable<DataTypeBasic>> GetGroupedPropertyEditors()
|
||||
{
|
||||
var datadefs = Services.DataTypeService
|
||||
.GetAllDataTypeDefinitions()
|
||||
.ToArray();
|
||||
|
||||
var datatypes = new List<DataTypeBasic>();
|
||||
|
||||
//this is a very specific map - if a property editor does not have prevalue - and there is a datatype already using this type, return that.
|
||||
//also, we exclude all the system listviews from the list
|
||||
|
||||
var propertyEditors = PropertyEditorResolver.Current.PropertyEditors;
|
||||
foreach (var propertyEditor in propertyEditors)
|
||||
{
|
||||
var hasPrevalues = propertyEditor.PreValueEditor.Fields.Any();
|
||||
|
||||
//check if a data type exists for this property editor
|
||||
var dataDef = datadefs.FirstOrDefault(x => x.PropertyEditorAlias == propertyEditor.Alias);
|
||||
|
||||
//if no prevalues and a datatype exists with this property editor
|
||||
if (hasPrevalues == false && dataDef != null)
|
||||
{
|
||||
//exclude system list views
|
||||
if (dataDef.Name.InvariantStartsWith(Constants.Conventions.DataTypes.ListViewPrefix) == false)
|
||||
{
|
||||
datatypes.Add(Mapper.Map<DataTypeBasic>(dataDef));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//else, just add a clean property editor
|
||||
var basic = Mapper.Map<DataTypeBasic>(propertyEditor);
|
||||
basic.HasPrevalues = hasPrevalues;
|
||||
datatypes.Add(basic);
|
||||
}
|
||||
var basic = Mapper.Map<DataTypeBasic>(propertyEditor);
|
||||
basic.HasPrevalues = hasPrevalues;
|
||||
datatypes.Add(basic);
|
||||
}
|
||||
|
||||
|
||||
var grouped = datatypes
|
||||
.GroupBy(x => x.Group.IsNullOrWhiteSpace() ? "" : x.Group.ToLower())
|
||||
.ToDictionary(group => group.Key, group => group.AsEnumerable());
|
||||
.ToDictionary(group => group.Key, group => group.OrderBy(d => d.Name).AsEnumerable());
|
||||
|
||||
return grouped;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user