Compare commits

...

33 Commits

Author SHA1 Message Date
Kevin Giszewski a4c1a59e23 Merge pull request #436 from kgiszewski/feature/slow-the-updates-roll
Feature/slow the updates roll
2017-10-07 07:10:36 -04:00
Kevin Giszewski e164be1823 Merge logic 2017-10-03 13:31:43 -04:00
Kevin Giszewski f32451fffa Clean up private var 2017-10-03 13:28:25 -04:00
Kevin Giszewski a541dbd038 Limit the version check to once every 7 days (unless the app is reloaded) 2017-10-03 13:27:03 -04:00
Kevin Giszewski 69e0bb70e5 Fix scrunchy fieldset picker titles 2017-10-03 11:07:10 -04:00
Kevin Giszewski c22a2623c2 Merge pull request #434 from ceee/ui-refactor
Update UI to better match Grid & Nested Content
2017-10-03 08:56:52 -04:00
swcs c229cc9953 correct layout for cross dragging between archetype instances 2017-10-03 14:32:34 +02:00
swcs 7d155ee176 force visibility of editor controls if a fieldset collapser is open 2017-10-02 15:49:37 +02:00
swcs 93659e5a22 increase char limit for RTE label generator from 50 to 160 2017-10-02 15:40:04 +02:00
swcs 46bbf24edf limit fieldset label to 2 lines 2017-09-29 10:34:34 +02:00
swcs da1057c681 fix style for nested archetype fieldsets 2017-09-28 14:14:16 +02:00
swcs 81881a5734 allow 100% width for fieldset labels and add background for controls on the right 2017-09-28 14:05:09 +02:00
swcs 25678a812c new empty content display and add button 2017-09-26 11:25:51 +02:00
Kevin Giszewski ec2edce74c Bump version 2017-09-25 13:31:52 -04:00
Kevin Giszewski 4756551518 Merge pull request #433 from Nicholas-Westby/fix/432-resolve-label-templates
Fix for label templates sometimes not resolving: https://github.com/k…
2017-09-25 08:28:23 -04:00
Nicholas-Westby e053b42950 Fix for label templates sometimes not resolving: https://github.com/kgiszewski/Archetype/issues/432 2017-09-23 17:16:50 -07:00
swcs ff21951ea1 make the container/boundaries for the fieldset collapser more visible 2017-09-21 14:22:21 +02:00
swcs 18935b4a69 update control icons and do only show them on fieldset hover 2017-09-21 13:41:47 +02:00
swcs cd93e17494 improve fieldset list layout and spacing 2017-09-21 13:15:58 +02:00
Kevin Giszewski 3a2190b232 Merge pull request #431 from kgiszewski/feature/letstryagain
Feature/letstryagain
2017-09-20 08:03:00 -04:00
Kevin Giszewski 46b0396652 Use a quicker cache lookup 2017-09-19 08:52:51 -04:00
Kevin Giszewski 0c3fcce58b Add args example 2017-09-15 15:50:39 -04:00
Kevin Giszewski cef7a36bd4 I remember adding these and now I think that was dumb. We should be injecting these :) 2017-09-15 13:41:24 -04:00
Kevin Giszewski 03d511ca80 Update sampleLabelHelpers and inject entityResource instead of off the scope 2017-09-15 13:39:18 -04:00
Kevin Giszewski 123546b11c Promise fixes 2017-09-15 12:46:33 -04:00
Kevin Giszewski 4aa6b83d82 Move to all promises, this is WIP 2017-09-15 10:58:04 -04:00
Kevin Giszewski 6f3a414c4d Handle native stuff a bit differently 2017-09-13 22:19:09 -04:00
Kevin Giszewski 4443d628dc Maybe works? 2017-09-13 21:56:43 -04:00
Kevin Giszewski 0f9a44c539 RTE is working, but not the UrlPicker one 2017-09-13 18:18:29 -04:00
Kevin Giszewski dd47218bd3 Add an asset only task 2017-09-13 17:15:11 -04:00
Kevin Giszewski 5e3e37af31 Update package.nuspec 2017-09-12 10:57:13 -04:00
Kevin Giszewski dbf1bffe34 Update package_binaries.nuspec 2017-09-12 10:56:53 -04:00
Kevin Giszewski cbf87264ac Update package_courier.nuspec 2017-09-12 10:56:41 -04:00
16 changed files with 535 additions and 384 deletions
+1
View File
@@ -322,4 +322,5 @@ 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']);
};
@@ -20,6 +20,9 @@ namespace Archetype.Api
[PluginController("ArchetypeApi")]
public class ArchetypeDataTypeController : UmbracoAuthorizedJsonController
{
private static DateTime _lastVersionCheck;
private const int IntervalInDaysBetweenVersionChecks = 7;
public IEnumerable<object> GetAllPropertyEditors()
{
return
@@ -30,13 +33,33 @@ namespace Archetype.Api
/// <summary>
/// Gets all datatypes.
/// </summary>
/// <returns></returns>
/// <returns>System.Object.</returns>
public object GetAll()
{
var dataTypes = Services.DataTypeService.GetAllDataTypeDefinitions();
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>
@@ -119,7 +142,7 @@ namespace Archetype.Api
[HttpPost]
public object CheckForUpdates()
{
if (!ArchetypeGlobalSettings.Instance.CheckForUpdates)
if (!ArchetypeGlobalSettings.Instance.CheckForUpdates || !IsItTimeToCheck())
{
return new
{
@@ -128,6 +151,7 @@ namespace Archetype.Api
}
var updateNotificationModel = ArchetypeHelper.Instance.CheckForUpdates();
_lastVersionCheck = DateTime.UtcNow;
return new
{
@@ -138,5 +162,10 @@ namespace Archetype.Api
url = updateNotificationModel.Url
};
}
internal bool IsItTimeToCheck()
{
return _lastVersionCheck.AddDays(IntervalInDaysBetweenVersionChecks) < DateTime.UtcNow;
}
}
}
@@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.16.0")]
[assembly: AssemblyFileVersion("1.16.0")]
[assembly: AssemblyVersion("1.17.1")]
[assembly: AssemblyFileVersion("1.17.1")]
+27 -28
View File
@@ -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;
@@ -27,24 +29,15 @@ 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];
@@ -63,18 +56,13 @@ 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;
});
// Still loading a title, so do not return a title.
archetypeLabelService.getFieldsetTitle($scope, fieldsetConfigModel, fieldsetIndex).then(function(value) {
// Finished loading the title.
title.loaded = true;
title.loading = false;
title.value = value;
});
};
/**
@@ -126,6 +114,7 @@ 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();
@@ -187,7 +176,6 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
},
stop: function (ev, ui) {
// Done sorting.
draggedParent.scope().doingSort = false;
@@ -202,6 +190,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
}
archetypeService.restoreEditors(parent);
archetypeService.getEditors().removeClass('archetypeDragging');
}
};
@@ -500,6 +489,13 @@ 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;
@@ -582,6 +578,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();
@@ -998,5 +998,4 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc
}
return null;
}
});
+1 -4
View File
@@ -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);
+49 -68
View File
@@ -1,70 +1,51 @@
var ArchetypeSampleLabelTemplates = (function() {
//create a namespace (optional)
var ArchetypeSampleLabelHelpers = {};
//public functions
return {
Entity: function (value, scope, args) {
if(!args.entityType) {
args = {entityType: "Document", propertyName: "name"}
}
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);
}
//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);
}
})();
}
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;
}
}
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;
}
}
+146 -53
View File
@@ -35,8 +35,7 @@
.fieldsetIcon {
float: left;
padding: 0 4px 0 0;
color: #333;
padding: 0 10px 0 0;
vertical-align: text-bottom;
}
@@ -54,7 +53,6 @@
fieldset {
border-bottom: 1px dashed #dddddd;
padding: 0;
margin-bottom: 5px;
clear: both;
display: inline-block;
width: 100%;
@@ -93,10 +91,10 @@
.archetypeFieldsetLabel {
position: relative;
width: 100%;
min-height: 42px;
background: white;
.label-sub {
padding: 8px 0 8px 0;
padding: 18px 0;
display: inline-block;
min-height: 20px; /* this makes the header clickable when there's no icon and no text */
&.module-label {
@@ -106,9 +104,9 @@
cursor: pointer;
label {
span {
text-decoration: underline;
}
// span {
// text-decoration: underline;
// }
&:hover {
cursor: pointer;
}
@@ -129,7 +127,7 @@
}
span {
font-weight: bold;
// font-weight: bold;
&.menu-label { font-weight: normal; }
}
@@ -145,57 +143,99 @@
label {
margin-bottom: 0;
margin-left: 18px;
white-space: nowrap;
padding: 0;
width: ~"calc(100% - 144px)";
position: absolute;
display: block;
span {
display: block;
overflow: hidden;
text-overflow: ellipsis;
max-height: 40px;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
display: -webkit-box;
}
&.dimmed {
i, span {
color: #d9d9d9 !important;
}
}
&.dimmed {
label {
color: #d9d9d9 !important;
}
}
.archetypeEditorControls {
float: none;
position: absolute;
right: 15px;
right: 0;
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 {
color: #ddd;
padding: 2px;
display: inline-block;
height: 28px;
width: 28px;
line-height: 28px;
border-radius: 14px;
border: 1px solid #d6d6d6;
color: #5f5f5f;
background: white;
font-size: 16px;
text-align: center;
margin-left: 8px;
&:hover {
color: #333;
background: #f3f3f5;
}
&.icon-delete:hover {
color: #b94a48;
&.icon-trash:hover {
background: #fe5b57;
border-color: #fe5b57;
color: white;
}
&.icon-disabled {
cursor: default;
&:hover {
color: #ddd;
background: white;
}
}
&.icon-active {
color: #333;
color: #bbb;
&:hover {
color: #333;
color: white;
}
}
}
}
&:hover {
&:hover .archetypeEditorControls {
opacity: 1;
}
}
&.is-open > .archetypeFieldsetLabel .archetypeEditorControls {
opacity: 1;
}
.archetypePropertyError {
margin-bottom: 5px;
padding-top: 3px;
@@ -213,9 +253,24 @@
.archetypeCollapser {
clear: both;
height: 100%;
padding: 12px 0 0 20px;
background-color: #fff;
border-radius: 0 0 0 5px;
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);
}
}
form {
margin-left:20px;
@@ -246,25 +301,69 @@
border: 1px solid #b94a48;
}
.archetypeFooter {
text-align: center;
margin-top: 20px;
}
.archetypeAddButton {
color: #ddd;
.icon {
vertical-align: middle;
}
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;
&:hover {
color: #333;
text-decoration: none;
cursor: pointer;
.archetypeAddButtonText {
text-decoration: underline;
}
.icon {
color: #333;
}
background: #00aea2;
border-color: #00aea2;
color: white;
}
}
.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 {
@@ -275,6 +374,9 @@
list-style: none;
margin-left: 0;
}
li {
line-height: 20px;
}
.show-validation.ng-invalid .control-group.error .control-label {
span {
@@ -377,15 +479,6 @@
}
}
}
// 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,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(
+68 -87
View File
@@ -1,106 +1,87 @@
angular.module('umbraco.services').factory('archetypeCacheService', function (archetypePropertyEditorResource) {
angular.module('umbraco.services').factory('archetypeCacheService', function (archetypePropertyEditorResource, $q, entityResource) {
//private
var isEntityLookupLoading = false;
var entityCache = [];
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) {
_.each(data, function(datatype) {
datatypeCache[datatype.dataTypeGuid] = datatype;
});
});
},
getDataTypeFromCache: function(guid) {
return datatypeCache[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(id, type) {
var deferred = $q.defer();
//console.log(entityCache);
var cachedEntity = entityCache[id];
if(cachedEntity) {
return cachedEntity;
}
if(cachedEntity) {
//console.log("Found ID " + id);
deferred.resolve(cachedEntity);
return deferred.promise;
}
//go get it from server
if (!isEntityLookupLoading) {
isEntityLookupLoading = true;
//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);
});
scope.resources.entityResource.getById(id, type).then(function(entity) {
return deferred.promise;
},
entityCache.push(entity);
//perhaps this should return a promise?
getEntityByUmbracoId: function(udi, type) {
var deferred = $q.defer();
var cachedEntity = entityCache[udi];
isEntityLookupLoading = false;
if(cachedEntity) {
//console.log("Found UDI " + udi);
deferred.resolve(cachedEntity);
return deferred.promise;
}
return entity;
});
}
//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: "" };
return null;
},
entityCache[udi] = entity;
//console.log("entity UDI is now resolved into cache...");
//console.log(entityCache);
getEntityByUmbracoId: function(scope, udi, type) {
var cachedEntity = _.find(entityCache, function (e){
return e.udi == udi;
});
deferred.resolve(entity);
});
if(cachedEntity) {
return cachedEntity;
}
//go get it from server
if (!isEntityLookupLoading) {
isEntityLookupLoading = true;
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 deferred.promise;
}
}
});
+171 -120
View File
@@ -1,4 +1,4 @@
angular.module('umbraco.services').factory('archetypeLabelService', function (archetypeCacheService, $q, $injector) {
angular.module('umbraco.services').factory('archetypeLabelService', function (archetypeCacheService, $q, $injector, $timeout) {
//private
/**
@@ -12,6 +12,7 @@ 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.
@@ -19,9 +20,7 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
promises = promises.slice(originalLength);
return repeatedlyWaitForPromises(promises);
}
});
}
/**
@@ -47,21 +46,18 @@ 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.
@@ -70,14 +66,10 @@ 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;
}
}
/**
@@ -115,7 +107,6 @@ 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 [];
@@ -158,7 +149,6 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
// Get next match.
match = rgx.exec(value);
}
// The text after the last match.
@@ -175,7 +165,6 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
// Return information about the matches.
return splitParts;
}
function executeFunctionByName(functionName, context) {
@@ -196,31 +185,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 "";
}
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;
}
}
function coreDropdown(value, scope, args) {
@@ -240,6 +229,7 @@ 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':
@@ -251,32 +241,39 @@ 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) {
var entity = archetypeCacheService.getEntityById(scope, id, type);
if(entity) {
entityArray.push(entity.name);
}
promises.push(archetypeCacheService.getEntityById(id, type).then(function(entity){
if(entity) {
entityArray.push(entity.name);
}
}).promise);
}
});
return entityArray.join(', ');
$q.all(promises).then(function() {
deferred.resolve(entityArray.join(', '));
});
return deferred.promise;
}
function coreMntpV2(value, scope, args) {
function coreMntpV2(value, scope, args) {
var deferred = $q.defer();
var ids = value.split(',');
if (ids.length == 0) {
return "";
}
var type = "document";
switch(args.preValues[0].value.type) {
@@ -293,119 +290,173 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar
default:
break;
}
var entity;
var entityArray = [];
var promises = [];
_.each(ids, function (id) {
if(id && !entity) {
entity = archetypeCacheService.getEntityByUmbracoId(scope, id, type);
if(id) {
promises.push(archetypeCacheService.getEntityByUmbracoId(id, type).then(function(entity) {
if(entity) {
entityArray.push(entity.name);
}
}).promise);
}
});
return (entity != null ? entity.name : "") + (ids.length > 1 ? ", ..." : "");
$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;
}
function coreMediaPicker(value, scope, args) {
var deferred = $q.defer();
if(value) {
var entity = archetypeCacheService.getEntityById(scope, value, "media");
if(entity) {
return entity.name;
}
archetypeCacheService.getEntityById(value, "media").then(function(entity) {
deferred.resolve(entity.name);
});
}
else
{
deferred.resolve("");
}
return "";
return deferred.promise;
}
function coreMediaPickerV2(value, scope, args) {
var deferred = $q.defer();
//console.log("value=");
//console.log(value);
if(value) {
var entity = archetypeCacheService.getEntityByUmbracoId(scope, value, "media");
if(entity) {
return entity.name;
}
archetypeCacheService.getEntityByUmbracoId(value, "media").then(function(entity) {
deferred.resolve(entity.name);
});
}
else
{
deferred.resolve("");
}
return "";
return deferred.promise;
}
function coreContentPicker(value, scope, args) {
if (value) {
var entity = archetypeCacheService.getEntityById(scope, value, "document");
if (entity) {
return entity.name;
var deferred = $q.defer();
if(value) {
archetypeCacheService.getEntityById(value, "document").then(function(entity) {
deferred.resolve(entity.name);
});
}
}
return "";
else
{
deferred.resolve("");
}
return deferred.promise;
}
function coreContentPickerV2(value, scope, args) {
if (value) {
var entity = archetypeCacheService.getEntityByUmbracoId(scope, value, "document");
if (entity) {
return entity.name;
var deferred = $q.defer();
if (value) {
archetypeCacheService.getEntityByUmbracoId(value, "document").then(function(entity) {
deferred.resolve(entity.name);
});
}
else
{
deferred.resolve("");
}
}
return "";
return deferred.promise;
}
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);
}
var entity;
//console.log("urlpicker value...");
//console.log(value);
if(value.length) {
value = value[0];
}
switch (value.type) {
case "content":
if(value.typeData.contentId) {
entity = archetypeCacheService.getEntityById(scope, value.typeData.contentId, "Document");
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]);
});
}
break;
case "media":
if(value.typeData.mediaId) {
entity = archetypeCacheService.getEntityById(scope, value.typeData.mediaId, "Media");
archetypeCacheService.getEntityById(value.typeData.mediaId, "Media").then(function(entity) {
deferred.resolve(entity[args.propertyName]);
});
}
break;
case "url":
return value.typeData.url;
deferred.resolve(value.typeData.url);
return deferred.promise;
default:
break;
}
if(entity) {
return entity[args.propertyName];
}
return "";
return deferred.promise;
}
function coreTinyMce(value, scope, args) {
if(!args.contentLength) {
args = {contentLength: 50}
args = {contentLength: 160}
}
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) {
@@ -416,9 +467,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("");
@@ -475,12 +526,13 @@ 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;
@@ -491,41 +543,40 @@ 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 label = getNativeLabel(datatype, templateLabelValue, scope);
if(label) {
templateLabelValue = label;
}
}
if(datatype) {
//try to get built-in label
var label = getNativeLabel(datatype, rawValue, 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 combinedSubstrigs = substrings.join('');
var combinedSubstrings = substrings.join('');
//console.log(combinedSubstrings);
// Return the title.
return combinedSubstrigs;
return combinedSubstrings;
});
}
}
}
});
+8
View File
@@ -2,6 +2,7 @@ angular.module('umbraco.services').factory('archetypeService', function () {
// Variables.
var draggedRteArchetype;
var archetypeEditors;
var rteClass = ".archetypeEditor .umb-rte textarea";
var editorSettings = {};
var disabledSortables = [];
@@ -215,6 +216,13 @@ 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;
}
}
});
+19 -13
View File
@@ -2,14 +2,6 @@
<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>
@@ -21,11 +13,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' : '')]" ng-init="fieldsetConfigModel = getConfigFieldsetByAlias(fieldset.alias)">
<div class="archetypeFieldsetLabel" ng-class="{enableCollapsing: model.config.enableCollapsing}">
<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)}">
<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 ng-class="{dimmed: isDisabled(fieldset)}">
<label>
<i class="fieldsetIcon icon ng-class:fieldsetConfigModel.icon"></i>
<span ng-bind="getFieldsetTitle(fieldsetConfigModel, $index)"></span>
</label>
@@ -34,9 +26,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-power" ng-class="{'icon-active': fieldset.disabled}" ng-click="enableDisable(fieldset)" ng-show="showDisableIcon(fieldset)"></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-time icon-disabled" ng-class="{'icon-active': isDisabledByPublishing(fieldset)}" ng-show="showPublishingIcon(fieldset)"></i>
<i class="icon icon-delete" ng-click="removeRow($index)" ng-show="canRemove()"></i>
<i class="icon icon-trash" 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)">
@@ -109,6 +101,20 @@
</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.16.0",
"version": "1.17.1",
"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/",
+2 -2
View File
@@ -9,10 +9,10 @@
<projectUrl>http://github.com/kgiszewski/archetype</projectUrl>
<description><![CDATA[Archetype for Umbraco]]></description>
<tags>umbraco</tags>
<iconUrl>http://imulus.github.io/Archetype/images/logo.png</iconUrl>
<iconUrl>http://kgiszewski.github.io/Archetype/images/logo.png</iconUrl>
<licenseUrl><%= licenseUrl %></licenseUrl>
<dependencies>
<dependency id="Archetype.Binaries" version="<%= version %>" />
</dependencies>
</metadata>
</package>
</package>
+2 -2
View File
@@ -9,10 +9,10 @@
<projectUrl>http://github.com/kgiszewski/archetype</projectUrl>
<description><![CDATA[Archetype binaries for Umbraco]]></description>
<tags>umbraco</tags>
<iconUrl>http://imulus.github.io/Archetype/images/logo.png</iconUrl>
<iconUrl>http://kgiszewski.github.io/Archetype/images/logo.png</iconUrl>
<licenseUrl><%= licenseUrl %></licenseUrl>
<dependencies>
<dependency id="UmbracoCms.Core" version="7.2.2" />
</dependencies>
</metadata>
</package>
</package>
+2 -2
View File
@@ -9,10 +9,10 @@
<projectUrl>http://github.com/kgiszewski/archetype</projectUrl>
<description><![CDATA[Archetype Courier extension for Umbraco]]></description>
<tags>umbraco</tags>
<iconUrl>http://imulus.github.io/Archetype/images/logo.png</iconUrl>
<iconUrl>http://kgiszewski.github.io/Archetype/images/logo.png</iconUrl>
<licenseUrl><%= licenseUrl %></licenseUrl>
<dependencies>
<dependency id="Archetype.Binaries" version="<%= version %>" />
</dependencies>
</metadata>
</package>
</package>