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

RateFeature.vue « RateFeature « src « vue « Feedback « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ba90382e55b7404074560f468ac42d14a1ce6d0e (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!--
  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
    :title="translate('Feedback_RateFeatureTitle', $sanitize(title))"
    class="ratefeature"
  >
    <div
      class="iconContainer"
      v-on:mouseenter="expanded = true"
      v-on:mouseleave="expanded = false"
    >
      <img
        v-on:click="likeFeature();showFeedbackForm=true"
        class="like-icon"
        src="plugins/Feedback/vue/src/RateFeature/thumbs-up.png"
      />
      <img
        v-on:click="dislikeFeature();showFeedbackForm=true"
        class="dislike-icon"
        v-show="expanded"
        src="plugins/Feedback/vue/src/RateFeature/thumbs-down.png"
      />
    </div>
    <MatomoDialog
      v-model="showFeedbackForm"
      @yes="sendFeedback()"
    >
      <div
        class="ui-confirm ratefeatureDialog"
      >
        <h2>{{ translate('Feedback_RateFeatureThankYouTitle', title) }}</h2>
        <p v-if="like">{{ translate('Feedback_RateFeatureLeaveMessageLike') }}</p>
        <p v-if="!like">{{ translate('Feedback_RateFeatureLeaveMessageDislike') }}</p>
        <br />
        <div class="messageContainer">
          <textarea v-model="feedbackMessage" />
        </div>
        <input
          type="button"
          :title="translate('Feedback_RateFeatureSendFeedbackInformation')"
          :value="translate('Feedback_SendFeedback')"
          role="yes"
        />
        <input
          type="button"
          role="cancel"
          :value="translate('General_Cancel')"
        />
      </div>
    </MatomoDialog>
    <MatomoDialog
      v-model="ratingDone"
    >
      <div
        class="ui-confirm ratefeatureDialog"
      >
        <h2>{{ translate('Feedback_ThankYou', title) }}</h2>
        <div
          v-if="like"
        >
        </div>
        <input
          type="button"
          :value="translate('General_Ok')"
          role="yes"
        />
      </div>
    </MatomoDialog>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { MatomoDialog, AjaxHelper } from 'CoreHome';

export default defineComponent({
  props: {
    title: String,
  },
  components: {
    MatomoDialog,
  },
  data() {
    return {
      like: false,
      ratingDone: false,
      expanded: false,
      showFeedbackForm: false,
      feedbackMessage: '',
    };
  },
  methods: {
    dislikeFeature() {
      this.like = false;
    },
    likeFeature() {
      this.like = true;
    },
    sendFeedback() {
      AjaxHelper.fetch({
        method: 'Feedback.sendFeedbackForFeature',
        featureName: this.title,
        like: this.like ? '1' : '0',
        message: this.feedbackMessage,
      });
      this.ratingDone = true;
    },
  },
});
</script>