layers-design-system 2.3.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/layers-design-system.js +78496 -0
  2. package/dist/layers-design-system.umd.cjs +285 -0
  3. package/dist/style.css +1 -0
  4. package/package.json +26 -12
  5. package/.nvmrc +0 -1
  6. package/babel.config.js +0 -5
  7. package/src/assets/button-text-editor/double-quotes.svg +0 -4
  8. package/src/assets/button-text-editor/remove-formatting.svg +0 -5
  9. package/src/assets/button-text-editor/title.svg +0 -4
  10. package/src/assets/failed-to-load/failed-to-load.svg +0 -60
  11. package/src/assets/l-presentation/external-apps.png +0 -0
  12. package/src/assets/l-presentation/notification.png +0 -0
  13. package/src/assets/search-topics/empty-tags.svg +0 -59
  14. package/src/components/LAlert/docs.vue +0 -81
  15. package/src/components/LAlert/index.vue +0 -43
  16. package/src/components/LAttachmentChip/docs.vue +0 -84
  17. package/src/components/LAttachmentChip/index.vue +0 -179
  18. package/src/components/LBox/docs.vue +0 -26
  19. package/src/components/LBox/index.vue +0 -19
  20. package/src/components/LBoxHeader/index.vue +0 -24
  21. package/src/components/LBreadcrumb/docs.vue +0 -21
  22. package/src/components/LBreadcrumb/index.vue +0 -22
  23. package/src/components/LBreadcrumbItem/index.vue +0 -7
  24. package/src/components/LButton/docs.vue +0 -205
  25. package/src/components/LButton/index.vue +0 -369
  26. package/src/components/LButtonGroup/index.vue +0 -7
  27. package/src/components/LCarousel/docs.vue +0 -32
  28. package/src/components/LCarousel/index.vue +0 -88
  29. package/src/components/LCheckbox/docs.vue +0 -62
  30. package/src/components/LCheckbox/index.vue +0 -34
  31. package/src/components/LCheckboxButton/index.vue +0 -30
  32. package/src/components/LCheckboxGroup/index.vue +0 -53
  33. package/src/components/LChip/docs.vue +0 -113
  34. package/src/components/LChip/index.vue +0 -78
  35. package/src/components/LCircularLoader/docs.vue +0 -30
  36. package/src/components/LCircularLoader/index.vue +0 -97
  37. package/src/components/LCollapse/docs.vue +0 -68
  38. package/src/components/LCollapse/index.vue +0 -13
  39. package/src/components/LCollapseItem/index.vue +0 -28
  40. package/src/components/LDatePicker/docs.vue +0 -66
  41. package/src/components/LDatePicker/index.vue +0 -63
  42. package/src/components/LDialog/docs.vue +0 -36
  43. package/src/components/LDialog/index.vue +0 -37
  44. package/src/components/LDropdown/index.vue +0 -7
  45. package/src/components/LDropdownItem/index.vue +0 -13
  46. package/src/components/LDropdownMenu/docs.vue +0 -44
  47. package/src/components/LDropdownMenu/index.vue +0 -12
  48. package/src/components/LFailedToLoad/docs.vue +0 -37
  49. package/src/components/LFailedToLoad/index.vue +0 -61
  50. package/src/components/LForm/index.vue +0 -7
  51. package/src/components/LFormItem/index.vue +0 -12
  52. package/src/components/LHelperBox/assets/link.svg +0 -4
  53. package/src/components/LHelperBox/assets/open-envelope.svg +0 -9
  54. package/src/components/LHelperBox/docs.vue +0 -29
  55. package/src/components/LHelperBox/index.vue +0 -83
  56. package/src/components/LIcon/docs.vue +0 -174
  57. package/src/components/LIcon/index.vue +0 -55
  58. package/src/components/LImage/index.vue +0 -7
  59. package/src/components/LImageViewer/docs.vue +0 -111
  60. package/src/components/LImageViewer/index.vue +0 -449
  61. package/src/components/LInput/docs.vue +0 -43
  62. package/src/components/LInput/index.vue +0 -60
  63. package/src/components/LLinearProgress/docs.vue +0 -21
  64. package/src/components/LLinearProgress/index.vue +0 -74
  65. package/src/components/LNotice/docs.vue +0 -26
  66. package/src/components/LNotice/index.vue +0 -86
  67. package/src/components/LNotification/index.vue +0 -182
  68. package/src/components/LOption/index.vue +0 -7
  69. package/src/components/LOptionGroup/index.vue +0 -7
  70. package/src/components/LPresentation/docs.vue +0 -35
  71. package/src/components/LPresentation/index.vue +0 -182
  72. package/src/components/LProgress/index.vue +0 -7
  73. package/src/components/LPromptDialog/index.vue +0 -82
  74. package/src/components/LRadio/docs.vue +0 -54
  75. package/src/components/LRadio/index.vue +0 -13
  76. package/src/components/LRadioButton/index.vue +0 -30
  77. package/src/components/LRadioGroup/index.vue +0 -54
  78. package/src/components/LSearchBar/AddFilterButton.vue +0 -71
  79. package/src/components/LSearchBar/Filters/Editors/AmountEditor.vue +0 -110
  80. package/src/components/LSearchBar/Filters/Editors/DateEditor.vue +0 -146
  81. package/src/components/LSearchBar/Filters/Editors/NumberEditor.vue +0 -141
  82. package/src/components/LSearchBar/Filters/Editors/StringEditor.vue +0 -140
  83. package/src/components/LSearchBar/Filters/Editors/index.js +0 -16
  84. package/src/components/LSearchBar/Filters/FilterChip.vue +0 -105
  85. package/src/components/LSearchBar/Filters/Views/AmountView.vue +0 -28
  86. package/src/components/LSearchBar/Filters/Views/DateView.vue +0 -46
  87. package/src/components/LSearchBar/Filters/Views/NumberView.vue +0 -24
  88. package/src/components/LSearchBar/Filters/Views/StringView.vue +0 -47
  89. package/src/components/LSearchBar/Filters/Views/index.js +0 -16
  90. package/src/components/LSearchBar/docs.vue +0 -60
  91. package/src/components/LSearchBar/index.vue +0 -240
  92. package/src/components/LSearchTopics/RecentTermSearched.vue +0 -30
  93. package/src/components/LSearchTopics/TopicItem.vue +0 -346
  94. package/src/components/LSearchTopics/docs/drawer.vue +0 -254
  95. package/src/components/LSearchTopics/docs.vue +0 -60
  96. package/src/components/LSearchTopics/header.vue +0 -199
  97. package/src/components/LSearchTopics/helpers/showDialogConfirmation.js +0 -30
  98. package/src/components/LSearchTopics/helpers/showDiscardChangesDialog.js +0 -27
  99. package/src/components/LSearchTopics/index.vue +0 -750
  100. package/src/components/LSelect/docs.vue +0 -129
  101. package/src/components/LSelect/index.vue +0 -9
  102. package/src/components/LSlider/index.vue +0 -7
  103. package/src/components/LSwitch/docs.vue +0 -24
  104. package/src/components/LSwitch/index.vue +0 -60
  105. package/src/components/LTabPane/index.vue +0 -7
  106. package/src/components/LTable/FieldTypes/AmountView.vue +0 -16
  107. package/src/components/LTable/FieldTypes/DateView.vue +0 -18
  108. package/src/components/LTable/FieldTypes/EmailView.vue +0 -8
  109. package/src/components/LTable/FieldTypes/NumberView.vue +0 -13
  110. package/src/components/LTable/FieldTypes/PaymentStatusView.vue +0 -8
  111. package/src/components/LTable/FieldTypes/StringView.vue +0 -24
  112. package/src/components/LTable/FieldTypes/index.js +0 -18
  113. package/src/components/LTable/LTableBody.vue +0 -245
  114. package/src/components/LTable/LTableBodySpacer.vue +0 -17
  115. package/src/components/LTable/LTableEndspace.vue +0 -20
  116. package/src/components/LTable/LTableHeader.vue +0 -155
  117. package/src/components/LTable/LTableHeaderCell.vue +0 -188
  118. package/src/components/LTable/LTableHeaderLoader.vue +0 -62
  119. package/src/components/LTable/LTableHeaderResizer.vue +0 -162
  120. package/src/components/LTable/LTableLoadMore.vue +0 -56
  121. package/src/components/LTable/LTablePagination.vue +0 -174
  122. package/src/components/LTable/LTableReloader.vue +0 -61
  123. package/src/components/LTable/ListAdapter.js +0 -74
  124. package/src/components/LTable/docs.vue +0 -111
  125. package/src/components/LTable/helpers.js +0 -194
  126. package/src/components/LTable/index.vue +0 -961
  127. package/src/components/LTabs/docs.vue +0 -28
  128. package/src/components/LTabs/index.vue +0 -37
  129. package/src/components/LTargetChip/docs.vue +0 -86
  130. package/src/components/LTargetChip/index.vue +0 -64
  131. package/src/components/LTargetInput/docs.vue +0 -72
  132. package/src/components/LTargetInput/index.vue +0 -78
  133. package/src/components/LTextEditor/FloatingLink.vue +0 -91
  134. package/src/components/LTextEditor/LinkBox.vue +0 -94
  135. package/src/components/LTextEditor/docs.vue +0 -32
  136. package/src/components/LTextEditor/extensions/LayersBlockquote.js +0 -12
  137. package/src/components/LTextEditor/extensions/LayersBold.js +0 -11
  138. package/src/components/LTextEditor/extensions/LayersBreakLine.js +0 -16
  139. package/src/components/LTextEditor/extensions/LayersBubbleMenu.js +0 -10
  140. package/src/components/LTextEditor/extensions/LayersBulletList.js +0 -12
  141. package/src/components/LTextEditor/extensions/LayersHeading.js +0 -13
  142. package/src/components/LTextEditor/extensions/LayersHistory.js +0 -10
  143. package/src/components/LTextEditor/extensions/LayersItalic.js +0 -11
  144. package/src/components/LTextEditor/extensions/LayersLink.js +0 -29
  145. package/src/components/LTextEditor/extensions/LayersOrderedList.js +0 -12
  146. package/src/components/LTextEditor/extensions/LayersParagraph.js +0 -44
  147. package/src/components/LTextEditor/extensions/LayersPlaceholder.js +0 -11
  148. package/src/components/LTextEditor/extensions/LayersUnderline.js +0 -29
  149. package/src/components/LTextEditor/helpers/addProtocol.js +0 -5
  150. package/src/components/LTextEditor/helpers/removeEmptyTags.js +0 -5
  151. package/src/components/LTextEditor/index.vue +0 -421
  152. package/src/components/LTimeSelect/docs.vue +0 -41
  153. package/src/components/LTimeSelect/index.vue +0 -49
  154. package/src/components/LToggleButtonGroup/index.vue +0 -87
  155. package/src/components/LTooltip/docs.vue +0 -66
  156. package/src/components/LTooltip/index.vue +0 -28
  157. package/src/components/LTransitionExpand/docs.vue +0 -26
  158. package/src/components/LTransitionExpand/index.vue +0 -88
  159. package/src/components/LUpload/index.vue +0 -7
  160. package/src/docs/Colors.vue +0 -50
  161. package/src/docs/Home.vue +0 -11
  162. package/src/docs/Notifications.vue +0 -88
  163. package/src/docs/index.vue +0 -76
  164. package/src/docs/routes.js +0 -20
  165. package/src/helpers/Colors.js +0 -79
  166. package/src/helpers/FieldTypeComponents.js +0 -43
  167. package/src/helpers/Icons.js +0 -67
  168. package/src/helpers/Notification.js +0 -94
  169. package/src/helpers/PrettySize.js +0 -25
  170. package/src/helpers/RegisterElementUIComponents.js +0 -9
  171. package/src/helpers/Schemas.js +0 -18
  172. package/src/helpers/util.js +0 -15
  173. package/src/main-docs.js +0 -132
  174. package/src/main.js +0 -101
  175. package/src/style/colors.scss +0 -31
  176. package/src/style/element-variables.scss +0 -21
  177. package/src/style/icons.scss +0 -5
  178. package/src/style/layers-variables.scss +0 -73
  179. package/src/style/layout.scss +0 -2288
  180. package/src/style/main.scss +0 -11
  181. package/src/style/notifications.scss +0 -88
  182. package/src/style/transitions.scss +0 -43
  183. package/src/style/typography.scss +0 -155
  184. package/vue.config.js +0 -14
  185. /package/{public → dist}/favicon.ico +0 -0
  186. /package/{public → dist}/index.html +0 -0
@@ -1,750 +0,0 @@
1
- <template>
2
- <div class="search-topics-page l-col l-d-flex column">
3
- <SearchTopicsHeader
4
- class="drawer-search-topics-header"
5
- :kinds="headerKinds"
6
- :query="querySearchTopics"
7
- :typing="typing"
8
- :loading="loading"
9
- :hasAnySelectedTopic="selectedTopics.length > 0"
10
- @save="onSave"
11
- @close="onClose"
12
- @input="onInput"
13
- />
14
- <div class="px-0 py-2 l-container scroll-y l-flex-grow-1">
15
- <template v-if="loading || typing">
16
- <div class="gray-70--text searching-label mx-3">
17
- Procurando {{ searchingSpan }}...
18
- </div>
19
- </template>
20
- <template v-else-if="hasAnySearchedTopic">
21
- <div class="mb-5">
22
- <div class="recent-search mb-3 mx-3" v-if="showRecentSearchedTopics">
23
- <div class="recent-search-title gray-70--text mb-2 l-text-regular">
24
- Buscas recentes
25
- </div>
26
- <RecentTermSearched
27
- v-for="(term, index) in recentTopicsFiltered"
28
- @click.native="useRecentTermSearched(term)"
29
- :term="term"
30
- :key="index"
31
- class="mb-2 cursor-pointer"
32
- @remove="removeFromRecentTopicsSearched(term)"
33
- />
34
- </div>
35
-
36
- <div
37
- class="topic-item-tag-for-all mx-3"
38
- v-if="canSendForAll && !this.hasQuery"
39
- >
40
- <div class="l-flex lead-light--text l-text-regular">
41
- Enviar para todos
42
- </div>
43
- <l-checkbox v-model="forAllTag"></l-checkbox>
44
- </div>
45
-
46
- <div class="results-total mb-2 px-3" v-if="total >= 1 && hasQuery">
47
- {{ totalLabel }}
48
- </div>
49
-
50
- <div
51
- class="topics-searched mb-3"
52
- v-for="kind in resultKinds"
53
- :key="kind"
54
- >
55
- <h6
56
- v-if="isAllEntities"
57
- class="topic-kind-title gray-70--text mb-2 px-3"
58
- >
59
- {{ getKindNamePlural(kind) }} ({{ getTopicTotal(kind) }})
60
- </h6>
61
-
62
- <TopicItemGroup
63
- v-for="topic in getTopicHits(kind)"
64
- @input="updateSelectedTopics($event)"
65
- :topic="topic"
66
- :populateTopic="populateTopic"
67
- :disabled="forAllTagChecked"
68
- :checked="isChecked(topic)"
69
- :isCheckedFunction="isChecked"
70
- :key="topic.id"
71
- />
72
- <div v-if="isAllEntities && needShowMore(kind)" class="m-3">
73
- <l-button
74
- :loading="loading"
75
- @click.native="filterForKind(kind)"
76
- plain
77
- fill
78
- >
79
- Mostrar mais {{ getKindNamePlural(kind).toLowerCase() }}
80
- </l-button>
81
- </div>
82
-
83
- <div v-if="!isAllEntities && needShowMore(kind)" class="m-3">
84
- <l-button
85
- class="ma-3"
86
- :loading="loadingMore"
87
- @click.native="loadMore()"
88
- plain
89
- fill
90
- >
91
- Carregar mais
92
- </l-button>
93
- </div>
94
- </div>
95
- </div>
96
- </template>
97
-
98
- <template v-else>
99
- <div style="display: flex; flex-direction: column; height: 100%; align-items: stretch">
100
- <div
101
- class="topic-item-tag-for-all empty-tags-groups-for-all mx-3"
102
- v-if="canSendForAll && !this.hasQuery"
103
- >
104
- <div class="l-flex lead-light--text l-text-regular">
105
- Enviar para todos
106
- </div>
107
- <l-checkbox v-model="forAllTag"></l-checkbox>
108
- </div>
109
- <!-- show placeholder -->
110
- <div class="empty-tags-groups-placeholder" v-if="!querySearchTopics.q">
111
- <img src="../../assets/search-topics/empty-tags.svg" />
112
- <div class="empty-tags-groups-placeholder-text mt-2">
113
- <h3>Busque por marcadores, turmas, alunos e usuários</h3>
114
- <span class="text-small lead-light--text">
115
- Quando você tiver marcadores e turmas, eles aparecerão aqui.
116
- </span>
117
- </div>
118
- </div>
119
- <div v-else-if="!typing && !loading" class="not-found-result mx-3">
120
- <h4 class="bold lead--text m-0">Não encontramos resultados</h4>
121
- <p class="lead-light--text l-text-regular mt-3 mb-0">
122
- Tenha certeza que você está digitando uma palavra-chave correta
123
- </p>
124
- </div>
125
- </div>
126
- </template>
127
- </div>
128
-
129
- <div class="selected-topics" v-if="selectedTopics && selectedTopics.length">
130
- <button
131
- class="selected-topics-button l-d-flex l-align-items-center"
132
- style="padding: 0;"
133
- @click="forAllTagChecked ? (forAllTag = false) : (showSelected = true)"
134
- >
135
- <div class="selected-topics-button-bg"></div>
136
- <div class="ml-2 topics-selected-summary l-flex link--text">
137
- {{ topicsSummary }}
138
- </div>
139
- <l-button class="mr-2 bold link--text" type="text">
140
- {{ forAllTagChecked ? 'Limpar' : 'ver tudo' }}
141
- </l-button>
142
- </button>
143
-
144
- <van-action-sheet
145
- v-model="showSelected"
146
- lock-scroll
147
- style="max-height: 500px; min-height: 180px;"
148
- >
149
- <div class="l-d-flex m-3 l-align-items-center ">
150
- <div class="l-flex lead-light--text l-text-regular">
151
- Destinatários selecionados
152
- </div>
153
- <l-button
154
- @click="showSelected = false"
155
- circle
156
- icon="uil-multiply"
157
- class="border-none gray-70--text f-24 p-1"
158
- >
159
- </l-button>
160
- </div>
161
-
162
- <div class="mx-3 mb-3">
163
- <l-target-chip
164
- v-for="topic in selectedTopics"
165
- @remove="removeTopic(topic)"
166
- :key="topic.id"
167
- :kind="topic.kind"
168
- :name="topic.name"
169
- :closeable="true"
170
- class="mr-2 mb-2"
171
- />
172
- </div>
173
- </van-action-sheet>
174
- </div>
175
- </div>
176
- </template>
177
-
178
- <script>
179
- import cloneDeep from 'lodash/cloneDeep'
180
- import get from "lodash/get"
181
- import filter from 'lodash/filter'
182
- import debounce from 'lodash/debounce'
183
- import keys from 'lodash/keys'
184
- import difference from 'lodash/difference'
185
-
186
- import TopicItemGroup from './TopicItem.vue'
187
- import RecentTermSearched from './RecentTermSearched.vue'
188
- import SearchTopicsHeader from './header.vue'
189
- import showDialogConfirmation from './helpers/showDialogConfirmation'
190
- import showDiscardChangesDialog from './helpers/showDiscardChangesDialog'
191
- import { errorHandler } from 'layers-utils'
192
-
193
- export default {
194
- tagName: 'l-search-topics',
195
- name: 'LSearchTopics',
196
- components: {
197
- TopicItemGroup,
198
- RecentTermSearched,
199
- SearchTopicsHeader,
200
- },
201
- // props
202
- props: {
203
- canSendForAll: {
204
- type: Boolean,
205
- default: false,
206
- },
207
- searchTopics: {
208
- type: Function,
209
- },
210
- populateTopic: {
211
- type: Function,
212
- },
213
- alreadySelectedTopics: {
214
- type: Array,
215
- },
216
- recentTopicsSearched: {
217
- type: Object,
218
- },
219
- },
220
- // data
221
- data: function() {
222
- return {
223
- forAllTagChecked: false,
224
- showSelected: false,
225
- selectedTopics: [],
226
-
227
- querySearchTopics: {
228
- q: null,
229
- kind: '*',
230
- page: 0,
231
- },
232
-
233
- searchedTopics: {
234
- tag: {
235
- hits: [],
236
- total: 0,
237
- },
238
- group: {
239
- hits: [],
240
- total: 0,
241
- },
242
- member: {
243
- hits: [],
244
- total: 0,
245
- },
246
- user: {
247
- hits: [],
248
- total: 0,
249
- },
250
- },
251
-
252
- total: 0,
253
-
254
- kinds: ['*', 'tag', 'group', 'member', 'user'],
255
- kindsIcons: {
256
- tag: 'uil-tag-alt',
257
- group: 'uil-users-alt',
258
- member: 'uil-graduation-cap',
259
- user: 'uil-user',
260
- '*': '',
261
- },
262
-
263
- // waiters
264
- typing: false,
265
- loading: false,
266
- loadingMore: false,
267
- }
268
- },
269
- watch: {
270
- selectedTopics(val) {
271
- if (!val || val.length === 0) {
272
- this.showSelected = false
273
- }
274
- },
275
- querySearchTopics() {
276
- if (!this.typing && !this.loadingMore) this.typing = true
277
- this.searchDebounced()
278
- },
279
- },
280
- computed: {
281
- searchingSpan() {
282
- if (this.querySearchTopics.q) return this.querySearchTopics.q
283
- if (this.querySearchTopics.kind === '*') return ''
284
- return this.getKindNamePlural(this.querySearchTopics.kind).toLowerCase()
285
- },
286
- hasQuery() {
287
- return this.querySearchTopics.q || this.querySearchTopics.kind !== '*'
288
- },
289
-
290
- showRecentSearchedTopics() {
291
- if (!this.recentTopicsSearched.data) return false
292
- return this.recentTopicsSearched.data.length > 0 && !this.hasQuery
293
- },
294
-
295
- filteredSearchedTopics() {
296
- return {
297
- ...this.searchedTopics,
298
- tag: {
299
- hits: this.searchedTopics.tag.hits.filter((tag) => tag.id !== '*'),
300
- total: this.searchedTopics.tag.total,
301
- },
302
- }
303
- },
304
-
305
- forAllTag: {
306
- get() {
307
- return this.forAllTagChecked
308
- },
309
- set(val) {
310
- const tags = this.searchedTopics.tag.hits
311
- if (
312
- this.selectedTopics &&
313
- this.selectedTopics.length &&
314
- this.selectedTopics.find((t) => t.id !== '*') &&
315
- val !== 'confirm'
316
- ) {
317
- this.showForAllTagAlert().then((result) => {
318
- if (!result) {
319
- this.forAllTagChecked = false
320
- return
321
- }
322
- const tagAll = tags.find((tag) => tag.id === '*')
323
- this.setSelectedTopics([tagAll])
324
- this.forAllTagChecked = true
325
- })
326
- return
327
- }
328
- val = !!val
329
- if (val && this.searchedTopics && tags) {
330
- const tagAll = tags.find((tag) => tag.id === '*')
331
- this.setSelectedTopics([tagAll])
332
- } else {
333
- this.setSelectedTopics([])
334
- }
335
- this.forAllTagChecked = val
336
- },
337
- },
338
-
339
- recentTopicsFiltered() {
340
- const terms = cloneDeep(this.recentTopicsSearched.data)
341
- return terms.reverse().slice(0, 3)
342
- },
343
-
344
- topicsSummary() {
345
- if (!this.selectedTopics || !this.selectedTopics.length) return ''
346
-
347
- if (this.forAllTagChecked) {
348
- return 'Enviando para todos'
349
- }
350
-
351
- const summary = []
352
- this.kinds
353
- .filter((k) => k !== '*')
354
- .forEach((kind) => {
355
- const total = filter(this.selectedTopics, { kind }).length
356
- if (total === 1)
357
- summary.push(`1 ${this.getKindName(kind).toLowerCase()}`)
358
- else if (total > 1)
359
- summary.push(
360
- `${total} ${this.getKindNamePlural(kind).toLowerCase()}`
361
- )
362
- })
363
-
364
- if (summary.length) {
365
- return summary.join(', ')
366
- }
367
- return null
368
- },
369
-
370
- hasAnySearchedTopic() {
371
- if (!this.total) return null
372
- return this.total > 0
373
- },
374
-
375
- headerKinds() {
376
- return this.kinds
377
- .filter((kind) => kind !== 'tag' || this.canSendForAll)
378
- .map((kind) => {
379
- return {
380
- value: kind,
381
- name: this.getKindNamePlural(kind),
382
- icon: this.kindsIcons[kind],
383
- }
384
- })
385
- },
386
-
387
- resultKinds() {
388
- const filteredKinds = this.kinds.filter((k) => k !== '*')
389
- return filteredKinds.filter(
390
- (k) =>
391
- this.filteredSearchedTopics[k].total &&
392
- this.filteredSearchedTopics[k].hits.length
393
- )
394
- },
395
-
396
- totalLabel() {
397
- if (this.total === 1) {
398
- return '1 resultado encontrado'
399
- }
400
-
401
- return this.total + ' resultados encontrados'
402
- },
403
-
404
- isAllEntities() {
405
- return this.querySearchTopics.kind === '*'
406
- },
407
- },
408
- async created() {
409
- this.loading = true
410
- try {
411
- const searchResponse = await this.searchTopics(this.querySearchTopics)
412
- this.searchedTopics = searchResponse.result
413
- this.total = searchResponse.total
414
- } catch (error) {
415
- this.$notify({
416
- ...errorHandler('Erro ao carregar o público alvo.'),
417
- duration: 10000,
418
- position: 'bottom',
419
- showClose: true,
420
- })
421
- } finally {
422
- this.loading = false
423
- }
424
-
425
- this.selectedTopics = this.alreadySelectedTopics
426
-
427
- if (
428
- this.selectedTopics &&
429
- this.selectedTopics.length &&
430
- this.selectedTopics.find(
431
- (topic) => topic.id === '*' && topic.kind === 'tag'
432
- )
433
- ) {
434
- this.forAllTag = true
435
- }
436
- },
437
-
438
- destroyed() {
439
- this.setSelectedTopics([])
440
- },
441
-
442
- methods: {
443
- searchDebounced: debounce(
444
- async function() {
445
- if (get(this.querySearchTopics, 'q.length', null) > 3) {
446
- this.recentTopicsSearched.push(this.querySearchTopics.q)
447
- }
448
- await this.getSearchedTopics(this.querySearchTopics)
449
- this.typing = false
450
- },
451
- 500,
452
- { leading: false, trailing: true }
453
- ),
454
-
455
- useRecentTermSearched(term) {
456
- this.setQuerySearchTopics({
457
- q: term,
458
- kind: '*',
459
- })
460
- },
461
-
462
- getKindName(kind, locale = 'pt-br') {
463
- const names = {
464
- 'pt-br': {
465
- '*': 'Procurar em tudo',
466
- tag: 'Marcador',
467
- group: 'Turma',
468
- member: 'Aluno',
469
- user: 'Usuário',
470
- },
471
- 'en-us': {
472
- '*': 'Search all',
473
- tag: 'Tag',
474
- group: 'Group',
475
- member: 'Member',
476
- user: 'User',
477
- },
478
- }
479
- return names[locale][kind]
480
- },
481
-
482
- getKindNamePlural(kind, locale = 'pt-br') {
483
- const names = {
484
- 'pt-br': {
485
- '*': 'Procurar em tudo',
486
- tag: 'Marcadores',
487
- group: 'Turmas',
488
- member: 'Alunos',
489
- user: 'Usuários',
490
- },
491
- 'en-us': {
492
- '*': 'Search all',
493
- tag: 'Tags',
494
- group: 'Groups',
495
- member: 'Members',
496
- user: 'Users',
497
- },
498
- }
499
- return names[locale][kind]
500
- },
501
-
502
- async getSearchedTopics(params) {
503
- if (!this.loadingMore) this.loading = true
504
- try {
505
- const data = await this.searchTopics(params)
506
-
507
- if (params.page > 0) {
508
- // Increment arrays with results from pagination
509
- const searchedTopics = cloneDeep(this.searchedTopics)
510
-
511
- await Promise.all(
512
- keys(data.result).map((topicKind) => {
513
- if (!searchedTopics[topicKind]) {
514
- searchedTopics[topicKind] = {
515
- hits: [],
516
- total: null,
517
- }
518
- }
519
- searchedTopics[topicKind].hits = [
520
- ...searchedTopics[topicKind].hits,
521
- ...data.result[topicKind].hits,
522
- ]
523
- })
524
- )
525
- this.searchedTopics = searchedTopics
526
- } else {
527
- this.searchedTopics = data.result
528
- this.total = data.total
529
- }
530
- } catch (err) {
531
- this.$notify({
532
- ...errorHandler('Erro ao buscar o público desejado.'),
533
- duration: 10000,
534
- position: 'bottom',
535
- showClose: true,
536
- })
537
- } finally {
538
- this.loading = false
539
- this.loadingMore = false
540
- }
541
- },
542
-
543
- loadMore() {
544
- this.loadingMore = true
545
- const page = get(this.querySearchTopics, 'page', 0) + 1
546
- const q = get(this.querySearchTopics, 'q', null)
547
- const kind = get(this.querySearchTopics, 'kind', null)
548
-
549
- this.setQuerySearchTopics({
550
- q,
551
- kind,
552
- page,
553
- })
554
- },
555
-
556
- getTopicHits(kind) {
557
- return get(this.filteredSearchedTopics, `${kind}.hits`, [])
558
- },
559
-
560
- getTopicTotal(kind) {
561
- return get(this.filteredSearchedTopics, `${kind}.total`, [])
562
- },
563
-
564
- needShowMore(kind) {
565
- return this.getTopicTotal(kind) > this.getTopicHits(kind).length
566
- },
567
-
568
- isChecked(topic) {
569
- if (this.forAllTagChecked) return true
570
- return (
571
- this.selectedTopics.filter(
572
- (selectedTopic) =>
573
- selectedTopic.kind === topic.kind && selectedTopic.id === topic.id
574
- ).length !== 0
575
- )
576
- },
577
-
578
- filterForKind(kind) {
579
- this.setQuerySearchTopics({
580
- q: this.querySearchTopics.q,
581
- kind: kind,
582
- page: 0,
583
- })
584
- },
585
-
586
- setSelectedTopics(topics) {
587
- this.selectedTopics = topics
588
- },
589
-
590
- removeFromRecentTopicsSearched(term) {
591
- this.recentTopicsSearched.remove(term)
592
- },
593
-
594
- setQuerySearchTopics(query) {
595
- this.querySearchTopics = query
596
- },
597
-
598
- async showForAllTagAlert() {
599
- const result = await showDialogConfirmation({
600
- title:
601
- 'Você já selecionou alguns destinatários e eles serão substituídos pela tag todos.',
602
- buttonCloseLabel: 'Cancelar',
603
- buttonConfirmLabel: 'Continuar',
604
- })
605
- if (result) return result
606
- },
607
-
608
- addTopic(topic) {
609
- const filteredSelectedTopics = this.selectedTopics.filter(
610
- (selectedTopic) =>
611
- selectedTopic.id === topic.id && selectedTopic.kind === topic.kind
612
- )
613
- if (filteredSelectedTopics.length === 0) {
614
- const clone = cloneDeep(this.selectedTopics)
615
- clone.push(topic)
616
- this.setSelectedTopics(clone)
617
- }
618
- },
619
-
620
- removeTopic(topic) {
621
- const indexToRemove = this.selectedTopics.findIndex(
622
- (v) => v.id === topic.id && v.kind === topic.kind
623
- )
624
- if (indexToRemove == -1) return
625
- const clone = cloneDeep(this.selectedTopics)
626
- clone.splice(indexToRemove, 1)
627
- this.setSelectedTopics(clone)
628
- },
629
-
630
- updateSelectedTopics({ topic, value }) {
631
- if (!value) {
632
- this.removeTopic(topic)
633
- return
634
- }
635
- this.addTopic(topic)
636
- },
637
-
638
- // event handlers
639
- onSave() {
640
- const topics = this.selectedTopics.map((topic) => ({
641
- hash: topic.hash,
642
- name: topic.name,
643
- kind: topic.kind,
644
- id: topic.id,
645
- }))
646
- this.$emit('answer', topics)
647
- },
648
-
649
- async onClose() {
650
- const alreadySelectedTopics = cloneDeep(this.alreadySelectedTopics).map(v => v.kind + v.id)
651
- const selectedTopics = cloneDeep(this.selectedTopics).map(v => v.kind + v.id)
652
- const diffs = difference(selectedTopics, alreadySelectedTopics)
653
- if (diffs.length === 0) {
654
- this.$emit('close')
655
- return
656
- }
657
-
658
- const result = await showDiscardChangesDialog()
659
-
660
- if (result) {
661
- this.$emit('close')
662
- }
663
- },
664
-
665
- onInput(v) {
666
- this.querySearchTopics = v
667
- },
668
- },
669
- }
670
- </script>
671
- <style type="text/css" scoped>
672
- .border-none {
673
- border: none !important;
674
- }
675
- .search-topics-page {
676
- flex: 1 1 auto;
677
- position: relative;
678
- min-height: 100%;
679
- padding: 0px !important;
680
- }
681
- .topic-kind-title,
682
- .recent-search-title,
683
- .results-total {
684
- color: var(--gray-70);
685
- min-height: 24px;
686
- display: flex;
687
- align-items: center;
688
- }
689
- .topic-item-tag-for-all {
690
- min-height: 48px;
691
- display: flex;
692
- align-items: center;
693
- }
694
- .selected-topics-button {
695
- cursor: pointer;
696
- height: 48px;
697
- position: fixed;
698
- width: 100%;
699
- left: 0px;
700
- bottom: 0px;
701
- background: white;
702
- border: none;
703
- text-align: left;
704
- z-index: 100;
705
- }
706
- .selected-topics-button-bg {
707
- left: 0px;
708
- background-color: var(--link);
709
- opacity: 0.12;
710
- position: absolute;
711
- width: 100%;
712
- height: 100%;
713
- }
714
- .searching-label {
715
- font-size: 14px;
716
- line-height: 18px;
717
- display: flex;
718
- align-items: center;
719
- min-height: 24px;
720
- }
721
- .not-found-result {
722
- margin-top: 40px;
723
- text-align: center;
724
- }
725
-
726
- .empty-tags-groups-placeholder {
727
- display: flex;
728
- flex-direction: column;
729
- justify-content: center;
730
- align-items: center;
731
- text-align: center;
732
- height: 100%;
733
- }
734
-
735
- .empty-tags-groups-placeholder-text {
736
- width: 248px;
737
- }
738
-
739
- .cursor-pointer {
740
- cursor: pointer;
741
- }
742
-
743
- @media (min-width: 768px) {
744
- .search-topics-page {
745
- width: 600px !important;
746
- min-width: 600px;
747
- max-width: 600px;
748
- }
749
- }
750
- </style>