From e33eb863e6e97f07b1a079cc6f8073502d3d9ad1 Mon Sep 17 00:00:00 2001 From: kjac Date: Tue, 29 Mar 2016 16:01:14 +0200 Subject: [PATCH 1/6] #326 - support tags (and other built-in datatypes) --- app/directives/archetypeproperty.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/directives/archetypeproperty.js b/app/directives/archetypeproperty.js index 62045e1..7a9cd84 100644 --- a/app/directives/archetypeproperty.js +++ b/app/directives/archetypeproperty.js @@ -93,9 +93,11 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c } } - //upload, colorpicker datatype hack - if(view.indexOf('fileupload.html') != -1 || view.indexOf('colorpicker.html') != -1) { + //hacks for various built-in datatyps including upload, colorpicker and tags + if (!scope.propertyForm) { scope.propertyForm = scope.form; + } + if (!scope.model.validation) { scope.model.validation = {}; scope.model.validation.mandatory = 0; } From 6b79a508bb9f6606714ce06109ec9d96e8062fb0 Mon Sep 17 00:00:00 2001 From: kjac Date: Mon, 4 Apr 2016 21:28:19 +0200 Subject: [PATCH 2/6] Fix publishing when all fieldsets are collapsed Because of the lazy loading of property editors, the submitWatcherOnSubmit method is not necessarily called when an Archetype is saved. This is indeed the case when all fieldsets are collapsed. --- app/controllers/controller.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/controller.js b/app/controllers/controller.js index 226a3cc..bf98dbe 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -558,13 +558,18 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc return $scope.activeSubmitWatcher; } $scope.submitWatcherOnSubmit = function (args) { - _.each($scope.model.value.fieldsets, function(fieldset) { + $scope.$broadcast("archetypeFormSubmitting", args); + } + + // we need to hook into this event to save the custom fieldset properties because the lazy loading + // of property editors means that the submitWatcherOnSubmit won't necessarily be fired + $scope.$on("formSubmitting", function(ev, args) { + _.each($scope.model.value.fieldsets, function (fieldset) { // extract the publish configuration from the fieldsets (and convert local datetimes to UTC) fieldset.releaseDate = toUtc(fieldset.releaseDateModel.value); fieldset.expireDate = toUtc(fieldset.expireDateModel.value); }); - $scope.$broadcast("archetypeFormSubmitting", args); - } + }); function toUtc(date) { if (!date) { From a081d9754609f2bfe1f2b670e0238c58c642502d Mon Sep 17 00:00:00 2001 From: Kevin Giszewski Date: Wed, 6 Apr 2016 09:31:13 -0400 Subject: [PATCH 3/6] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e263c35..e03b235 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ Install the selected rele ## Official Docs ## https://github.com/kgiszewski/ArchetypeManual + +##News and Updates## Follow us on Twitter https://twitter.com/ArchetypeKit ##Core Team## From 4b874dc5b59f7701942a9f348d354889cfd24dd8 Mon Sep 17 00:00:00 2001 From: kjac Date: Wed, 6 Apr 2016 20:40:29 +0200 Subject: [PATCH 4/6] Another stab at fixing publishing for collapsed fieldsets --- app/controllers/controller.js | 6 ++---- app/directives/archetypesubmitwatcher.js | 11 ++++++----- app/views/archetype.default.html | 2 ++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/controller.js b/app/controllers/controller.js index bf98dbe..39fe1df 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -561,15 +561,13 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc $scope.$broadcast("archetypeFormSubmitting", args); } - // we need to hook into this event to save the custom fieldset properties because the lazy loading - // of property editors means that the submitWatcherOnSubmit won't necessarily be fired - $scope.$on("formSubmitting", function(ev, args) { + $scope.saveCustomFieldsetProperties = function () { _.each($scope.model.value.fieldsets, function (fieldset) { // extract the publish configuration from the fieldsets (and convert local datetimes to UTC) fieldset.releaseDate = toUtc(fieldset.releaseDateModel.value); fieldset.expireDate = toUtc(fieldset.expireDateModel.value); }); - }); + } function toUtc(date) { if (!date) { diff --git a/app/directives/archetypesubmitwatcher.js b/app/directives/archetypesubmitwatcher.js index 75b4ac0..dab7c84 100644 --- a/app/directives/archetypesubmitwatcher.js +++ b/app/directives/archetypesubmitwatcher.js @@ -1,11 +1,11 @@ angular.module("umbraco.directives").directive('archetypeSubmitWatcher', function ($rootScope) { var linker = function (scope, element, attrs, ngModelCtrl) { // call the load callback on scope to obtain the ID of this submit watcher - var id = scope.loadCallback(); - scope.$on("formSubmitting", function (ev, args) { + var id = scope.loadCallback ? scope.loadCallback() : 0; + scope.$on("formSubmitting", function (ev, args) { // on the "formSubmitting" event, call the submit callback on scope to notify the Archetype controller to do it's magic - if (id == scope.activeSubmitWatcher) { + if (id == scope.activeSubmitWatcher || scope.forceSubmitCallback) { scope.submitCallback(args); } }); @@ -19,7 +19,8 @@ angular.module("umbraco.directives").directive('archetypeSubmitWatcher', functio scope: { loadCallback: '=', submitCallback: '=', - activeSubmitWatcher: '=' + activeSubmitWatcher: '=', + forceSubmitCallback: '=' } } -}); +}); \ No newline at end of file diff --git a/app/views/archetype.default.html b/app/views/archetype.default.html index 8d20074..70bb84f 100644 --- a/app/views/archetype.default.html +++ b/app/views/archetype.default.html @@ -76,6 +76,8 @@ + +
From 0b6af3b4e1718805e5b3030efbeca50f9290777d Mon Sep 17 00:00:00 2001 From: kjac Date: Sun, 10 Apr 2016 19:23:31 +0200 Subject: [PATCH 5/6] Another stab at fixing publishing for collapsed fieldsets Make sure we've loaded moment.js before attempting to use it. Also a small update to styles to accommodate 7.4 --- app/controllers/controller.js | 18 ++++++++++-------- app/less/archetype.less | 3 +++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/controllers/controller.js b/app/controllers/controller.js index 39fe1df..61092a0 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -277,19 +277,19 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc return true; } - $scope.isDisabledByPublishing = function (fieldset) { + $scope.isDisabledByPublishing = function(fieldset) { if ($scope.canPublish() === false) { return false; } // NOTE: all comparison is done in local datetime // - that's fine because the selected local datetimes will be converted to UTC datetimes when submitted - if (fieldset.expireDateModel && fieldset.expireDateModel.value) { + if (fieldset.expireDateModel && fieldset.expireDateModel.value && (moment() > moment(fieldset.expireDateModel.value))) { // an expired release affects the fieldset - return moment() > moment(fieldset.expireDateModel.value); + return true; } - if (fieldset.releaseDateModel && fieldset.releaseDateModel.value) { + if (fieldset.releaseDateModel && fieldset.releaseDateModel.value && (moment(fieldset.releaseDateModel.value) > moment())) { // a pending release affects the fieldset - return moment(fieldset.releaseDateModel.value) > moment(); + return true; } return false; } @@ -317,13 +317,15 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc } function addCustomProperties(fieldsets) { - _.each(fieldsets, function (fieldset) { - addCustomPropertiesToFieldset(fieldset); + // make sure we have loaded moment.js before using it + assetsService.loadJs("lib/moment/moment-with-locales.js").then(function() { + _.each(fieldsets, function(fieldset) { + addCustomPropertiesToFieldset(fieldset); + }); }); } function addCustomPropertiesToFieldset(fieldset) { - // create models for publish configuration (utilizing the built-in datepicker data type) // NOTE: all datetimes must be converted from UTC to local fieldset.releaseDateModel = { diff --git a/app/less/archetype.less b/app/less/archetype.less index 7d2e8a0..786fe35 100644 --- a/app/less/archetype.less +++ b/app/less/archetype.less @@ -319,6 +319,9 @@ } } .settingsHeader { + label { + display: inline-block; + } &:hover { cursor: pointer; label { From 394572a8fc8a049e2ad5f52f1e51c8488388438e Mon Sep 17 00:00:00 2001 From: kjac Date: Sat, 23 Apr 2016 10:14:56 +0200 Subject: [PATCH 6/6] Yet another stab at fixing it By tracking the fieldsets that have been expanded (loaded), we can make sure the submit watchers fire appropriately, even when the fieldsets are collapsed down again. Apart from hopefully fixing the publishing issues for collapsed fieldsets, this also adds a performance gain if the users expand and collapse the same fieldsets more than once, since the fieldsets now only load the first time they're expanded (instead of every time). This also - at least partially - fixes the validation issue #325 introduced by #301 --- app/controllers/controller.js | 17 +++++++++++++++-- app/directives/archetypesubmitwatcher.js | 5 ++--- app/views/archetype.default.html | 11 +++++------ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/controllers/controller.js b/app/controllers/controller.js index 61092a0..f690129 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -364,6 +364,12 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc return fieldset.collapse; } + // added to track loaded fieldsets + $scope.loadedFieldsets = []; + $scope.isLoaded = function (fieldset) { + return $scope.loadedFieldsets.indexOf(fieldset) >= 0; + } + //helper for expanding/collapsing fieldsets $scope.focusFieldset = function(fieldset){ fixDisableSelection(); @@ -386,12 +392,14 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc if(!fieldset && $scope.model.value.fieldsets.length == 1) { $scope.model.value.fieldsets[0].collapse = false; + $scope.loadedFieldsets.push($scope.model.value.fieldsets[0]); return; } if(iniState && fieldset) { fieldset.collapse = !iniState; + $scope.loadedFieldsets.push(fieldset); } } @@ -448,6 +456,9 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc // reset submit watcher counter on save $scope.activeSubmitWatcher = 0; + // init loaded fieldsets tracking + $scope.loadedFieldsets = _.where($scope.model.value.fieldsets, { collapse: false }); + // create properties needed for the backoffice to work (data that is not serialized to DB) addCustomProperties($scope.model.value.fieldsets); }); @@ -563,13 +574,15 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc $scope.$broadcast("archetypeFormSubmitting", args); } - $scope.saveCustomFieldsetProperties = function () { + // we'll use our own "archetypeFormSubmitting" event to save custom properties, as at least some + // of the editors store their values back to the model on the core "formSubmitting" event + $scope.$on("archetypeFormSubmitting", function (ev, args) { _.each($scope.model.value.fieldsets, function (fieldset) { // extract the publish configuration from the fieldsets (and convert local datetimes to UTC) fieldset.releaseDate = toUtc(fieldset.releaseDateModel.value); fieldset.expireDate = toUtc(fieldset.expireDateModel.value); }); - } + }); function toUtc(date) { if (!date) { diff --git a/app/directives/archetypesubmitwatcher.js b/app/directives/archetypesubmitwatcher.js index dab7c84..3311e6c 100644 --- a/app/directives/archetypesubmitwatcher.js +++ b/app/directives/archetypesubmitwatcher.js @@ -5,7 +5,7 @@ angular.module("umbraco.directives").directive('archetypeSubmitWatcher', functio scope.$on("formSubmitting", function (ev, args) { // on the "formSubmitting" event, call the submit callback on scope to notify the Archetype controller to do it's magic - if (id == scope.activeSubmitWatcher || scope.forceSubmitCallback) { + if (id == scope.activeSubmitWatcher) { scope.submitCallback(args); } }); @@ -19,8 +19,7 @@ angular.module("umbraco.directives").directive('archetypeSubmitWatcher', functio scope: { loadCallback: '=', submitCallback: '=', - activeSubmitWatcher: '=', - forceSubmitCallback: '=' + activeSubmitWatcher: '=' } } }); \ No newline at end of file diff --git a/app/views/archetype.default.html b/app/views/archetype.default.html index 70bb84f..8a661db 100644 --- a/app/views/archetype.default.html +++ b/app/views/archetype.default.html @@ -6,8 +6,7 @@
- - +
-
+
-
+
@@ -76,8 +77,6 @@
- -