Skip to content

Commit bc3acc1

Browse files
authored
🎨 [Frontend] ViP Market: force accept Terms and Conditions (#7239)
1 parent 77ed00a commit bc3acc1

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

services/static-webserver/client/source/class/osparc/study/PricingUnitLicense.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ qx.Class.define("osparc.study.PricingUnitLicense", {
2929
nullable: true,
3030
event: "changeShowRentButton"
3131
},
32+
33+
licenseUrl: {
34+
check: "String",
35+
init: false,
36+
nullable: true,
37+
event: "changeLicenseUrl"
38+
},
3239
},
3340

3441
statics: {
@@ -94,12 +101,38 @@ qx.Class.define("osparc.study.PricingUnitLicense", {
94101
caption: this.tr("Rent"),
95102
confirmText: this.tr("Rent"),
96103
});
104+
105+
if (this.getLicenseUrl()) {
106+
const useCacheCB = new qx.ui.form.CheckBox().set({
107+
value: false,
108+
label: this.tr("Accept <u>Terms and Conditions</u>"),
109+
rich: true,
110+
});
111+
useCacheCB.getChildControl("label").set({
112+
anonymous: false,
113+
cursor: "pointer",
114+
});
115+
useCacheCB.getChildControl("label").addListener("tap", () => this.__openLicense());
116+
confirmationWin.addWidget(useCacheCB);
117+
confirmationWin.getExtraWidgetsLayout().setPaddingTop(0); // reset paddingTop
118+
useCacheCB.bind("value", confirmationWin.getConfirmButton(), "enabled");
119+
}
120+
97121
confirmationWin.open();
98122
confirmationWin.addListener("close", () => {
99123
if (confirmationWin.getConfirmed()) {
100124
this.fireEvent("rentPricingUnit");
101125
}
102126
}, this);
103127
},
128+
129+
__openLicense: function() {
130+
const mdWindow = new osparc.ui.markdown.MarkdownWindow(this.getLicenseUrl()).set({
131+
caption: this.tr("Terms and Conditions"),
132+
width: 800,
133+
height: 600,
134+
});
135+
mdWindow.open();
136+
},
104137
}
105138
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* oSPARC - The SIMCORE frontend - https://osparc.io
3+
* Copyright: 2025 IT'IS Foundation - https://itis.swiss
4+
* License: MIT - https://opensource.org/licenses/MIT
5+
* Authors: Odei Maiz (odeimaiz)
6+
*/
7+
8+
qx.Class.define("osparc.ui.markdown.MarkdownWindow", {
9+
extend: osparc.ui.window.Window,
10+
11+
construct: function(markdownUrl) {
12+
this.base(arguments);
13+
14+
this.set({
15+
layout: new qx.ui.layout.VBox(),
16+
resizable: true,
17+
showMaximize: false,
18+
showMinimize: false,
19+
centerOnAppear: true,
20+
clickAwayClose: true,
21+
modal: true
22+
});
23+
24+
const markdown = new osparc.ui.markdown.Markdown().set({
25+
padding: 15,
26+
});
27+
const scrollContainer = new qx.ui.container.Scroll();
28+
scrollContainer.add(markdown);
29+
this._add(scrollContainer, {
30+
flex: 1,
31+
});
32+
33+
if (markdownUrl) {
34+
fetch(markdownUrl)
35+
.then(res => res.text())
36+
.then(text => markdown.setValue(text));
37+
}
38+
},
39+
});

services/static-webserver/client/source/class/osparc/ui/window/Dialog.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ qx.Class.define("osparc.ui.window.Dialog", {
100100
this.__extraWidgetsLayout.add(widget);
101101
},
102102

103+
getExtraWidgetsLayout: function() {
104+
return this.__extraWidgetsLayout;
105+
},
106+
103107
/**
104108
* Adds a button to the dialog.
105109
* @param {qx.ui.form.Button} button Button that will be added to the bottom bar of the dialog.

services/static-webserver/client/source/class/osparc/vipMarket/AnatomicalModelDetails.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ qx.Class.define("osparc.vipMarket.AnatomicalModelDetails", {
341341
});
342342
const pUnit = new osparc.study.PricingUnitLicense(pricingUnit).set({
343343
showRentButton: true,
344+
licenseUrl: licensedItemData["termsOfUseUrl"],
344345
});
345346
pUnit.addListener("rentPricingUnit", () => {
346347
this.fireDataEvent("modelPurchaseRequested", {

0 commit comments

Comments
 (0)