Skip to content

Commit a0b16f5

Browse files
committed
compactField property
1 parent c1a90af commit a0b16f5

File tree

2 files changed

+56
-27
lines changed

2 files changed

+56
-27
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ qx.Class.define("osparc.auth.ui.RequestAccount", {
7777
break;
7878
}
7979

80-
const phone = new osparc.ui.form.IntlTelInput();
80+
const phone = new osparc.ui.form.IntlTelInput().set({
81+
compactField: true,
82+
});
8183
this._form.add(phone, this.tr("Phone Number"), null, "phone");
8284

8385

services/static-webserver/client/source/class/osparc/ui/form/IntlTelInput.js

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
4141
const phoneNumber = this.getChildControl("phone-input-field");
4242
phoneNumber.setHtml(html);
4343
phoneNumber.addListenerOnce("appear", () => this.__convertInputToPhoneInput(), this);
44+
45+
const themeManager = qx.theme.manager.Meta.getInstance();
46+
themeManager.addListener("changeTheme", () => this.__updateStyle());
4447
},
4548

4649
properties: {
@@ -50,21 +53,13 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
5053
nullable: true,
5154
event: "changeValue",
5255
apply: "_applyValue"
53-
}
54-
},
55-
56-
statics: {
57-
updateStyle: function(itiInput, checkIcon) {
58-
const textColor = qx.theme.manager.Color.getInstance().resolve("text");
59-
const bgColor = qx.theme.manager.Color.getInstance().resolve("input_background");
60-
itiInput.a.style["width"] = checkIcon && checkIcon.isVisible() ? "185px" : "215px";
61-
itiInput.a.style["height"] = "26px";
62-
itiInput.a.style["borderWidth"] = "0px";
63-
itiInput.a.style["backgroundColor"] = bgColor;
64-
itiInput.a.style["color"] = textColor;
56+
},
6557

66-
document.documentElement.style.setProperty('--country-list-dropdown-bg', bgColor);
67-
document.documentElement.style.setProperty('--country-list-dropdown-text', textColor);
58+
compactField: {
59+
check: "Boolean",
60+
init: false,
61+
nullable: false,
62+
apply: "__updateStyle",
6863
}
6964
},
7065

@@ -76,19 +71,14 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
7671
let control;
7772
switch (id) {
7873
case "phone-input-field":
79-
control = new qx.ui.embed.Html().set({
80-
marginTop: 2,
81-
marginLeft: 2,
82-
marginRight: 2,
83-
minWidth: 185,
84-
maxHeight: 25
85-
});
74+
control = new qx.ui.embed.Html();
8675
this._add(control, { flex: 1 });
8776
break;
8877
case "feedback-icon":
8978
control = new qx.ui.basic.Image();
79+
control.exclude();
9080
this._add(control);
91-
break
81+
break;
9282
}
9383
return control || this.base(arguments, id);
9484
},
@@ -121,6 +111,7 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
121111

122112
verifyPhoneNumber: function() {
123113
const feedbackIcon = this.getChildControl("feedback-icon");
114+
feedbackIcon.show();
124115
const isValid = this.isValidNumber();
125116
feedbackIcon.set({
126117
toolTipText: "E.164: " + this.getValue(),
@@ -141,7 +132,44 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
141132
toolTipText: errorMsg + ". " + feedbackIcon.getToolTipText()
142133
});
143134
}
144-
this.self().updateStyle(this.__itiInput, feedbackIcon);
135+
this.__updateStyle();
136+
},
137+
138+
__updateStyle: function() {
139+
const phoneNumber = this.getChildControl("phone-input-field");
140+
const itiInput = this.__itiInput;
141+
const feedbackIcon = this.getChildControl("feedback-icon");
142+
const isCompact = this.isCompactField();
143+
144+
const textColor = qx.theme.manager.Color.getInstance().resolve("text");
145+
const bgColor = qx.theme.manager.Color.getInstance().resolve("input_background");
146+
147+
if (isCompact) {
148+
phoneNumber.set({
149+
margin: 0,
150+
minWidth: 185,
151+
maxHeight: 25
152+
});
153+
} else {
154+
phoneNumber.set({
155+
marginTop: 2,
156+
marginLeft: 2,
157+
marginRight: 2,
158+
minWidth: 185,
159+
maxHeight: 25
160+
})
161+
}
162+
163+
if (itiInput) {
164+
itiInput.a.style["width"] = feedbackIcon.isVisible() ? "185px" : "215px";
165+
itiInput.a.style["height"] = "25px";
166+
itiInput.a.style["borderWidth"] = "0px";
167+
itiInput.a.style["backgroundColor"] = isCompact ? "transparent" : bgColor;
168+
itiInput.a.style["color"] = textColor;
169+
}
170+
171+
document.documentElement.style.setProperty('--country-list-dropdown-bg', bgColor);
172+
document.documentElement.style.setProperty('--country-list-dropdown-text', textColor);
145173
},
146174

147175
__convertInputToPhoneInput: function() {
@@ -152,6 +180,7 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
152180
phoneNumber.getContentElement().setStyles({
153181
"overflow": "visible" // needed for countries dropdown menu
154182
});
183+
this.__updateStyle();
155184
};
156185

157186
const intlTelInputLib = osparc.wrapper.IntlTelInput.getInstance();
@@ -178,9 +207,7 @@ qx.Class.define("osparc.ui.form.IntlTelInput", {
178207
preferredCountries: [],
179208
dropdownContainer: document.body,
180209
});
181-
const themeManager = qx.theme.manager.Meta.getInstance();
182-
themeManager.addListener("changeTheme", () => this.self().updateStyle(iti));
183-
this.self().updateStyle(iti);
210+
this.__updateStyle();
184211
return iti;
185212
}
186213
}

0 commit comments

Comments
 (0)