From 6b79a508bb9f6606714ce06109ec9d96e8062fb0 Mon Sep 17 00:00:00 2001 From: kjac Date: Mon, 4 Apr 2016 21:28:19 +0200 Subject: [PATCH] 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) {