summaryrefslogtreecommitdiff
path: root/src/views/_sila/SILA/RAID/Settings/ActionSettingsPopover.vue
blob: 2f3093ab81f47756a88b54e3b45cc1d347d77bd6 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<template>
  <b-popover
    placement="left"
    triggers="focus"
    :show.sync="show"
    custom-class="apply-reload-popover"
    :target="`popover-action-${id}`"
    @hidden="onHidden"
  >
    <b-button
      id="popover-apply-button"
      variant="popover"
      :class="{ 'hovered-apply-button': scale === topPosition }"
      @mouseover="scale = topPosition"
      @click="
        () => {
          show = false;
          appalyOnReload();
        }
      "
    >
      При перезагрузке
    </b-button>
    <b-button
      id="popover-apply-button"
      variant="popover"
      :class="{ 'hovered-apply-button': scale === middlePosition }"
      @mouseover="scale = middlePosition"
      @click="
        () => {
          show = false;
          appalyOption1();
        }
      "
    >
      Опция 1
    </b-button>
    <b-button
      id="popover-apply-button"
      variant="popover"
      :class="{ 'hovered-apply-button': scale === bottomPosition }"
      @mouseover="scale = bottomPosition"
      @click="
        () => {
          show = false;
          appalyOption2();
        }
      "
    >
      Опция 2
    </b-button>
    <div class="slider" :style="`left: 5px; top: ${scale}px;`"></div>
  </b-popover>
</template>

<script>
export default {
  props: {
    id: {
      type: Number,
      default: null,
    },
    appalyOnReload: {
      type: Function,
      default: null,
    },
    appalyOption1: {
      type: Function,
      default: null,
    },
    appalyOption2: {
      type: Function,
      default: null,
    },
    applyType: {
      type: String,
      default: 'reload',
    },
  },
  data() {
    return {
      topPosition: 5,
      middlePosition: 33,
      bottomPosition: 60,
      show: false,
      scale: 5,
    };
  },
  methods: {
    onHidden() {
      if (this.applyType === 'reload') {
        this.scale = this.topPosition;
      } else if (this.applyType === 'option1') {
        this.scale = this.middlePosition;
      } else {
        this.scale = this.bottomPosition;
      }
    },
  },
};
</script>
<style lang="scss">
.analytical-table__status {
  width: 10%;
}

#popover-apply-ractive {
  padding-left: 5px;
}

.hovered-apply-button {
  color: $white;
}
</style>
<style lang="scss" scoped>
#popover-apply-button {
  justify-content: flex-start;
  width: 240px;
}

.slider {
  width: 240px;
  height: 28px;
  border-radius: 8px;
  background-color: $red-brand-primary;
  box-shadow: 1px 2px 4px -1px rgb(79 37 37 / 40%) inset;
  position: absolute;
  transition: ease-in 0.2s;
  z-index: -1;
}
</style>