From a36b1097c55d802368e7c2cccacdf7712eae8446 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 21 Sep 2017 13:56:03 +0200 Subject: [PATCH] added event to load audit trail on Properties tab only --- .../content/umbcontentnodeinfo.directive.js | 11 ++++++++--- .../directives/components/tabs/umbtabs.directive.js | 9 ++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js index 5f9917a018..5f3d6270f3 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js @@ -32,11 +32,16 @@ // get document type details scope.documentType = getDocumentType(scope.node); - loadAuditTrail(); - + // load audit trail on tab change + eventsService.on("tab change", function (event, args) { + if (args.context.innerHTML === "Properties" && args.context.hash === "#tab0") { + console.log(args.context.alias); + loadAuditTrail(); + } + }); } - scope.auditTrailPageChange = function(pageNumber) { + scope.auditTrailPageChange = function (pageNumber) { scope.auditTrailOptions.pageNumber = pageNumber; loadAuditTrail(); }; diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/tabs/umbtabs.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/tabs/umbtabs.directive.js index aa23b80665..259e9083cd 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/tabs/umbtabs.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/tabs/umbtabs.directive.js @@ -8,7 +8,7 @@ angular.module("umbraco.directives") .directive('umbTabs', function () { return { restrict: 'A', - controller: function ($scope, $element, $attrs) { + controller: function ($scope, $element, $attrs, eventsService) { var callbacks = []; this.onTabShown = function(cb) { @@ -20,13 +20,20 @@ angular.module("umbraco.directives") var curr = $(event.target); // active tab var prev = $(event.relatedTarget); // previous tab + //emit tab change event + eventsService.emit("tab change", curr); + $scope.$apply(); for (var c in callbacks) { callbacks[c].apply(this, [{current: curr, previous: prev}]); } + + } + + //NOTE: it MUST be done this way - binding to an ancestor element that exists // in the DOM to bind to the dynamic elements that will be created. // It would be nicer to create this event handler as a directive for which child