Skip to content

Commit 8129783

Browse files
odeimaizjsaq007
authored andcommitted
🎨 [Frontend] App mode: Scrollable Instructions (ITISFoundation#6430)
1 parent 93dbcb3 commit 8129783

File tree

5 files changed

+65
-21
lines changed

5 files changed

+65
-21
lines changed

services/static-webserver/client/source/class/osparc/CookiePolicy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ qx.Class.define("osparc.CookiePolicy", {
6666
return link;
6767
},
6868

69-
getZMTEULALink: function(linkText = "end users license agreement (EULA)") {
69+
getZMTEULALink: function(linkText = "end-users license agreement (EULA)") {
7070
const color = qx.theme.manager.Color.getInstance().resolve("text");
7171
const link = `<a href='https://zurichmedtech.github.io/s4l-manual/#/docs/licensing/copyright_Sim4Life?id=zurich-medtech-ag-zmt' style='color: ${color}' target='_blank''>${linkText}</a>`;
7272
return link;

services/static-webserver/client/source/class/osparc/auth/ui/RequestAccount.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,21 @@ qx.Class.define("osparc.auth.ui.RequestAccount", {
129129
rich: true
130130
});
131131
country.add(cItem);
132-
})
132+
});
133+
// preselect
133134
fetch("https://ipapi.co/json")
134135
.then(res => res.json())
135136
.then(data => {
136137
const countryFound = country.getSelectables().find(c => c.getModel().toUpperCase() === data.country_code.toUpperCase());
137138
if (countryFound) {
138139
country.setSelection([countryFound])
139140
}
141+
})
142+
.catch(err => {
143+
console.error(err);
144+
const emptyItem = new qx.ui.form.ListItem("", null, "");
145+
country.add(emptyItem);
146+
country.setSelection([emptyItem]);
140147
});
141148
this._form.add(country, this.tr("Country"), null, "country");
142149

@@ -321,7 +328,7 @@ qx.Class.define("osparc.auth.ui.RequestAccount", {
321328

322329
// Eula link
323330
if (osparc.product.Utils.getProductName() !== "osparc") {
324-
const eulaLink = osparc.CookiePolicy.getZMTEULALink("end users license agreement (EULA)");
331+
const eulaLink = osparc.CookiePolicy.getZMTEULALink("end-users license agreement (EULA)");
325332
const eulaText = "I accept the " + eulaLink + " and I will use the product in accordance with it";
326333
const eula = new qx.ui.form.CheckBox().set({
327334
required: true,

services/static-webserver/client/source/class/osparc/node/slideshow/BaseNodeView.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,20 +235,20 @@ qx.Class.define("osparc.node.slideshow.BaseNodeView", {
235235
}
236236
const desc = this.getNode().getSlideshowInstructions();
237237
if (desc) {
238-
const descView = new osparc.ui.markdown.Markdown().set({
238+
const markdownInstructions = new osparc.ui.markdown.Markdown().set({
239239
value: desc,
240240
padding: 3,
241241
font: "text-14"
242242
});
243-
const scrollContainer = new qx.ui.container.Scroll();
244-
scrollContainer.add(descView);
245243
const title = this.tr("Instructions") + " - " + this.getNode().getLabel();
246-
const width = 500;
247-
const height = 500;
248-
const win = this.__instructionsWindow = osparc.ui.window.Window.popUpInWindow(scrollContainer, title, width, height).set({
244+
const width = 600;
245+
const minHeight = 200;
246+
const win = this.__instructionsWindow = osparc.ui.window.Window.popUpInWindow(markdownInstructions, title, width, minHeight).set({
249247
modal: false,
250248
clickAwayClose: false
251249
});
250+
markdownInstructions.addListener("resized", () => win.center());
251+
252252
win.getContentElement().setStyles({
253253
"border-color": qx.theme.manager.Color.getInstance().resolve("strong-main")
254254
});

services/static-webserver/client/source/class/osparc/product/quickStart/tis/Slides.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ qx.Class.define("osparc.product.quickStart.tis.Slides", {
2626
footerLinks: function() {
2727
const footerLinks = [];
2828

29-
const videoText = osparc.utils.Utils.createHTMLLink("TIP video", "https://youtu.be/-ZE6yOJ3ipw");
29+
const videoText = osparc.utils.Utils.createHTMLLink("TIP videos", "https://www.youtube.com/playlist?list=PLcJQYcVCSqDu5gXnJj-_vS_spGhZOe-jF");
3030
const videoLabel = new qx.ui.basic.Label(videoText).set({
3131
textAlign: "center",
3232
rich : true

services/static-webserver/client/source/class/osparc/ui/markdown/Markdown.js

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ qx.Class.define("osparc.ui.markdown.Markdown", {
7171
}
7272
},
7373

74+
events: {
75+
"resized": "qx.event.type.Event",
76+
},
77+
7478
members: {
7579
__loadMarked: null,
7680
/**
@@ -138,7 +142,26 @@ qx.Class.define("osparc.ui.markdown.Markdown", {
138142
} else {
139143
this.setMinHeight(elemHeight);
140144
}
145+
146+
const elemMaxWidth = this.__getChildrenElementMaxWidth(domElement.children);
147+
if (this.getMaxWidth() && elemMaxWidth > this.getMaxWidth()) {
148+
this.setWidth(elemMaxWidth);
149+
} else {
150+
this.setMinWidth(elemMaxWidth);
151+
}
141152
}
153+
this.fireEvent("resized");
154+
},
155+
156+
__getDomElement: function() {
157+
if (!this.getContentElement || this.getContentElement() === null) {
158+
return null;
159+
}
160+
const domElement = this.getContentElement().getDomElement();
161+
if (domElement) {
162+
return domElement;
163+
}
164+
return null;
142165
},
143166

144167
__getChildrenElementHeight: function(children) {
@@ -155,23 +178,37 @@ qx.Class.define("osparc.ui.markdown.Markdown", {
155178
if (this.getNoMargin()) {
156179
element.style.marginTop = 0;
157180
element.style.marginBottom = 0;
158-
const size = qx.bom.element.Dimension.getSize(element);
181+
const size = this.__getElementSize(element);
159182
return size.height;
160183
}
161-
const size = qx.bom.element.Dimension.getSize(element);
184+
const size = this.__getElementSize(element);
162185
// add padding
163-
return size.height + 15;
186+
return size.height + 20;
164187
},
165188

166-
__getDomElement: function() {
167-
if (!this.getContentElement || this.getContentElement() === null) {
168-
return null;
189+
__getChildrenElementMaxWidth: function(children) {
190+
let maxWidth = 0;
191+
for (let i=0; i < children.length; i++) {
192+
maxWidth = Math.max(this.__getElementWidth(children[i]), maxWidth);
169193
}
170-
const domElement = this.getContentElement().getDomElement();
171-
if (domElement) {
172-
return domElement;
194+
return maxWidth;
195+
},
196+
197+
__getElementWidth: function(element) {
198+
const size = this.__getElementSize(element);
199+
return size.width;
200+
},
201+
202+
__getElementSize: function(element) {
203+
if (
204+
element &&
205+
element.children &&
206+
element.children.length &&
207+
element.children[0].localName === "img"
208+
) {
209+
return qx.bom.element.Dimension.getSize(element.children[0]);
173210
}
174-
return null;
175-
}
211+
return qx.bom.element.Dimension.getSize(element);
212+
},
176213
}
177214
});

0 commit comments

Comments
 (0)