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

Allow to pass in boolean to preventEnterSubmit directive #8639

Merged
merged 11 commits into from
Mar 31, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ angular.module("umbraco.directives")
}

$(element).on("keypress", function (event) {
if (event.which === 13) {
if (event.which === 13 && enabled === true) {
event.preventDefault();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@param {boolean} model Set to <code>true</code> or <code>false</code> to set the checkbox to checked or unchecked.
@param {string} inputId Set the <code>id</code> of the checkbox.
@param {string} text Set the text for the checkbox label.
@param {string} labelKey Set a dictinary/localization string for the checkbox label
@param {string} labelKey Set a dictionary/localization string for the checkbox label
@param {callback} onChange Callback when the value of the checkbox change by interaction.
@param {boolean} autoFocus Add autofocus to the input field
@param {boolean} preventSubmitOnEnter Set the enter prevent directive or not
Expand All @@ -42,13 +42,15 @@
vm.change = change;

function onInit() {
vm.inputId = vm.inputId || "umb-check_" + String.CreateGuid();
vm.inputId = vm.inputId || "umb-search-filter_" + String.CreateGuid();
vm.autoFocus = Object.toBoolean(vm.autoFocus) === true;
vm.preventSubmitOnEnter = Object.toBoolean(vm.preventSubmitOnEnter) === true;

// If a labelKey is passed let's update the returned text if it's does not contain an opening square bracket [
if (vm.labelKey) {
localizationService.localize(vm.labelKey).then(function (data) {
if(data.indexOf('[') === -1){
vm.text = data;
if (data.indexOf('[') === -1){
vm.text = data;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ html .umb-search-filter {
// "icon-search" class it kept for backward compatibility
.umb-icon,
.icon-search {
color: #d8d7d9;
color: @gray-8;
position: absolute;
top: 0;
bottom: 0;
left: 10px;
margin: auto 0;
pointer-events: none;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,14 @@
<div class="umb-search-filter" ng-class="vm.cssClass">
<label for="{{vm.inputId}}" class="sr-only">{{vm.text}}</label>
<umb-icon icon="icon-search" class="icon-search"></umb-icon>
<input
ng-if="vm.preventSubmitOnEnter"
id="{{vm.inputId}}"
type="text"
ng-change="vm.change()"
ng-model="vm.model"
class="umb-search-filter__input"
placeholder="{{vm.text}}"
umb-auto-focus="{{vm.autoFocus === true}}"
prevent-enter-submit
no-dirty-check />

<input
ng-if="!vm.preventSubmitOnEnter"
id="{{vm.inputId}}"
type="text"
ng-change="vm.change()"
ng-model="vm.model"
class="umb-search-filter__input {{vm.cssClass}}"
placeholder="{{vm.text}}"
umb-auto-focus="{{vm.autoFocus === true}}"
no-dirty-check />
<input type="text"
id="{{vm.inputId}}"
ng-change="vm.change()"
ng-model="vm.model"
class="umb-search-filter__input"
placeholder="{{vm.text}}"
umb-auto-focus="{{vm.autoFocus}}"
prevent-enter-submit="{{vm.preventSubmitOnEnter}}"
no-dirty-check />
</div>
</div>