Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MatomoDialog.adapter.ts « MatomoDialog « src « vue « CoreHome « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cd5965d1c68acf2f601c02e206f20e3b7b832dce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*!
 * Matomo - free/libre analytics platform
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

import { IParseService } from 'angular';
import { ComponentPublicInstance } from 'vue';
import MatomoDialog from './MatomoDialog.vue';
import createAngularJsAdapter from '../createAngularJsAdapter';

export default createAngularJsAdapter<[IParseService]>({
  component: MatomoDialog,
  scope: {
    show: {
      vue: 'modelValue',
      default: false,
    },
    element: {
      default: (scope, element) => element[0],
    },
  },
  events: {
    yes: ($event, vm, scope, element, attrs) => {
      if (attrs.yes) {
        scope.$eval(attrs.yes);
        setTimeout(() => { scope.$apply(); }, 0);
      }
    },
    no: ($event, vm, scope, element, attrs) => {
      if (attrs.no) {
        scope.$eval(attrs.no);
        setTimeout(() => { scope.$apply(); }, 0);
      }
    },
    validation: ($event, vm, scope, element, attrs) => {
      if (attrs.no) {
        scope.$eval(attrs.no);
        setTimeout(() => { scope.$apply(); }, 0);
      }
    },
    close: ($event, scope, element, attrs) => {
      if (attrs.close) {
        scope.$eval(attrs.close);
        setTimeout(() => { scope.$apply(); }, 0);
      }
    },
    'update:modelValue': (newValue, vm, scope, element, attrs, controller, $parse: IParseService) => {
      setTimeout(() => {
        scope.$apply($parse(attrs.piwikDialog).assign(scope, newValue));
      }, 0);
    },
  },
  $inject: ['$parse'],
  directiveName: 'piwikDialog',
  transclude: true,
  mountPointFactory: (scope, element) => {
    const vueRootPlaceholder = $('<div class="vue-placeholder"/>');
    vueRootPlaceholder.appendTo(element);
    return vueRootPlaceholder[0];
  },
  postCreate: (vm: ComponentPublicInstance, scope, element, attrs) => {
    scope.$watch(attrs.piwikDialog, (newValue: boolean, oldValue: boolean) => {
      if (oldValue !== newValue) {
        vm.modelValue = newValue || false;
      }
    });
  },
  noScope: true,
});