template div -- if folder already exist -- div class dropdown-menu dro

  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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<template>
<div>
<!--.........if folder already exist...........-->
<div class="dropdown-menu dropdown-menu-right feeder_no_cursor_pointer">
<template v-if="getFeederGroupList.length > 0 && !is_create_new_group">
<li class="heading">Select Group</li>
<ul class="inner">
<template v-for="group in getSortedFeederGroupList">
<li class="list_item ">
<span class="feeder-group-item--name">{{limitTextLength(group.name, 18)}}</span>
<template v-if="isAddedToFolderAlready(group)">
<span class="feeder-group-item--remove" @click="removeFeedFromGroup(group)"
:class="{'disable_click feeder_disable_click': group.is_remove}">
<span class="text-center">
<i class="fa fa-times"></i> <template
v-if="group.is_remove && state_of_loader==='removing'">Removing</template><template
v-else>Remove</template>
</span>
<span class="feeder-group-inline-block ml-2"
v-if="group.is_remove && state_of_loader==='removing'">
<clip-loader :color="'#ea7070'" :size="'14px'"></clip-loader>
</span>
</span>
</template>
<template v-else>
<span class="feeder-group-item--add feeder-group-inline-block"
:class="{'disable_click feeder_disable_click': group.is_add}"
@click="addFeedToGroup(group)">
<span class="text-center">
<i class="fa fa-plus"></i> <template
v-if="group.is_add && state_of_loader==='adding'">Adding</template><template
v-else>Add</template>
</span>
<span class="feeder-group-inline-block ml-2"
v-if="group.is_add && state_of_loader==='adding'">
<clip-loader :color="'#1ecb7b'" :size="'14px'"></clip-loader>
</span>
</span>
</template>
<!--<img @click.prevent="removeFolder(folder._id,folder.name, index)" class="remove close_this" src="../../assets/article/delete_icon.svg" alt="remove topic">-->
</li>
</template>
</ul>
</template>
<div class="dd_footer close_this " v-if="!is_create_new_group && this.getFeederGroupList.length > 0">
<button class="btn light_gray" @click.prevent="isCreateNewGroup()">
<i class="far fa-plus mr-2"></i>
Create New Group
</button>
</div>
<template v-if="is_create_new_group || this.getFeederGroupList.length === 0">
<li class="heading new_folder">Create New Group</li>
<div class="dd_footer close_this ">
<div class="create_input">
<input type="text" v-model="getFeederGroupStore.name"
@keyup.enter="validateAndStoreGroupFromDropdown()"
placeholder="Enter Group Name e.g SEO, Marketing">
<p class="error_message_about_group pt-1" v-if="state ==='group_exists'">A group with that name
already exists</p>
<div class="input_icon">
<i v-if="getFeederGroupStore.name && getFeederGroupStore.name.length >= 1"
class="remove far fa-times" @click="clearFeederGroupText()"></i>
<!--<img class="remove" src="../../assets/article/delete_icon.svg" alt="remove topic">-->
</div>
</div>
<div class="create_group_input_buttons mt-3">
<button :disabled="!getFeederGroupStore.name || loaders.folder_create"
@click="validateAndStoreGroupFromDropdown()"
class="btn gradient_btn btn_loader loader_right create_action_button mr-2"
:class="{'input-field-error': getFeederGroupValidations.fields.name}">
<span>Create</span>
<clip-loader :color="'#ffffff'" :size="'12px'"
v-if="loaders.folder_create"></clip-loader>
</button>
<button class="btn btn_loader loader_right cancel_action_button"
@click="is_create_new_group = false" v-if="this.getFeederGroupList.length > 0">
<span>Cancel</span>
</button>
</div>
</div>
</template>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import sortBy from 'lodash.sortby'
export default {
props: {
feed_id: {},
removeFromFollowedList: {},
addToFollowedList: {}
},
data () {
return {
addFolderStatus: true,
folderName: null,
state: '',
is_create_new_group: false,
state_of_loader: '',
loaders: {
folder_create: false
}
}
},
computed: {
...mapGetters(['getFeederGroupStore', 'getFeederGroupList', 'getFeederGroupValidations']),
getSortedFeederGroupList () {
return sortBy(this.getFeederGroupList, ['name'], ['asc'])
}
},
methods: {
// ...mapActions([''])
isCreateNewGroup () {
this.clearFeederGroupText()
this.is_create_new_group = true
},
clearFeederGroupText () {
this.$set(this.getFeederGroupStore, 'name', '')
},
async validateAndStoreGroupFromDropdown () {
{
let validationFields = this.getFeederGroupValidations.fields
this.$set(validationFields, 'name', this.requiredCheck(this.getFeederGroupStore.name))
let result = Object.keys(validationFields).every(k => validationFields[k] === false)
if (result) {
this.loaders.folder_create = true
let res = await this.$store.dispatch('storeFeederGroup')
this.loaders.folder_create = false
console.log(res)
if (res && res.data) {
if (!res.data.status) {
this.state = res.data.state
} else {
let groupId = res.data.data.uuid
let groupItem = this.getFeederGroupList.find(item => item.uuid === res.data.data.uuid)
this.is_create_new_group = false
this.$set(groupItem, 'is_add', true)
this.state_of_loader = 'adding'
let feedResponse = await this.$store.dispatch('storeUserFeed', {
feedId: this.feed_id,
groupId: groupId
})
console.log(feedResponse)
if (feedResponse && feedResponse.data && feedResponse.data.data) {
this.$store.dispatch('addUserFeedToGroup', feedResponse.data.data)
this.addToFollowedList(this.feed_id)
this.clearFeederGroupText()
}
this.$set(groupItem, 'is_add', false)
this.state_of_loader = ''
}
}
}
}
},
isAddedToFolderAlready (group) {
if (group.user_feed_details) {
let item = group.user_feed_details.find(item => item.feed_id === this.feed_id)
return !!(item)
}
return false
},
async removeFeedFromGroup (group) {
this.state_of_loader = 'removing'
this.$set(group, 'is_remove', true)
let feedResponse = await this.$store.dispatch('deleteUserFeed', {
feedId: this.feed_id,
groupId: group.uuid
})
if (feedResponse && feedResponse.data && feedResponse.data.status) {
await this.$store.dispatch('removeUserFeedFromGroup', { feed_id: this.feed_id, group_id: group.uuid })
this.removeFromFollowedList(this.feed_id)
}
console.log(feedResponse)
this.$set(group, 'is_remove', false)
this.state_of_loader = ''
},
async addFeedToGroup (group) {
this.state_of_loader = 'adding'
this.$set(group, 'is_add', true)
console.log('add feed to group')
let feedResponse = await this.$store.dispatch('storeUserFeed', {
feedId: this.feed_id,
groupId: group.uuid
})
console.log(feedResponse)
if (feedResponse && feedResponse.data && feedResponse.data.data) {
await this.$store.dispatch('addUserFeedToGroup', feedResponse.data.data)
this.addToFollowedList(this.feed_id)
}
this.$set(group, 'is_add', false)
this.state_of_loader = ''
}
},
watch: {
'getFeederGroupStore.name.length' (value) {
if (this.state === 'group_exists') this.state = ''
}
}
}
</script>
<style scoped lang="less">
.create_group_input_buttons {
.create_action_button {
span {
color: #fff !important;
}
}
.cancel_action_button {
span {
color: #4a4a4a !important
}
background: #dddddd !important;
}
}
.error_message_about_group {
color: #f44336 !important;
font-size: 12px;
}
.input_icon {
i {
color: #989eb5 !important
}
}
.feeder-group-item--name {
display: inline-block !important;
padding: 4px 0;
}
.feeder-group-item--add {
cursor: pointer !important;
width: 125px;
border-radius: 2px;
padding: 4px 10px;
display: inline-block;
float: right;
color: #1ecb7b;
border: 1px solid #1ecb7b;
text-align: center;
i {
padding-right: 5px;
}
}
.feeder-group-item--add:hover {
color: #00c489;
border: 1px solid #00af7a;
}
.feeder-group-item--remove {
cursor: pointer !important;
width: 125px;
text-align: center;
border-radius: 2px;
padding: 4px 10px;
display: inline-block;
float: right;
color: #ea7070;
border: 1px solid #ea7070;
i {
padding-right: 5px;
}
}
.feeder-group-item--red:hover {
color: #db5353;
border: 1px solid #c84d4d;
.v-spinner {
display: inline-block !important;
}
}
.feeder-group-item-spinner, .feeder-group-inline-block {
display: inline-block;
}
.follow_feeds_dropdown .dropdown-menu li.list_item span {
display: inline-block;
}
.feeder_no_cursor_pointer {
cursor: auto !important;
}
.feeder_disable_click {
opacity: 0.5 !important;
}
</style>