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 @@