Skip to content

Commit

Permalink
[TS] Fully disable input validation (microsoft#3091)
Browse files Browse the repository at this point in the history
  • Loading branch information
dclaux committed Jun 19, 2019
1 parent d34e4cb commit e21b8aa
Show file tree
Hide file tree
Showing 4 changed files with 1,464 additions and 1,462 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,24 @@ a.ac-anchor:visited:active {
}

.ac-pushButton {
overflow: hidden;
text-overflow: ellipsis;
text-align: center;
vertical-align: middle;
cursor: default;
font-family: "Segoe UI", sans-serif;
font-family: "Calibri", sans-serif;
font-size: 14px;
font-weight: 600;
padding: 4px 10px 5px 10px;
padding: 10px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: none;
background-color: #DDDDDD;
border: 1px solid #DDDDDD;
background-color: #FFFFFF;
color: #0063B1;
}

.ac-pushButton:hover {
background-color: #CCCCCC;
}

.ac-pushButton:active {
background-color: #BABABA;
.ac-pushButton:focus {
border-color: #0063B1;
}

.ac-pushButton.style-positive {
Expand All @@ -118,7 +113,7 @@ a.ac-anchor:visited:active {
text-align: center;
vertical-align: middle;
cursor: default;
font-family: "Segoe UI", sans-serif;
font-family: "Calibri", sans-serif;
font-size: 14px;
font-weight: 600;
-webkit-user-select: none;
Expand All @@ -130,7 +125,7 @@ a.ac-anchor:visited:active {
}

.ac-input {
font-family: "Segoe UI", sans-serif;
font-family: "Calibri", sans-serif;
font-size: 14px;
color: black;
}
Expand Down Expand Up @@ -176,8 +171,8 @@ a.ac-anchor:visited:active {
text-align: center;
vertical-align: middle;
cursor: pointer;
font-family: "Segoe UI", sans-serif;
font-size: 14px;
font-family: "Calibri", sans-serif;
font-size: 13.3px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
Expand Down Expand Up @@ -209,4 +204,4 @@ a.ac-anchor:visited:active {
padding: 8px;
width: 416px;
border-radius: 4px;
}
}
34 changes: 18 additions & 16 deletions source/nodejs/adaptivecards-designer/src/designer-peers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2081,25 +2081,27 @@ export abstract class InputPeer<TInput extends Adaptive.Input> extends TypedCard
this.changed(false);
}

let validationNecessity = addLabelAndInput(card, "Necessity:", Adaptive.ChoiceSetInput);
validationNecessity.input.isCompact = true;
validationNecessity.input.choices.push(new Adaptive.Choice("Optional", Adaptive.InputValidationNecessity.Optional.toString()));
validationNecessity.input.choices.push(new Adaptive.Choice("Required", Adaptive.InputValidationNecessity.Required.toString()));
validationNecessity.input.choices.push(new Adaptive.Choice("Required with visual cue", Adaptive.InputValidationNecessity.RequiredWithVisualCue.toString()));
validationNecessity.input.defaultValue = this.cardElement.validation.necessity.toString();
validationNecessity.input.onValueChanged = () => {
this.cardElement.validation.necessity = <Adaptive.InputValidationNecessity>parseInt(validationNecessity.input.value);
if (Adaptive.AdaptiveCard.useBuiltInInputValidation) {
let validationNecessity = addLabelAndInput(card, "Necessity:", Adaptive.ChoiceSetInput);
validationNecessity.input.isCompact = true;
validationNecessity.input.choices.push(new Adaptive.Choice("Optional", Adaptive.InputValidationNecessity.Optional.toString()));
validationNecessity.input.choices.push(new Adaptive.Choice("Required", Adaptive.InputValidationNecessity.Required.toString()));
validationNecessity.input.choices.push(new Adaptive.Choice("Required with visual cue", Adaptive.InputValidationNecessity.RequiredWithVisualCue.toString()));
validationNecessity.input.defaultValue = this.cardElement.validation.necessity.toString();
validationNecessity.input.onValueChanged = () => {
this.cardElement.validation.necessity = <Adaptive.InputValidationNecessity>parseInt(validationNecessity.input.value);

this.changed(false);
}
this.changed(false);
}

let validationErrorMessage = addLabelAndInput(card, "Error message:", Adaptive.TextInput);
validationErrorMessage.input.placeholder = "(not set)";
validationErrorMessage.input.defaultValue = this.cardElement.validation.errorMessage;
validationErrorMessage.input.onValueChanged = () => {
this.cardElement.validation.errorMessage = validationErrorMessage.input.value;
let validationErrorMessage = addLabelAndInput(card, "Error message:", Adaptive.TextInput);
validationErrorMessage.input.placeholder = "(not set)";
validationErrorMessage.input.defaultValue = this.cardElement.validation.errorMessage;
validationErrorMessage.input.onValueChanged = () => {
this.cardElement.validation.errorMessage = validationErrorMessage.input.value;

this.changed(false);
this.changed(false);
}
}
}

Expand Down
15 changes: 10 additions & 5 deletions source/nodejs/adaptivecards/src/card-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2743,7 +2743,7 @@ export abstract class Input extends CardElement implements Shared.IInput {
this._renderedInputControlElement = this.internalRender();
this._renderedInputControlElement.style.minWidth = "0px";

if (this.isNullable && this.validation.necessity == Enums.InputValidationNecessity.RequiredWithVisualCue) {
if (AdaptiveCard.useBuiltInInputValidation && this.isNullable && this.validation.necessity == Enums.InputValidationNecessity.RequiredWithVisualCue) {
this._renderedInputControlElement.classList.add(hostConfig.makeCssClassName("ac-input-required"));
}

Expand Down Expand Up @@ -2803,7 +2803,10 @@ export abstract class Input extends CardElement implements Shared.IInput {

Utils.setProperty(result, "title", this.title);
Utils.setProperty(result, "value", this.renderedElement && !Utils.isNullOrEmpty(this.value) ? this.value : this.defaultValue);
Utils.setProperty(result, "validation", this.validation.toJSON());

if (AdaptiveCard.useBuiltInInputValidation) {
Utils.setProperty(result, "validation", this.validation.toJSON());
}

return result;
}
Expand Down Expand Up @@ -2846,10 +2849,12 @@ export abstract class Input extends CardElement implements Shared.IInput {
this.id = Utils.getStringValue(json["id"]);
this.defaultValue = Utils.getStringValue(json["value"]);

let jsonValidation = json["validation"];
if (AdaptiveCard.useBuiltInInputValidation) {
let jsonValidation = json["validation"];

if (jsonValidation) {
this.validation.parse(jsonValidation);
if (jsonValidation) {
this.validation.parse(jsonValidation);
}
}
}

Expand Down
Loading

0 comments on commit e21b8aa

Please sign in to comment.