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'))
|
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) {
|
updateMetacodeSet: function(set, index, custom) {
|
||||||
if (custom && Create.newSelectedMetacodes.length === 0) {
|
if (custom && Create.newSelectedMetacodes.length === 0) {
|
||||||
window.alert('Please select at least one metacode to use!')
|
window.alert('Please select at least one metacode to use!')
|
||||||
|
@ -114,7 +130,6 @@ const Create = {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
cancelMetacodeSetSwitch: function() {
|
cancelMetacodeSetSwitch: function() {
|
||||||
var self = Create
|
var self = Create
|
||||||
self.isSwitchingSet = false
|
self.isSwitchingSet = false
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* global $ */
|
/* global $ */
|
||||||
|
|
||||||
import Active from './Active'
|
import Active from './Active'
|
||||||
|
import Create from './Create'
|
||||||
import Control from './Control'
|
import Control from './Control'
|
||||||
import DataModel from './DataModel'
|
import DataModel from './DataModel'
|
||||||
import JIT from './JIT'
|
import JIT from './JIT'
|
||||||
|
@ -35,7 +36,11 @@ const Listeners = {
|
||||||
Control.deleteSelected()
|
Control.deleteSelected()
|
||||||
break
|
break
|
||||||
case 65: // if a or A is pressed
|
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 nodesCount = Object.keys(Visualize.mGraph.graph.nodes).length
|
||||||
const selectedNodesCount = Selected.Nodes.length
|
const selectedNodesCount = Selected.Nodes.length
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
Loading…
Add table
Reference in a new issue