Attract multi edit: Edit multiple tasks/shots/assets at the same time
For the user: Ctrl + L-Mouse to select multiple tasks/shots/assets and then edit the nodes as before. When multiple items are selected a chain icon can be seen in editor next to the fields. If the chain is broken it indicates that the values are not the same on all the selected items. When a field has been edited it will be marked with a green background color. The items are saved one by one in parallel. This means that one item could fail to be saved, while the others get updated. For developers: The editor and activities has been ported to Vue. The table and has been updated to support multi select. MultiEditEngine is the core of the multi edit. It keeps track of what values differs and what has been edited.
This commit is contained in:
@@ -1,3 +1,14 @@
|
||||
/**
|
||||
* Helper class to trigger/listen to global events on new/updated/deleted nodes.
|
||||
*
|
||||
* @example
|
||||
* function myCallback(event) {
|
||||
* console.log('Updated node:', event.detail);
|
||||
* }
|
||||
* Nodes.onUpdated('5c1cc4a5a013573d9787164b', myCallback);
|
||||
* Nodes.triggerUpdated(myUpdatedNode);
|
||||
*/
|
||||
|
||||
class EventName {
|
||||
static parentCreated(parentId, node_type) {
|
||||
return `pillar:node:${parentId}:created-${node_type}`;
|
||||
@@ -16,74 +27,115 @@ class EventName {
|
||||
}
|
||||
}
|
||||
|
||||
function trigger(eventName, data) {
|
||||
document.dispatchEvent(new CustomEvent(eventName, {detail: data}));
|
||||
}
|
||||
|
||||
function on(eventName, cb) {
|
||||
document.addEventListener(eventName, cb);
|
||||
}
|
||||
|
||||
function off(eventName, cb) {
|
||||
document.removeEventListener(eventName, cb);
|
||||
}
|
||||
|
||||
class Nodes {
|
||||
/**
|
||||
* Trigger events that node has been created
|
||||
* @param {Object} node
|
||||
*/
|
||||
static triggerCreated(node) {
|
||||
if (node.parent) {
|
||||
$('body').trigger(
|
||||
trigger(
|
||||
EventName.parentCreated(node.parent, node.node_type),
|
||||
node);
|
||||
}
|
||||
$('body').trigger(
|
||||
trigger(
|
||||
EventName.globalCreated(node.node_type),
|
||||
node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notified when new nodes where parent === parentId and node_type === node_type
|
||||
* @param {String} parentId
|
||||
* @param {String} node_type
|
||||
* @param {Function(Event)} cb
|
||||
*/
|
||||
static onParentCreated(parentId, node_type, cb){
|
||||
$('body').on(
|
||||
on(
|
||||
EventName.parentCreated(parentId, node_type),
|
||||
cb);
|
||||
}
|
||||
|
||||
static offParentCreated(parentId, node_type, cb){
|
||||
$('body').off(
|
||||
off(
|
||||
EventName.parentCreated(parentId, node_type),
|
||||
cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notified when new nodes where node_type === node_type is created
|
||||
* @param {String} node_type
|
||||
* @param {Function(Event)} cb
|
||||
*/
|
||||
static onCreated(node_type, cb){
|
||||
$('body').on(
|
||||
on(
|
||||
EventName.globalCreated(node_type),
|
||||
cb);
|
||||
}
|
||||
|
||||
static offCreated(node_type, cb){
|
||||
$('body').off(
|
||||
off(
|
||||
EventName.globalCreated(node_type),
|
||||
cb);
|
||||
}
|
||||
|
||||
static triggerUpdated(node) {
|
||||
$('body').trigger(
|
||||
trigger(
|
||||
EventName.updated(node._id),
|
||||
node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notified when node with _id === nodeId is updated
|
||||
* @param {String} nodeId
|
||||
* @param {Function(Event)} cb
|
||||
*/
|
||||
static onUpdated(nodeId, cb) {
|
||||
$('body').on(
|
||||
on(
|
||||
EventName.updated(nodeId),
|
||||
cb);
|
||||
}
|
||||
|
||||
static offUpdated(nodeId, cb) {
|
||||
$('body').off(
|
||||
off(
|
||||
EventName.updated(nodeId),
|
||||
cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify that node has been deleted.
|
||||
* @param {String} nodeId
|
||||
*/
|
||||
static triggerDeleted(nodeId) {
|
||||
$('body').trigger(
|
||||
trigger(
|
||||
EventName.deleted(nodeId),
|
||||
nodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen to events of new nodes where _id === nodeId
|
||||
* @param {String} nodeId
|
||||
* @param {Function(Event)} cb
|
||||
*/
|
||||
static onDeleted(nodeId, cb) {
|
||||
$('body').on(
|
||||
on(
|
||||
EventName.deleted(nodeId),
|
||||
cb);
|
||||
}
|
||||
|
||||
static offDeleted(nodeId, cb) {
|
||||
$('body').off(
|
||||
off(
|
||||
EventName.deleted(nodeId),
|
||||
cb);
|
||||
}
|
||||
|
Reference in New Issue
Block a user