diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2017-03-18 03:54:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-18 03:54:05 +0300 |
commit | 173294bc2f06ef819ba072b4be51457b0746bd2b (patch) | |
tree | 4d63d17f33057d3d7256f4be3c6b6532ab152f2f /plugins | |
parent | 77fb7f76d09e9e92dc2f44ee0a047b5f751da94d (diff) |
Post JavaScript events when performing an action (#11463)
* post JS events when a user performs an action
* post events for website
* also post the measurable type
Diffstat (limited to 'plugins')
4 files changed, 31 insertions, 2 deletions
diff --git a/plugins/Goals/angularjs/manage-goals/manage-goals.controller.js b/plugins/Goals/angularjs/manage-goals/manage-goals.controller.js index c2eb80eca1..8ef619c310 100644 --- a/plugins/Goals/angularjs/manage-goals/manage-goals.controller.js +++ b/plugins/Goals/angularjs/manage-goals/manage-goals.controller.js @@ -157,6 +157,13 @@ }; this.createGoal = function () { + + var parameters = {isAllowed: true}; + $rootScope.$emit('Goals.initAddGoal', parameters); + if (parameters && !parameters.isAllowed) { + return; + } + this.showAddEditForm(); initGoalForm('Goals.addGoal', _pk_translate('Goals_AddGoal'), '', '', 'url', '', 'contains', /*caseSensitive = */false, /*allowMultiple = */'0', '0'); scrollToTop(); diff --git a/plugins/SegmentEditor/javascripts/Segmentation.js b/plugins/SegmentEditor/javascripts/Segmentation.js index 90fc6cc7f5..231746a37a 100644 --- a/plugins/SegmentEditor/javascripts/Segmentation.js +++ b/plugins/SegmentEditor/javascripts/Segmentation.js @@ -546,6 +546,14 @@ Segmentation = (function($) { }); self.target.on('click', '.add_new_segment', function (e) { + + var parameters = {isAllowed: true}; + var $rootScope = piwikHelper.getAngularDependency('$rootScope'); + $rootScope.$emit('Segmentation.initAddSegment', parameters); + if (parameters && !parameters.isAllowed) { + return; + } + e.stopPropagation(); displayFormAddNewSegment(e); }); diff --git a/plugins/SitesManager/angularjs/sites-manager/sites-manager.controller.js b/plugins/SitesManager/angularjs/sites-manager/sites-manager.controller.js index 3fbd008740..64b3bfb88d 100644 --- a/plugins/SitesManager/angularjs/sites-manager/sites-manager.controller.js +++ b/plugins/SitesManager/angularjs/sites-manager/sites-manager.controller.js @@ -194,6 +194,13 @@ }; var addSite = function(type) { + + var parameters = {isAllowed: true, measurableType: type}; + $rootScope.$emit('SitesManager.initAddSite', parameters); + if (parameters && !parameters.isAllowed) { + return; + } + if (!type) { type = 'website'; // todo shall we really hard code this or trigger an exception or so? } diff --git a/plugins/UsersManager/angularjs/manage-users/manage-users.controller.js b/plugins/UsersManager/angularjs/manage-users/manage-users.controller.js index 621113355c..a10d331e4f 100644 --- a/plugins/UsersManager/angularjs/manage-users/manage-users.controller.js +++ b/plugins/UsersManager/angularjs/manage-users/manage-users.controller.js @@ -7,9 +7,9 @@ (function () { angular.module('piwikApp').controller('ManageUsersController', ManageUsersController); - ManageUsersController.$inject = ['piwik', 'piwikApi', '$timeout']; + ManageUsersController.$inject = ['piwik', 'piwikApi', '$timeout', '$rootScope']; - function ManageUsersController(piwik, piwikApi, $timeout) { + function ManageUsersController(piwik, piwikApi, $timeout, $rootScope) { // remember to keep controller very simple. Create a service/factory (model) if needed var self = this; @@ -132,6 +132,13 @@ } this.createUser = function () { + + var parameters = {isAllowed: true}; + $rootScope.$emit('UsersManager.initAddUser', parameters); + if (parameters && !parameters.isAllowed) { + return; + } + this.showCreateUser = false; var numberOfRows = $('table#users')[0].rows.length; |