RTE is working, but not the UrlPicker one
This commit is contained in:
@@ -37,6 +37,26 @@ namespace Archetype.Api
|
||||
return dataTypes.Select(t => new { guid = t.Key, name = t.Name });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all details.
|
||||
/// </summary>
|
||||
/// <returns>System.Object.</returns>
|
||||
public object GetAllDetails()
|
||||
{
|
||||
var dataTypes = Services.DataTypeService.GetAllDataTypeDefinitions();
|
||||
|
||||
var list = new List<object>();
|
||||
|
||||
foreach (var dataType in dataTypes)
|
||||
{
|
||||
var dataTypeDisplay = Mapper.Map<IDataTypeDefinition, DataTypeDisplay>(dataType);
|
||||
|
||||
list.Add(new { selectedEditor = dataTypeDisplay.SelectedEditor, preValues = dataTypeDisplay.PreValues, dataTypeGuid = dataType.Key });
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the datatype by GUID.
|
||||
/// </summary>
|
||||
|
||||
@@ -3,6 +3,8 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
|
||||
|
||||
// Variables.
|
||||
var draggedParent;
|
||||
|
||||
var isCacheInitialized = false;
|
||||
|
||||
//$scope.model.value = "";
|
||||
$scope.model.hideLabel = $scope.model.config.hideLabel == 1;
|
||||
@@ -28,7 +30,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
|
||||
|
||||
init();
|
||||
|
||||
//hold references to helper resources
|
||||
//hold references to helper resources
|
||||
$scope.resources = {
|
||||
entityResource: entityResource,
|
||||
archetypePropertyEditorResource: archetypePropertyEditorResource
|
||||
@@ -44,7 +46,10 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
|
||||
//helper to get $eval the labelTemplate
|
||||
$scope.fieldsetTitles = [];
|
||||
$scope.getFieldsetTitle = function (fieldsetConfigModel, fieldsetIndex) {
|
||||
|
||||
if(!isCacheInitialized) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Ensure the collection of titles is large enough.
|
||||
ensureEnoughTitles(fieldsetIndex + 1);
|
||||
var title = $scope.fieldsetTitles[fieldsetIndex];
|
||||
@@ -63,18 +68,15 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
|
||||
title.loading = true;
|
||||
title.loaded = false;
|
||||
title.value = null;
|
||||
archetypeLabelService.getFieldsetTitle($scope, fieldsetConfigModel, fieldsetIndex)
|
||||
.then(function(value) {
|
||||
|
||||
// Finished loading the title.
|
||||
title.loaded = true;
|
||||
title.loading = false;
|
||||
title.value = value;
|
||||
|
||||
});
|
||||
|
||||
archetypeLabelService.getFieldsetTitle($scope, fieldsetConfigModel, fieldsetIndex).then(function(value) {
|
||||
// Finished loading the title.
|
||||
title.loaded = true;
|
||||
title.loading = false;
|
||||
title.value = value;
|
||||
});
|
||||
|
||||
// Still loading a title, so do not return a title.
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -582,6 +584,10 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
|
||||
function init() {
|
||||
$scope.model.value = removeNulls($scope.model.value);
|
||||
addDefaultProperties($scope.model.value.fieldsets);
|
||||
|
||||
archetypeCacheService.initialize().then(function() {
|
||||
isCacheInitialized = true;
|
||||
});
|
||||
|
||||
$timeout(function () {
|
||||
$scope.handleMandatoryValidation();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
angular.module("umbraco.directives").directive('archetypeProperty', function ($compile, $http, archetypePropertyEditorResource, umbPropEditorHelper, $timeout, $rootScope, $q, fileManager, editorState, archetypeService, archetypeCacheService) {
|
||||
angular.module("umbraco.directives").directive('archetypeProperty', function ($compile, $http, archetypePropertyEditorResource, umbPropEditorHelper, $timeout, $rootScope, $q, fileManager, editorState, archetypeService) {
|
||||
|
||||
var linker = function (scope, element, attrs, ngModelCtrl) {
|
||||
var configFieldsetModel = archetypeService.getFieldsetByAlias(scope.archetypeConfig.fieldsets, scope.fieldset.alias);
|
||||
@@ -25,9 +25,6 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
|
||||
config = configObj;
|
||||
|
||||
//caching for use by label templates later
|
||||
archetypeCacheService.addDatatypeToCache(data, dataTypeGuid);
|
||||
|
||||
//determine the view to use [...] and load it
|
||||
archetypePropertyEditorResource.getPropertyEditorMapping(data.selectedEditor).then(function(propertyEditor) {
|
||||
var pathToView = umbPropEditorHelper.getViewPath(propertyEditor.view);
|
||||
|
||||
@@ -6,6 +6,11 @@ angular.module('umbraco.resources').factory('archetypePropertyEditorResource', f
|
||||
$http.get("backoffice/ArchetypeApi/ArchetypeDataType/GetAll"), 'Failed to retrieve datatypes from tree service'
|
||||
);
|
||||
},
|
||||
getAllDataTypesForCache: function() {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get("backoffice/ArchetypeApi/ArchetypeDataType/GetAllDetails"), 'Failed to retrieve datatypes from tree service'
|
||||
);
|
||||
},
|
||||
getDataType: function (guid, useDeepDatatypeLookup, contentTypeAlias, propertyTypeAlias, archetypeAlias, nodeId) {
|
||||
if(useDeepDatatypeLookup) {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
|
||||
@@ -6,101 +6,81 @@ angular.module('umbraco.services').factory('archetypeCacheService', function (ar
|
||||
|
||||
var isDatatypeLookupLoading = false;
|
||||
var datatypeCache = [];
|
||||
|
||||
|
||||
|
||||
return {
|
||||
getDataTypeFromCache: function(guid) {
|
||||
return _.find(datatypeCache, function (dt){
|
||||
return dt.dataTypeGuid == guid;
|
||||
});
|
||||
},
|
||||
|
||||
addDatatypeToCache: function(datatype, dataTypeGuid) {
|
||||
var cachedDatatype = this.getDataTypeFromCache(dataTypeGuid);
|
||||
|
||||
if(!cachedDatatype) {
|
||||
datatype.dataTypeGuid = dataTypeGuid;
|
||||
datatypeCache.push(datatype);
|
||||
}
|
||||
},
|
||||
initialize: function() {
|
||||
return archetypePropertyEditorResource.getAllDataTypesForCache().then(function(data) {
|
||||
datatypeCache = data;
|
||||
});
|
||||
},
|
||||
|
||||
getDataTypeFromCache: function(guid) {
|
||||
return _.find(datatypeCache, function (dt){
|
||||
return dt.dataTypeGuid == guid;
|
||||
});
|
||||
},
|
||||
|
||||
getDatatypeByGuid: function(guid) {
|
||||
var cachedDatatype = this.getDataTypeFromCache(guid);
|
||||
getDatatypeByGuid: function(guid) {
|
||||
var cachedDatatype = this.getDataTypeFromCache(guid);
|
||||
|
||||
if(cachedDatatype) {
|
||||
return cachedDatatype;
|
||||
}
|
||||
|
||||
if(cachedDatatype) {
|
||||
return cachedDatatype;
|
||||
}
|
||||
|
||||
//go get it from server, but this should already be pre-populated from the directive, but I suppose I'll leave this in in case used ad-hoc
|
||||
if (!isDatatypeLookupLoading) {
|
||||
isDatatypeLookupLoading = true;
|
||||
|
||||
archetypePropertyEditorResource.getDataType(guid).then(function(datatype) {
|
||||
|
||||
datatype.dataTypeGuid = guid;
|
||||
|
||||
datatypeCache.push(datatype);
|
||||
|
||||
isDatatypeLookupLoading = false;
|
||||
|
||||
return datatype;
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
return null;
|
||||
},
|
||||
|
||||
getEntityById: function(scope, id, type) {
|
||||
var cachedEntity = _.find(entityCache, function (e){
|
||||
return e.id == id;
|
||||
});
|
||||
getEntityById: function(scope, id, type) {
|
||||
var cachedEntity = _.find(entityCache, function (e){
|
||||
return e.id == id;
|
||||
});
|
||||
|
||||
if(cachedEntity) {
|
||||
return cachedEntity;
|
||||
}
|
||||
if(cachedEntity) {
|
||||
return cachedEntity;
|
||||
}
|
||||
|
||||
//go get it from server
|
||||
if (!isEntityLookupLoading) {
|
||||
isEntityLookupLoading = true;
|
||||
//go get it from server
|
||||
if (!isEntityLookupLoading) {
|
||||
isEntityLookupLoading = true;
|
||||
|
||||
scope.resources.entityResource.getById(id, type).then(function(entity) {
|
||||
scope.resources.entityResource.getById(id, type).then(function(entity) {
|
||||
|
||||
entityCache.push(entity);
|
||||
entityCache.push(entity);
|
||||
|
||||
isEntityLookupLoading = false;
|
||||
isEntityLookupLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
return null;
|
||||
},
|
||||
getEntityByUmbracoId: function(scope, udi, type) {
|
||||
var cachedEntity = _.find(entityCache, function (e){
|
||||
return e.udi == udi;
|
||||
});
|
||||
|
||||
getEntityByUmbracoId: function(scope, udi, type) {
|
||||
var cachedEntity = _.find(entityCache, function (e){
|
||||
return e.udi == udi;
|
||||
});
|
||||
if(cachedEntity) {
|
||||
return cachedEntity;
|
||||
}
|
||||
|
||||
if(cachedEntity) {
|
||||
return cachedEntity;
|
||||
}
|
||||
//go get it from server
|
||||
if (!isEntityLookupLoading) {
|
||||
isEntityLookupLoading = true;
|
||||
|
||||
//go get it from server
|
||||
if (!isEntityLookupLoading) {
|
||||
isEntityLookupLoading = true;
|
||||
|
||||
scope.resources.entityResource.getByIds([udi], type).then(function (entities) {
|
||||
scope.resources.entityResource.getByIds([udi], type).then(function (entities) {
|
||||
// prevent infinite lookups with a default entity
|
||||
var entity = entities.length > 0 ? entities[0] : { udi: udi, name: "" };
|
||||
|
||||
entityCache.push(entity);
|
||||
|
||||
isEntityLookupLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user