ability to select/unselect all metacodes in custom set with keyboard shortcut
This commit is contained in:
parent
ba943b20f1
commit
b8d99a2f9a
2 changed files with 22 additions and 2 deletions
|
@ -44,6 +44,22 @@ const Create = {
|
|||
self.newSelectedMetacodeNames.push($(this).attr('data-name'))
|
||||
}
|
||||
},
|
||||
metacodeSelectorToggleSelectAll: function() {
|
||||
// should be called when Create.isSwitchingSet is true and .customMetacodeList is visible
|
||||
if (!Create.isSwitchingSet) return
|
||||
if (!$('.customMetacodeList').is(':visible')) return
|
||||
|
||||
// If all are selected, then select none. Otherwise, select all.
|
||||
const anyToggledOff = $('.customMetacodeList li').toArray()
|
||||
.map(li => $(li).is('.toggledOff'))
|
||||
.reduce((curr, prev) => curr || prev)
|
||||
if (anyToggledOff) {
|
||||
$('.customMetacodeList li.toggledOff').each(Create.toggleMetacodeSelected)
|
||||
} else {
|
||||
// this should be every single one
|
||||
$('.customMetacodeList li').not('.toggledOff').each(Create.toggleMetacodeSelected)
|
||||
}
|
||||
},
|
||||
updateMetacodeSet: function(set, index, custom) {
|
||||
if (custom && Create.newSelectedMetacodes.length === 0) {
|
||||
window.alert('Please select at least one metacode to use!')
|
||||
|
@ -114,7 +130,6 @@ const Create = {
|
|||
}
|
||||
})
|
||||
},
|
||||
|
||||
cancelMetacodeSetSwitch: function() {
|
||||
var self = Create
|
||||
self.isSwitchingSet = false
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* global $ */
|
||||
|
||||
import Active from './Active'
|
||||
import Create from './Create'
|
||||
import Control from './Control'
|
||||
import DataModel from './DataModel'
|
||||
import JIT from './JIT'
|
||||
|
@ -35,7 +36,11 @@ const Listeners = {
|
|||
Control.deleteSelected()
|
||||
break
|
||||
case 65: // if a or A is pressed
|
||||
if ((e.ctrlKey || e.metaKey) && onCanvas) {
|
||||
if (Create.isSwitchingSet && e.ctrlKey || e.metaKey) {
|
||||
Create.metacodeSelectorToggleSelectAll()
|
||||
e.preventDefault()
|
||||
break
|
||||
} else if ((e.ctrlKey || e.metaKey) && onCanvas) {
|
||||
const nodesCount = Object.keys(Visualize.mGraph.graph.nodes).length
|
||||
const selectedNodesCount = Selected.Nodes.length
|
||||
e.preventDefault()
|
||||
|
|
Loading…
Add table
Reference in a new issue