Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to define different widget layouts for different screen sizes #545

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8cb4be0
Add multiple screen size functionality
oxixes May 16, 2024
dbca9f8
Added editing UI for screen sizes
oxixes May 27, 2024
bc7e8dc
Improve UX when editing screen sizes.
oxixes May 29, 2024
41fc23c
Merge branch 'Wirecloud:develop' into screen-sizes
oxixes Jun 13, 2024
b073a2b
Progress (xml and json import / export, fix sidebar layout)
oxixes Jun 13, 2024
3ae1941
Fix sidebars resetting their active state on window resize
oxixes Jun 17, 2024
3830b43
Add RDF parsing and writing of screen sizes
oxixes Jun 18, 2024
8546910
Use database migrations for screen sizes
oxixes Jun 18, 2024
b07899e
Fix noselenium tests
oxixes Jun 21, 2024
03136c7
Fix grunt tests
oxixes Jun 24, 2024
d063cb6
Fix small bug and selenium tests
oxixes Jun 25, 2024
64d36d4
Some work on tests
oxixes Jun 28, 2024
8e4d8bf
Merge branch 'Wirecloud:develop' into screen-sizes
oxixes Jun 28, 2024
2fcc4ca
Remove unused CSSPrimitiveValue import in WorkspaceTabViewDragboard.js
oxixes Jun 28, 2024
f18d405
Make sure the screen size is 800x600 in js tests
oxixes Jun 28, 2024
71a2b6c
Try to fix test now
oxixes Jun 28, 2024
3a58927
Add name to screen sizes
oxixes Jun 28, 2024
3a18c75
More tests and better UX when defining screen sizes
oxixes Jul 1, 2024
1cb100b
More django tests
oxixes Jul 1, 2024
ece1ade
Exclude non-relevant files from search indexers tests
oxixes Jul 1, 2024
20e3c80
Fix bug and add selenium tests
oxixes Jul 2, 2024
f9702d0
Fix identation
oxixes Jul 2, 2024
196f94e
Move the editing interval message to the bottom and keep it present a…
oxixes Jul 2, 2024
4c8983f
Remove print
oxixes Jul 8, 2024
9ee4e0d
Forgot to remove TODO
oxixes Jul 10, 2024
edeee6b
Add updateWidgetScreenSizeWithId
oxixes Aug 14, 2024
0ad8d66
Fix
oxixes Aug 14, 2024
952b9c3
Add test
oxixes Aug 15, 2024
8f152a2
Fix widget instance bug and some improvements
oxixes Oct 1, 2024
db6bb8c
Forgot this file in the commit
oxixes Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
curl "http://localhost:8983/solr/admin/cores?action=RELOAD&core=tester"
fi
python manage.py collectstatic -v 0 -c --noinput
coverage run -a --branch --source wirecloud --omit="*/wirecloud/semanticwiring/*,*/wirecloud/guidebuilder/*,*/tests/*,*/tests.py,*/wirecloud/commons/utils/template/*" manage.py test --noinput --nologcapture -v 2 -a tags='wirecloud-search-api'
coverage run -a --branch --source wirecloud --omit="*/wirecloud/semanticwiring/*,*/wirecloud/guidebuilder/*,*/tests/*,*/tests.py,*/wirecloud/commons/utils/template/*,*/wirecloud/platform/workspace/*,*/wirecloud/platform/iwidget/*" manage.py test --noinput --nologcapture -v 2 -a tags='wirecloud-search-api'
- name: Coveralls Parallel
uses: AndreMiras/coveralls-python-action@develop
with:
Expand Down
2 changes: 1 addition & 1 deletion src/GruntFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var WirecloudFiles = [
'wirecloud/platform/static/js/wirecloud/ui/WorkspaceTabView.js',
'wirecloud/platform/static/js/wirecloud/ui/WorkspaceTabViewDragboard.js',
'wirecloud/platform/static/js/wirecloud/ui/SharingWindowMenu.js',

'wirecloud/platform/static/js/wirecloud/ui/ScreenSizesInputInterface.js',
'wirecloud/platform/static/js/wirecloud/DragboardPosition.js',
'wirecloud/platform/static/js/wirecloud/ui/DragboardCursor.js',
'wirecloud/platform/static/js/wirecloud/ui/MultiValuedSize.js',
Expand Down
17 changes: 17 additions & 0 deletions src/js_tests/styledelements/AlertSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@
expect(element.body).toEqual(jasmine.any(se.Container));
});

it("should allow changing the message", () => {
const element = new se.Alert();
element.setMessage("New message");

expect(element.body.wrapperElement.textContent).toEqual("New message");
});

it("should allow to show and hide the alert", () => {
const element = new se.Alert();
element.hide();

expect(element.wrapperElement.style.display).toEqual("none");

element.show();
expect(element.wrapperElement.style.display).toEqual("");
});

});

});
Expand Down
10 changes: 5 additions & 5 deletions src/js_tests/styledelements/NotebookSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,32 +468,32 @@

});

describe("addButton(button, position)", function () {
describe("addToEastSection(elem, position)", function () {
let element;

beforeEach(function () {
element = new StyledElements.Notebook();
});

it("throws an exception if button is not a button", function () {
expect(function () {element.addButton(null);}).toThrow(jasmine.any(TypeError));
expect(function () {element.addToEastSection(null);}).toThrow(jasmine.any(TypeError));
});

it("place buttons on the right by default", function () {
const button = new StyledElements.Button();
element.addButton(button);
element.addToEastSection(button);
expect(element.tabWrapper.east.children).toEqual([element.moveRightButton, button]);
});

it("place buttons on the right by default", function () {
const button = new StyledElements.Button();
element.addButton(button, 'right');
element.addToEastSection(button, 'right');
expect(element.tabWrapper.east.children).toEqual([element.moveRightButton, button]);
});

it("should allow to add buttons on the left side", function () {
const button = new StyledElements.Button();
element.addButton(button, 'left');
element.addToEastSection(button, 'left');
expect(element.tabWrapper.west.children).toEqual([button, element.moveLeftButton]);
});
});
Expand Down
231 changes: 229 additions & 2 deletions src/js_tests/wirecloud/WidgetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,61 @@
};
Object.freeze(WIDGET_META_PREFS);

const WIDGET_LAYOUT_CONFIGS = [{
id: 0,
moreOrEqual: 0,
lessOrEqual: 800,
anchor: 'top-left',
relx: true,
rely: true,
left: 0,
top: 0,
zIndex: 0,
relheight: true,
relwidth: true,
height: 1,
width: 1,
minimized: false,
fulldragboard: false,
titlevisible: true
}, {
id: 1,
moreOrEqual: 801,
lessOrEqual: 999,
anchor: 'top-right',
relx: true,
rely: true,
left: 1,
top: 0,
zIndex: 1,
relheight: true,
relwidth: true,
height: 2,
width: 1,
minimized: false,
fulldragboard: true,
titlevisible: true
},
{
id: 2,
moreOrEqual: 1000,
lessOrEqual: -1,
anchor: 'top-left',
relx: true,
rely: true,
left: 0,
top: 0,
zIndex: 0,
relheight: true,
relwidth: true,
height: 1,
width: 1,
minimized: false,
fulldragboard: false,
titlevisible: true
}];
Object.freeze(WIDGET_LAYOUT_CONFIGS);

describe("Wirecloud.Widget", function () {

beforeAll(() => {
Expand Down Expand Up @@ -1764,13 +1819,19 @@
it("updates titlevisible property", (done) => {
const widget = new Wirecloud.Widget(LOCKED_WORKSPACE_TAB, EMPTY_WIDGET_META, {
id: "1",
titlevisible: false
layoutConfigurations: [{
titlevisible: false,
id: 0,
moreOrEqual: 0,
lessOrEqual: -1
}]
});
spyOn(Wirecloud.io, "makeRequest");
expect(widget.titlevisible).toBe(false);

const p = widget.setTitleVisibility(true, false);
expect(widget.titlevisible).toBe(true);
expect(widget.currentLayoutConfig.titlevisible).toBe(true);
expect(Wirecloud.io.makeRequest).not.toHaveBeenCalled();
p.then(
(value) => {
Expand All @@ -1785,7 +1846,12 @@
it("updates titlevisible property on the server", (done) => {
const widget = new Wirecloud.Widget(LOCKED_WORKSPACE_TAB, EMPTY_WIDGET_META, {
id: "1",
titlevisible: false
layoutConfigurations: [{
titlevisible: false,
id: 0,
moreOrEqual: 0,
lessOrEqual: -1
}]
});
spyOn(Wirecloud.io, "makeRequest").and.callFake(function (url, options) {
expect(options.method).toEqual("POST");
Expand All @@ -1796,6 +1862,7 @@
});
});
expect(widget.titlevisible).toBe(false);
expect(widget.currentLayoutConfig.titlevisible).toBe(false);

const p = widget.setTitleVisibility(true, true);
p.then(
Expand Down Expand Up @@ -2239,6 +2306,166 @@

});

describe("updateWindowSize(windowSize)", () => {

it("should update the widget information accordingly", () => {

// Force window size to 800
Object.defineProperty(window, 'innerWidth', {
writable: true,
configurable: true,
value: 750
});

const widget = new Wirecloud.Widget(WORKSPACE_TAB, EMPTY_WIDGET_META, {
id: "1",
layoutConfigurations: WIDGET_LAYOUT_CONFIGS
});

expect(widget.layoutConfigurations).toBe(WIDGET_LAYOUT_CONFIGS);

expect(widget.updateWindowSize(800)).toBe(false);
expect(widget.updateWindowSize(900)).toBe(true);

expect(widget.currentLayoutConfig).toBe(widget.layoutConfigurations[1]);

expect(widget.fulldragboard).toBe(true);
expect(widget.position.z).toBe(1);
expect(widget.shape.height).toBe(2);

expect(widget.updateWindowSize(800)).toBe(true);

expect(widget.currentLayoutConfig).toBe(widget.layoutConfigurations[0]);

expect(widget.fulldragboard).toBe(false);
expect(widget.position.z).toBe(0);
expect(widget.shape.height).toBe(1);

});

});

describe("setLayoutPosition(layoutPosition)", () => {

it("should update the current layout position accordingly", () => {

const widget = new Wirecloud.Widget(WORKSPACE_TAB, EMPTY_WIDGET_META, {
id: "1",
layoutConfigurations: WIDGET_LAYOUT_CONFIGS
});

expect(widget.setLayoutPosition({
anchor: 'top-left',
relx: false,
rely: true,
x: 1,
y: 0,
z: 0
})).toBe(widget);

expect(widget.currentLayoutConfig.left).toBe(1);
expect(widget.currentLayoutConfig.relx).toBe(false);

expect(widget.position.x).toBe(0);
expect(widget.position.relx).toBe(true);

});

});

describe("setLayoutShape(layoutShape)", () => {

it("should update the current layout shape accordingly", () => {

const widget = new Wirecloud.Widget(WORKSPACE_TAB, EMPTY_WIDGET_META, {
id: "1",
layoutConfigurations: WIDGET_LAYOUT_CONFIGS
});

expect(widget.setLayoutShape({
relwidth: false,
relheight: true,
width: 1,
height: 2
})).toBe(widget);

expect(widget.currentLayoutConfig.height).toBe(2);
expect(widget.currentLayoutConfig.relwidth).toBe(false);

expect(widget.shape.height).toBe(1);
expect(widget.shape.relwidth).toBe(true);

});

});

describe("setLayoutIndex(index)", () => {

it("should update the layout accordingly", () => {

const widget = new Wirecloud.Widget(WORKSPACE_TAB, EMPTY_WIDGET_META, {
id: "1",
layoutConfigurations: WIDGET_LAYOUT_CONFIGS
});

expect(widget.setLayoutIndex(3)).toBe(widget);
expect(widget.layout).toBe(3);

widget.setLayoutIndex(1);
expect(widget.layout).toBe(1);
});

});

describe("setLayoutFulldragboard(fulldragboard)", () => {

it("should update the fulldragboard property of the layout accordingly", () => {

const widget = new Wirecloud.Widget(WORKSPACE_TAB, EMPTY_WIDGET_META, {
id: "1",
layoutConfigurations: WIDGET_LAYOUT_CONFIGS
});

expect(widget.setLayoutFulldragboard(true)).toBe(widget);
expect(widget.currentLayoutConfig.fulldragboard).toBe(true);
expect(widget.fulldragboard).toBe(false);
});

});

describe("setLayoutMinimizedStatus(minimized)", () => {

it("should update the minimized property of the layout accordingly", () => {

const widget = new Wirecloud.Widget(WORKSPACE_TAB, EMPTY_WIDGET_META, {
id: "1",
layoutConfigurations: WIDGET_LAYOUT_CONFIGS
});

expect(widget.setLayoutMinimizedStatus(true)).toBe(widget);
expect(widget.minimized).toBe(widget.currentLayoutConfig.minimized);
expect(widget.currentLayoutConfig.minimized).toBe(true);
});

});

describe("getLayoutConfigBySize(size)", () => {

it("should return the layout configuration that fits the given size", () => {

const widget = new Wirecloud.Widget(WORKSPACE_TAB, EMPTY_WIDGET_META, {
id: "1",
layoutConfigurations: WIDGET_LAYOUT_CONFIGS
});

expect(widget.getLayoutConfigBySize(800)).toBe(widget.layoutConfigurations[0]);
expect(widget.getLayoutConfigBySize(900)).toBe(widget.layoutConfigurations[1]);
expect(widget.getLayoutConfigBySize(1000)).toBe(widget.layoutConfigurations[2]);

});

});

});

})();
10 changes: 5 additions & 5 deletions src/js_tests/wirecloud/ui/ColumnLayoutSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@

});

describe("adaptColumnOffset(size)", () => {
describe("adaptColumnOffset(size[, width])", () => {

it("should return 0 LU as minimum", () => {
const layout = new ns.ColumnLayout({leftMargin: 4}, 4, 13, 4, 4, 10);
Expand All @@ -310,7 +310,7 @@

const value = layout.adaptColumnOffset("2px");

expect(layout.fromPixelsToHCells).toHaveBeenCalledWith(0);
expect(layout.fromPixelsToHCells).toHaveBeenCalledWith(0, undefined);
expect(value.inPixels).toBe(0);
expect(value.inLU).toBe(0);
});
Expand All @@ -323,7 +323,7 @@

const value = layout.adaptColumnOffset("204px");

expect(layout.fromPixelsToHCells).toHaveBeenCalledWith(200);
expect(layout.fromPixelsToHCells).toHaveBeenCalledWith(200, undefined);
expect(value.inPixels).toBe(200);
expect(value.inLU).toBe(1);
});
Expand Down Expand Up @@ -563,7 +563,7 @@

});

describe("getColumnOffset(cells[, css])", () => {
describe("getColumnOffset(cells[, width, css])", () => {

it("should work", () => {
const dragboard = {
Expand All @@ -579,7 +579,7 @@
10
);
expect(layout.getColumnOffset({x: 2})).toBe(400 + 4 + 2);
expect(layout.getColumnOffset({x: 2}, true)).toBe("406px");
expect(layout.getColumnOffset({x: 2}, undefined, true)).toBe("406px");
});

});
Expand Down
Loading
Loading