199
199
<p class =" display-2 grey--text text--lighten-1" v-html =" __('ui_no_list_tip')" ></p >
200
200
</v-layout >
201
201
202
- <v-menu
203
- v-model =" showMenu"
204
- :position-x =" x"
205
- :position-y =" y"
206
- min-width =" 200"
207
- absolute
208
- offset-y
209
- >
210
- <v-list dense >
211
- <!-- <v-subheader>{{ __('ui_move_to') }}</v-subheader> -->
212
- <v-menu offset-x open-on-hover >
213
- <v-list-tile @click =" init" slot =" activator" >
214
- <v-list-tile-action >
215
- <v-icon small >move_to_inbox</v-icon >
216
- </v-list-tile-action >
217
- <v-list-tile-content >
218
- {{ __('ui_move_to') }}
219
- </v-list-tile-content >
220
- <v-list-tile-action >
221
- <v-icon :style =" {transform: 'rotate(-90deg)'}" >arrow_drop_down</v-icon >
222
- </v-list-tile-action >
223
- </v-list-tile >
224
- <v-list dense >
225
- <v-list-tile
226
- v-for =" (list, listIndex) in lists"
227
- :key =" listIndex"
228
- @click =" moveSelectedItemsTo(listIndex)"
229
- v-if =" list.title"
230
- :color =" list.color"
231
- >
232
- <v-list-tile-title >{{ list.title }}</v-list-tile-title >
233
- </v-list-tile >
234
- <v-list-tile @click =" moveSelectedItemsTo(-1)" >
235
- <v-list-tile-title >{{ __('ui_a_new_list') }}</v-list-tile-title >
236
- </v-list-tile >
237
- </v-list >
238
- </v-menu >
239
-
240
- <v-divider class =" my-1" ></v-divider >
241
-
242
- <v-list-tile @click =" duplicateSelectedItems" >
243
- <v-list-tile-action >
244
- <v-icon small >content_copy</v-icon >
245
- </v-list-tile-action >
246
- <v-list-tile-content >
247
- {{ __('ui_duplicate') }}
248
- </v-list-tile-content >
249
- </v-list-tile >
250
-
251
- <v-list-tile @click =" copyLinksOfSelectedItems" >
252
- <v-list-tile-action >
253
- <v-icon small >link</v-icon >
254
- </v-list-tile-action >
255
- <v-list-tile-content >
256
- {{ __('ui_copy_link') }}
257
- </v-list-tile-content >
258
- </v-list-tile >
259
-
260
- <v-list-tile @click =" copyTitleOfSelectedItems" >
261
- <v-list-tile-action >
262
- <v-icon small >title</v-icon >
263
- </v-list-tile-action >
264
- <v-list-tile-content >
265
- {{ __('ui_copy_title') }}
266
- </v-list-tile-content >
267
- </v-list-tile >
268
-
269
- <v-divider class =" my-1" ></v-divider >
270
-
271
- <v-list-tile @click =" removeSelectedItems" >
272
- <v-list-tile-action >
273
- <v-icon small >delete</v-icon >
274
- </v-list-tile-action >
275
- <v-list-tile-content >
276
- {{ __('ui_remove') }}
277
- </v-list-tile-content >
278
- </v-list-tile >
279
- </v-list >
280
- </v-menu >
202
+ <context-menu v-model =" showMenu" ref =" contextMenu" @click =" contextMenuClicked" ></context-menu >
281
203
282
204
<v-fab-transition >
283
205
<v-btn :key =" 1" v-if =" scrollY > 100" color =" pink" dark fab fixed bottom right @click =" $vuetify.goTo(0)" >
@@ -347,6 +269,7 @@ import tabs from '@/common/tabs'
347
269
import {createNewTabList } from ' @/common/list'
348
270
import {formatTime , getColorByHash } from ' @/common/utils'
349
271
import dynamicTime from ' @/app/component/DynamicTime'
272
+ import contextMenu from ' @/app/component/main/detailList/ContextMenu'
350
273
import {COLORS } from ' @/common/constants'
351
274
import {mapState , mapActions , mapMutations , mapGetters } from ' vuex'
352
275
@@ -357,9 +280,7 @@ export default {
357
280
processed: false , // if task to get list completed
358
281
choice: null , // choice in search result
359
282
showMenu: false , // item right click menu
360
- x: NaN , y: NaN , // menu position
361
- rightClickedItem: null , // if right click on an item
362
- multiOpBtnClickedListIndex: null ,
283
+ rightClickedListIndex: null ,
363
284
currentHighlightItem: null , // after jump to an item
364
285
draggableOptions: {
365
286
group: {
@@ -416,8 +337,10 @@ export default {
416
337
components: {
417
338
draggable,
418
339
dynamicTime,
340
+ contextMenu,
419
341
},
420
342
methods: {
343
+ log: console .log ,
421
344
__,
422
345
formatTime,
423
346
getColorByHash,
@@ -467,42 +390,50 @@ export default {
467
390
this .expandStatus = this .getExpandStatus ()
468
391
}
469
392
},
470
- openTab (listIndex , tabIndex ) {
471
- tabs .openTab (this .lists [listIndex].tabs [tabIndex])
472
- },
473
393
getDomain (url ) {
474
394
try {
475
395
return new URL (url).hostname
476
396
} catch (error) {
477
397
return ' '
478
398
}
479
399
},
400
+ async contextMenuClicked (func , ... args ) {
401
+ await this [func](... args)
402
+ this .showMenu = false
403
+ },
480
404
rightClicked (listIndex , tabIndex , $event ) {
481
405
$event .preventDefault ()
482
406
this .showMenu = false
483
- this .rightClickedItem = {listIndex, tabIndex}
484
- this .multiOpBtnClickedListIndex = null
485
- this .x = $event .clientX
486
- this .y = $event .clientY
407
+ this .rightClickedListIndex = listIndex
408
+
409
+ // refer gmail behaviour: unselect all except it if clicked item is not selected
410
+ if (! this .lists [listIndex].tabs [tabIndex].selected ) {
411
+ for (let i = 0 ; i < this .lists [listIndex].tabs .length ; i += 1 ) {
412
+ this .tabSelected ([listIndex, i, i === tabIndex])
413
+ }
414
+ }
415
+
416
+ this .$refs .contextMenu .x = $event .clientX
417
+ this .$refs .contextMenu .y = $event .clientY
487
418
this .$nextTick (() => {
488
419
this .showMenu = true
489
420
})
490
421
},
491
422
getSelectedItems () {
492
- if ( this . rightClickedItem ) return [this .rightClickedItem ]
493
- else if ( isFinite ( this . multiOpBtnClickedListIndex )) {
494
- const listIndex = this . multiOpBtnClickedListIndex
495
- const list = this . lists [listIndex]
496
- const selectedItems = []
497
- list . tabs . forEach (( tab , tabIndex ) => {
498
- if ( tab . selected ) selectedItems . push ({listIndex, tabIndex})
423
+ const list = this . lists [this .rightClickedListIndex ]
424
+ const selectedItems = []
425
+ list . tabs . forEach (( tab , tabIndex ) => {
426
+ if ( tab . selected ) selectedItems . push ({
427
+ // for avoid to change old functions
428
+ listIndex : this . rightClickedListIndex ,
429
+ tabIndex,
499
430
})
500
- return selectedItems
501
- }
431
+ })
432
+ return selectedItems
502
433
},
503
434
moveSelectedItemsTo (targetListIndex ) {
504
435
const items = this .getSelectedItems ()
505
- if (! items) return
436
+ if (! ( items && items . length ) ) return
506
437
const changedLists = [targetListIndex]
507
438
const tabs = items .map (({listIndex, tabIndex}) => {
508
439
changedLists .push (listIndex)
@@ -520,9 +451,15 @@ export default {
520
451
this .tabMoved (changedLists)
521
452
}
522
453
},
454
+ openSelectedItems () {
455
+ const items = this .getSelectedItems ()
456
+ if (! (items && items .length )) return
457
+ const toRestoredTabs = items .map (({listIndex, tabIndex}) => this .lists [listIndex].tabs [tabIndex])
458
+ return tabs .restoreTabs (toRestoredTabs)
459
+ },
523
460
duplicateSelectedItems () {
524
461
const items = this .getSelectedItems ()
525
- if (! items) return
462
+ if (! ( items && items . length ) ) return
526
463
const changedLists = []
527
464
items .forEach (({listIndex, tabIndex}) => {
528
465
changedLists .push (listIndex)
@@ -532,7 +469,7 @@ export default {
532
469
},
533
470
async copyLinksOfSelectedItems () {
534
471
const items = this .getSelectedItems ()
535
- if (! items) return
472
+ if (! ( items && items . length ) ) return
536
473
const text = items .map (({listIndex, tabIndex}) => {
537
474
const tab = this .lists [listIndex].tabs [tabIndex]
538
475
return tab .url
@@ -541,7 +478,7 @@ export default {
541
478
},
542
479
async copyTitleOfSelectedItems () {
543
480
const items = this .getSelectedItems ()
544
- if (! items) return
481
+ if (! ( items && items . length ) ) return
545
482
const text = items .map (({listIndex, tabIndex}) => {
546
483
const tab = this .lists [listIndex].tabs [tabIndex]
547
484
return tab .title
@@ -550,7 +487,7 @@ export default {
550
487
},
551
488
removeSelectedItems () {
552
489
const items = this .getSelectedItems ()
553
- if (! items) return
490
+ if (! ( items && items . length ) ) return
554
491
const changedLists = []
555
492
items .sort ((a , b ) => b .tabIndex - a .tabIndex )
556
493
.forEach (({listIndex, tabIndex}) => {
@@ -574,8 +511,9 @@ export default {
574
511
this .x = $event .x
575
512
this .y = $event .y
576
513
this .multiOpBtnClickedListIndex = listIndex
577
- this .rightClickedItem = null
578
- this .showMenu = true
514
+ this .$nextTick (() => {
515
+ this .showMenu = true
516
+ })
579
517
},
580
518
async jumpTo (item ) {
581
519
const page = item .listIndex / this .opts .listsPerPage << 0
0 commit comments