diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2022-03-11 13:41:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-11 13:41:12 +0300 |
commit | 222f2d9bf1042e36ab52ce75cfe776dc29889386 (patch) | |
tree | 9a6b52f452e245b1a8b7a9211a6d2e698c7820b0 /plugins/Goals | |
parent | 130107669b8f3bb75d9439b56a93ca15eb6d8816 (diff) |
[Vue] migrate manage goals directive and twig templates to Vue (#18917)
* start converting goal form/edit from twig/angularjs
* more tweaks
* some more changes
* get to build
* fix typo in directive name causing strange regressions
* get to build and load in UI, twig postEvent hack seems to work
* another TODO
* implement alternative way to use twig events in vue components using named slots, does not work in all cases
* remove templates
* allow target=_blank in dompurify if noreferrer noopener are present
* Allow numbers for fieldcheckbox value.
* remove use of const in vanilla js
* get managegoals.vue to work + remove angularjs files
* correct camel case
* correct property name
* correct 0 check
* switch back to angularjs adapter and using dynamic components for twig events since piwik-manage-goals is selected for in plugins and because angularjs directives are sometimes pre-compiled, sometimes not
Diffstat (limited to 'plugins/Goals')
-rw-r--r-- | plugins/Goals/Controller.php | 29 | ||||
-rw-r--r-- | plugins/Goals/Goals.php | 50 | ||||
-rw-r--r-- | plugins/Goals/angularjs/manage-goals/manage-goals.controller.js | 215 | ||||
-rw-r--r-- | plugins/Goals/angularjs/manage-goals/manage-goals.directive.js | 38 | ||||
-rw-r--r-- | plugins/Goals/templates/_addEditGoal.twig | 42 | ||||
-rw-r--r-- | plugins/Goals/templates/_formAddGoal.twig | 183 | ||||
-rw-r--r-- | plugins/Goals/templates/_listGoalEdit.twig | 122 | ||||
-rw-r--r-- | plugins/Goals/vue/dist/Goals.umd.js | 936 | ||||
-rw-r--r-- | plugins/Goals/vue/dist/Goals.umd.min.js | 16 | ||||
-rw-r--r-- | plugins/Goals/vue/dist/umd.metadata.json | 3 | ||||
-rw-r--r-- | plugins/Goals/vue/src/Goal.ts | 24 | ||||
-rw-r--r-- | plugins/Goals/vue/src/ManageGoals/ManageGoals.adapter.ts | 64 | ||||
-rw-r--r-- | plugins/Goals/vue/src/ManageGoals/ManageGoals.vue | 821 | ||||
-rw-r--r-- | plugins/Goals/vue/src/ManageGoals/PiwikApiMock.ts | 38 | ||||
-rw-r--r-- | plugins/Goals/vue/src/index.ts | 4 |
15 files changed, 1985 insertions, 600 deletions
diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php index 79b8b34dd3..c0c7d2f766 100644 --- a/plugins/Goals/Controller.php +++ b/plugins/Goals/Controller.php @@ -78,6 +78,7 @@ class Controller extends \Piwik\Plugin\Controller $this->setGeneralVariablesView($view); $this->setEditGoalsViewVariables($view); $this->setGoalOptions($view); + $this->execAndSetResultsForTwigEvents($view); return $view->render(); } @@ -123,6 +124,7 @@ class Controller extends \Piwik\Plugin\Controller $this->setGeneralVariablesView($view); $this->setGoalOptions($view); $view->onlyShowAddNewGoal = true; + $this->execAndSetResultsForTwigEvents($view); return $view->render(); } @@ -132,9 +134,35 @@ class Controller extends \Piwik\Plugin\Controller $this->setGeneralVariablesView($view); $this->setEditGoalsViewVariables($view); $this->setGoalOptions($view); + $this->execAndSetResultsForTwigEvents($view); return $view->render(); } + private function execAndSetResultsForTwigEvents(View $view) + { + if (empty($view->onlyShowAddGoal)) { + $beforeGoalListActionsBody = []; + foreach ($view->goals as $goal) { + $str = ''; + Piwik::postEvent('Template.beforeGoalListActionsBody', [&$str, $goal]); + + $beforeGoalListActionsBody[$goal['idgoal']] = $str; + } + $view->beforeGoalListActionsBodyEventResult = $beforeGoalListActionsBody; + + $str = ''; + Piwik::postEvent('Template.beforeGoalListActionsHead', [&$str]); + $view->beforeGoalListActionsHead = $str; + } + + if (!empty($view->userCanEditGoals)) { + $str = ''; + Piwik::postEvent('Template.endGoalEditTable', [&$str]); + + $view->endEditTable = $str; + } + } + public function hasConversions() { $this->checkSitePermission(); @@ -374,6 +402,7 @@ class Controller extends \Piwik\Plugin\Controller if (isset($goal['pattern'])) { $goal['pattern'] = Common::unsanitizeInputValue($goal['pattern']); } + $goal['revenue_pretty'] = \Piwik\piwik_format_money($goal['revenue'], $this->idSite); } $view->goals = $goals; diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index fa2220a3d4..a06be4ccf7 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -94,7 +94,6 @@ class Goals extends \Piwik\Plugin public function registerEvents() { $hooks = array( - 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'Tracker.Cache.getSiteAttributes' => 'fetchGoalsFromDb', 'API.getReportMetadata.end' => 'getReportMetadataEnd', @@ -340,12 +339,6 @@ class Goals extends \Piwik\Plugin return $reportsWithGoals; } - public function getJsFiles(&$jsFiles) - { - $jsFiles[] = "plugins/Goals/angularjs/manage-goals/manage-goals.controller.js"; - $jsFiles[] = "plugins/Goals/angularjs/manage-goals/manage-goals.directive.js"; - } - public function getStylesheetFiles(&$stylesheets) { $stylesheets[] = "plugins/Goals/stylesheets/goals.css"; @@ -363,12 +356,51 @@ class Goals extends \Piwik\Plugin $translationKeys[] = 'Goals_AddNewGoal'; $translationKeys[] = 'Goals_UpdateGoal'; $translationKeys[] = 'Goals_DeleteGoalConfirm'; - $translationKeys[] = 'Goals_UpdateGoal'; - $translationKeys[] = 'Goals_DeleteGoalConfirm'; $translationKeys[] = 'Goals_Ecommerce'; $translationKeys[] = 'Goals_Optional'; $translationKeys[] = 'Goals_TimeInMinutes'; $translationKeys[] = 'Goals_Pattern'; $translationKeys[] = 'Goals_ClickToViewThisGoal'; + $translationKeys[] = 'Goals_ManageGoals'; + $translationKeys[] = 'Goals_GoalName'; + $translationKeys[] = 'Goals_GoalIsTriggeredWhen'; + $translationKeys[] = 'Goals_ThereIsNoGoalToManage'; + $translationKeys[] = 'Goals_ManuallyTriggeredUsingJavascriptFunction'; + $translationKeys[] = 'Goals_VisitUrl'; + $translationKeys[] = 'Goals_ClickOutlink'; + $translationKeys[] = 'Goals_SendEvent'; + $translationKeys[] = 'Goals_GoalIsTriggered'; + $translationKeys[] = 'Goals_WhereThe'; + $translationKeys[] = 'Goals_URL'; + $translationKeys[] = 'General_ForExampleShort'; + $translationKeys[] = 'Goals_Contains'; + $translationKeys[] = 'Goals_IsExactly'; + $translationKeys[] = 'Goals_MatchesExpression'; + $translationKeys[] = 'Goals_AllowMultipleConversionsPerVisit'; + $translationKeys[] = 'Goals_HelpOneConversionPerVisit'; + $translationKeys[] = 'Goals_DefaultRevenueHelp'; + $translationKeys[] = 'Goals_DefaultRevenueLabel'; + $translationKeys[] = 'Goals_GoalRevenue'; + $translationKeys[] = 'Goals_Filename'; + $translationKeys[] = 'Goals_ExternalWebsiteUrl'; + $translationKeys[] = 'Goals_VisitDuration'; + $translationKeys[] = 'Goals_AtLeastMinutes'; + $translationKeys[] = 'Goals_VisitPageTitle'; + $translationKeys[] = 'Intl_NMinutes'; + $translationKeys[] = 'Goals_PageTitle'; + $translationKeys[] = 'Goals_UseEventValueAsRevenue'; + $translationKeys[] = 'Goals_EventValueAsRevenueHelp'; + $translationKeys[] = 'Goals_EventValueAsRevenueHelp2'; + $translationKeys[] = 'Events_EventCategory'; + $translationKeys[] = 'Goals_WhereVisitedPageManuallyCallsJavascriptTrackerLearnMore'; + $translationKeys[] = 'Goals_LearnMoreAboutGoalTrackingDocumentation'; + $translationKeys[] = 'Goals_EcommerceReports'; + $translationKeys[] = 'SitesManager_WebsitesManagement'; + $translationKeys[] = 'Goals_CaseSensitive'; + $translationKeys[] = 'Goals_Download'; + $translationKeys[] = 'Events_EventAction'; + $translationKeys[] = 'Events_EventCategory'; + $translationKeys[] = 'Events_EventName'; + $translationKeys[] = 'Goals_YouCanEnableEcommerceReports'; } } diff --git a/plugins/Goals/angularjs/manage-goals/manage-goals.controller.js b/plugins/Goals/angularjs/manage-goals/manage-goals.controller.js deleted file mode 100644 index 1b8ecff484..0000000000 --- a/plugins/Goals/angularjs/manage-goals/manage-goals.controller.js +++ /dev/null @@ -1,215 +0,0 @@ -/*! - * Matomo - free/libre analytics platform - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ -(function () { - angular.module('piwikApp').controller('ManageGoalsController', ManageGoalsController); - - ManageGoalsController.$inject = ['piwik', 'piwikApi', '$timeout', '$location', 'reportingMenuModel', '$rootScope']; - - function ManageGoalsController(piwik, piwikApi, $timeout, $location, reportingMenuModel, $rootScope) { - // remember to keep controller very simple. Create a service/factory (model) if needed - - var self = this; - - if (!this.goal) { - this.goal = {}; - } - this.showEditGoal = false; - this.showGoalList = true; - - function scrollToTop() - { - $timeout(function () { - piwik.helper.lazyScrollTo(".pageWrap", 200); - }); - } - - function initGoalForm(goalMethodAPI, submitText, goalName, description, matchAttribute, pattern, patternType, caseSensitive, revenue, allowMultiple, useEventValueAsRevenue, goalId) { - - $rootScope.$emit('Goals.beforeInitGoalForm', goalMethodAPI, goalId); - - self.goal = {}; - self.goal.name = goalName; - self.goal.description = description; - - if (matchAttribute == 'manually') { - self.goal.triggerType = 'manually'; - matchAttribute = 'url'; - } else { - self.goal.triggerType = 'visitors'; - } - - if (0 === matchAttribute.indexOf('event')) { - self.goal.eventType = matchAttribute; - matchAttribute = 'event'; - } else { - self.goal.eventType = 'event_category'; - } - - self.goal.matchAttribute = matchAttribute; - self.goal.allowMultiple = allowMultiple == true ? "1" : "0"; - self.goal.patternType = patternType; - self.goal.pattern = pattern; - self.goal.caseSensitive = caseSensitive; - self.goal.revenue = revenue; - self.goal.apiMethod = goalMethodAPI; - self.goal.useEventValueAsRevenue = useEventValueAsRevenue; - - self.goal.submitText = submitText; - self.goal.goalId = goalId; - - $timeout(function () { - var text = _pk_translate('Goals_AddNewGoal'); - if (goalId) { - text = _pk_translate('Goals_UpdateGoal') - } - - $('.addEditGoal .card-title').text(text); - }); - } - - this.isManuallyTriggered = function () { - return this.goal.triggerType == 'manually'; - } - - this.save = function () { - - var parameters = {}; - parameters.name = encodeURIComponent(this.goal.name); - parameters.description = encodeURIComponent(this.goal.description); - - if (this.isManuallyTriggered()) { - parameters.matchAttribute = 'manually'; - parameters.patternType = 'regex'; - parameters.pattern = '.*'; - parameters.caseSensitive = 0; - } else { - parameters.matchAttribute = this.goal.matchAttribute; - - if (parameters.matchAttribute === 'event') { - parameters.matchAttribute = this.goal.eventType; - } - - parameters.patternType = this.goal.patternType; - parameters.pattern = encodeURIComponent(this.goal.pattern); - parameters.caseSensitive = this.goal.caseSensitive == true ? 1 : 0; - } - parameters.revenue = this.goal.revenue || 0; - parameters.allowMultipleConversionsPerVisit = this.goal.allowMultiple == true ? 1 : 0; - parameters.useEventValueAsRevenue = this.goal.useEventValueAsRevenue == true ? 1 : 0; - - parameters.idGoal = this.goal.goalId; - parameters.method = this.goal.apiMethod; - - var isCreate = parameters.method === 'Goals.addGoal'; - var isUpdate = parameters.method === 'Goals.updateGoal'; - - if (isUpdate) { - $rootScope.$emit('Goals.beforeUpdateGoal', parameters, piwikApi); - } else if (isCreate) { - $rootScope.$emit('Goals.beforeAddGoal', parameters, piwikApi); - } - - if (parameters && 'undefined' !== typeof parameters.cancelRequest && parameters.cancelRequest) { - return; - } - - this.isLoading = true; - - piwikApi.fetch(parameters).then(function () { - var search = $location.search(); - if (search - && search.subcategory - && search.subcategory == 'Goals_AddNewGoal' - && piwik.helper.isAngularRenderingThePage()) { - // when adding a goal for the first time we need to load manage goals page afterwards - reportingMenuModel.reloadMenuItems().then(function () { - $location.search('subcategory', 'Goals_ManageGoals'); - self.isLoading = false; - }); - } else { - location.reload(); - } - }, function () { - scrollToTop(); - self.isLoading = false; - }); - }; - - this.changedTriggerType = function () { - if (!this.isManuallyTriggered() && !this.goal.patternType) { - this.goal.patternType = 'contains'; - } - } - - this.showListOfReports = function (shouldScrollToTop) { - $rootScope.$emit('Goals.cancelForm'); - - this.showGoalList = true; - this.showEditGoal = false; - scrollToTop(); - }; - - this.showAddEditForm = function () { - this.showGoalList = false; - this.showEditGoal = true; - }; - - 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 = */ false, /*useEventValueAsRevenue = */ false, 0); - scrollToTop(); - }; - - this.editGoal = function (goalId) { - this.showAddEditForm(); - var goal = piwik.goals[goalId]; - initGoalForm("Goals.updateGoal", _pk_translate('Goals_UpdateGoal'), goal.name, goal.description, goal.match_attribute, goal.pattern, goal.pattern_type, (goal.case_sensitive != '0'), goal.revenue, goal.allow_multiple, (goal.event_value_as_revenue != '0'), goalId); - scrollToTop(); - }; - - this.deleteGoal = function (goalId) { - var goal = piwik.goals[goalId]; - - $('#confirm').find('h2').text(sprintf(_pk_translate('Goals_DeleteGoalConfirm'), '"' + goal.name + '"')); - piwikHelper.modalConfirm('#confirm', {yes: function () { - self.isLoading = true; - - piwikApi.fetch({idGoal: goalId, method: 'Goals.deleteGoal'}).then(function () { - location.reload(); - }, function () { - self.isLoading = false; - }); - - }}); - }; - - this.isMatchAttributeNumeric = function () { - return ['visit_duration'].indexOf(this.goal.matchAttribute) > -1; - }; - - this.initPatternType = function () { - if (this.isMatchAttributeNumeric()) { - this.goal.patternType = 'greater_than'; - } else { - this.goal.patternType = 'contains'; - } - }; - - this.getPatternFieldLabel = function () { - return this.goal.matchAttribute === 'visit_duration' ? _pk_translate('Goals_TimeInMinutes') : _pk_translate('Goals_Pattern'); - }; - - this.showListOfReports(false); - } -})(); diff --git a/plugins/Goals/angularjs/manage-goals/manage-goals.directive.js b/plugins/Goals/angularjs/manage-goals/manage-goals.directive.js deleted file mode 100644 index 91b5e6b4b6..0000000000 --- a/plugins/Goals/angularjs/manage-goals/manage-goals.directive.js +++ /dev/null @@ -1,38 +0,0 @@ -/*! - * Matomo - free/libre analytics platform - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - - -/** - * Usage: - * <div piwik-manage-goals> - */ -(function () { - angular.module('piwikApp').directive('piwikManageGoals', piwikManageGoals); - - piwikManageGoals.$inject = ['piwik']; - - function piwikManageGoals(piwik){ - - return { - restrict: 'A', - priority: 10, - controller: 'ManageGoalsController', - controllerAs: 'manageGoals', - compile: function (element, attrs) { - - return function (scope, element, attrs, controller) { - if (attrs.showAddGoal) { - controller.createGoal(); - } else if (attrs.showGoal) { - controller.editGoal(attrs.showGoal); - } - - }; - } - }; - } -})();
\ No newline at end of file diff --git a/plugins/Goals/templates/_addEditGoal.twig b/plugins/Goals/templates/_addEditGoal.twig index 16be9c2424..ab1a57acf6 100644 --- a/plugins/Goals/templates/_addEditGoal.twig +++ b/plugins/Goals/templates/_addEditGoal.twig @@ -13,22 +13,32 @@ </script> -<div piwik-manage-goals - {% if userCanEditGoals %} - {% if onlyShowAddNewGoal is not defined %} - {% if idGoal %} - show-goal="{{ idGoal|e('js') }}" - {% endif %} - {% else %} - show-add-goal="true" - {% endif %} - {% endif %}> - - {% if onlyShowAddNewGoal is not defined %} - {% include "@Goals/_listGoalEdit.twig" %} - {% endif %} +<div + piwik-manage-goals + user-can-edit-goals="{{ userCanEditGoals|json_encode|e('html_attr') }}" + only-show-add-new-goal="{{ onlyShowAddNewGoal|default(false)|json_encode|e('html_attr') }}" + ecommerce-enabled="{{ ecommerceEnabled|json_encode|e('html_attr') }}" {% if userCanEditGoals %} - {% include "@Goals/_formAddGoal.twig" %} + {% if onlyShowAddNewGoal is not defined or not onlyShowAddNewGoal %} + goals="{{ goals|json_encode|e('html_attr') }}" + {% if idGoal %} + show-goal="{{ idGoal|e('js') }}" + {% endif %} + {% else %} + show-add-goal="true" + {% endif %} + {% else %} + goals="{{ goals|json_encode|e('html_attr') }}" {% endif %} - <a id='bottom'></a> + {% if addNewGoalIntro is defined %}add-new-goal-intro="{{ addNewGoalIntro|json_encode|e('html_attr') }}"{% endif %} + goal-trigger-type-options="{{ goalTriggerTypeOptions|json_encode|e('html_attr') }}" + goal-match-attribute-options="{{ goalMatchAttributeOptions|json_encode|e('html_attr') }}" + event-type-options="{{ eventTypeOptions|json_encode|e('html_attr') }}" + pattern-type-options="{{ patternTypeOptions|json_encode|e('html_attr') }}" + numeric-comparison-type-options="{{ numericComparisonTypeOptions|json_encode|e('html_attr') }}" + allow-multiple-options="{{ allowMultipleOptions|json_encode|e('html_attr') }}" + before-goal-list-actions-body="{{ beforeGoalListActionsBodyEventResult|default(null)|json_encode|e('html_attr') }}" + end-edit-table="{{ endEditTable|default(null)|json_encode|e('html_attr') }}" + before-goal-list-actions-head="{{ beforeGoalListActionsHead|default(null)|json_encode|e('html_attr') }}" +> </div> diff --git a/plugins/Goals/templates/_formAddGoal.twig b/plugins/Goals/templates/_formAddGoal.twig deleted file mode 100644 index 174a98ce1e..0000000000 --- a/plugins/Goals/templates/_formAddGoal.twig +++ /dev/null @@ -1,183 +0,0 @@ -<div piwik-content-block - content-title="{{ 'Goals_AddNewGoal'|translate|e('html_attr') }}" - class="addEditGoal" - ng-show="manageGoals.showEditGoal"> - - {% if addNewGoalIntro is defined and addNewGoalIntro %} - {{ addNewGoalIntro|raw }} - {% endif %} - - <div piwik-form> - <div piwik-field uicontrol="text" name="goal_name" - ng-model="manageGoals.goal.name" - maxlength="50" - data-title="{{ 'Goals_GoalName'|translate|e('html_attr') }}"> - </div> - - <div piwik-field uicontrol="text" name="goal_description" - ng-model="manageGoals.goal.description" - maxlength="255" - data-title="{{ 'General_Description'|translate|e('html_attr') }}"> - </div> - - <div class="row goalIsTriggeredWhen"> - <div class="col s12"> - <h3>{{ 'Goals_GoalIsTriggered'|translate|e('html_attr') }}</h3> - </div> - </div> - - <div class="row"> - <div class="col s12 m6 goalTriggerType"> - <div piwik-field uicontrol="select" name="trigger_type" - ng-model="manageGoals.goal.triggerType" - ng-change="manageGoals.changedTriggerType()" - full-width="true" - options="{{ goalTriggerTypeOptions|json_encode }}"> - </div> - </div> - <div class="col s12 m6"> - <div piwik-alert="info" ng-show="manageGoals.goal.triggerType == 'manually'"> - {{ 'Goals_WhereVisitedPageManuallyCallsJavascriptTrackerLearnMore'|translate("<a target='_blank' rel='noreferrer noopener' href='https://developer.matomo.org/guides/tracking-javascript-guide#manually-trigger-goal-conversions'>","</a>")|raw }} - </div> - - <div piwik-field uicontrol="radio" name="match_attribute" - ng-show="manageGoals.goal.triggerType != 'manually'" - full-width="true" - ng-model="manageGoals.goal.matchAttribute" - ng-change="manageGoals.initPatternType()" - options="{{ goalMatchAttributeOptions|json_encode }}"> - </div> - </div> - </div> - - <div class="row whereTheMatchAttrbiute" ng-show="manageGoals.goal.triggerType != 'manually'"> - <h3 class="col s12">{{ 'Goals_WhereThe'|translate|e('html_attr') }} - <span ng-show="manageGoals.goal.matchAttribute == 'url'"> - {{ 'Goals_URL'|translate }} - </span> - <span ng-show="manageGoals.goal.matchAttribute == 'title'"> - {{ 'Goals_PageTitle'|translate }} - </span> - <span ng-show="manageGoals.goal.matchAttribute == 'file'"> - {{ 'Goals_Filename'|translate }} - </span> - <span ng-show="manageGoals.goal.matchAttribute == 'external_website'"> - {{ 'Goals_ExternalWebsiteUrl'|translate }} - </span> - <span ng-show="manageGoals.goal.matchAttribute == 'visit_duration'"> - {{ 'Goals_VisitDuration'|translate }} - </span> - </h3> - </div> - - <div class="row" ng-show="manageGoals.goal.triggerType != 'manually'"> - <div class="col s12 m6 l4" - ng-show="manageGoals.goal.matchAttribute == 'event'"> - <div piwik-field uicontrol="select" name="event_type" - ng-model="manageGoals.goal.eventType" - full-width="true" - options="{{ eventTypeOptions|json_encode }}"> - </div> - </div> - - <div class="col s12 m6 l4" ng-if="!manageGoals.isMatchAttributeNumeric()"> - <div piwik-field uicontrol="select" name="pattern_type" - ng-model="manageGoals.goal.patternType" - full-width="true" - options="{{ patternTypeOptions|json_encode }}"> - </div> - </div> - - <div class="col s12 m6 l4" ng-if="manageGoals.isMatchAttributeNumeric()"> - <div piwik-field uicontrol="select" name="pattern_type" - ng-model="manageGoals.goal.patternType" - full-width="true" - options="{{ numericComparisonTypeOptions|json_encode }}"> - </div> - </div> - - <div class="col s12 m6 l4"> - <div piwik-field uicontrol="text" name="pattern" - ng-model="manageGoals.goal.pattern" - maxlength="255" - data-title="{{ "{{ manageGoals.getPatternFieldLabel() }}"|raw }}" - full-width="true"> - </div> - </div> - - <div id="examples_pattern" class="col s12" piwik-alert="info"> - <span ng-show="manageGoals.goal.matchAttribute == 'url'"> - {{ 'General_ForExampleShort'|translate }} {{ 'Goals_Contains'|translate("'checkout/confirmation'") }} - <br />{{ 'General_ForExampleShort'|translate }} {{ 'Goals_IsExactly'|translate("'http://example.com/thank-you.html'") }} - <br />{{ 'General_ForExampleShort'|translate }} {{ 'Goals_MatchesExpression'|translate("'(.*)\\\/demo\\\/(.*)'") }} - </span> - <span ng-show="manageGoals.goal.matchAttribute == 'title'"> - {{ 'General_ForExampleShort'|translate }} {{ 'Goals_Contains'|translate("'Order confirmation'") }} - </span> - <span ng-show="manageGoals.goal.matchAttribute == 'file'"> - {{ 'General_ForExampleShort'|translate }} {{ 'Goals_Contains'|translate("'files/brochure.pdf'") }} - <br />{{ 'General_ForExampleShort'|translate }} {{ 'Goals_IsExactly'|translate("'http://example.com/files/brochure.pdf'") }} - <br />{{ 'General_ForExampleShort'|translate }} {{ 'Goals_MatchesExpression'|translate("'(.*)\\\.zip'") }} - </span> - <span ng-show="manageGoals.goal.matchAttribute == 'external_website'"> - {{ 'General_ForExampleShort'|translate }} {{ 'Goals_Contains'|translate("'amazon.com'") }} - <br />{{ 'General_ForExampleShort'|translate }} {{ 'Goals_IsExactly'|translate("'http://mypartner.com/landing.html'") }} - <br />{{ 'General_ForExampleShort'|translate }} {{ 'Goals_MatchesExpression'|translate("'http://www.amazon.com\\\/(.*)\\\/yourAffiliateId'") }} - </span> - <span ng-show="manageGoals.goal.matchAttribute == 'event'"> - {{ 'General_ForExampleShort'|translate }} {{ 'Goals_Contains'|translate("'video'") }} - <br />{{ 'General_ForExampleShort'|translate }} {{ 'Goals_IsExactly'|translate("'click'") }} - <br />{{ 'General_ForExampleShort'|translate }} {{ 'Goals_MatchesExpression'|translate("'(.*)_banner'") }}" - </span> - <span ng-show="manageGoals.goal.matchAttribute == 'visit_duration'"> - {{ 'General_ForExampleShort'|translate }} {{ 'Goals_AtLeastMinutes'|translate('5', '0.5') }} - </span> - </div> - </div> - - <div piwik-field uicontrol="checkbox" name="case_sensitive" - ng-model="manageGoals.goal.caseSensitive" - ng-show="manageGoals.goal.triggerType != 'manually' && !manageGoals.isMatchAttributeNumeric()" - data-title="{{ 'Goals_CaseSensitive'|translate|e('html_attr') }} {{ 'Goals_Optional'|translate|e('html_attr') }}"> - </div> - - <div piwik-field uicontrol="radio" name="allow_multiple" - ng-model="manageGoals.goal.allowMultiple" - ng-if="manageGoals.goal.matchAttribute !== 'visit_duration'" - options="{{ allowMultipleOptions|json_encode }}" - introduction="{{ 'Goals_AllowMultipleConversionsPerVisit'|translate|e('html_attr') }}" - inline-help="{{ 'Goals_HelpOneConversionPerVisit'|translate|e('html_attr') }}"> - </div> - - <h3>{{ 'Goals_GoalRevenue'|translate }} {{ 'Goals_Optional'|translate }}</h3> - - <div piwik-field uicontrol="number" name="revenue" - ng-model="manageGoals.goal.revenue" - placeholder="{{ 'Goals_DefaultRevenueLabel'|translate }}" - inline-help="{{ 'Goals_DefaultRevenueHelp'|translate|e('html_attr') }}"> - </div> - - <div piwik-field uicontrol="checkbox" name="use_event_value" - ng-model="manageGoals.goal.useEventValueAsRevenue" - data-title="{{ 'Goals_UseEventValueAsRevenue'|translate|e('html_attr') }}" - ng-show="manageGoals.goal.matchAttribute == 'event'" - inline-help="{{ 'Goals_EventValueAsRevenueHelp'|translate|e('html_attr') }} <br/><br/> {{ 'Goals_EventValueAsRevenueHelp2'|translate|e('html_attr') }}" - > - </div> - - {{ postEvent("Template.endGoalEditTable") }} - - <input type="hidden" name="goalIdUpdate" value=""/> - <div piwik-save-button - saving="manageGoals.isLoading" - onconfirm="manageGoals.save()" - ng-value="manageGoals.goal.submitText"></div> - - {% if onlyShowAddNewGoal is not defined %} - <div class='entityCancel' ng-show="manageGoals.showEditGoal" ng-click="manageGoals.showListOfReports()"> - {{ 'General_OrCancel'|translate("<a class='entityCancelLink'>","</a>")|raw }} - </div> - {% endif %} - </div> - -</div> diff --git a/plugins/Goals/templates/_listGoalEdit.twig b/plugins/Goals/templates/_listGoalEdit.twig deleted file mode 100644 index 1a30547343..0000000000 --- a/plugins/Goals/templates/_listGoalEdit.twig +++ /dev/null @@ -1,122 +0,0 @@ -<div id='entityEditContainer' feature="true" - ng-show="manageGoals.showGoalList" - piwik-content-block content-title="{{ 'Goals_ManageGoals'|translate|e('html_attr') }}" - class="managegoals"> - - <div piwik-activity-indicator loading="manageGoals.isLoading"></div> - - <div class="contentHelp"> - {{ 'Goals_LearnMoreAboutGoalTrackingDocumentation'|translate("<a target='_blank' rel='noreferrer noopener' href='https://matomo.org/docs/tracking-goals-web-analytics/'>","</a>")|raw }} - - {% if not ecommerceEnabled %} - <br /><br/> - {% set websiteManageText %} - <a href='{{ linkTo({'module':'SitesManager','action':'index' }) }}'>{{ 'SitesManager_WebsitesManagement'|translate }}</a> - {% endset %} - {% set ecommerceReportText %} - <a href="https://matomo.org/docs/ecommerce-analytics/" rel="noreferrer noopener" target="_blank">{{ 'Goals_EcommerceReports'|translate }}</a> - {% endset %} - {{ 'Goals_Optional'|translate }} {{ 'Goals_Ecommerce'|translate }}: {{ 'Goals_YouCanEnableEcommerceReports'|translate(ecommerceReportText,websiteManageText)|raw }} - {% endif %} - </div> - - <table piwik-content-table> - <thead> - <tr> - <th class="first">Id</th> - <th>{{ 'Goals_GoalName'|translate }}</th> - <th>{{ 'General_Description'|translate }}</th> - <th>{{ 'Goals_GoalIsTriggeredWhen'|translate }}</th> - <th>{{ 'General_ColumnRevenue'|translate }}</th> - {{ postEvent("Template.beforeGoalListActionsHead") }} - {% if userCanEditGoals %} - <th>{{ 'General_Edit'|translate }}</th> - <th>{{ 'General_Delete'|translate }}</th> - {% endif %} - </tr> - </thead> - {% if goals is empty %} - <tr> - <td colspan='8'> - <br/> - {{ 'Goals_ThereIsNoGoalToManage'|translate(siteName)|rawSafeDecoded }}. - <br/><br/> - </td> - </tr> - {% else %} - {% for goal in goals %} - <tr id="{{ goal.idgoal }}"> - <td class="first">{{ goal.idgoal }}</td> - <td>{{ goal.name }}</td> - <td>{{ goal.description }}</td> - <td> - <span class='matchAttribute'>{{ goal.match_attribute }}</span> - {% if goal.match_attribute == 'visit_duration' %} - {{ 'General_OperationGreaterThan'|translate|lcfirst }} {{ 'Intl_NMinutes'|translate(goal.pattern) }} - {% else %} - {% if goal.pattern_type is defined %} - <br/> - {{ 'Goals_Pattern'|translate }} {{ goal.pattern_type }}: {{ goal.pattern }} - {% endif %} - {% endif %} - </td> - <td class="center"> - {% if goal.revenue==0 %}-{% else %}{{ goal.revenue|money(idSite)|raw }}{% endif %} - </td> - {{ postEvent("Template.beforeGoalListActionsBody", goal) }} - {% if userCanEditGoals %} - <td style="padding-top:2px"> - <button ng-click="manageGoals.editGoal({{ goal.idgoal }})" class="table-action" title="{{ 'General_Edit'|translate }}"> - <span class="icon-edit"></span> - </button> - </td> - <td style="padding-top:2px"> - <button ng-click="manageGoals.deleteGoal({{ goal.idgoal }})" class="table-action" title="{{ 'General_Delete'|translate }}"> - <span class="icon-delete"></span> - </button> - </td> - {% endif %} - </tr> - {% endfor %} - {% endif %} - </table> - - {% if userCanEditGoals and onlyShowAddNewGoal is not defined %} - <div class="tableActionBar"> - <button id="add-goal" ng-click="manageGoals.createGoal()"> - <span class="icon-add"></span> - {{ 'Goals_AddNewGoal'|translate }} - </button> - </div> - {% endif %} - -</div> - -<div class="ui-confirm" id="confirm"> - <h2></h2> - <input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/> - <input role="no" type="button" value="{{ 'General_No'|translate }}"/> -</div> - -<script type="text/javascript"> - var goalTypeToTranslation = { - "manually": "{{ 'Goals_ManuallyTriggeredUsingJavascriptFunction'|translate }}", - "file": "{{ 'Goals_Download'|translate }}", - "url": "{{ 'Goals_VisitUrl'|translate }}", - "title": "{{ 'Goals_VisitPageTitle'|translate }}", - "external_website": "{{ 'Goals_ClickOutlink'|translate }}", - "event_action": "{{ 'Goals_SendEvent'|translate }} ({{ 'Events_EventAction'|translate }})", - "event_category": "{{ 'Goals_SendEvent'|translate }} ({{ 'Events_EventCategory'|translate }})", - "event_name": "{{ 'Goals_SendEvent'|translate }} ({{ 'Events_EventName'|translate }})", - "visit_duration": "{{ 'Goals_VisitDuration'|translate|ucfirst }}" - }; - - $(document).ready(function () { - // translation of the goal "match attribute" to human readable description - $('.matchAttribute').each(function () { - var matchAttribute = $(this).text(); - var translation = goalTypeToTranslation[matchAttribute]; - $(this).text(translation); - }); - }); -</script> diff --git a/plugins/Goals/vue/dist/Goals.umd.js b/plugins/Goals/vue/dist/Goals.umd.js index b12794fad0..c87161e4da 100644 --- a/plugins/Goals/vue/dist/Goals.umd.js +++ b/plugins/Goals/vue/dist/Goals.umd.js @@ -1,13 +1,13 @@ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("CoreHome")); + module.exports = factory(require("CoreHome"), require("vue"), require("CorePluginsAdmin")); else if(typeof define === 'function' && define.amd) - define(["CoreHome"], factory); + define(["CoreHome", , "CorePluginsAdmin"], factory); else if(typeof exports === 'object') - exports["Goals"] = factory(require("CoreHome")); + exports["Goals"] = factory(require("CoreHome"), require("vue"), require("CorePluginsAdmin")); else - root["Goals"] = factory(root["CoreHome"]); -})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__19dc__) { + root["Goals"] = factory(root["CoreHome"], root["Vue"], root["CorePluginsAdmin"]); +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__19dc__, __WEBPACK_EXTERNAL_MODULE__8bbf__, __WEBPACK_EXTERNAL_MODULE_a5a2__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -103,6 +103,20 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__19dc__; /***/ }), +/***/ "8bbf": +/***/ (function(module, exports) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__8bbf__; + +/***/ }), + +/***/ "a5a2": +/***/ (function(module, exports) { + +module.exports = __WEBPACK_EXTERNAL_MODULE_a5a2__; + +/***/ }), + /***/ "fae3": /***/ (function(module, __webpack_exports__, __webpack_require__) { @@ -112,6 +126,7 @@ __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, "GoalPageLink", function() { return /* reexport */ GoalPageLink_GoalPageLink; }); +__webpack_require__.d(__webpack_exports__, "ManageGoals", function() { return /* reexport */ ManageGoals; }); // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js // This file is imported into lib/wc client bundles. @@ -141,7 +156,7 @@ var external_CoreHome_ = __webpack_require__("19dc"); */ var _window = window, - $ = _window.$; // usage v-goal-page-link="{ idGoal: 5 }" + GoalPageLink_$ = _window.$; // usage v-goal-page-link="{ idGoal: 5 }" var GoalPageLink = { mounted: function mounted(el, binding) { @@ -149,8 +164,8 @@ var GoalPageLink = { return; } - var title = $(el).text(); - var link = $('<a></a>'); + var title = GoalPageLink_$(el).text(); + var link = GoalPageLink_$('<a></a>'); link.text(title); link.attr('title', Object(external_CoreHome_["translate"])('Goals_ClickToViewThisGoal')); link.click(function (e) { @@ -160,7 +175,7 @@ var GoalPageLink = { subcategory: binding.value.idGoal })); }); - $(el).html(link[0]); + GoalPageLink_$(el).html(link[0]); } }; /* harmony default export */ var GoalPageLink_GoalPageLink = (GoalPageLink); // manually handle occurrence of goal-page-link on datatable html attributes since dataTable.js is @@ -169,11 +184,11 @@ var GoalPageLink = { external_CoreHome_["Matomo"].on('Matomo.processDynamicHtml', function ($element) { $element.find('[goal-page-link]').each(function (i, e) { - if ($(e).attr('goal-page-link-handled')) { + if (GoalPageLink_$(e).attr('goal-page-link-handled')) { return; } - var idGoal = $(e).attr('goal-page-link'); + var idGoal = GoalPageLink_$(e).attr('goal-page-link'); if (idGoal) { GoalPageLink.mounted(e, { @@ -187,7 +202,7 @@ external_CoreHome_["Matomo"].on('Matomo.processDynamicHtml', function ($element) }); } - $(e).attr('goal-page-link-handled', '1'); + GoalPageLink_$(e).attr('goal-page-link-handled', '1'); }); }); // CONCATENATED MODULE: ./plugins/Goals/vue/src/GoalPageLink/GoalPageLink.adapter.ts @@ -216,7 +231,837 @@ function piwikGoalPageLink() { }; } window.angular.module('piwikApp').directive('piwikGoalPageLink', piwikGoalPageLink); -// CONCATENATED MODULE: ./plugins/Goals/vue/src/index.ts +// EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"} +var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__("8bbf"); + +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/Goals/vue/src/ManageGoals/ManageGoals.vue?vue&type=template&id=065a1b7c + +var _hoisted_1 = { + id: "entityEditContainer", + feature: "true", + class: "managegoals" +}; +var _hoisted_2 = { + class: "contentHelp" +}; +var _hoisted_3 = ["innerHTML"]; +var _hoisted_4 = { + key: 0 +}; + +var _hoisted_5 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_6 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_7 = ["innerHTML"]; +var _hoisted_8 = { + class: "first" +}; +var _hoisted_9 = { + key: 1 +}; +var _hoisted_10 = { + key: 2 +}; +var _hoisted_11 = { + key: 0 +}; +var _hoisted_12 = { + colspan: "8" +}; + +var _hoisted_13 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_14 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_15 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_16 = ["id"]; +var _hoisted_17 = { + class: "first" +}; +var _hoisted_18 = { + class: "matchAttribute" +}; +var _hoisted_19 = { + key: 0 +}; +var _hoisted_20 = { + key: 1 +}; + +var _hoisted_21 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_22 = ["innerHTML"]; +var _hoisted_23 = { + key: 1, + style: { + "padding-top": "2px" + } +}; +var _hoisted_24 = ["onClick", "title"]; + +var _hoisted_25 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + class: "icon-edit" +}, null, -1); + +var _hoisted_26 = [_hoisted_25]; +var _hoisted_27 = { + key: 2, + style: { + "padding-top": "2px" + } +}; +var _hoisted_28 = ["onClick", "title"]; + +var _hoisted_29 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + class: "icon-delete" +}, null, -1); + +var _hoisted_30 = [_hoisted_29]; +var _hoisted_31 = { + key: 0, + class: "tableActionBar" +}; + +var _hoisted_32 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + class: "icon-add" +}, null, -1); + +var _hoisted_33 = { + class: "ui-confirm", + ref: "confirm" +}; +var _hoisted_34 = ["value"]; +var _hoisted_35 = ["value"]; +var _hoisted_36 = { + class: "addEditGoal" +}; +var _hoisted_37 = ["innerHTML"]; +var _hoisted_38 = { + class: "row goalIsTriggeredWhen" +}; +var _hoisted_39 = { + class: "col s12" +}; +var _hoisted_40 = { + class: "row" +}; +var _hoisted_41 = { + class: "col s12 m6 goalTriggerType" +}; +var _hoisted_42 = { + class: "col s12 m6" +}; +var _hoisted_43 = ["innerHTML"]; +var _hoisted_44 = { + class: "row whereTheMatchAttrbiute" +}; +var _hoisted_45 = { + class: "col s12" +}; +var _hoisted_46 = { + class: "row" +}; +var _hoisted_47 = { + class: "col s12 m6 l4" +}; +var _hoisted_48 = { + key: 0, + class: "col s12 m6 l4" +}; +var _hoisted_49 = { + key: 1, + class: "col s12 m6 l4" +}; +var _hoisted_50 = { + class: "col s12 m6 l4" +}; +var _hoisted_51 = { + id: "examples_pattern", + class: "col s12" +}; + +var _hoisted_52 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_53 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_54 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_55 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_56 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_57 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_58 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_59 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_60 = { + ref: "endedittable" +}; + +var _hoisted_61 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { + type: "hidden", + name: "goalIdUpdate", + value: "" +}, null, -1); + +var _hoisted_62 = { + key: 0 +}; +var _hoisted_63 = ["innerHTML"]; + +var _hoisted_64 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("a", { + id: "bottom" +}, null, -1); + +function render(_ctx, _cache, $props, $setup, $data, $options) { + var _ctx$goalToDelete; + + var _component_ActivityIndicator = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("ActivityIndicator"); + + var _component_ContentBlock = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("ContentBlock"); + + var _component_Field = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("Field"); + + var _component_Alert = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("Alert"); + + var _component_SaveButton = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("SaveButton"); + + var _directive_content_table = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("content-table"); + + var _directive_form = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("form"); + + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_ContentBlock, { + "content-title": _ctx.translate('Goals_ManageGoals') + }, { + default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_ActivityIndicator, { + loading: _ctx.isLoading + }, null, 8, ["loading"]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_2, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + innerHTML: _ctx.learnMoreAboutGoalTracking + }, null, 8, _hoisted_3), !_ctx.ecommerceEnabled ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", _hoisted_4, [_hoisted_5, _hoisted_6, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_Optional')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_Ecommerce')) + ": ", 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + innerHTML: _ctx.youCanEnableEcommerceReports + }, null, 8, _hoisted_7)])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("table", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("thead", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("tr", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", _hoisted_8, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Id')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_GoalName')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Description')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_GoalIsTriggeredWhen')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ColumnRevenue')), 1), _ctx.beforeGoalListActionsHeadComponent ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDynamicComponent"])(_ctx.beforeGoalListActionsHeadComponent), { + key: 0 + })) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), _ctx.userCanEditGoals ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("th", _hoisted_9, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Edit')), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), _ctx.userCanEditGoals ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("th", _hoisted_10, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Delete')), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("tbody", null, [!Object.keys(_ctx.goals || {}).length ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("tr", _hoisted_11, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", _hoisted_12, [_hoisted_13, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_ThereIsNoGoalToManage', _ctx.siteName)) + " ", 1), _hoisted_14, _hoisted_15])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.goals || [], function (goal) { + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("tr", { + id: goal.idgoal, + key: goal.idgoal + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", _hoisted_17, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(goal.idgoal), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(goal.name), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(goal.description), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", _hoisted_18, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.goalMatchAttributeTranslations[goal.match_attribute] || goal.match_attribute), 1), goal.match_attribute === 'visit_duration' ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", _hoisted_19, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.lcfirst(_ctx.translate('General_OperationGreaterThan'))) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Intl_NMinutes', goal.pattern)), 1)) : !!goal.pattern_type ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", _hoisted_20, [_hoisted_21, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_Pattern')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(goal.pattern_type) + ": " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(goal.pattern), 1)])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", { + class: "center", + innerHTML: goal.revenue === 0 || goal.revenue === '0' ? '-' : _ctx.$sanitize(goal.revenue_pretty) + }, null, 8, _hoisted_22), _ctx.beforeGoalListActionsBodyComponent[goal.idgoal] ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDynamicComponent"])(_ctx.beforeGoalListActionsBodyComponent[goal.idgoal]), { + key: 0 + })) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), _ctx.userCanEditGoals ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("td", _hoisted_23, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("button", { + onClick: function onClick($event) { + return _ctx.editGoal(goal.idgoal); + }, + class: "table-action", + title: _ctx.translate('General_Edit') + }, _hoisted_26, 8, _hoisted_24)])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), _ctx.userCanEditGoals ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("td", _hoisted_27, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("button", { + onClick: function onClick($event) { + return _ctx.deleteGoal(goal.idgoal); + }, + class: "table-action", + title: _ctx.translate('General_Delete') + }, _hoisted_30, 8, _hoisted_28)])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)], 8, _hoisted_16); + }), 128))])], 512), [[_directive_content_table]]), _ctx.userCanEditGoals && !_ctx.onlyShowAddNewGoal ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_31, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("button", { + id: "add-goal", + onClick: _cache[0] || (_cache[0] = function ($event) { + return _ctx.createGoal(); + }) + }, [_hoisted_32, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_AddNewGoal')), 1)])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]; + }), + _: 1 + }, 8, ["content-title"])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.showGoalList]]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_33, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("h2", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_DeleteGoalConfirm', "\"".concat((_ctx$goalToDelete = _ctx.goalToDelete) === null || _ctx$goalToDelete === void 0 ? void 0 : _ctx$goalToDelete.name, "\""))), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { + role: "yes", + type: "button", + value: _ctx.translate('General_Yes') + }, null, 8, _hoisted_34), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { + role: "no", + type: "button", + value: _ctx.translate('General_No') + }, null, 8, _hoisted_35)], 512)], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.onlyShowAddNewGoal]]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_36, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_ContentBlock, { + "content-title": _ctx.goal.idgoal ? _ctx.translate('Goals_UpdateGoal') : _ctx.translate('Goals_AddNewGoal') + }, { + default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", { + innerHTML: _ctx.$sanitize(_ctx.addNewGoalIntro) + }, null, 8, _hoisted_37), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "text", + name: "goal_name", + modelValue: _ctx.goal.name, + "onUpdate:modelValue": _cache[1] || (_cache[1] = function ($event) { + return _ctx.goal.name = $event; + }), + maxlength: 50, + title: _ctx.translate('Goals_GoalName') + }, null, 8, ["modelValue", "title"])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "text", + name: "goal_description", + modelValue: _ctx.goal.description, + "onUpdate:modelValue": _cache[2] || (_cache[2] = function ($event) { + return _ctx.goal.description = $event; + }), + maxlength: 255, + title: _ctx.translate('General_Description') + }, null, 8, ["modelValue", "title"])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_38, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_39, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("h3", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_GoalIsTriggered')), 1)])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_40, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_41, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "trigger_type", + "model-value": _ctx.triggerType, + "onUpdate:modelValue": _cache[3] || (_cache[3] = function ($event) { + _ctx.triggerType = $event; + + _ctx.changedTriggerType(); + }), + "full-width": true, + options: _ctx.goalTriggerTypeOptions + }, null, 8, ["model-value", "options"])])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_42, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Alert, { + severity: "info" + }, { + default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + innerHTML: _ctx.whereVisitedPageManuallyCallsJsTrackerText + }, null, 8, _hoisted_43)]; + }), + _: 1 + }, 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.triggerType === 'manually']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "radio", + name: "match_attribute", + "full-width": true, + "model-value": _ctx.goal.match_attribute, + "onUpdate:modelValue": _cache[4] || (_cache[4] = function ($event) { + _ctx.goal.match_attribute = $event; + + _ctx.initPatternType(); + }), + options: _ctx.goalMatchAttributeOptions + }, null, 8, ["model-value", "options"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.triggerType !== 'manually']])])])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_44, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("h3", _hoisted_45, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_WhereThe')) + " ", 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_URL')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'url']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_PageTitle')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'title']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_Filename')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'file']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_ExternalWebsiteUrl')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'external_website']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_VisitDuration')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'visit_duration']])])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.triggerType !== 'manually']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_46, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_47, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "event_type", + modelValue: _ctx.eventType, + "onUpdate:modelValue": _cache[5] || (_cache[5] = function ($event) { + return _ctx.eventType = $event; + }), + "full-width": true, + options: _ctx.eventTypeOptions + }, null, 8, ["modelValue", "options"])])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'event']]), !_ctx.isMatchAttributeNumeric ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_48, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "pattern_type", + modelValue: _ctx.goal.pattern_type, + "onUpdate:modelValue": _cache[6] || (_cache[6] = function ($event) { + return _ctx.goal.pattern_type = $event; + }), + "full-width": true, + options: _ctx.patternTypeOptions + }, null, 8, ["modelValue", "options"])])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), _ctx.isMatchAttributeNumeric ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_49, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "pattern_type", + modelValue: _ctx.goal.pattern_type, + "onUpdate:modelValue": _cache[7] || (_cache[7] = function ($event) { + return _ctx.goal.pattern_type = $event; + }), + "full-width": true, + options: _ctx.numericComparisonTypeOptions + }, null, 8, ["modelValue", "options"])])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_50, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "text", + name: "pattern", + modelValue: _ctx.goal.pattern, + "onUpdate:modelValue": _cache[8] || (_cache[8] = function ($event) { + return _ctx.goal.pattern = $event; + }), + maxlength: 255, + title: _ctx.patternFieldLabel, + "full-width": true + }, null, 8, ["modelValue", "title"])])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_51, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Alert, { + severity: "info" + }, { + default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_Contains', "'checkout/confirmation'")) + " ", 1), _hoisted_52, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_IsExactly', "'http://example.com/thank-you.html'")) + " ", 1), _hoisted_53, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_MatchesExpression', "'(.*)\\\/demo\\\/(.*)'")), 1)], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'url']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_Contains', "'Order confirmation'")), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'title']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_Contains', "'files/brochure.pdf'")) + " ", 1), _hoisted_54, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_IsExactly', "'http://example.com/files/brochure.pdf'")) + " ", 1), _hoisted_55, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_MatchesExpression', "'(.*)\\\.zip'")), 1)], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'file']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_Contains', "'amazon.com'")) + " ", 1), _hoisted_56, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_IsExactly', "'http://mypartner.com/landing.html'")) + " ", 1), _hoisted_57, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.matchesExpressionExternal), 1)], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'external_website']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_Contains', "'video'")) + " ", 1), _hoisted_58, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_IsExactly', "'click'")) + " ", 1), _hoisted_59, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_MatchesExpression', "'(.*)_banner'")) + "\" ", 1)], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'event']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_ForExampleShort')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_AtLeastMinutes', '5', '0.5')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'visit_duration']])]; + }), + _: 1 + })])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.triggerType !== 'manually']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "checkbox", + name: "case_sensitive", + modelValue: _ctx.goal.case_sensitive, + "onUpdate:modelValue": _cache[9] || (_cache[9] = function ($event) { + return _ctx.goal.case_sensitive = $event; + }), + title: _ctx.caseSensitiveTitle + }, null, 8, ["modelValue", "title"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.triggerType !== 'manually' && !_ctx.isMatchAttributeNumeric]])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [_ctx.goal.match_attribute !== 'visit_duration' ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(_component_Field, { + key: 0, + uicontrol: "radio", + name: "allow_multiple", + "model-value": _ctx.goal.allow_multiple ? 1 : 0, + "onUpdate:modelValue": _cache[10] || (_cache[10] = function ($event) { + return _ctx.goal.allow_multiple = $event; + }), + options: _ctx.allowMultipleOptions, + introduction: _ctx.translate('Goals_AllowMultipleConversionsPerVisit'), + "inline-help": _ctx.translate('Goals_HelpOneConversionPerVisit') + }, null, 8, ["model-value", "options", "introduction", "inline-help"])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("h3", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_GoalRevenue')) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Goals_Optional')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "number", + name: "revenue", + modelValue: _ctx.goal.revenue, + "onUpdate:modelValue": _cache[11] || (_cache[11] = function ($event) { + return _ctx.goal.revenue = $event; + }), + placeholder: _ctx.translate('Goals_DefaultRevenueLabel'), + "inline-help": _ctx.translate('Goals_DefaultRevenueHelp') + }, null, 8, ["modelValue", "placeholder", "inline-help"])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "checkbox", + name: "use_event_value", + modelValue: _ctx.goal.event_value_as_revenue, + "onUpdate:modelValue": _cache[12] || (_cache[12] = function ($event) { + return _ctx.goal.event_value_as_revenue = $event; + }), + title: _ctx.translate('Goals_UseEventValueAsRevenue'), + "inline-help": _ctx.useEventValueAsRevenueHelp + }, null, 8, ["modelValue", "title", "inline-help"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.goal.match_attribute === 'event']])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_60, [_ctx.endEditTableComponent ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDynamicComponent"])(_ctx.endEditTableComponent), { + key: 0 + })) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)], 512), _hoisted_61, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_SaveButton, { + saving: _ctx.isLoading, + onConfirm: _cache[13] || (_cache[13] = function ($event) { + return _ctx.save(); + }), + value: _ctx.submitText + }, null, 8, ["saving", "value"]), !_ctx.onlyShowAddNewGoal ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_62, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", { + class: "entityCancel", + onClick: _cache[14] || (_cache[14] = function ($event) { + return _ctx.showListOfReports(); + }), + innerHTML: _ctx.cancelText + }, null, 8, _hoisted_63), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.showEditGoal]])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)], 512), [[_directive_form]])]; + }), + _: 1 + }, 8, ["content-title"])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.showEditGoal]])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.userCanEditGoals]]), _hoisted_64]); +} +// CONCATENATED MODULE: ./plugins/Goals/vue/src/ManageGoals/ManageGoals.vue?vue&type=template&id=065a1b7c + +// EXTERNAL MODULE: external "CorePluginsAdmin" +var external_CorePluginsAdmin_ = __webpack_require__("a5a2"); + +// CONCATENATED MODULE: ./plugins/Goals/vue/src/ManageGoals/PiwikApiMock.ts +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/*! +* Matomo - free/libre analytics platform +* +* @link https://matomo.org +* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +*/ +// the piwikApi angularjs service is passed in some frontend events to allow plugins to modify +// a request before it is sent. for the time being in Vue we use this mock, which has the same +// API as the piwikApi service, to modify the input used with AjaxHelper. this provides BC +// with for plugins that haven't been converted. +// +// should be removed in Matomo 5. +var PiwikApiMock = /*#__PURE__*/function () { + function PiwikApiMock(parameters, options) { + _classCallCheck(this, PiwikApiMock); + + _defineProperty(this, "parameters", void 0); + + _defineProperty(this, "options", void 0); + + this.parameters = parameters; + this.options = options; + } + + _createClass(PiwikApiMock, [{ + key: "addParams", + value: function addParams(params) { + Object.assign(this.parameters, params); + } + }, { + key: "withTokenInUrl", + value: function withTokenInUrl() { + this.options.withTokenInUrl = true; + } + }, { + key: "reset", + value: function reset() { + var _this = this; + + Object.keys(this.parameters).forEach(function (name) { + delete _this.parameters[name]; + }); + delete this.options.postParams; + } + }, { + key: "addPostParams", + value: function addPostParams(params) { + this.options.postParams = Object.assign(Object.assign({}, this.options.postParams), params); + } + }]); + + return PiwikApiMock; +}(); + + +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/Goals/vue/src/ManageGoals/ManageGoals.vue?vue&type=script&lang=ts + + + + +/* harmony default export */ var ManageGoalsvue_type_script_lang_ts = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ + inheritAttrs: false, + props: { + onlyShowAddNewGoal: Boolean, + userCanEditGoals: Boolean, + ecommerceEnabled: Boolean, + goals: { + type: Object, + required: true + }, + addNewGoalIntro: String, + goalTriggerTypeOptions: Object, + goalMatchAttributeOptions: Array, + eventTypeOptions: Array, + patternTypeOptions: Array, + numericComparisonTypeOptions: Array, + allowMultipleOptions: Array, + showAddGoal: Boolean, + showGoal: Number, + beforeGoalListActionsBody: Object, + endEditTable: String, + beforeGoalListActionsHead: String + }, + data: function data() { + return { + showEditGoal: false, + showGoalList: true, + goal: {}, + isLoading: false, + eventType: 'event_category', + triggerType: 'visitors', + apiMethod: '', + submitText: '', + goalToDelete: null, + addEditTableComponent: false + }; + }, + components: { + SaveButton: external_CorePluginsAdmin_["SaveButton"], + ContentBlock: external_CoreHome_["ContentBlock"], + ActivityIndicator: external_CoreHome_["ActivityIndicator"], + Field: external_CorePluginsAdmin_["Field"], + Alert: external_CoreHome_["Alert"] + }, + directives: { + ContentTable: external_CoreHome_["ContentTable"], + Form: external_CorePluginsAdmin_["Form"] + }, + mounted: function mounted() { + var _this = this; + + if (this.showAddGoal) { + this.createGoal(); + } else if (this.showGoal) { + this.editGoal(this.showGoal); + } + + this.showListOfReports(); // this component can be used in multiple places, one where + // Matomo.helper.compileAngularComponents() is already called, one where it's not. + // to make sure this function is only applied once to the slot data, we explicitly do not + // add it to vue, then on the next update, add it and call compileAngularComponents() + + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["nextTick"])(function () { + _this.addEditTableComponent = true; + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["nextTick"])(function () { + var el = _this.$refs.endedittable; + var scope = external_CoreHome_["Matomo"].helper.getAngularDependency('$rootScope').$new(true); + $(el).data('scope', scope); + external_CoreHome_["Matomo"].helper.compileAngularComponents(el, { + scope: scope + }); + }); + }); + }, + beforeUnmount: function beforeUnmount() { + var el = this.$refs.endedittable; + $(el).data('scope').$destroy(); + }, + methods: { + scrollToTop: function scrollToTop() { + setTimeout(function () { + external_CoreHome_["Matomo"].helper.lazyScrollTo('.pageWrap', 200); + }); + }, + initGoalForm: function initGoalForm(goalMethodAPI, submitText, goalName, description, matchAttribute, pattern, patternType, caseSensitive, revenue, allowMultiple, useEventValueAsRevenue, goalId) { + external_CoreHome_["Matomo"].postEvent('Goals.beforeInitGoalForm', goalMethodAPI, goalId); + this.apiMethod = goalMethodAPI; + this.goal = {}; + this.goal.name = goalName; + this.goal.description = description; + var actualMatchAttribute = matchAttribute; + + if (actualMatchAttribute === 'manually') { + this.triggerType = 'manually'; + actualMatchAttribute = 'url'; + } else { + this.triggerType = 'visitors'; + } + + if (actualMatchAttribute.indexOf('event') === 0) { + this.eventType = actualMatchAttribute; + actualMatchAttribute = 'event'; + } else { + this.eventType = 'event_category'; + } + + this.goal.match_attribute = actualMatchAttribute; + this.goal.allow_multiple = allowMultiple; + this.goal.pattern_type = patternType; + this.goal.pattern = pattern; + this.goal.case_sensitive = caseSensitive; + this.goal.revenue = revenue; + this.goal.event_value_as_revenue = useEventValueAsRevenue; + this.submitText = submitText; + this.goal.idgoal = goalId; + }, + showListOfReports: function showListOfReports() { + external_CoreHome_["Matomo"].postEvent('Goals.cancelForm'); + this.showGoalList = true; + this.showEditGoal = false; + this.scrollToTop(); + }, + showAddEditForm: function showAddEditForm() { + this.showGoalList = false; + this.showEditGoal = true; + }, + createGoal: function createGoal() { + var parameters = { + isAllowed: true + }; + external_CoreHome_["Matomo"].postEvent('Goals.initAddGoal', parameters); + + if (parameters && !parameters.isAllowed) { + return; + } + + this.showAddEditForm(); + this.initGoalForm('Goals.addGoal', Object(external_CoreHome_["translate"])('Goals_AddGoal'), '', '', 'url', '', 'contains', false, 0, false, false, 0); + this.scrollToTop(); + }, + editGoal: function editGoal(goalId) { + this.showAddEditForm(); + var goal = this.goals["".concat(goalId)]; + this.initGoalForm('Goals.updateGoal', Object(external_CoreHome_["translate"])('Goals_UpdateGoal'), goal.name, goal.description, goal.match_attribute, goal.pattern, goal.pattern_type, !!goal.case_sensitive && goal.case_sensitive !== '0', parseInt("".concat(goal.revenue), 10), !!goal.allow_multiple && goal.allow_multiple !== '0', !!goal.event_value_as_revenue && goal.event_value_as_revenue !== '0', goalId); + this.scrollToTop(); + }, + deleteGoal: function deleteGoal(goalId) { + var _this2 = this; + + this.goalToDelete = this.goals["".concat(goalId)]; + external_CoreHome_["Matomo"].helper.modalConfirm(this.$refs.confirm, { + yes: function yes() { + _this2.isLoading = true; + external_CoreHome_["AjaxHelper"].fetch({ + idGoal: goalId, + method: 'Goals.deleteGoal' + }).then(function () { + window.location.reload(); + }).finally(function () { + _this2.isLoading = false; + }); + } + }); + }, + save: function save() { + var _this3 = this; + + var parameters = {}; // TODO: test removal of encoding, should be handled by ajax request + + parameters.name = this.goal.name; + parameters.description = this.goal.description; + + if (this.isManuallyTriggered) { + parameters.matchAttribute = 'manually'; + parameters.patternType = 'regex'; + parameters.pattern = '.*'; + parameters.caseSensitive = 0; + } else { + parameters.matchAttribute = this.goal.match_attribute; + + if (parameters.matchAttribute === 'event') { + parameters.matchAttribute = this.eventType; + } + + parameters.patternType = this.goal.pattern_type; + parameters.pattern = this.goal.pattern; + parameters.caseSensitive = this.goal.case_sensitive ? 1 : 0; + } + + parameters.revenue = this.goal.revenue || 0; + parameters.allowMultipleConversionsPerVisit = this.goal.allow_multiple ? 1 : 0; + parameters.useEventValueAsRevenue = this.goal.event_value_as_revenue ? 1 : 0; + parameters.idGoal = this.goal.idgoal; + parameters.method = this.apiMethod; + var isCreate = parameters.method === 'Goals.addGoal'; + var isUpdate = parameters.method === 'Goals.updateGoal'; + var options = {}; + var piwikApiMock = new PiwikApiMock(parameters, options); + + if (isUpdate) { + external_CoreHome_["Matomo"].postEvent('Goals.beforeUpdateGoal', parameters, piwikApiMock); + } else if (isCreate) { + external_CoreHome_["Matomo"].postEvent('Goals.beforeAddGoal', parameters, piwikApiMock); + } + + if (parameters !== null && parameters !== void 0 && parameters.cancelRequest) { + return; + } + + this.isLoading = true; + external_CoreHome_["AjaxHelper"].fetch(parameters, options).then(function () { + var subcategory = external_CoreHome_["MatomoUrl"].parsed.value.subcategory; + + if (subcategory === 'Goals_AddNewGoal' && external_CoreHome_["Matomo"].helper.isAngularRenderingThePage()) { + // when adding a goal for the first time we need to load manage goals page afterwards + external_CoreHome_["ReportingMenuStore"].reloadMenuItems().then(function () { + external_CoreHome_["MatomoUrl"].updateHash(Object.assign(Object.assign({}, external_CoreHome_["MatomoUrl"].hashParsed.value), {}, { + subcategory: 'Goals_ManageGoals' + })); + _this3.isLoading = false; + }); + } else { + window.location.reload(); + } + }).catch(function () { + _this3.scrollToTop(); + + _this3.isLoading = false; + }); + }, + changedTriggerType: function changedTriggerType() { + if (!this.isManuallyTriggered && !this.goal.pattern_type) { + this.goal.pattern_type = 'contains'; + } + }, + initPatternType: function initPatternType() { + if (this.isMatchAttributeNumeric) { + this.goal.pattern_type = 'greater_than'; + } else { + this.goal.pattern_type = 'contains'; + } + }, + lcfirst: function lcfirst(s) { + return "".concat(s.substr(0, 1).toLowerCase()).concat(s.substr(1)); + }, + ucfirst: function ucfirst(s) { + return "".concat(s.substr(0, 1).toUpperCase()).concat(s.substr(1)); + } + }, + computed: { + learnMoreAboutGoalTracking: function learnMoreAboutGoalTracking() { + return Object(external_CoreHome_["translate"])('Goals_LearnMoreAboutGoalTrackingDocumentation', '<a target="_blank" rel="noreferrer noopener" ' + 'href="https://matomo.org/docs/tracking-goals-web-analytics/">', '</a>'); + }, + youCanEnableEcommerceReports: function youCanEnableEcommerceReports() { + var link = external_CoreHome_["MatomoUrl"].stringify(Object.assign(Object.assign({}, external_CoreHome_["MatomoUrl"].urlParsed.value), {}, { + module: 'SitesManager', + action: 'index' + })); + var ecommerceReportsText = '<a href="https://matomo.org/docs/ecommerce-analytics/" ' + "rel=\"noreferrer noopener\" target=\"_blank\">".concat(Object(external_CoreHome_["translate"])('Goals_EcommerceReports'), "</a>"); + var websiteManageText = "<a href='".concat(link, "'>").concat(Object(external_CoreHome_["translate"])('SitesManager_WebsitesManagement'), "</a>"); + return Object(external_CoreHome_["translate"])('Goals_YouCanEnableEcommerceReports', ecommerceReportsText, websiteManageText); + }, + siteName: function siteName() { + return external_CoreHome_["Matomo"].helper.htmlDecode(external_CoreHome_["Matomo"].siteName); + }, + whereVisitedPageManuallyCallsJsTrackerText: function whereVisitedPageManuallyCallsJsTrackerText() { + var link = 'https://developer.matomo.org/guides/tracking-javascript-guide#manually-trigger-goal-conversions'; + return Object(external_CoreHome_["translate"])('Goals_WhereVisitedPageManuallyCallsJavascriptTrackerLearnMore', "<a target=\"_blank\" rel=\"noreferrer noopener\" href=\"".concat(link, "\">"), '</a>'); + }, + caseSensitiveTitle: function caseSensitiveTitle() { + return "".concat(Object(external_CoreHome_["translate"])('Goals_CaseSensitive'), " ").concat(Object(external_CoreHome_["translate"])('Goals_Optional')); + }, + useEventValueAsRevenueHelp: function useEventValueAsRevenueHelp() { + return "".concat(Object(external_CoreHome_["translate"])('Goals_EventValueAsRevenueHelp'), " <br/><br/> ").concat(Object(external_CoreHome_["translate"])('Goals_EventValueAsRevenueHelp2')); + }, + cancelText: function cancelText() { + return Object(external_CoreHome_["translate"])('General_OrCancel', '<a class=\'entityCancelLink\'>', '</a>'); + }, + isMatchAttributeNumeric: function isMatchAttributeNumeric() { + return ['visit_duration'].indexOf(this.goal.match_attribute) > -1; + }, + patternFieldLabel: function patternFieldLabel() { + return this.goal.match_attribute === 'visit_duration' ? Object(external_CoreHome_["translate"])('Goals_TimeInMinutes') : Object(external_CoreHome_["translate"])('Goals_Pattern'); + }, + goalMatchAttributeTranslations: function goalMatchAttributeTranslations() { + return { + manually: Object(external_CoreHome_["translate"])('Goals_ManuallyTriggeredUsingJavascriptFunction'), + file: Object(external_CoreHome_["translate"])('Goals_Download'), + url: Object(external_CoreHome_["translate"])('Goals_VisitUrl'), + title: Object(external_CoreHome_["translate"])('Goals_VisitPageTitle'), + external_website: Object(external_CoreHome_["translate"])('Goals_ClickOutlink'), + event_action: "".concat(Object(external_CoreHome_["translate"])('Goals_SendEvent'), " (").concat(Object(external_CoreHome_["translate"])('Events_EventAction'), ")"), + event_category: "".concat(Object(external_CoreHome_["translate"])('Goals_SendEvent'), " (").concat(Object(external_CoreHome_["translate"])('Events_EventCategory'), ")"), + event_name: "".concat(Object(external_CoreHome_["translate"])('Goals_SendEvent'), " (").concat(Object(external_CoreHome_["translate"])('Events_EventName'), ")"), + visit_duration: "".concat(this.ucfirst(Object(external_CoreHome_["translate"])('Goals_VisitDuration'))) + }; + }, + beforeGoalListActionsBodyComponent: function beforeGoalListActionsBodyComponent() { + var _this4 = this; + + if (!this.beforeGoalListActionsBody) { + return {}; + } + + var componentsByIdGoal = {}; + Object.values(this.goals).forEach(function (g) { + componentsByIdGoal[g.idgoal] = { + template: _this4.beforeGoalListActionsBody[g.idgoal] + }; + }); + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["markRaw"])(componentsByIdGoal); + }, + endEditTableComponent: function endEditTableComponent() { + if (!this.endEditTable || !this.addEditTableComponent) { + return null; + } + + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["markRaw"])({ + template: this.endEditTable + }); + }, + beforeGoalListActionsHeadComponent: function beforeGoalListActionsHeadComponent() { + if (!this.beforeGoalListActionsHead) { + return null; + } + + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["markRaw"])({ + template: this.beforeGoalListActionsHead + }); + }, + isManuallyTriggered: function isManuallyTriggered() { + return this.triggerType === 'manually'; + }, + matchesExpressionExternal: function matchesExpressionExternal() { + var url = "'http://www.amazon.com\\/(.*)\\/yourAffiliateId'"; + return Object(external_CoreHome_["translate"])('Goals_MatchesExpression', url); + } + } +})); +// CONCATENATED MODULE: ./plugins/Goals/vue/src/ManageGoals/ManageGoals.vue?vue&type=script&lang=ts + +// CONCATENATED MODULE: ./plugins/Goals/vue/src/ManageGoals/ManageGoals.vue + + + +ManageGoalsvue_type_script_lang_ts.render = render + +/* harmony default export */ var ManageGoals = (ManageGoalsvue_type_script_lang_ts); +// CONCATENATED MODULE: ./plugins/Goals/vue/src/ManageGoals/ManageGoals.adapter.ts /*! * Matomo - free/libre analytics platform * @@ -225,6 +1070,71 @@ window.angular.module('piwikApp').directive('piwikGoalPageLink', piwikGoalPageLi */ +/* harmony default export */ var ManageGoals_adapter = (Object(external_CoreHome_["createAngularJsAdapter"])({ + component: ManageGoals, + directiveName: 'piwikManageGoals', + scope: { + userCanEditGoals: { + angularJsBind: '<' + }, + onlyShowAddNewGoal: { + angularJsBind: '<' + }, + ecommerceEnabled: { + angularJsBind: '<' + }, + goals: { + angularJsBind: '<' + }, + showGoal: { + angularJsBind: '<' + }, + showAddGoal: { + angularJsBind: '<' + }, + addNewGoalIntro: { + angularJsBind: '<' + }, + goalTriggerTypeOptions: { + angularJsBind: '<' + }, + goalMatchAttributeOptions: { + angularJsBind: '<' + }, + eventTypeOptions: { + angularJsBind: '<' + }, + patternTypeOptions: { + angularJsBind: '<' + }, + numericComparisonTypeOptions: { + angularJsBind: '<' + }, + allowMultipleOptions: { + angularJsBind: '<' + }, + beforeGoalListActionsBody: { + angularJsBind: '<' + }, + endEditTable: { + angularJsBind: '<' + }, + beforeGoalListActionsHead: { + angularJsBind: '<' + } + } +})); +// CONCATENATED MODULE: ./plugins/Goals/vue/src/index.ts +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +*/ + + + + // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib-no-default.js diff --git a/plugins/Goals/vue/dist/Goals.umd.min.js b/plugins/Goals/vue/dist/Goals.umd.min.js index bb91dc1933..beedb32148 100644 --- a/plugins/Goals/vue/dist/Goals.umd.min.js +++ b/plugins/Goals/vue/dist/Goals.umd.min.js @@ -1,9 +1,21 @@ -(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("CoreHome")):"function"===typeof define&&define.amd?define(["CoreHome"],t):"object"===typeof exports?exports["Goals"]=t(require("CoreHome")):e["Goals"]=t(e["CoreHome"])})("undefined"!==typeof self?self:this,(function(e){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="plugins/Goals/vue/dist/",n(n.s="fae3")}({"19dc":function(t,n){t.exports=e},fae3:function(e,t,n){"use strict";if(n.r(t),n.d(t,"GoalPageLink",(function(){return c})),"undefined"!==typeof window){var o=window.document.currentScript,r=o&&o.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);r&&(n.p=r[1])}var i=n("19dc"),a=window,l=a.$,u={mounted:function(e,t){if(i["Matomo"].helper.isAngularRenderingThePage()){var n=l(e).text(),o=l("<a></a>");o.text(n),o.attr("title",Object(i["translate"])("Goals_ClickToViewThisGoal")),o.click((function(e){e.preventDefault(),i["MatomoUrl"].updateHash(Object.assign(Object.assign({},i["MatomoUrl"].hashParsed.value),{},{category:"Goals_Goals",subcategory:t.value.idGoal}))})),l(e).html(o[0])}}},c=u; +(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("CoreHome"),require("vue"),require("CorePluginsAdmin")):"function"===typeof define&&define.amd?define(["CoreHome",,"CorePluginsAdmin"],t):"object"===typeof exports?exports["Goals"]=t(require("CoreHome"),require("vue"),require("CorePluginsAdmin")):e["Goals"]=t(e["CoreHome"],e["Vue"],e["CorePluginsAdmin"])})("undefined"!==typeof self?self:this,(function(e,t,a){return function(e){var t={};function a(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,a),o.l=!0,o.exports}return a.m=e,a.c=t,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)a.d(n,o,function(t){return e[t]}.bind(null,o));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="plugins/Goals/vue/dist/",a(a.s="fae3")}({"19dc":function(t,a){t.exports=e},"8bbf":function(e,a){e.exports=t},a5a2:function(e,t){e.exports=a},fae3:function(e,t,a){"use strict";if(a.r(t),a.d(t,"GoalPageLink",(function(){return s})),a.d(t,"ManageGoals",(function(){return De})),"undefined"!==typeof window){var n=window.document.currentScript,o=n&&n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);o&&(a.p=o[1])}var l=a("19dc"),r=window,i=r.$,c={mounted:function(e,t){if(l["Matomo"].helper.isAngularRenderingThePage()){var a=i(e).text(),n=i("<a></a>");n.text(a),n.attr("title",Object(l["translate"])("Goals_ClickToViewThisGoal")),n.click((function(e){e.preventDefault(),l["MatomoUrl"].updateHash(Object.assign(Object.assign({},l["MatomoUrl"].hashParsed.value),{},{category:"Goals_Goals",subcategory:t.value.idGoal}))})),i(e).html(n[0])}}},s=c; /*! * Matomo - free/libre analytics platform * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -function f(){return{restrict:"A",link:function(e,t,n){var o={instance:null,value:{idGoal:n.piwikGoalPageLink},oldValue:null,modifiers:{},dir:{}};c.mounted(t[0],o)}}}i["Matomo"].on("Matomo.processDynamicHtml",(function(e){e.find("[goal-page-link]").each((function(e,t){if(!l(t).attr("goal-page-link-handled")){var n=l(t).attr("goal-page-link");n&&u.mounted(t,{instance:null,value:{idGoal:n},oldValue:null,modifiers:{},dir:{}}),l(t).attr("goal-page-link-handled","1")}}))})),window.angular.module("piwikApp").directive("piwikGoalPageLink",f)}})})); +function u(){return{restrict:"A",link:function(e,t,a){var n={instance:null,value:{idGoal:a.piwikGoalPageLink},oldValue:null,modifiers:{},dir:{}};s.mounted(t[0],n)}}}l["Matomo"].on("Matomo.processDynamicHtml",(function(e){e.find("[goal-page-link]").each((function(e,t){if(!i(t).attr("goal-page-link-handled")){var a=i(t).attr("goal-page-link");a&&c.mounted(t,{instance:null,value:{idGoal:a},oldValue:null,modifiers:{},dir:{}}),i(t).attr("goal-page-link-handled","1")}}))})),window.angular.module("piwikApp").directive("piwikGoalPageLink",u);var d=a("8bbf"),b={id:"entityEditContainer",feature:"true",class:"managegoals"},p={class:"contentHelp"},m=["innerHTML"],O={key:0},j=Object(d["createElementVNode"])("br",null,null,-1),g=Object(d["createElementVNode"])("br",null,null,-1),h=["innerHTML"],v={class:"first"},y={key:1},f={key:2},_={key:0},G={colspan:"8"},E=Object(d["createElementVNode"])("br",null,null,-1),V=Object(d["createElementVNode"])("br",null,null,-1),N=Object(d["createElementVNode"])("br",null,null,-1),w=["id"],T={class:"first"},S={class:"matchAttribute"},k={key:0},D={key:1},C=Object(d["createElementVNode"])("br",null,null,-1),x=["innerHTML"],A={key:1,style:{"padding-top":"2px"}},M=["onClick","title"],B=Object(d["createElementVNode"])("span",{class:"icon-edit"},null,-1),L=[B],P={key:2,style:{"padding-top":"2px"}},H=["onClick","title"],F=Object(d["createElementVNode"])("span",{class:"icon-delete"},null,-1),U=[F],R={key:0,class:"tableActionBar"},I=Object(d["createElementVNode"])("span",{class:"icon-add"},null,-1),J={class:"ui-confirm",ref:"confirm"},q=["value"],W=["value"],z={class:"addEditGoal"},Y=["innerHTML"],K={class:"row goalIsTriggeredWhen"},Q={class:"col s12"},X={class:"row"},Z={class:"col s12 m6 goalTriggerType"},ee={class:"col s12 m6"},te=["innerHTML"],ae={class:"row whereTheMatchAttrbiute"},ne={class:"col s12"},oe={class:"row"},le={class:"col s12 m6 l4"},re={key:0,class:"col s12 m6 l4"},ie={key:1,class:"col s12 m6 l4"},ce={class:"col s12 m6 l4"},se={id:"examples_pattern",class:"col s12"},ue=Object(d["createElementVNode"])("br",null,null,-1),de=Object(d["createElementVNode"])("br",null,null,-1),be=Object(d["createElementVNode"])("br",null,null,-1),pe=Object(d["createElementVNode"])("br",null,null,-1),me=Object(d["createElementVNode"])("br",null,null,-1),Oe=Object(d["createElementVNode"])("br",null,null,-1),je=Object(d["createElementVNode"])("br",null,null,-1),ge=Object(d["createElementVNode"])("br",null,null,-1),he={ref:"endedittable"},ve=Object(d["createElementVNode"])("input",{type:"hidden",name:"goalIdUpdate",value:""},null,-1),ye={key:0},fe=["innerHTML"],_e=Object(d["createElementVNode"])("a",{id:"bottom"},null,-1);function Ge(e,t,a,n,o,l){var r,i=Object(d["resolveComponent"])("ActivityIndicator"),c=Object(d["resolveComponent"])("ContentBlock"),s=Object(d["resolveComponent"])("Field"),u=Object(d["resolveComponent"])("Alert"),B=Object(d["resolveComponent"])("SaveButton"),F=Object(d["resolveDirective"])("content-table"),$=Object(d["resolveDirective"])("form");return Object(d["openBlock"])(),Object(d["createElementBlock"])("div",null,[Object(d["withDirectives"])(Object(d["createElementVNode"])("div",null,[Object(d["withDirectives"])(Object(d["createElementVNode"])("div",b,[Object(d["createVNode"])(c,{"content-title":e.translate("Goals_ManageGoals")},{default:Object(d["withCtx"])((function(){return[Object(d["createVNode"])(i,{loading:e.isLoading},null,8,["loading"]),Object(d["createElementVNode"])("div",p,[Object(d["createElementVNode"])("span",{innerHTML:e.learnMoreAboutGoalTracking},null,8,m),e.ecommerceEnabled?Object(d["createCommentVNode"])("",!0):(Object(d["openBlock"])(),Object(d["createElementBlock"])("span",O,[j,g,Object(d["createTextVNode"])(" "+Object(d["toDisplayString"])(e.translate("Goals_Optional"))+" "+Object(d["toDisplayString"])(e.translate("Goals_Ecommerce"))+": ",1),Object(d["createElementVNode"])("span",{innerHTML:e.youCanEnableEcommerceReports},null,8,h)]))]),Object(d["withDirectives"])(Object(d["createElementVNode"])("table",null,[Object(d["createElementVNode"])("thead",null,[Object(d["createElementVNode"])("tr",null,[Object(d["createElementVNode"])("th",v,Object(d["toDisplayString"])(e.translate("General_Id")),1),Object(d["createElementVNode"])("th",null,Object(d["toDisplayString"])(e.translate("Goals_GoalName")),1),Object(d["createElementVNode"])("th",null,Object(d["toDisplayString"])(e.translate("General_Description")),1),Object(d["createElementVNode"])("th",null,Object(d["toDisplayString"])(e.translate("Goals_GoalIsTriggeredWhen")),1),Object(d["createElementVNode"])("th",null,Object(d["toDisplayString"])(e.translate("General_ColumnRevenue")),1),e.beforeGoalListActionsHeadComponent?(Object(d["openBlock"])(),Object(d["createBlock"])(Object(d["resolveDynamicComponent"])(e.beforeGoalListActionsHeadComponent),{key:0})):Object(d["createCommentVNode"])("",!0),e.userCanEditGoals?(Object(d["openBlock"])(),Object(d["createElementBlock"])("th",y,Object(d["toDisplayString"])(e.translate("General_Edit")),1)):Object(d["createCommentVNode"])("",!0),e.userCanEditGoals?(Object(d["openBlock"])(),Object(d["createElementBlock"])("th",f,Object(d["toDisplayString"])(e.translate("General_Delete")),1)):Object(d["createCommentVNode"])("",!0)])]),Object(d["createElementVNode"])("tbody",null,[Object.keys(e.goals||{}).length?Object(d["createCommentVNode"])("",!0):(Object(d["openBlock"])(),Object(d["createElementBlock"])("tr",_,[Object(d["createElementVNode"])("td",G,[E,Object(d["createTextVNode"])(" "+Object(d["toDisplayString"])(e.translate("Goals_ThereIsNoGoalToManage",e.siteName))+" ",1),V,N])])),(Object(d["openBlock"])(!0),Object(d["createElementBlock"])(d["Fragment"],null,Object(d["renderList"])(e.goals||[],(function(t){return Object(d["openBlock"])(),Object(d["createElementBlock"])("tr",{id:t.idgoal,key:t.idgoal},[Object(d["createElementVNode"])("td",T,Object(d["toDisplayString"])(t.idgoal),1),Object(d["createElementVNode"])("td",null,Object(d["toDisplayString"])(t.name),1),Object(d["createElementVNode"])("td",null,Object(d["toDisplayString"])(t.description),1),Object(d["createElementVNode"])("td",null,[Object(d["createElementVNode"])("span",S,Object(d["toDisplayString"])(e.goalMatchAttributeTranslations[t.match_attribute]||t.match_attribute),1),"visit_duration"===t.match_attribute?(Object(d["openBlock"])(),Object(d["createElementBlock"])("span",k,Object(d["toDisplayString"])(e.lcfirst(e.translate("General_OperationGreaterThan")))+" "+Object(d["toDisplayString"])(e.translate("Intl_NMinutes",t.pattern)),1)):t.pattern_type?(Object(d["openBlock"])(),Object(d["createElementBlock"])("span",D,[C,Object(d["createTextVNode"])(" "+Object(d["toDisplayString"])(e.translate("Goals_Pattern"))+" "+Object(d["toDisplayString"])(t.pattern_type)+": "+Object(d["toDisplayString"])(t.pattern),1)])):Object(d["createCommentVNode"])("",!0)]),Object(d["createElementVNode"])("td",{class:"center",innerHTML:0===t.revenue||"0"===t.revenue?"-":e.$sanitize(t.revenue_pretty)},null,8,x),e.beforeGoalListActionsBodyComponent[t.idgoal]?(Object(d["openBlock"])(),Object(d["createBlock"])(Object(d["resolveDynamicComponent"])(e.beforeGoalListActionsBodyComponent[t.idgoal]),{key:0})):Object(d["createCommentVNode"])("",!0),e.userCanEditGoals?(Object(d["openBlock"])(),Object(d["createElementBlock"])("td",A,[Object(d["createElementVNode"])("button",{onClick:function(a){return e.editGoal(t.idgoal)},class:"table-action",title:e.translate("General_Edit")},L,8,M)])):Object(d["createCommentVNode"])("",!0),e.userCanEditGoals?(Object(d["openBlock"])(),Object(d["createElementBlock"])("td",P,[Object(d["createElementVNode"])("button",{onClick:function(a){return e.deleteGoal(t.idgoal)},class:"table-action",title:e.translate("General_Delete")},U,8,H)])):Object(d["createCommentVNode"])("",!0)],8,w)})),128))])],512),[[F]]),e.userCanEditGoals&&!e.onlyShowAddNewGoal?(Object(d["openBlock"])(),Object(d["createElementBlock"])("div",R,[Object(d["createElementVNode"])("button",{id:"add-goal",onClick:t[0]||(t[0]=function(t){return e.createGoal()})},[I,Object(d["createTextVNode"])(" "+Object(d["toDisplayString"])(e.translate("Goals_AddNewGoal")),1)])])):Object(d["createCommentVNode"])("",!0)]})),_:1},8,["content-title"])],512),[[d["vShow"],e.showGoalList]]),Object(d["createElementVNode"])("div",J,[Object(d["createElementVNode"])("h2",null,Object(d["toDisplayString"])(e.translate("Goals_DeleteGoalConfirm",'"'.concat(null===(r=e.goalToDelete)||void 0===r?void 0:r.name,'"'))),1),Object(d["createElementVNode"])("input",{role:"yes",type:"button",value:e.translate("General_Yes")},null,8,q),Object(d["createElementVNode"])("input",{role:"no",type:"button",value:e.translate("General_No")},null,8,W)],512)],512),[[d["vShow"],!e.onlyShowAddNewGoal]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("div",null,[Object(d["withDirectives"])(Object(d["createElementVNode"])("div",z,[Object(d["createVNode"])(c,{"content-title":e.goal.idgoal?e.translate("Goals_UpdateGoal"):e.translate("Goals_AddNewGoal")},{default:Object(d["withCtx"])((function(){return[Object(d["createElementVNode"])("div",{innerHTML:e.$sanitize(e.addNewGoalIntro)},null,8,Y),Object(d["withDirectives"])(Object(d["createElementVNode"])("div",null,[Object(d["createElementVNode"])("div",null,[Object(d["createVNode"])(s,{uicontrol:"text",name:"goal_name",modelValue:e.goal.name,"onUpdate:modelValue":t[1]||(t[1]=function(t){return e.goal.name=t}),maxlength:50,title:e.translate("Goals_GoalName")},null,8,["modelValue","title"])]),Object(d["createElementVNode"])("div",null,[Object(d["createVNode"])(s,{uicontrol:"text",name:"goal_description",modelValue:e.goal.description,"onUpdate:modelValue":t[2]||(t[2]=function(t){return e.goal.description=t}),maxlength:255,title:e.translate("General_Description")},null,8,["modelValue","title"])]),Object(d["createElementVNode"])("div",K,[Object(d["createElementVNode"])("div",Q,[Object(d["createElementVNode"])("h3",null,Object(d["toDisplayString"])(e.translate("Goals_GoalIsTriggered")),1)])]),Object(d["createElementVNode"])("div",X,[Object(d["createElementVNode"])("div",Z,[Object(d["createElementVNode"])("div",null,[Object(d["createVNode"])(s,{uicontrol:"select",name:"trigger_type","model-value":e.triggerType,"onUpdate:modelValue":t[3]||(t[3]=function(t){e.triggerType=t,e.changedTriggerType()}),"full-width":!0,options:e.goalTriggerTypeOptions},null,8,["model-value","options"])])]),Object(d["createElementVNode"])("div",ee,[Object(d["withDirectives"])(Object(d["createVNode"])(u,{severity:"info"},{default:Object(d["withCtx"])((function(){return[Object(d["createElementVNode"])("span",{innerHTML:e.whereVisitedPageManuallyCallsJsTrackerText},null,8,te)]})),_:1},512),[[d["vShow"],"manually"===e.triggerType]]),Object(d["createElementVNode"])("div",null,[Object(d["withDirectives"])(Object(d["createVNode"])(s,{uicontrol:"radio",name:"match_attribute","full-width":!0,"model-value":e.goal.match_attribute,"onUpdate:modelValue":t[4]||(t[4]=function(t){e.goal.match_attribute=t,e.initPatternType()}),options:e.goalMatchAttributeOptions},null,8,["model-value","options"]),[[d["vShow"],"manually"!==e.triggerType]])])])]),Object(d["withDirectives"])(Object(d["createElementVNode"])("div",ae,[Object(d["createElementVNode"])("h3",ne,[Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("Goals_WhereThe"))+" ",1),Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,Object(d["toDisplayString"])(e.translate("Goals_URL")),513),[[d["vShow"],"url"===e.goal.match_attribute]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,Object(d["toDisplayString"])(e.translate("Goals_PageTitle")),513),[[d["vShow"],"title"===e.goal.match_attribute]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,Object(d["toDisplayString"])(e.translate("Goals_Filename")),513),[[d["vShow"],"file"===e.goal.match_attribute]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,Object(d["toDisplayString"])(e.translate("Goals_ExternalWebsiteUrl")),513),[[d["vShow"],"external_website"===e.goal.match_attribute]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,Object(d["toDisplayString"])(e.translate("Goals_VisitDuration")),513),[[d["vShow"],"visit_duration"===e.goal.match_attribute]])])],512),[[d["vShow"],"manually"!==e.triggerType]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("div",oe,[Object(d["withDirectives"])(Object(d["createElementVNode"])("div",le,[Object(d["createElementVNode"])("div",null,[Object(d["createVNode"])(s,{uicontrol:"select",name:"event_type",modelValue:e.eventType,"onUpdate:modelValue":t[5]||(t[5]=function(t){return e.eventType=t}),"full-width":!0,options:e.eventTypeOptions},null,8,["modelValue","options"])])],512),[[d["vShow"],"event"===e.goal.match_attribute]]),e.isMatchAttributeNumeric?Object(d["createCommentVNode"])("",!0):(Object(d["openBlock"])(),Object(d["createElementBlock"])("div",re,[Object(d["createElementVNode"])("div",null,[Object(d["createVNode"])(s,{uicontrol:"select",name:"pattern_type",modelValue:e.goal.pattern_type,"onUpdate:modelValue":t[6]||(t[6]=function(t){return e.goal.pattern_type=t}),"full-width":!0,options:e.patternTypeOptions},null,8,["modelValue","options"])])])),e.isMatchAttributeNumeric?(Object(d["openBlock"])(),Object(d["createElementBlock"])("div",ie,[Object(d["createElementVNode"])("div",null,[Object(d["createVNode"])(s,{uicontrol:"select",name:"pattern_type",modelValue:e.goal.pattern_type,"onUpdate:modelValue":t[7]||(t[7]=function(t){return e.goal.pattern_type=t}),"full-width":!0,options:e.numericComparisonTypeOptions},null,8,["modelValue","options"])])])):Object(d["createCommentVNode"])("",!0),Object(d["createElementVNode"])("div",ce,[Object(d["createElementVNode"])("div",null,[Object(d["createVNode"])(s,{uicontrol:"text",name:"pattern",modelValue:e.goal.pattern,"onUpdate:modelValue":t[8]||(t[8]=function(t){return e.goal.pattern=t}),maxlength:255,title:e.patternFieldLabel,"full-width":!0},null,8,["modelValue","title"])])]),Object(d["createElementVNode"])("div",se,[Object(d["createVNode"])(u,{severity:"info"},{default:Object(d["withCtx"])((function(){return[Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,[Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_Contains","'checkout/confirmation'"))+" ",1),ue,Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_IsExactly","'http://example.com/thank-you.html'"))+" ",1),de,Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_MatchesExpression","'(.*)\\/demo\\/(.*)'")),1)],512),[[d["vShow"],"url"===e.goal.match_attribute]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_Contains","'Order confirmation'")),513),[[d["vShow"],"title"===e.goal.match_attribute]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,[Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_Contains","'files/brochure.pdf'"))+" ",1),be,Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_IsExactly","'http://example.com/files/brochure.pdf'"))+" ",1),pe,Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_MatchesExpression","'(.*)\\.zip'")),1)],512),[[d["vShow"],"file"===e.goal.match_attribute]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,[Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_Contains","'amazon.com'"))+" ",1),me,Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_IsExactly","'http://mypartner.com/landing.html'"))+" ",1),Oe,Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.matchesExpressionExternal),1)],512),[[d["vShow"],"external_website"===e.goal.match_attribute]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,[Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_Contains","'video'"))+" ",1),je,Object(d["createTextVNode"])(" "+Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_IsExactly","'click'"))+" ",1),ge,Object(d["createTextVNode"])(Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_MatchesExpression","'(.*)_banner'"))+'" ',1)],512),[[d["vShow"],"event"===e.goal.match_attribute]]),Object(d["withDirectives"])(Object(d["createElementVNode"])("span",null,Object(d["toDisplayString"])(e.translate("General_ForExampleShort"))+" "+Object(d["toDisplayString"])(e.translate("Goals_AtLeastMinutes","5","0.5")),513),[[d["vShow"],"visit_duration"===e.goal.match_attribute]])]})),_:1})])],512),[[d["vShow"],"manually"!==e.triggerType]]),Object(d["createElementVNode"])("div",null,[Object(d["withDirectives"])(Object(d["createVNode"])(s,{uicontrol:"checkbox",name:"case_sensitive",modelValue:e.goal.case_sensitive,"onUpdate:modelValue":t[9]||(t[9]=function(t){return e.goal.case_sensitive=t}),title:e.caseSensitiveTitle},null,8,["modelValue","title"]),[[d["vShow"],"manually"!==e.triggerType&&!e.isMatchAttributeNumeric]])]),Object(d["createElementVNode"])("div",null,["visit_duration"!==e.goal.match_attribute?(Object(d["openBlock"])(),Object(d["createBlock"])(s,{key:0,uicontrol:"radio",name:"allow_multiple","model-value":e.goal.allow_multiple?1:0,"onUpdate:modelValue":t[10]||(t[10]=function(t){return e.goal.allow_multiple=t}),options:e.allowMultipleOptions,introduction:e.translate("Goals_AllowMultipleConversionsPerVisit"),"inline-help":e.translate("Goals_HelpOneConversionPerVisit")},null,8,["model-value","options","introduction","inline-help"])):Object(d["createCommentVNode"])("",!0)]),Object(d["createElementVNode"])("h3",null,Object(d["toDisplayString"])(e.translate("Goals_GoalRevenue"))+" "+Object(d["toDisplayString"])(e.translate("Goals_Optional")),1),Object(d["createElementVNode"])("div",null,[Object(d["createVNode"])(s,{uicontrol:"number",name:"revenue",modelValue:e.goal.revenue,"onUpdate:modelValue":t[11]||(t[11]=function(t){return e.goal.revenue=t}),placeholder:e.translate("Goals_DefaultRevenueLabel"),"inline-help":e.translate("Goals_DefaultRevenueHelp")},null,8,["modelValue","placeholder","inline-help"])]),Object(d["createElementVNode"])("div",null,[Object(d["withDirectives"])(Object(d["createVNode"])(s,{uicontrol:"checkbox",name:"use_event_value",modelValue:e.goal.event_value_as_revenue,"onUpdate:modelValue":t[12]||(t[12]=function(t){return e.goal.event_value_as_revenue=t}),title:e.translate("Goals_UseEventValueAsRevenue"),"inline-help":e.useEventValueAsRevenueHelp},null,8,["modelValue","title","inline-help"]),[[d["vShow"],"event"===e.goal.match_attribute]])]),Object(d["createElementVNode"])("div",he,[e.endEditTableComponent?(Object(d["openBlock"])(),Object(d["createBlock"])(Object(d["resolveDynamicComponent"])(e.endEditTableComponent),{key:0})):Object(d["createCommentVNode"])("",!0)],512),ve,Object(d["createVNode"])(B,{saving:e.isLoading,onConfirm:t[13]||(t[13]=function(t){return e.save()}),value:e.submitText},null,8,["saving","value"]),e.onlyShowAddNewGoal?Object(d["createCommentVNode"])("",!0):(Object(d["openBlock"])(),Object(d["createElementBlock"])("div",ye,[Object(d["withDirectives"])(Object(d["createElementVNode"])("div",{class:"entityCancel",onClick:t[14]||(t[14]=function(t){return e.showListOfReports()}),innerHTML:e.cancelText},null,8,fe),[[d["vShow"],e.showEditGoal]])]))],512),[[$]])]})),_:1},8,["content-title"])],512),[[d["vShow"],e.showEditGoal]])],512),[[d["vShow"],e.userCanEditGoals]]),_e])}var Ee=a("a5a2");function Ve(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ne(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function we(e,t,a){return t&&Ne(e.prototype,t),a&&Ne(e,a),e}function Te(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e} +/*! +* Matomo - free/libre analytics platform +* +* @link https://matomo.org +* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +*/var Se=function(){function e(t,a){Ve(this,e),Te(this,"parameters",void 0),Te(this,"options",void 0),this.parameters=t,this.options=a}return we(e,[{key:"addParams",value:function(e){Object.assign(this.parameters,e)}},{key:"withTokenInUrl",value:function(){this.options.withTokenInUrl=!0}},{key:"reset",value:function(){var e=this;Object.keys(this.parameters).forEach((function(t){delete e.parameters[t]})),delete this.options.postParams}},{key:"addPostParams",value:function(e){this.options.postParams=Object.assign(Object.assign({},this.options.postParams),e)}}]),e}(),ke=Object(d["defineComponent"])({inheritAttrs:!1,props:{onlyShowAddNewGoal:Boolean,userCanEditGoals:Boolean,ecommerceEnabled:Boolean,goals:{type:Object,required:!0},addNewGoalIntro:String,goalTriggerTypeOptions:Object,goalMatchAttributeOptions:Array,eventTypeOptions:Array,patternTypeOptions:Array,numericComparisonTypeOptions:Array,allowMultipleOptions:Array,showAddGoal:Boolean,showGoal:Number,beforeGoalListActionsBody:Object,endEditTable:String,beforeGoalListActionsHead:String},data:function(){return{showEditGoal:!1,showGoalList:!0,goal:{},isLoading:!1,eventType:"event_category",triggerType:"visitors",apiMethod:"",submitText:"",goalToDelete:null,addEditTableComponent:!1}},components:{SaveButton:Ee["SaveButton"],ContentBlock:l["ContentBlock"],ActivityIndicator:l["ActivityIndicator"],Field:Ee["Field"],Alert:l["Alert"]},directives:{ContentTable:l["ContentTable"],Form:Ee["Form"]},mounted:function(){var e=this;this.showAddGoal?this.createGoal():this.showGoal&&this.editGoal(this.showGoal),this.showListOfReports(),Object(d["nextTick"])((function(){e.addEditTableComponent=!0,Object(d["nextTick"])((function(){var t=e.$refs.endedittable,a=l["Matomo"].helper.getAngularDependency("$rootScope").$new(!0);$(t).data("scope",a),l["Matomo"].helper.compileAngularComponents(t,{scope:a})}))}))},beforeUnmount:function(){var e=this.$refs.endedittable;$(e).data("scope").$destroy()},methods:{scrollToTop:function(){setTimeout((function(){l["Matomo"].helper.lazyScrollTo(".pageWrap",200)}))},initGoalForm:function(e,t,a,n,o,r,i,c,s,u,d,b){l["Matomo"].postEvent("Goals.beforeInitGoalForm",e,b),this.apiMethod=e,this.goal={},this.goal.name=a,this.goal.description=n;var p=o;"manually"===p?(this.triggerType="manually",p="url"):this.triggerType="visitors",0===p.indexOf("event")?(this.eventType=p,p="event"):this.eventType="event_category",this.goal.match_attribute=p,this.goal.allow_multiple=u,this.goal.pattern_type=i,this.goal.pattern=r,this.goal.case_sensitive=c,this.goal.revenue=s,this.goal.event_value_as_revenue=d,this.submitText=t,this.goal.idgoal=b},showListOfReports:function(){l["Matomo"].postEvent("Goals.cancelForm"),this.showGoalList=!0,this.showEditGoal=!1,this.scrollToTop()},showAddEditForm:function(){this.showGoalList=!1,this.showEditGoal=!0},createGoal:function(){var e={isAllowed:!0};l["Matomo"].postEvent("Goals.initAddGoal",e),e&&!e.isAllowed||(this.showAddEditForm(),this.initGoalForm("Goals.addGoal",Object(l["translate"])("Goals_AddGoal"),"","","url","","contains",!1,0,!1,!1,0),this.scrollToTop())},editGoal:function(e){this.showAddEditForm();var t=this.goals["".concat(e)];this.initGoalForm("Goals.updateGoal",Object(l["translate"])("Goals_UpdateGoal"),t.name,t.description,t.match_attribute,t.pattern,t.pattern_type,!!t.case_sensitive&&"0"!==t.case_sensitive,parseInt("".concat(t.revenue),10),!!t.allow_multiple&&"0"!==t.allow_multiple,!!t.event_value_as_revenue&&"0"!==t.event_value_as_revenue,e),this.scrollToTop()},deleteGoal:function(e){var t=this;this.goalToDelete=this.goals["".concat(e)],l["Matomo"].helper.modalConfirm(this.$refs.confirm,{yes:function(){t.isLoading=!0,l["AjaxHelper"].fetch({idGoal:e,method:"Goals.deleteGoal"}).then((function(){window.location.reload()})).finally((function(){t.isLoading=!1}))}})},save:function(){var e=this,t={};t.name=this.goal.name,t.description=this.goal.description,this.isManuallyTriggered?(t.matchAttribute="manually",t.patternType="regex",t.pattern=".*",t.caseSensitive=0):(t.matchAttribute=this.goal.match_attribute,"event"===t.matchAttribute&&(t.matchAttribute=this.eventType),t.patternType=this.goal.pattern_type,t.pattern=this.goal.pattern,t.caseSensitive=this.goal.case_sensitive?1:0),t.revenue=this.goal.revenue||0,t.allowMultipleConversionsPerVisit=this.goal.allow_multiple?1:0,t.useEventValueAsRevenue=this.goal.event_value_as_revenue?1:0,t.idGoal=this.goal.idgoal,t.method=this.apiMethod;var a="Goals.addGoal"===t.method,n="Goals.updateGoal"===t.method,o={},r=new Se(t,o);n?l["Matomo"].postEvent("Goals.beforeUpdateGoal",t,r):a&&l["Matomo"].postEvent("Goals.beforeAddGoal",t,r),null!==t&&void 0!==t&&t.cancelRequest||(this.isLoading=!0,l["AjaxHelper"].fetch(t,o).then((function(){var t=l["MatomoUrl"].parsed.value.subcategory;"Goals_AddNewGoal"===t&&l["Matomo"].helper.isAngularRenderingThePage()?l["ReportingMenuStore"].reloadMenuItems().then((function(){l["MatomoUrl"].updateHash(Object.assign(Object.assign({},l["MatomoUrl"].hashParsed.value),{},{subcategory:"Goals_ManageGoals"})),e.isLoading=!1})):window.location.reload()})).catch((function(){e.scrollToTop(),e.isLoading=!1})))},changedTriggerType:function(){this.isManuallyTriggered||this.goal.pattern_type||(this.goal.pattern_type="contains")},initPatternType:function(){this.isMatchAttributeNumeric?this.goal.pattern_type="greater_than":this.goal.pattern_type="contains"},lcfirst:function(e){return"".concat(e.substr(0,1).toLowerCase()).concat(e.substr(1))},ucfirst:function(e){return"".concat(e.substr(0,1).toUpperCase()).concat(e.substr(1))}},computed:{learnMoreAboutGoalTracking:function(){return Object(l["translate"])("Goals_LearnMoreAboutGoalTrackingDocumentation",'<a target="_blank" rel="noreferrer noopener" href="https://matomo.org/docs/tracking-goals-web-analytics/">',"</a>")},youCanEnableEcommerceReports:function(){var e=l["MatomoUrl"].stringify(Object.assign(Object.assign({},l["MatomoUrl"].urlParsed.value),{},{module:"SitesManager",action:"index"})),t='<a href="https://matomo.org/docs/ecommerce-analytics/" '+'rel="noreferrer noopener" target="_blank">'.concat(Object(l["translate"])("Goals_EcommerceReports"),"</a>"),a="<a href='".concat(e,"'>").concat(Object(l["translate"])("SitesManager_WebsitesManagement"),"</a>");return Object(l["translate"])("Goals_YouCanEnableEcommerceReports",t,a)},siteName:function(){return l["Matomo"].helper.htmlDecode(l["Matomo"].siteName)},whereVisitedPageManuallyCallsJsTrackerText:function(){var e="https://developer.matomo.org/guides/tracking-javascript-guide#manually-trigger-goal-conversions";return Object(l["translate"])("Goals_WhereVisitedPageManuallyCallsJavascriptTrackerLearnMore",'<a target="_blank" rel="noreferrer noopener" href="'.concat(e,'">'),"</a>")},caseSensitiveTitle:function(){return"".concat(Object(l["translate"])("Goals_CaseSensitive")," ").concat(Object(l["translate"])("Goals_Optional"))},useEventValueAsRevenueHelp:function(){return"".concat(Object(l["translate"])("Goals_EventValueAsRevenueHelp")," <br/><br/> ").concat(Object(l["translate"])("Goals_EventValueAsRevenueHelp2"))},cancelText:function(){return Object(l["translate"])("General_OrCancel","<a class='entityCancelLink'>","</a>")},isMatchAttributeNumeric:function(){return["visit_duration"].indexOf(this.goal.match_attribute)>-1},patternFieldLabel:function(){return"visit_duration"===this.goal.match_attribute?Object(l["translate"])("Goals_TimeInMinutes"):Object(l["translate"])("Goals_Pattern")},goalMatchAttributeTranslations:function(){return{manually:Object(l["translate"])("Goals_ManuallyTriggeredUsingJavascriptFunction"),file:Object(l["translate"])("Goals_Download"),url:Object(l["translate"])("Goals_VisitUrl"),title:Object(l["translate"])("Goals_VisitPageTitle"),external_website:Object(l["translate"])("Goals_ClickOutlink"),event_action:"".concat(Object(l["translate"])("Goals_SendEvent")," (").concat(Object(l["translate"])("Events_EventAction"),")"),event_category:"".concat(Object(l["translate"])("Goals_SendEvent")," (").concat(Object(l["translate"])("Events_EventCategory"),")"),event_name:"".concat(Object(l["translate"])("Goals_SendEvent")," (").concat(Object(l["translate"])("Events_EventName"),")"),visit_duration:"".concat(this.ucfirst(Object(l["translate"])("Goals_VisitDuration")))}},beforeGoalListActionsBodyComponent:function(){var e=this;if(!this.beforeGoalListActionsBody)return{};var t={};return Object.values(this.goals).forEach((function(a){t[a.idgoal]={template:e.beforeGoalListActionsBody[a.idgoal]}})),Object(d["markRaw"])(t)},endEditTableComponent:function(){return this.endEditTable&&this.addEditTableComponent?Object(d["markRaw"])({template:this.endEditTable}):null},beforeGoalListActionsHeadComponent:function(){return this.beforeGoalListActionsHead?Object(d["markRaw"])({template:this.beforeGoalListActionsHead}):null},isManuallyTriggered:function(){return"manually"===this.triggerType},matchesExpressionExternal:function(){var e="'http://www.amazon.com\\/(.*)\\/yourAffiliateId'";return Object(l["translate"])("Goals_MatchesExpression",e)}}});ke.render=Ge;var De=ke; +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */Object(l["createAngularJsAdapter"])({component:De,directiveName:"piwikManageGoals",scope:{userCanEditGoals:{angularJsBind:"<"},onlyShowAddNewGoal:{angularJsBind:"<"},ecommerceEnabled:{angularJsBind:"<"},goals:{angularJsBind:"<"},showGoal:{angularJsBind:"<"},showAddGoal:{angularJsBind:"<"},addNewGoalIntro:{angularJsBind:"<"},goalTriggerTypeOptions:{angularJsBind:"<"},goalMatchAttributeOptions:{angularJsBind:"<"},eventTypeOptions:{angularJsBind:"<"},patternTypeOptions:{angularJsBind:"<"},numericComparisonTypeOptions:{angularJsBind:"<"},allowMultipleOptions:{angularJsBind:"<"},beforeGoalListActionsBody:{angularJsBind:"<"},endEditTable:{angularJsBind:"<"},beforeGoalListActionsHead:{angularJsBind:"<"}}})}})})); //# sourceMappingURL=Goals.umd.min.js.map
\ No newline at end of file diff --git a/plugins/Goals/vue/dist/umd.metadata.json b/plugins/Goals/vue/dist/umd.metadata.json index 9ecfcc0456..dce4477a3c 100644 --- a/plugins/Goals/vue/dist/umd.metadata.json +++ b/plugins/Goals/vue/dist/umd.metadata.json @@ -1,5 +1,6 @@ { "dependsOn": [ - "CoreHome" + "CoreHome", + "CorePluginsAdmin" ] }
\ No newline at end of file diff --git a/plugins/Goals/vue/src/Goal.ts b/plugins/Goals/vue/src/Goal.ts new file mode 100644 index 0000000000..7609ea75ee --- /dev/null +++ b/plugins/Goals/vue/src/Goal.ts @@ -0,0 +1,24 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +interface Goal { + idgoal: string|number; + name: string; + allow_multiple: string|number|boolean; + case_sensitive: string|number|boolean; + deleted: string|number|boolean; + description: string; + event_value_as_revenue: string|number|boolean; + idsite: string|number; + match_attribute: string; + pattern: string; + pattern_type: string; + revenue: string|number; + revenue_pretty?: string; +} + +export default Goal; diff --git a/plugins/Goals/vue/src/ManageGoals/ManageGoals.adapter.ts b/plugins/Goals/vue/src/ManageGoals/ManageGoals.adapter.ts new file mode 100644 index 0000000000..72237788a8 --- /dev/null +++ b/plugins/Goals/vue/src/ManageGoals/ManageGoals.adapter.ts @@ -0,0 +1,64 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +import { createAngularJsAdapter } from 'CoreHome'; +import ManageGoals from './ManageGoals.vue'; + +export default createAngularJsAdapter({ + component: ManageGoals, + directiveName: 'piwikManageGoals', + scope: { + userCanEditGoals: { + angularJsBind: '<', + }, + onlyShowAddNewGoal: { + angularJsBind: '<', + }, + ecommerceEnabled: { + angularJsBind: '<', + }, + goals: { + angularJsBind: '<', + }, + showGoal: { + angularJsBind: '<', + }, + showAddGoal: { + angularJsBind: '<', + }, + addNewGoalIntro: { + angularJsBind: '<', + }, + goalTriggerTypeOptions: { + angularJsBind: '<', + }, + goalMatchAttributeOptions: { + angularJsBind: '<', + }, + eventTypeOptions: { + angularJsBind: '<', + }, + patternTypeOptions: { + angularJsBind: '<', + }, + numericComparisonTypeOptions: { + angularJsBind: '<', + }, + allowMultipleOptions: { + angularJsBind: '<', + }, + beforeGoalListActionsBody: { + angularJsBind: '<', + }, + endEditTable: { + angularJsBind: '<', + }, + beforeGoalListActionsHead: { + angularJsBind: '<', + }, + }, +}); diff --git a/plugins/Goals/vue/src/ManageGoals/ManageGoals.vue b/plugins/Goals/vue/src/ManageGoals/ManageGoals.vue new file mode 100644 index 0000000000..667935117b --- /dev/null +++ b/plugins/Goals/vue/src/ManageGoals/ManageGoals.vue @@ -0,0 +1,821 @@ +<!-- + Matomo - free/libre analytics platform + @link https://matomo.org + @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +--> + +<template> + <div> + <!-- v-show required until funnels/multiattribution are using vue and not angularjs --> + <div v-show="!onlyShowAddNewGoal"> + <div + id='entityEditContainer' + feature="true" + v-show="showGoalList" + class="managegoals" + > + <ContentBlock :content-title="translate('Goals_ManageGoals')"> + <ActivityIndicator :loading="isLoading"/> + + <div class="contentHelp"> + <span v-html="learnMoreAboutGoalTracking"/> + <span v-if="!ecommerceEnabled"> + <br /><br/> + + {{ translate('Goals_Optional') }} {{ translate('Goals_Ecommerce') }}: + <span v-html="youCanEnableEcommerceReports"/> + </span> + </div> + + <table v-content-table> + <thead> + <tr> + <th class="first">{{ translate('General_Id') }}</th> + <th>{{ translate('Goals_GoalName') }}</th> + <th>{{ translate('General_Description') }}</th> + <th>{{ translate('Goals_GoalIsTriggeredWhen') }}</th> + <th>{{ translate('General_ColumnRevenue') }}</th> + + <component + v-if="beforeGoalListActionsHeadComponent" + :is="beforeGoalListActionsHeadComponent" + ></component> + + <th v-if="userCanEditGoals">{{ translate('General_Edit') }}</th> + <th v-if="userCanEditGoals">{{ translate('General_Delete') }}</th> + </tr> + </thead> + <tbody> + <tr v-if="!Object.keys(goals || {}).length"> + <td colspan='8'> + <br/> + {{ translate('Goals_ThereIsNoGoalToManage', siteName) }} + <br/><br/> + </td> + </tr> + <tr v-for="goal in goals || []" :id="goal.idgoal" :key="goal.idgoal"> + <td class="first">{{ goal.idgoal }}</td> + <td>{{ goal.name }}</td> + <td>{{ goal.description }}</td> + <td> + <span class='matchAttribute'> + {{ goalMatchAttributeTranslations[goal.match_attribute] + || goal.match_attribute }} + </span> + <span v-if="goal.match_attribute === 'visit_duration'"> + {{ lcfirst(translate('General_OperationGreaterThan')) }} + {{ translate('Intl_NMinutes', goal.pattern) }} + </span> + <span v-else-if="!!goal.pattern_type"> + <br/> + {{ translate('Goals_Pattern') }} {{ goal.pattern_type }}: {{ goal.pattern }} + </span> + </td> + <td + class="center" + v-html="goal.revenue === 0 || goal.revenue === '0' + ? '-' + : $sanitize(goal.revenue_pretty)" + > + </td> + + <component + v-if="beforeGoalListActionsBodyComponent[goal.idgoal]" + :is="beforeGoalListActionsBodyComponent[goal.idgoal]" + ></component> + + <td v-if="userCanEditGoals" style="padding-top:2px"> + <button + @click="editGoal(goal.idgoal)" + class="table-action" + :title="translate('General_Edit')" + > + <span class="icon-edit"></span> + </button> + </td> + <td v-if="userCanEditGoals" style="padding-top:2px"> + <button + @click="deleteGoal(goal.idgoal)" + class="table-action" + :title="translate('General_Delete')" + > + <span class="icon-delete"></span> + </button> + </td> + </tr> + </tbody> + </table> + + <div class="tableActionBar" v-if="userCanEditGoals && !onlyShowAddNewGoal"> + <button id="add-goal" @click="createGoal()"> + <span class="icon-add"></span> + {{ translate('Goals_AddNewGoal') }} + </button> + </div> + </ContentBlock> + </div> + + <div class="ui-confirm" ref="confirm"> + <h2>{{ translate('Goals_DeleteGoalConfirm', `"${goalToDelete?.name}"`) }}</h2> + <input role="yes" type="button" :value="translate('General_Yes')"/> + <input role="no" type="button" :value="translate('General_No')"/> + </div> + </div> + + <!-- v-show required until funnels/multiattribution are using vue and not angularjs --> + <div v-show="userCanEditGoals"> + <div class="addEditGoal" v-show="showEditGoal"> + <ContentBlock + :content-title="goal.idgoal + ? translate('Goals_UpdateGoal') + : translate('Goals_AddNewGoal')" + > + <div v-html="$sanitize(addNewGoalIntro)"></div> + + <div v-form> + <div> + <Field + uicontrol="text" + name="goal_name" + v-model="goal.name" + :maxlength="50" + :title="translate('Goals_GoalName')"> + </Field> + </div> + + <div> + <Field + uicontrol="text" + name="goal_description" + v-model="goal.description" + :maxlength="255" + :title="translate('General_Description')" + /> + </div> + + <div class="row goalIsTriggeredWhen"> + <div class="col s12"> + <h3>{{ translate('Goals_GoalIsTriggered') }}</h3> + </div> + </div> + + <div class="row"> + <div class="col s12 m6 goalTriggerType"> + <div> + <Field + uicontrol="select" name="trigger_type" + :model-value="triggerType" + @update:model-value="triggerType = $event; changedTriggerType()" + :full-width="true" + :options="goalTriggerTypeOptions" + /> + </div> + </div> + <div class="col s12 m6"> + <Alert severity="info" v-show="triggerType === 'manually'"> + <span v-html="whereVisitedPageManuallyCallsJsTrackerText"></span> + </Alert> + + <div> + <Field + uicontrol="radio" + name="match_attribute" + v-show="triggerType !== 'manually'" + :full-width="true" + :model-value="goal.match_attribute" + @update:model-value="goal.match_attribute = $event; initPatternType()" + :options="goalMatchAttributeOptions" + /> + </div> + </div> + </div> + + <div class="row whereTheMatchAttrbiute" v-show="triggerType !== 'manually'"> + <h3 class="col s12">{{ translate('Goals_WhereThe') }} + <span v-show="goal.match_attribute === 'url'"> + {{ translate('Goals_URL') }} + </span> + <span v-show="goal.match_attribute === 'title'"> + {{ translate('Goals_PageTitle') }} + </span> + <span v-show="goal.match_attribute === 'file'"> + {{ translate('Goals_Filename') }} + </span> + <span v-show="goal.match_attribute === 'external_website'"> + {{ translate('Goals_ExternalWebsiteUrl') }} + </span> + <span v-show="goal.match_attribute === 'visit_duration'"> + {{ translate('Goals_VisitDuration') }} + </span> + </h3> + </div> + + <div class="row" v-show="triggerType !== 'manually'"> + <div class="col s12 m6 l4" + v-show="goal.match_attribute === 'event'"> + <div> + <Field + uicontrol="select" name="event_type" + v-model="eventType" + :full-width="true" + :options="eventTypeOptions" + /> + </div> + </div> + + <div class="col s12 m6 l4" v-if="!isMatchAttributeNumeric"> + <div> + <Field + uicontrol="select" + name="pattern_type" + v-model="goal.pattern_type" + :full-width="true" + :options="patternTypeOptions" + /> + </div> + </div> + + <div class="col s12 m6 l4" v-if="isMatchAttributeNumeric"> + <div> + <Field + uicontrol="select" name="pattern_type" + v-model="goal.pattern_type" + :full-width="true" + :options="numericComparisonTypeOptions" + /> + </div> + </div> + + <div class="col s12 m6 l4"> + <div> + <Field + uicontrol="text" name="pattern" + v-model="goal.pattern" + :maxlength="255" + :title="patternFieldLabel" + :full-width="true" + /> + </div> + </div> + + <div id="examples_pattern" class="col s12"> + <Alert severity="info"> + <span v-show="goal.match_attribute === 'url'"> + {{ translate('General_ForExampleShort') }} + {{ translate('Goals_Contains', "'checkout/confirmation'") }} + <br />{{ translate('General_ForExampleShort') }} + {{ translate('Goals_IsExactly', "'http://example.com/thank-you.html'") }} + <br />{{ translate('General_ForExampleShort') }} + {{ translate('Goals_MatchesExpression', "'(.*)\\\/demo\\\/(.*)'") }} + </span> + <span v-show="goal.match_attribute === 'title'"> + {{ translate('General_ForExampleShort') }} + {{ translate('Goals_Contains', "'Order confirmation'") }} + </span> + <span v-show="goal.match_attribute === 'file'"> + {{ translate('General_ForExampleShort') }} + {{ translate('Goals_Contains', "'files/brochure.pdf'") }} + <br />{{ translate('General_ForExampleShort') }} + {{ translate('Goals_IsExactly', "'http://example.com/files/brochure.pdf'") }} + <br />{{ translate('General_ForExampleShort') }} + {{ translate('Goals_MatchesExpression', "'(.*)\\\.zip'") }} + </span> + <span v-show="goal.match_attribute === 'external_website'"> + {{ translate('General_ForExampleShort') }} + {{ translate('Goals_Contains', "'amazon.com'") }} + <br />{{ translate('General_ForExampleShort') }} + {{ translate('Goals_IsExactly', "'http://mypartner.com/landing.html'") }} + <br />{{ translate('General_ForExampleShort') }} + {{ matchesExpressionExternal }} + </span> + <span v-show="goal.match_attribute === 'event'"> + {{ translate('General_ForExampleShort') }} + {{ translate('Goals_Contains', "'video'") }} + <br /> + {{ translate('General_ForExampleShort') }} + {{ translate('Goals_IsExactly', "'click'") }} + <br />{{ translate('General_ForExampleShort') }} + {{ translate('Goals_MatchesExpression', "'(.*)_banner'") }}" + </span> + <span v-show="goal.match_attribute === 'visit_duration'"> + {{ translate('General_ForExampleShort') }} + {{ translate('Goals_AtLeastMinutes', '5', '0.5') }} + </span> + </Alert> + </div> + </div> + + <div> + <Field + uicontrol="checkbox" + name="case_sensitive" + v-model="goal.case_sensitive" + v-show="triggerType !== 'manually' && !isMatchAttributeNumeric" + :title="caseSensitiveTitle" + /> + </div> + + <div> + <Field + uicontrol="radio" + name="allow_multiple" + :model-value="goal.allow_multiple ? 1 : 0" + @update:model-value="goal.allow_multiple = $event" + v-if="goal.match_attribute !== 'visit_duration'" + :options="allowMultipleOptions" + :introduction="translate('Goals_AllowMultipleConversionsPerVisit')" + :inline-help="translate('Goals_HelpOneConversionPerVisit')" + /> + </div> + + <h3>{{ translate('Goals_GoalRevenue') }} {{ translate('Goals_Optional') }}</h3> + + <div> + <Field + uicontrol="number" + name="revenue" + v-model="goal.revenue" + :placeholder="translate('Goals_DefaultRevenueLabel')" + :inline-help="translate('Goals_DefaultRevenueHelp')" + /> + </div> + + <div> + <Field + uicontrol="checkbox" + name="use_event_value" + v-model="goal.event_value_as_revenue" + :title="translate('Goals_UseEventValueAsRevenue')" + v-show="goal.match_attribute === 'event'" + :inline-help="useEventValueAsRevenueHelp" + /> + </div> + + <div ref="endedittable"> + <component :is="endEditTableComponent" v-if="endEditTableComponent"/> + </div> + + <input type="hidden" name="goalIdUpdate" value=""/> + + <SaveButton + :saving="isLoading" + @confirm="save()" + :value="submitText" + /> + + <div v-if="!onlyShowAddNewGoal"> + <div + class='entityCancel' + v-show="showEditGoal" + @click="showListOfReports()" + v-html="cancelText" + > + </div> + </div> + </div> + </ContentBlock> + </div> + </div> + + <a id='bottom'></a> + </div> +</template> + +<script lang="ts"> +import { IScope } from 'angular'; +import { defineComponent, markRaw, nextTick } from 'vue'; +import { + Matomo, + AjaxHelper, + AjaxOptions, + translate, + ContentBlock, + ActivityIndicator, + MatomoUrl, + ContentTable, + Alert, + ReportingMenuStore, +} from 'CoreHome'; +import { + Form, + Field, + SaveButton, +} from 'CorePluginsAdmin'; +import Goal from '../Goal'; +import PiwikApiMock from './PiwikApiMock'; + +interface ManageGoalsState { + showEditGoal: boolean; + showGoalList: boolean; + goal: Goal; + isLoading: boolean; + eventType: string; + triggerType: string; + apiMethod: string; + submitText: string; + goalToDelete: Goal|null; + addEditTableComponent: boolean; +} + +export default defineComponent({ + inheritAttrs: false, + props: { + onlyShowAddNewGoal: Boolean, + userCanEditGoals: Boolean, + ecommerceEnabled: Boolean, + goals: { + type: Object, + required: true, + }, + addNewGoalIntro: String, + goalTriggerTypeOptions: Object, + goalMatchAttributeOptions: Array, + eventTypeOptions: Array, + patternTypeOptions: Array, + numericComparisonTypeOptions: Array, + allowMultipleOptions: Array, + showAddGoal: Boolean, + showGoal: Number, + beforeGoalListActionsBody: Object, + endEditTable: String, + beforeGoalListActionsHead: String, + }, + data(): ManageGoalsState { + return { + showEditGoal: false, + showGoalList: true, + goal: {} as unknown as Goal, + isLoading: false, + eventType: 'event_category', + triggerType: 'visitors', + apiMethod: '', + submitText: '', + goalToDelete: null, + addEditTableComponent: false, + }; + }, + components: { + SaveButton, + ContentBlock, + ActivityIndicator, + Field, + Alert, + }, + directives: { + ContentTable, + Form, + }, + mounted() { + if (this.showAddGoal) { + this.createGoal(); + } else if (this.showGoal) { + this.editGoal(this.showGoal); + } + + this.showListOfReports(); + + // this component can be used in multiple places, one where + // Matomo.helper.compileAngularComponents() is already called, one where it's not. + // to make sure this function is only applied once to the slot data, we explicitly do not + // add it to vue, then on the next update, add it and call compileAngularComponents() + nextTick(() => { + this.addEditTableComponent = true; + + nextTick(() => { + const el = this.$refs.endedittable as HTMLElement; + const scope = Matomo.helper.getAngularDependency('$rootScope').$new(true); + $(el).data('scope', scope); + Matomo.helper.compileAngularComponents(el, { scope }); + }); + }); + }, + beforeUnmount() { + const el = this.$refs.endedittable as HTMLElement; + ($(el).data('scope') as IScope).$destroy(); + }, + methods: { + scrollToTop() { + setTimeout(() => { + Matomo.helper.lazyScrollTo('.pageWrap', 200); + }); + }, + initGoalForm( + goalMethodAPI: string, + submitText: string, + goalName: string, + description: string, + matchAttribute: string, + pattern: string, + patternType: string, + caseSensitive: boolean, + revenue: number, + allowMultiple: boolean, + useEventValueAsRevenue: boolean, + goalId: string|number, + ) { + Matomo.postEvent('Goals.beforeInitGoalForm', goalMethodAPI, goalId); + + this.apiMethod = goalMethodAPI; + + this.goal = {} as unknown as Goal; + this.goal.name = goalName; + this.goal.description = description; + + let actualMatchAttribute = matchAttribute; + if (actualMatchAttribute === 'manually') { + this.triggerType = 'manually'; + actualMatchAttribute = 'url'; + } else { + this.triggerType = 'visitors'; + } + + if (actualMatchAttribute.indexOf('event') === 0) { + this.eventType = actualMatchAttribute; + actualMatchAttribute = 'event'; + } else { + this.eventType = 'event_category'; + } + + this.goal.match_attribute = actualMatchAttribute; + this.goal.allow_multiple = allowMultiple; + this.goal.pattern_type = patternType; + this.goal.pattern = pattern; + this.goal.case_sensitive = caseSensitive; + this.goal.revenue = revenue; + this.goal.event_value_as_revenue = useEventValueAsRevenue; + this.submitText = submitText; + this.goal.idgoal = goalId; + }, + showListOfReports() { + Matomo.postEvent('Goals.cancelForm'); + this.showGoalList = true; + this.showEditGoal = false; + this.scrollToTop(); + }, + showAddEditForm() { + this.showGoalList = false; + this.showEditGoal = true; + }, + createGoal() { + const parameters = { + isAllowed: true, + }; + Matomo.postEvent('Goals.initAddGoal', parameters); + + if (parameters && !parameters.isAllowed) { + return; + } + + this.showAddEditForm(); + this.initGoalForm( + 'Goals.addGoal', + translate('Goals_AddGoal'), + '', + '', + 'url', + '', + 'contains', + false, + 0, + false, + false, + 0, + ); + this.scrollToTop(); + }, + editGoal(goalId: string|number) { + this.showAddEditForm(); + const goal = this.goals[`${goalId}`] as Goal; + this.initGoalForm( + 'Goals.updateGoal', + translate('Goals_UpdateGoal'), + goal.name, + goal.description, + goal.match_attribute, + goal.pattern, + goal.pattern_type, + !!goal.case_sensitive && goal.case_sensitive !== '0', + parseInt(`${goal.revenue}`, 10), + !!goal.allow_multiple && goal.allow_multiple !== '0', + !!goal.event_value_as_revenue && goal.event_value_as_revenue !== '0', + goalId, + ); + this.scrollToTop(); + }, + deleteGoal(goalId: string|number) { + this.goalToDelete = this.goals[`${goalId}`]; + Matomo.helper.modalConfirm((this.$refs.confirm as HTMLElement), { + yes: () => { + this.isLoading = true; + + AjaxHelper.fetch({ + idGoal: goalId, + method: 'Goals.deleteGoal', + }).then(() => { + window.location.reload(); + }).finally(() => { + this.isLoading = false; + }); + }, + }); + }, + save() { + const parameters: QueryParameters = {}; + // TODO: test removal of encoding, should be handled by ajax request + parameters.name = this.goal.name; + parameters.description = this.goal.description; + + if (this.isManuallyTriggered) { + parameters.matchAttribute = 'manually'; + parameters.patternType = 'regex'; + parameters.pattern = '.*'; + parameters.caseSensitive = 0; + } else { + parameters.matchAttribute = this.goal.match_attribute; + + if (parameters.matchAttribute === 'event') { + parameters.matchAttribute = this.eventType; + } + + parameters.patternType = this.goal.pattern_type; + parameters.pattern = this.goal.pattern; + parameters.caseSensitive = this.goal.case_sensitive ? 1 : 0; + } + parameters.revenue = this.goal.revenue || 0; + parameters.allowMultipleConversionsPerVisit = this.goal.allow_multiple ? 1 : 0; + parameters.useEventValueAsRevenue = this.goal.event_value_as_revenue ? 1 : 0; + + parameters.idGoal = this.goal.idgoal; + parameters.method = this.apiMethod; + + const isCreate = parameters.method === 'Goals.addGoal'; + const isUpdate = parameters.method === 'Goals.updateGoal'; + + const options: AjaxOptions = {}; + + const piwikApiMock = new PiwikApiMock(parameters, options); + if (isUpdate) { + Matomo.postEvent('Goals.beforeUpdateGoal', parameters, piwikApiMock); + } else if (isCreate) { + Matomo.postEvent('Goals.beforeAddGoal', parameters, piwikApiMock); + } + + if (parameters?.cancelRequest) { + return; + } + + this.isLoading = true; + + AjaxHelper.fetch(parameters, options).then(() => { + const subcategory = MatomoUrl.parsed.value.subcategory as string; + if (subcategory === 'Goals_AddNewGoal' + && Matomo.helper.isAngularRenderingThePage() + ) { + // when adding a goal for the first time we need to load manage goals page afterwards + ReportingMenuStore.reloadMenuItems().then(() => { + MatomoUrl.updateHash({ + ...MatomoUrl.hashParsed.value, + subcategory: 'Goals_ManageGoals', + }); + + this.isLoading = false; + }); + } else { + window.location.reload(); + } + }).catch(() => { + this.scrollToTop(); + this.isLoading = false; + }); + }, + changedTriggerType() { + if (!this.isManuallyTriggered && !this.goal.pattern_type) { + this.goal.pattern_type = 'contains'; + } + }, + initPatternType() { + if (this.isMatchAttributeNumeric) { + this.goal.pattern_type = 'greater_than'; + } else { + this.goal.pattern_type = 'contains'; + } + }, + lcfirst(s: string) { + return `${s.substr(0, 1).toLowerCase()}${s.substr(1)}`; + }, + ucfirst(s: string) { + return `${s.substr(0, 1).toUpperCase()}${s.substr(1)}`; + }, + }, + computed: { + learnMoreAboutGoalTracking() { + return translate( + 'Goals_LearnMoreAboutGoalTrackingDocumentation', + '<a target="_blank" rel="noreferrer noopener" ' + + 'href="https://matomo.org/docs/tracking-goals-web-analytics/">', + '</a>', + ); + }, + youCanEnableEcommerceReports() { + const link = MatomoUrl.stringify({ + ...MatomoUrl.urlParsed.value, + module: 'SitesManager', + action: 'index', + }); + + const ecommerceReportsText = '<a href="https://matomo.org/docs/ecommerce-analytics/" ' + + `rel="noreferrer noopener" target="_blank">${translate('Goals_EcommerceReports')}</a>`; + const websiteManageText = `<a href='${link}'>${translate('SitesManager_WebsitesManagement')}</a>`; + + return translate( + 'Goals_YouCanEnableEcommerceReports', + ecommerceReportsText, + websiteManageText, + ); + }, + siteName() { + return Matomo.helper.htmlDecode(Matomo.siteName); + }, + whereVisitedPageManuallyCallsJsTrackerText() { + const link = 'https://developer.matomo.org/guides/tracking-javascript-guide#manually-trigger-goal-conversions'; + return translate( + 'Goals_WhereVisitedPageManuallyCallsJavascriptTrackerLearnMore', + `<a target="_blank" rel="noreferrer noopener" href="${link}">`, + '</a>', + ); + }, + caseSensitiveTitle() { + return `${translate('Goals_CaseSensitive')} ${translate('Goals_Optional')}`; + }, + useEventValueAsRevenueHelp() { + return `${translate('Goals_EventValueAsRevenueHelp')} <br/><br/> ${translate('Goals_EventValueAsRevenueHelp2')}`; + }, + cancelText() { + return translate( + 'General_OrCancel', + '<a class=\'entityCancelLink\'>', + '</a>', + ); + }, + isMatchAttributeNumeric() { + return ['visit_duration'].indexOf(this.goal.match_attribute) > -1; + }, + patternFieldLabel() { + return this.goal.match_attribute === 'visit_duration' + ? translate('Goals_TimeInMinutes') + : translate('Goals_Pattern'); + }, + goalMatchAttributeTranslations() { + return { + manually: translate('Goals_ManuallyTriggeredUsingJavascriptFunction'), + file: translate('Goals_Download'), + url: translate('Goals_VisitUrl'), + title: translate('Goals_VisitPageTitle'), + external_website: translate('Goals_ClickOutlink'), + event_action: `${translate('Goals_SendEvent')} (${translate('Events_EventAction')})`, + event_category: `${translate('Goals_SendEvent')} (${translate('Events_EventCategory')})`, + event_name: `${translate('Goals_SendEvent')} (${translate('Events_EventName')})`, + visit_duration: `${this.ucfirst(translate('Goals_VisitDuration'))}`, + }; + }, + beforeGoalListActionsBodyComponent() { + if (!this.beforeGoalListActionsBody) { + return {}; + } + + const componentsByIdGoal: Record<string, unknown> = {}; + Object.values(this.goals as Record<string, Goal>).forEach((g) => { + componentsByIdGoal[g.idgoal] = { + template: this.beforeGoalListActionsBody![g.idgoal], + }; + }); + return markRaw(componentsByIdGoal); + }, + endEditTableComponent() { + if (!this.endEditTable || !this.addEditTableComponent) { + return null; + } + + return markRaw({ + template: this.endEditTable, + }); + }, + beforeGoalListActionsHeadComponent() { + if (!this.beforeGoalListActionsHead) { + return null; + } + + return markRaw({ + template: this.beforeGoalListActionsHead, + }); + }, + isManuallyTriggered() { + return this.triggerType === 'manually'; + }, + matchesExpressionExternal() { + const url = "'http://www.amazon.com\\/(.*)\\/yourAffiliateId'"; + return translate('Goals_MatchesExpression', url); + }, + }, +}); +</script> diff --git a/plugins/Goals/vue/src/ManageGoals/PiwikApiMock.ts b/plugins/Goals/vue/src/ManageGoals/PiwikApiMock.ts new file mode 100644 index 0000000000..9745fe3543 --- /dev/null +++ b/plugins/Goals/vue/src/ManageGoals/PiwikApiMock.ts @@ -0,0 +1,38 @@ +/*! +* Matomo - free/libre analytics platform +* +* @link https://matomo.org +* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +*/ + +import { AjaxOptions } from 'CoreHome'; + +// the piwikApi angularjs service is passed in some frontend events to allow plugins to modify +// a request before it is sent. for the time being in Vue we use this mock, which has the same +// API as the piwikApi service, to modify the input used with AjaxHelper. this provides BC +// with for plugins that haven't been converted. +// +// should be removed in Matomo 5. +export default class PiwikApiMock { + constructor(private parameters: QueryParameters, private options: AjaxOptions) {} + + addParams(params: QueryParameters): void { + Object.assign(this.parameters, params); + } + + withTokenInUrl(): void { + this.options.withTokenInUrl = true; + } + + reset(): void { + Object.keys(this.parameters).forEach((name) => { + delete this.parameters[name]; + }); + + delete this.options.postParams; + } + + addPostParams(params: QueryParameters): void { + this.options.postParams = { ...this.options.postParams, ...params }; + } +} diff --git a/plugins/Goals/vue/src/index.ts b/plugins/Goals/vue/src/index.ts index 5be8221004..a792651336 100644 --- a/plugins/Goals/vue/src/index.ts +++ b/plugins/Goals/vue/src/index.ts @@ -3,8 +3,10 @@ * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ +*/ import './GoalPageLink/GoalPageLink.adapter'; +import './ManageGoals/ManageGoals.adapter'; export { default as GoalPageLink } from './GoalPageLink/GoalPageLink.ts'; +export { default as ManageGoals } from './ManageGoals/ManageGoals.vue'; |