Compare commits

..

1 Commits

Author SHA1 Message Date
Kevin Giszewski bbab61d416 Attempt at fixing #429 2017-09-13 12:03:21 -04:00
13 changed files with 368 additions and 498 deletions
-1
View File
@@ -322,5 +322,4 @@ module.exports = function(grunt) {
grunt.registerTask('nuget', ['copy:nuget', 'template:nuspec', 'template:nuspec_binaries', 'template:nuspec_courier', 'nugetpack']);
grunt.registerTask('umbraco', ['copy:umbraco', 'umbracoPackage']);
grunt.registerTask('package', ['clean:tmp', 'default', 'nuget', 'copy:umbraco', 'umbracoPackage', 'clean:tmp']);
grunt.registerTask('assets', ['clean', 'string-replace', 'less', 'concat', 'assemblyinfo', 'copy:assets', 'copy:html', 'copy:config', 'clean:html', 'clean:js', 'clean:less']);
};
@@ -37,26 +37,6 @@ 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>
@@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.17.0")]
[assembly: AssemblyFileVersion("1.17.0")]
[assembly: AssemblyVersion("1.16.0")]
[assembly: AssemblyFileVersion("1.16.0")]
+31 -27
View File
@@ -3,8 +3,6 @@ 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;
@@ -29,15 +27,24 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
};
init();
//hold references to helper resources
$scope.resources = {
entityResource: entityResource,
archetypePropertyEditorResource: archetypePropertyEditorResource
}
//hold references to helper services
$scope.services = {
archetypeService: archetypeService,
archetypeLabelService: archetypeLabelService,
archetypeCacheService: archetypeCacheService
}
//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];
@@ -56,14 +63,22 @@ 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.
};
$scope.$on('archetypeEntityCacheUpdated', function(event, entity) {
$scope.fieldsetTitles = _.reject($scope.fieldsetTitles, function(title) {
return title.loaded;
});
});
/**
* Ensure the collection of fieldset titles is large enough to accommodate the number of fieldsets.
@@ -114,7 +129,6 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
},
start: function(ev, ui) {
archetypeService.getEditors().addClass('archetypeDragging');
archetypeService.storeEditors(ui.item.parent());
$scope.$apply(function() {
draggedParent = ui.item.parent();
@@ -176,6 +190,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
},
stop: function (ev, ui) {
// Done sorting.
draggedParent.scope().doingSort = false;
@@ -190,7 +205,6 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
}
archetypeService.restoreEditors(parent);
archetypeService.getEditors().removeClass('archetypeDragging');
}
};
@@ -489,13 +503,6 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
//helpers for determining if the add button should be shown
$scope.showAddButton = function () {
var visible = countVisible();
return (visible === 0 && $scope.model.config.startWithAddButton)
|| (visible > 0 && $scope.canAdd());
}
//helper for determining if no content is available yet
$scope.showEmptyContentHint = function () {
return $scope.model.config.startWithAddButton
&& countVisible() === 0;
///&& $scope.model.config.fieldsets.length == 1;
@@ -578,10 +585,6 @@ 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();
@@ -998,4 +1001,5 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
}
return null;
}
});
+4 -1
View File
@@ -1,4 +1,4 @@
angular.module("umbraco.directives").directive('archetypeProperty', function ($compile, $http, archetypePropertyEditorResource, umbPropEditorHelper, $timeout, $rootScope, $q, fileManager, editorState, archetypeService) {
angular.module("umbraco.directives").directive('archetypeProperty', function ($compile, $http, archetypePropertyEditorResource, umbPropEditorHelper, $timeout, $rootScope, $q, fileManager, editorState, archetypeService, archetypeCacheService) {
var linker = function (scope, element, attrs, ngModelCtrl) {
var configFieldsetModel = archetypeService.getFieldsetByAlias(scope.archetypeConfig.fieldsets, scope.fieldset.alias);
@@ -25,6 +25,9 @@ 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);
+66 -47
View File
@@ -1,51 +1,70 @@
//create a namespace (optional)
var ArchetypeSampleLabelHelpers = {};
var ArchetypeSampleLabelTemplates = (function() {
//create a function
//you will add it to your label template field as `{{ArchetypeSampleLabelHelpers.testPromise(someArchetypePropertyAlias)}}`
ArchetypeSampleLabelHelpers.testPromise = function(value) {
//you can inject services
return function ($timeout, archetypeCacheService) {
//best to return a promise
//NOTE: $timeout returns a promise
return $timeout(function () {
return "As Promised: " + value;
}, 1000);
}
}
//public functions
return {
Entity: function (value, scope, args) {
ArchetypeSampleLabelHelpers.testEntityPromise = function(value, scope, args) {
//hey look, args!
//{{ArchetypeSampleLabelHelpers.testEntityPromise(someArchetypePropertyAlias, {foo: 1})}}
console.log(args);
return function ($q, entityResource) {
var deferred = $q.defer();
entityResource.getById(args.foo, 'document').then(function(entity) {
console.log("Hello from testEntityPromise");
console.log(entity);
deferred.resolve(entity.name);
});
return deferred.promise;
}
}
if(!args.entityType) {
args = {entityType: "Document", propertyName: "name"}
}
ArchetypeSampleLabelHelpers.testEntityPromise2 = function(value, scope, args) {
//hey look, args but we're also using the built-in archetypeCacheService
//{{ArchetypeSampleLabelHelpers.testEntityPromise(someArchetypePropertyAlias, {foo: 1234})}}
console.log(args);
return function ($q, archetypeCacheService) {
var deferred = $q.defer();
archetypeCacheService.getEntityById(args.foo, 'document').then(function(entity) {
console.log("Hello from testEntityPromise2");
console.log(entity);
deferred.resolve(entity.name);
});
return deferred.promise;
if (value) {
//if handed a csv list, take the first only
var id = value.split(",")[0];
if (id) {
var entity = scope.services.archetypeCacheService.getEntityById(scope, id, args.entityType);
if(entity) {
return entity[args.propertyName];
}
}
}
return "";
},
UrlPicker: function(value, scope, args) {
if(!args.propertyName) {
args = {propertyName: "name"}
}
var entity;
switch (value.type) {
case "content":
if(value.typeData.contentId) {
entity = scope.services.archetypeCacheService.getEntityById(scope, value.typeData.contentId, "Document");
}
break;
case "media":
if(value.typeData.mediaId) {
entity = scope.services.archetypeCacheService.getEntityById(scope, value.typeData.mediaId, "Media");
}
break;
case "url":
return value.typeData.url;
default:
break;
}
if(entity) {
return entity[args.propertyName];
}
return "";
},
Rte: function (value, scope, args) {
if(!args.contentLength) {
args = {contentLength: 50}
}
return $(value).text().substring(0, args.contentLength);
}
}
}
})();
+53 -146
View File
@@ -35,7 +35,8 @@
.fieldsetIcon {
float: left;
padding: 0 10px 0 0;
padding: 0 4px 0 0;
color: #333;
vertical-align: text-bottom;
}
@@ -53,6 +54,7 @@
fieldset {
border-bottom: 1px dashed #dddddd;
padding: 0;
margin-bottom: 5px;
clear: both;
display: inline-block;
width: 100%;
@@ -91,10 +93,10 @@
.archetypeFieldsetLabel {
position: relative;
width: 100%;
background: white;
min-height: 42px;
.label-sub {
padding: 18px 0;
padding: 8px 0 8px 0;
display: inline-block;
min-height: 20px; /* this makes the header clickable when there's no icon and no text */
&.module-label {
@@ -104,9 +106,9 @@
cursor: pointer;
label {
// span {
// text-decoration: underline;
// }
span {
text-decoration: underline;
}
&:hover {
cursor: pointer;
}
@@ -127,7 +129,7 @@
}
span {
// font-weight: bold;
font-weight: bold;
&.menu-label { font-weight: normal; }
}
@@ -143,99 +145,57 @@
label {
margin-bottom: 0;
margin-left: 18px;
white-space: nowrap;
padding: 0;
display: block;
width: ~"calc(100% - 144px)";
position: absolute;
span {
display: block;
overflow: hidden;
text-overflow: ellipsis;
max-height: 40px;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
display: -webkit-box;
}
}
&.dimmed {
label {
color: #d9d9d9 !important;
&.dimmed {
i, span {
color: #d9d9d9 !important;
}
}
}
.archetypeEditorControls {
float: none;
position: absolute;
right: 0;
right: 15px;
top: 0;
height: 100%;
padding: 0;
display: flex;
align-items: center;
opacity: 0;
transition: opacity .15s ease-in-out;
-moz-transition: opacity .15s ease-in-out;
-webkit-transition: opacity .15s ease-in-out;
background: white;
&:before {
content: ' ';
position: absolute;
display: block;
left: -40px;
width: 40px;
top: 0;
bottom: 0;
background: -webkit-linear-gradient(90deg, rgba(255,255,255,0), white);
background: -moz-linear-gradient(90deg, rgba(255,255,255,0), white);
background: linear-gradient(90deg, rgba(255,255,255,0), white);
}
.icon {
display: inline-block;
height: 28px;
width: 28px;
line-height: 28px;
border-radius: 14px;
border: 1px solid #d6d6d6;
color: #5f5f5f;
background: white;
color: #ddd;
padding: 2px;
font-size: 16px;
text-align: center;
margin-left: 8px;
&:hover {
background: #f3f3f5;
color: #333;
}
&.icon-trash:hover {
background: #fe5b57;
border-color: #fe5b57;
color: white;
&.icon-delete:hover {
color: #b94a48;
}
&.icon-disabled {
cursor: default;
&:hover {
color: #ddd;
background: white;
}
}
&.icon-active {
color: #bbb;
color: #333;
&:hover {
color: white;
color: #333;
}
}
}
}
&:hover .archetypeEditorControls {
opacity: 1;
&:hover {
}
}
&.is-open > .archetypeFieldsetLabel .archetypeEditorControls {
opacity: 1;
}
.archetypePropertyError {
margin-bottom: 5px;
padding-top: 3px;
@@ -253,24 +213,9 @@
.archetypeCollapser {
clear: both;
height: 100%;
padding: 24px 20px 0 20px;
background-color: #fafafa;
border-top: 1px dashed #e0e0e0;
line-height: 20px;
.archetypeFieldsetLabel {
background: #fafafa;
}
.archetypeEditorControls {
background: #fafafa;
&:before {
background: -webkit-linear-gradient(90deg, rgba(250,250,250,0), #fafafa);
background: -moz-linear-gradient(90deg, rgba(250,250,250,0), #fafafa);
background: linear-gradient(90deg, rgba(250,250,250,0), #fafafa);
}
}
padding: 12px 0 0 20px;
background-color: #fff;
border-radius: 0 0 0 5px;
form {
margin-left:20px;
@@ -301,69 +246,25 @@
border: 1px solid #b94a48;
}
.archetypeFooter {
text-align: center;
margin-top: 20px;
}
.archetypeAddButton {
display: inline-block;
height: 28px;
width: 28px;
line-height: 28px;
border-radius: 14px;
border: 1px solid #b6b6b6;
color: #5f5f5f;
background: white;
font-size: 16px;
text-align: center;
text-decoration: none;
cursor: pointer;
color: #ddd;
.icon {
vertical-align: middle;
}
&:hover {
background: #00aea2;
border-color: #00aea2;
color: white;
color: #333;
text-decoration: none;
cursor: pointer;
.archetypeAddButtonText {
text-decoration: underline;
}
.icon {
color: #333;
}
}
}
.archetypeEmptyContent {
text-align: center;
margin-bottom: 20px;
span {
display: inline-block;
padding: 10px 20px;
clear: both;
font-size: 14px;
color: #555;
background: #f8f8f8;
border-radius: 15px;
}
}
.archetypeCrossDraggable + .archetypeEmptyContent {
margin-top: -42px;
}
&.archetypeDragging .archetypeCrossDraggable + .archetypeEmptyContent {
display: none;
}
// Necessary to ensure empty lists can be dropped onto when sorting nested fieldsets.
.archetypeSortable.archetypeEmpty.archetypeCrossDraggable {
min-height: 40px;
border: 1px dashed transparent;
}
&.archetypeDragging .archetypeSortable.archetypeEmpty.archetypeCrossDraggable {
min-height: 56px;
border-color: #dddddd;
}
.archetypeCollapser .archetypeEmptyContent span {
background: #f2f2f2;
}
.multiPropertyTextbox {
@@ -374,9 +275,6 @@
list-style: none;
margin-left: 0;
}
li {
line-height: 0;
}
.show-validation.ng-invalid .control-group.error .control-label {
span {
@@ -479,6 +377,15 @@
}
}
}
// Necessary to ensure empty lists can be dropped onto when sorting nested fieldsets.
.archetypeSortable.archetypeEmpty {
&.archetypeCrossDraggable {
min-height: 42px;
border: 1px dashed #dddddd;
margin-top: 5px;
}
}
}
.archetypeEditor, .archetypeConfig {
@@ -6,11 +6,6 @@ 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(
+77 -50
View File
@@ -1,87 +1,114 @@
angular.module('umbraco.services').factory('archetypeCacheService', function (archetypePropertyEditorResource, $q, entityResource) {
angular.module('umbraco.services').factory('archetypeCacheService', function (archetypePropertyEditorResource) {
//private
var isEntityLookupLoading = false;
var entityCache = [];
var isDatatypeLookupLoading = false;
var datatypeCache = [];
var broadcastEntityCacheUpdated = function(scope, entity) {
scope.$broadcast("archetypeEntityCacheUpdated", entity);
}
return {
initialize: function() {
return archetypePropertyEditorResource.getAllDataTypesForCache().then(function(data) {
_.each(data, function(datatype) {
datatypeCache[datatype.dataTypeGuid] = datatype;
});
getDataTypeFromCache: function(guid) {
return _.find(datatypeCache, function (dt){
return dt.dataTypeGuid == guid;
});
},
getDataTypeFromCache: function(guid) {
return datatypeCache[guid];
addDatatypeToCache: function(datatype, dataTypeGuid) {
var cachedDatatype = this.getDataTypeFromCache(dataTypeGuid);
if(!cachedDatatype) {
datatype.dataTypeGuid = dataTypeGuid;
datatypeCache.push(datatype);
}
},
getDatatypeByGuid: function(guid) {
var cachedDatatype = this.getDataTypeFromCache(guid);
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;
},
getEntityById: function(id, type) {
var deferred = $q.defer();
//console.log(entityCache);
var cachedEntity = entityCache[id];
getEntityById: function(scope, id, type) {
var cachedEntity = _.find(entityCache, function (e){
return e.id == id;
});
if(cachedEntity) {
//console.log("Found ID " + id);
deferred.resolve(cachedEntity);
return deferred.promise;
return cachedEntity;
}
//go get it from server
entityResource.getById(id, type).then(function(entity) {
entityCache[id] = entity;
//console.log("entity ID is now resolved into cache...");
//console.log(entityCache);
deferred.resolve(entity);
});
if (!isEntityLookupLoading) {
isEntityLookupLoading = true;
return deferred.promise;
scope.resources.entityResource.getById(id, type).then(function(entity) {
entityCache.push(entity);
isEntityLookupLoading = false;
broadcastEntityCacheUpdated(scope, entity);
return entity;
});
}
return null;
},
//perhaps this should return a promise?
getEntityByUmbracoId: function(udi, type) {
var deferred = $q.defer();
var cachedEntity = entityCache[udi];
getEntityByUmbracoId: function(scope, udi, type) {
var cachedEntity = _.find(entityCache, function (e){
return e.udi == udi;
});
if(cachedEntity) {
//console.log("Found UDI " + udi);
deferred.resolve(cachedEntity);
return deferred.promise;
return cachedEntity;
}
//go get it from server
entityResource.getByIds([udi], type).then(function (entities) {
// prevent infinite lookups with a default entity
var entity = entities.length > 0 ? entities[0] : { udi: udi, name: "" };
if (!isEntityLookupLoading) {
isEntityLookupLoading = true;
entityCache[udi] = entity;
//console.log("entity UDI is now resolved into cache...");
//console.log(entityCache);
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: "" };
deferred.resolve(entity);
});
entityCache.push(entity);
return deferred.promise;
isEntityLookupLoading = false;
broadcastEntityCacheUpdated(scope, entity);
return entity;
});
}
return null;
}
}
});
+121 -171
View File
@@ -1,4 +1,4 @@
angular.module('umbraco.services').factory('archetypeLabelService', function (archetypeCacheService, $q, $injector, $timeout) {
angular.module('umbraco.services').factory('archetypeLabelService', function (archetypeCacheService, $q, $injector) {
//private
/**
@@ -12,7 +12,6 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
// Remember the original number of promises being resolved.
var originalLength = promises.length;
return $q.all(promises).then(function () {
// If there are new promises, resolve those too.
@@ -20,7 +19,9 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
promises = promises.slice(originalLength);
return repeatedlyWaitForPromises(promises);
}
});
}
/**
@@ -46,18 +47,21 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
}
// Set a new value now that it has been processed.
//console.log("Processing string..." + labelValue);
match.value = labelValue;
} else if (isPromise(labelValue)) {
// Remember the promise so we can wait for it to be completed before constructing the
// fieldset label.
promises.push(labelValue);
labelValue.then(function (value) {
//console.log("Processing final value..." + value);
// The value will probably be a string, but recursively process it in case it's
// something else.
processLabelValue(value, promises, match);
});
} else if (_.isFunction(labelValue)) {
// Allow for the function to accept injected parameters, and invoke it.
@@ -66,10 +70,14 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
// Recursively check result (may be a string, promise, or another function (another
// function would be pretty strange, though I see no reason to disallow it).
processLabelValue(labelValue, promises, match);
} else {
// Some other data type (e.g., number, date, object).
match.value = labelValue;
}
}
/**
@@ -107,6 +115,7 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
* indicating whether or not that substring was matched the regular expression.
*/
function splitByRegex(rgx, value) {
// Validate input.
if (!rgx || !value) {
return [];
@@ -149,6 +158,7 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
// Get next match.
match = rgx.exec(value);
}
// The text after the last match.
@@ -165,6 +175,7 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
// Return information about the matches.
return splitParts;
}
function executeFunctionByName(functionName, context) {
@@ -185,31 +196,31 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
}
function getNativeLabel(datatype, value, scope) {
switch (datatype.selectedEditor) {
case "Imulus.UrlPicker":
return imulusUrlPicker(value, scope, {});
case "Umbraco.TinyMCEv3":
return coreTinyMce(value, scope, {});
case "Umbraco.MultiNodeTreePicker":
return coreMntp(value, scope, datatype);
case "Umbraco.MultiNodeTreePicker2":
return coreMntpV2(value, scope, datatype);
case "Umbraco.MultipleMediaPicker":
case "Umbraco.MediaPicker":
return coreMediaPicker(value, scope, datatype);
case "Umbraco.MediaPicker2":
return coreMediaPickerV2(value, scope, datatype);
case "Umbraco.DropDown":
return coreDropdown(value, scope, datatype);
case "RJP.MultiUrlPicker":
return rjpMultiUrlPicker(value, scope, {});
case "Umbraco.ContentPickerAlias":
return coreContentPicker(value, scope, datatype);
case "Umbraco.ContentPicker2":
return coreContentPickerV2(value, scope, datatype);
default:
return null;
}
switch (datatype.selectedEditor) {
case "Imulus.UrlPicker":
return imulusUrlPicker(value, scope, {});
case "Umbraco.TinyMCEv3":
return coreTinyMce(value, scope, {});
case "Umbraco.MultiNodeTreePicker":
return coreMntp(value, scope, datatype);
case "Umbraco.MultiNodeTreePicker2":
return coreMntpV2(value, scope, datatype);
case "Umbraco.MultipleMediaPicker":
case "Umbraco.MediaPicker":
return coreMediaPicker(value, scope, datatype);
case "Umbraco.MediaPicker2":
return coreMediaPickerV2(value, scope, datatype);
case "Umbraco.DropDown":
return coreDropdown(value, scope, datatype);
case "RJP.MultiUrlPicker":
return rjpMultiUrlPicker(value, scope, {});
case "Umbraco.ContentPickerAlias":
return coreContentPicker(value, scope, datatype);
case "Umbraco.ContentPicker2":
return coreContentPickerV2(value, scope, datatype);
default:
return "";
}
}
function coreDropdown(value, scope, args) {
@@ -229,7 +240,6 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
function coreMntp(value, scope, args) {
var ids = value.split(',');
var type = "Document";
var deferred = $q.defer();
switch(args.preValues[0].value.type) {
case 'content':
@@ -241,39 +251,32 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
case 'member':
type = 'member';
break;
default:
break;
}
var entityArray = [];
var promises = [];
_.each(ids, function(id){
if(id) {
promises.push(archetypeCacheService.getEntityById(id, type).then(function(entity){
if(entity) {
entityArray.push(entity.name);
}
}).promise);
var entity = archetypeCacheService.getEntityById(scope, id, type);
if(entity) {
entityArray.push(entity.name);
}
}
});
$q.all(promises).then(function() {
deferred.resolve(entityArray.join(', '));
});
return deferred.promise;
return entityArray.join(', ');
}
function coreMntpV2(value, scope, args) {
var deferred = $q.defer();
function coreMntpV2(value, scope, args) {
var ids = value.split(',');
if (ids.length == 0) {
return "";
}
var type = "document";
switch(args.preValues[0].value.type) {
@@ -290,173 +293,119 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
default:
break;
}
var entityArray = [];
var promises = [];
var entity;
_.each(ids, function (id) {
if(id) {
promises.push(archetypeCacheService.getEntityByUmbracoId(id, type).then(function(entity) {
if(entity) {
entityArray.push(entity.name);
}
}).promise);
if(id && !entity) {
entity = archetypeCacheService.getEntityByUmbracoId(scope, id, type);
}
});
$q.all(promises).then(function() {
if(entityArray.length == 0) {
deferred.resolve("");
}
var firstEntityName = entityArray[0];
var value = firstEntityName + (ids.length > 1 ? ", ..." : "");
deferred.resolve(value);
});
return deferred.promise;
return (entity != null ? entity.name : "") + (ids.length > 1 ? ", ..." : "");
}
function coreMediaPicker(value, scope, args) {
var deferred = $q.defer();
if(value) {
archetypeCacheService.getEntityById(value, "media").then(function(entity) {
deferred.resolve(entity.name);
});
}
else
{
deferred.resolve("");
var entity = archetypeCacheService.getEntityById(scope, value, "media");
if(entity) {
return entity.name;
}
}
return deferred.promise;
return "";
}
function coreMediaPickerV2(value, scope, args) {
var deferred = $q.defer();
//console.log("value=");
//console.log(value);
if(value) {
archetypeCacheService.getEntityByUmbracoId(value, "media").then(function(entity) {
deferred.resolve(entity.name);
});
}
else
{
deferred.resolve("");
var entity = archetypeCacheService.getEntityByUmbracoId(scope, value, "media");
if(entity) {
return entity.name;
}
}
return deferred.promise;
return "";
}
function coreContentPicker(value, scope, args) {
var deferred = $q.defer();
if(value) {
archetypeCacheService.getEntityById(value, "document").then(function(entity) {
deferred.resolve(entity.name);
});
if (value) {
var entity = archetypeCacheService.getEntityById(scope, value, "document");
if (entity) {
return entity.name;
}
else
{
deferred.resolve("");
}
return deferred.promise;
}
return "";
}
function coreContentPickerV2(value, scope, args) {
var deferred = $q.defer();
if (value) {
archetypeCacheService.getEntityByUmbracoId(value, "document").then(function(entity) {
deferred.resolve(entity.name);
});
}
else
{
deferred.resolve("");
}
if (value) {
var entity = archetypeCacheService.getEntityByUmbracoId(scope, value, "document");
return deferred.promise;
if (entity) {
return entity.name;
}
}
return "";
}
function imulusUrlPicker(value, scope, args) {
var deferred = $q.defer();
if(!value) {
deferred.resolve("");
return deferred.promise;
}
if(!args.propertyName) {
args = {propertyName: "name"}
}
if(typeof(value) != "object") {
value = JSON.parse(value);
}
//console.log("urlpicker value...");
//console.log(value);
if(value.length) {
value = value[0];
}
var entity;
switch (value.type) {
case "content":
if(value.typeData.contentId) {
archetypeCacheService.getEntityById(value.typeData.contentId, "Document").then(function(entity) {
//console.log("Retrived entity from cache!");
//console.log("Resolving the entity name with " + entity[args.propertyName]);
deferred.resolve(entity[args.propertyName]);
});
entity = archetypeCacheService.getEntityById(scope, value.typeData.contentId, "Document");
}
break;
case "media":
if(value.typeData.mediaId) {
archetypeCacheService.getEntityById(value.typeData.mediaId, "Media").then(function(entity) {
deferred.resolve(entity[args.propertyName]);
});
entity = archetypeCacheService.getEntityById(scope, value.typeData.mediaId, "Media");
}
break;
case "url":
deferred.resolve(value.typeData.url);
return deferred.promise;
return value.typeData.url;
default:
break;
}
return deferred.promise;
if(entity) {
return entity[args.propertyName];
}
return "";
}
function coreTinyMce(value, scope, args) {
if(!args.contentLength) {
args = {contentLength: 160}
args = {contentLength: 50}
}
var suffix = "";
var strippedText = $("<div/>").html(value).text();
if(strippedText.length > args.contentLength) {
suffix = "…";
suffix = "…";
}
return strippedText.substring(0, args.contentLength) + suffix;
}
function rjpMultiUrlPicker(values, scope, args) {
function rjpMultiUrlPicker(values, scope, args) {
var names = [];
_.each(values, function (value) {
@@ -467,9 +416,9 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
return names.join(", ");
}
return {
getFieldsetTitle: function(scope, fieldsetConfigModel, fieldsetIndex) {
return {
getFieldsetTitle: function(scope, fieldsetConfigModel, fieldsetIndex) {
if(!fieldsetConfigModel)
return $q.when("");
@@ -526,13 +475,12 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
args = JSON.parse(normalizedJsonString);
}
templateLabelValue = executeFunctionByName(functionName, window, scope.getPropertyValueByAlias(fieldset, propertyAlias), scope, args);
}
//normal {{foo}} syntax
else {
propertyAlias = template;
var rawValue = scope.getPropertyValueByAlias(fieldset, propertyAlias);
templateLabelValue = rawValue;
@@ -543,39 +491,41 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
});
if(propertyConfig) {
var datatype = archetypeCacheService.getDatatypeByGuid(propertyConfig.dataTypeGuid);
var datatype = archetypeCacheService.getDatatypeByGuid(propertyConfig.dataTypeGuid);
if(datatype) {
//try to get built-in label
var templateLabelValue = getNativeLabel(datatype, rawValue, scope);
//console.log("Native label...");
//console.log(templateLabelValue);
}
if(datatype) {
//try to get built-in label
var label = getNativeLabel(datatype, templateLabelValue, scope);
if(label) {
templateLabelValue = label;
}
}
}
}
}
// Process the value (i.e., reduce any functions or promises down to strings).
processLabelValue(templateLabelValue, promises, match);
});
// Wait for all of the promises to resolve before constructing the full fieldset label.
return repeatedlyWaitForPromises(promises).then(function () {
//console.log("done waiting...")
// Extract string values and combine them into a single string.
var substrings = _.map(matches, function (value) {
return value.value;
});
var combinedSubstrings = substrings.join('');
var combinedSubstrigs = substrings.join('');
//console.log(combinedSubstrings);
// Return the title.
return combinedSubstrings;
return combinedSubstrigs;
});
}
}
}
});
-8
View File
@@ -2,7 +2,6 @@ angular.module('umbraco.services').factory('archetypeService', function () {
// Variables.
var draggedRteArchetype;
var archetypeEditors;
var rteClass = ".archetypeEditor .umb-rte textarea";
var editorSettings = {};
var disabledSortables = [];
@@ -216,13 +215,6 @@ angular.module('umbraco.services').factory('archetypeService', function () {
sortable.enable();
});
disabledSortables = [];
},
// Get all active archetype editors on the current page
getEditors: function() {
if (archetypeEditors == null) {
archetypeEditors = $('.archetypeEditor');
}
return archetypeEditors;
}
}
});
+13 -19
View File
@@ -2,6 +2,14 @@
<div class="archetypeEditor ng-class:model.config.customCssClass">
<textarea class="archetypeDeveloperModel" ng-show="model.config.developerMode" ng-model="model.value"></textarea>
<!-- "Add" button. -->
<div ng-show="showAddButton()">
<a class="archetypeAddButton" ng-click="openFieldsetPicker(0, $event)" prevent-default>
<i class="icon icon-add"></i>
<archetype-localize key="addFieldset">Add an item</archetype-localize>
</a>
</div>
<!-- Mandatory validation. -->
<input type="hidden" name="archetypeMandatory" ng-model="model.mandatoryValidation" ng-required="model.validation.mandatory" />
<div><span class="help-inline" val-msg-for="archetypeMandatory" val-toggle-msg="required"><archetype-localize key="required">Required</archetype-localize></span></div>
@@ -13,11 +21,11 @@
<!-- Fieldsets. -->
<ul ui-sortable="sortableOptions" class="archetypeSortable" ng-class="{archetypeEmpty: model.value.fieldsets.length === 0 || sortingLastItem(), archetypeCrossDraggable: model.config.enableCrossDragging}" ng-model="model.value.fieldsets">
<li ng-repeat="fieldset in model.value.fieldsets">
<fieldset ng-class="['archetype-fieldset-' + fieldset.alias, (getFieldsetValidity(fieldset) == false ? 'archetypeFieldsetError' : ''), (isCollapsed(fieldset) ? '' : 'is-open')]" ng-init="fieldsetConfigModel = getConfigFieldsetByAlias(fieldset.alias)">
<div class="archetypeFieldsetLabel" ng-class="{enableCollapsing: model.config.enableCollapsing, dimmed: isDisabled(fieldset)}">
<fieldset ng-class="['archetype-fieldset-' + fieldset.alias, (getFieldsetValidity(fieldset) == false ? 'archetypeFieldsetError' : '')]" ng-init="fieldsetConfigModel = getConfigFieldsetByAlias(fieldset.alias)">
<div class="archetypeFieldsetLabel" ng-class="{enableCollapsing: model.config.enableCollapsing}">
<div ng-click="focusFieldset(fieldset)" class="label-sub module-label">
<span class="caret" ng-class="{'caret-right': isCollapsed(fieldset)}" ng-show="model.config.enableCollapsing"></span>
<label>
<label ng-class="{dimmed: isDisabled(fieldset)}">
<i class="fieldsetIcon icon ng-class:fieldsetConfigModel.icon"></i>
<span ng-bind="getFieldsetTitle(fieldsetConfigModel, $index)"></span>
</label>
@@ -26,9 +34,9 @@
<i class="icon icon-add" ng-show="canAdd()" ng-click="openFieldsetPicker($index, $event)"></i>
<i class="icon icon-navigation handle" ng-show="canSort()"></i>
<i class="icon icon-documents" ng-click="cloneRow($index)" ng-show="canClone()"></i>
<i class="icon icon-eye" ng-class="{'icon-active': fieldset.disabled}" ng-click="enableDisable(fieldset)" ng-show="showDisableIcon(fieldset)"></i>
<i class="icon icon-power" ng-class="{'icon-active': fieldset.disabled}" ng-click="enableDisable(fieldset)" ng-show="showDisableIcon(fieldset)"></i>
<i class="icon icon-time icon-disabled" ng-class="{'icon-active': isDisabledByPublishing(fieldset)}" ng-show="showPublishingIcon(fieldset)"></i>
<i class="icon icon-trash" ng-click="removeRow($index)" ng-show="canRemove()"></i>
<i class="icon icon-delete" ng-click="removeRow($index)" ng-show="canRemove()"></i>
</div>
</div>
<div class="archetypeCollapser animate-hide" ng-hide="model.config.enableCollapsing && isCollapsed(fieldset)" ng-if="isLoaded(fieldset)">
@@ -101,20 +109,6 @@
</li>
</ul>
<!-- Empty content display. -->
<div class="archetypeEmptyContent" ng-show="showEmptyContentHint()">
<span>
<archetype-localize key="addFieldset">Add an item</archetype-localize>
</span>
</div>
<!-- "Add" button. -->
<div class="archetypeFooter" ng-show="showAddButton()">
<a class="archetypeAddButton" ng-click="openFieldsetPicker(model.value.fieldsets.length, $event)" prevent-default>
<i class="icon icon-add"></i>
</a>
</div>
<!-- Fieldset picker. -->
<div class="usky-grid fieldsetPicker" ng-class="{withGroups: overlayMenu.fieldsetGroups.length > 1}" ng-if="overlayMenu.show">
<div class="cell-tools-menu" ng-style="overlayMenu.style" delayed-mouseleave="closeFieldsetPicker()" archetype-click-outside="closeFieldsetPicker()">
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "Archetype",
"version": "1.17.0",
"version": "1.16.0",
"url": "http://github.com/kgiszewski/archetype/",
"author": "Kevin Giszewski - Tom Fulton - Lee Kelleher - Matt Brailsford - Kenn Jacobsen - Nicholas Westby - Et. Al.",
"authorUrl": "http://github.com/kgiszewski/archetype/",