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.
112 lines
3.2 KiB
JavaScript
112 lines
3.2 KiB
JavaScript
/**
|
|
* Vue helper mixin to push app state into browser history.
|
|
*
|
|
* How to use:
|
|
* Override browserHistoryState so it return the state you want to store
|
|
* Override historyStateUrl so it return the url you want to store with your state
|
|
* Override applyHistoryState to apply your state
|
|
*/
|
|
|
|
const StateSaveMode = Object.freeze({
|
|
IGNORE: Symbol("ignore"),
|
|
PUSH: Symbol("push"),
|
|
REPLACE: Symbol("replace")
|
|
});
|
|
|
|
let BrowserHistoryState = {
|
|
created() {
|
|
window.onpopstate = this._popHistoryState;
|
|
},
|
|
data() {
|
|
return {
|
|
_lastApplyedHistoryState: undefined
|
|
}
|
|
},
|
|
computed: {
|
|
/**
|
|
* Override and return state object
|
|
* @returns {Object} state object
|
|
*/
|
|
browserHistoryState() {
|
|
return {};
|
|
},
|
|
/**
|
|
* Override and return url to this state
|
|
* @returns {String} url to state
|
|
*/
|
|
historyStateUrl() {
|
|
return ''
|
|
}
|
|
},
|
|
watch: {
|
|
browserHistoryState(newState) {
|
|
if(JSON.stringify(newState) === JSON.stringify(window.history.state)) return; // Don't save state on apply
|
|
|
|
let mode = this.stateSaveMode(newState, window.history.state);
|
|
switch(mode) {
|
|
case StateSaveMode.IGNORE: break;
|
|
case StateSaveMode.PUSH:
|
|
this._pushHistoryState();
|
|
break;
|
|
case StateSaveMode.REPLACE:
|
|
this._replaceHistoryState();
|
|
break;
|
|
default:
|
|
console.log('Unknown state save mode', mode);
|
|
}
|
|
|
|
}
|
|
},
|
|
methods: {
|
|
/**
|
|
* Override to apply your state
|
|
* @param {Object} newState The state object you returned in @function browserHistoryState
|
|
*/
|
|
applyHistoryState(newState) {
|
|
|
|
},
|
|
/**
|
|
* Override to
|
|
* @param {Object} newState
|
|
* @param {Object} oldState
|
|
* @returns {StateSaveMode} Enum value to instruct how state change should be handled
|
|
*/
|
|
stateSaveMode(newState, oldState) {
|
|
if (!oldState) {
|
|
// Initial state. Replace what we have so we can go back to this state
|
|
return StateSaveMode.REPLACE;
|
|
}
|
|
return StateSaveMode.PUSH;
|
|
},
|
|
_pushHistoryState() {
|
|
let currentState = this.browserHistoryState;
|
|
if (!currentState) return;
|
|
|
|
let url = this.historyStateUrl;
|
|
window.history.pushState(
|
|
currentState,
|
|
undefined,
|
|
url
|
|
);
|
|
},
|
|
_replaceHistoryState() {
|
|
let currentState = this.browserHistoryState;
|
|
if (!currentState) return;
|
|
|
|
let url = this.historyStateUrl;
|
|
window.history.replaceState(
|
|
currentState,
|
|
undefined,
|
|
url
|
|
);
|
|
},
|
|
_popHistoryState(event) {
|
|
let newState = event.state;
|
|
if (!newState) return;
|
|
this.applyHistoryState(newState);
|
|
},
|
|
},
|
|
}
|
|
|
|
export { BrowserHistoryState, StateSaveMode }
|