Skip to content

Commit

Permalink
service param WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
crosshj committed Aug 29, 2022
1 parent 4a55d96 commit 11e1d01
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fiug/layout",
"version": "0.0.13",
"version": "0.0.14",
"description": "page layout for browser applications",
"main": "dist/layout.js",
"exports": {
Expand Down
10 changes: 6 additions & 4 deletions src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ function follow(evt) {
}

let dragging = false;
let file;
let file, service;
const dragStartMessage = (layout) => (e) => {
const { file: inputFile, source, dragStart, dragEnd, pointerId, pane, splitDirection } = JSON.parse(e.data);
const { file: inputFile, service: inputService, source, dragStart, dragEnd, pointerId, pane, splitDirection } = JSON.parse(e.data);
//document.body.setPointerCapture(pointerId);
file = inputFile || file;
service = inputService || service;

if(dragStart){
dragging = true;
Expand All @@ -70,7 +71,7 @@ const dragStartMessage = (layout) => (e) => {
}[splitDirection];
const splitPane = document.getElementById(pane?.id);
if(dir && splitPane){
const editorFile = `?file=${file}`;
const editorFile = `?file=${file}&service=${service}`;
const split = splitting.newPane(dir, splitPane, editorFile, layout);
layout.onDrop({
type: "split",
Expand All @@ -82,7 +83,7 @@ const dragStartMessage = (layout) => (e) => {
}
const tabbedPane = splitPane.classList.contains('tabbed');
if(!dir && tabbedPane){
const editorFile = `/fiugd/beta/dist/editor.html?file=${file}`;
const editorFile = `?file=${file}&service=${service}`;
layout.openTab({
pane: splitPane.id,
file: editorFile
Expand Down Expand Up @@ -160,6 +161,7 @@ export const dragStart = (ev, draggedEv) => {
pointerId: ev.pointerId,
dragStart: draggedEv.target.textContent,
file: draggedEv.target.textContent,
service: draggedEv.service,
source: location.href.split('/').pop()
});
window.parent.postMessage(message, '*');
Expand Down
35 changes: 16 additions & 19 deletions src/splitting.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,20 @@ const addPane = (node, target, append, vertical, row, layout) => {
};

export const newPane = (direction, node, target, layout) => {
try {
const row = node.parentNode.classList.contains('row');
const column = node.parentNode.classList.contains('column');
const horizontal = ["left", "right"].includes(direction);
const vertical = ["up", "down"].includes(direction);
const append = ["right", "down"].includes(direction);

const operation = (() => {
if(column && horizontal) return addPane;
if(row && vertical) return addPane;
if(column && vertical) return split;
if(row && horizontal) return split;
})();
if(!operation) return;

return operation(node, target, append, vertical, row, layout);
} catch(e){
debugger;
}
debugger;
const row = node.parentNode.classList.contains('row');
const column = node.parentNode.classList.contains('column');
const horizontal = ["left", "right"].includes(direction);
const vertical = ["up", "down"].includes(direction);
const append = ["right", "down"].includes(direction);

const operation = (() => {
if(column && horizontal) return addPane;
if(row && vertical) return addPane;
if(column && vertical) return split;
if(row && horizontal) return split;
})();
if(!operation) return;

return operation(node, target, append, vertical, row, layout);
};
7 changes: 6 additions & 1 deletion src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,16 @@ export const onDrop = (layout) => (args) => {
file, height, width, tabbed, dragTo,
pane, location, parent, sibling
} = addedPane;
const siblingConfig = configFlat
.find(x => x.id === sibling);
const parentConfig = configFlat
.find(x => x.id === parent);
const newPane = {};
if(!!width) newPane.width = width;
if(!!height) newPane.height = height;

if(siblingConfig?.module){
newPane.module = siblingConfig.module;
}
if(tabbed){
newPane.orient = "tabs";
newPane.id = pane;
Expand Down Expand Up @@ -239,6 +243,7 @@ export const onDrop = (layout) => (args) => {
}

if(!splitPane && !addedPane) return;
debugger;
layout.onChange();
};

Expand Down
5 changes: 2 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ export function addParams(url, toAdd){

export const getFilename = (target="") => {
const params = UrlParams(target);
const path = params.get('file');
if(!path) return "";
const path = params.get('file') || target;
const filename = path.split("/").pop();
return filename;
};

export const getFilepath = (target) => {
const params = UrlParams(target);
const path = params.get('file');
const path = params.get('file') || target;
return path;
};

Expand Down

0 comments on commit 11e1d01

Please sign in to comment.