Skip to content
Snippets Groups Projects
Commit 6e1c2586 authored by Shaun Ellis's avatar Shaun Ellis
Browse files

adds minimize and makes progress towards changing layout without removing windows from state

parent f101adcb
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ export class WindowTopBar extends Component {
* @return
*/
maximizeWindow() {
console.log('maximized!')
console.log('maximized!');
}
/**
......
......
......@@ -47,9 +47,17 @@ export class WorkspaceMosaic extends React.Component {
*/
determineWorkspaceLayout() {
const { windows, workspace } = this.props;
console.log(windows);
const windowKeys = Object.keys(windows).sort();
let windowKeys = Object.keys(windows).sort();
const leaveKeys = getLeaves(workspace.layout);
console.log(Object.keys(windows));
// First, check to see if any windows are maximized
// const maximizedWindows = windowKeys.map(id => windows[id]).filter(window => window.maximized === true)
// if (maximizedWindows.length) {
// windowKeys = maximizedWindows.map(window => window.id);
// }
windowKeys = [windowKeys[0]];
console.log(Object.keys(windows));
// console.log(windowKeys.map(id => windows[id]).filter(window => window.maximized === true));
// Check every window is in the layout, and all layout windows are present
// in store
if (!windowKeys.every(e => leaveKeys.includes(e))
......@@ -92,7 +100,7 @@ export class WorkspaceMosaic extends React.Component {
return (
<Mosaic
renderTile={this.tileRenderer}
initialValue={this.determineWorkspaceLayout() || workspace.layout}
initialValue={workspace.layout || this.determineWorkspaceLayout()}
onChange={this.mosaicChange}
className="mirador-mosaic"
zeroStateView={this.zeroStateView}
......
......
......@@ -12,7 +12,8 @@ const mapStateToProps = state => (
{
isWorkspaceControlPanelVisible: state.config.workspaceControlPanel.enabled,
workspaceType: state.config.workspace.type,
windows: pickBy(state.windows, window => window.displayable === true),
windows: state.windows,
// pickBy(state.windows, window => window.maximized === false),
// Object.keys(state.windows)
// .map(id => state.windows[id])
// .filter(window => window.displayable === true),
......
......
......@@ -9,6 +9,7 @@ const ActionTypes = {
ADD_MANIFEST: 'ADD_MANIFEST',
ADD_WINDOW: 'ADD_WINDOW',
MAXIMIZE_WINDOW: 'MAXIMIZE_WINDOW',
MINIMIZE_WINDOW: 'MINIMIZE_WINDOW',
NEXT_CANVAS: 'NEXT_CANVAS',
PREVIOUS_CANVAS: 'PREVIOUS_CANVAS',
SET_CANVAS: 'SET_CANVAS',
......
......
......@@ -30,7 +30,7 @@ export function addWindow(options) {
companionWindowIds: [],
rotation: null,
view: 'single',
displayable: true,
maximized: false,
};
return { type: ActionTypes.ADD_WINDOW, window: { ...defaultOptions, ...options } };
}
......@@ -44,6 +44,15 @@ export function maximizeWindow(windowId) {
return { type: ActionTypes.MAXIMIZE_WINDOW, windowId };
}
/**
* minimizeWindow
* @param {String} windowId
* @memberof ActionCreators
*/
export function minimizeWindow(windowId) {
return { type: ActionTypes.MINIMIZE_WINDOW, windowId };
}
/** */
export function updateWindow(id, payload) {
return { type: ActionTypes.UPDATE_WINDOW, id, payload };
......
......
......@@ -11,9 +11,18 @@ export const windowsReducer = (state = {}, action) => {
case ActionTypes.MAXIMIZE_WINDOW:
return Object.keys(state).reduce((object, key) => {
if (key !== action.windowId) {
object[key] = state[key];
object[key].displayable = false;
if (key === action.windowId) {
object[key] = state[key]; // eslint-disable-line no-param-reassign
object[key].maximized = true; // eslint-disable-line no-param-reassign
}
return object;
}, {});
case ActionTypes.MINIMIZE_WINDOW:
return Object.keys(state).reduce((object, key) => {
if (key === action.windowId) {
object[key] = state[key]; // eslint-disable-line no-param-reassign
object[key].maximized = false; // eslint-disable-line no-param-reassign
}
return object;
}, {});
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment