-
Notifications
You must be signed in to change notification settings - Fork 38
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
Fixes #8763: When the conditions contain spaces, there are kept and the generated file is invalid #429
Conversation
@@ -257,7 +258,7 @@ <h4 class="panel-title"> | |||
<span class="glyphicon glyphicon-plus-sign" style="margin-right:5px"></span> | |||
Add methods | |||
</div> | |||
<button ng-disabled="editForm.$pending || editForm.$invalid || CForm.form.$invalid || checkSelectedTechnique()" class="btn btn-default pull-right" ng-click="saveTechnique()">Save</button> | |||
<button ng-disabled="editForm.$pending || editForm.$invalid || CForm.form.$invalid || checkSelectedTechnique() || selectedMethod.advanced_class.indexOf(' ')>0 || CForm.versionForm.$invalid" class="btn btn-default pull-right" ng-click="saveTechnique()">Save</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YOu should not add the check on wetherit contains a space or not, but be based on the fact that Cform.form is $invalid (check advanced class input with a patter)
<input type="text" name="cfClasses" id="advanced" class="form-control" ng-change="updateClassContext()" ng-model="selectedMethod.advanced_class" placeholder=""> | ||
<div class="form-group condition-form" ng-class="{'has-error':selectedMethod.advanced_class.indexOf(' ')>0}"> | ||
<label class="control-label" for="advanced">Other CFEngine classes:</label> | ||
<input type="text" class="form-control" name="cfClasses" id="advanced" aria-describedby="helpBlock" ng-change="updateClassContext()" ng-model="selectedMethod.advanced_class" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add a ng-pattern here to check the input ( value should be ng-pattern="/^\S+$/" ) and then you can use angular form validation
<div class="form-group condition-form"> | ||
<label for="advanced">Other CFEngine classes:</label> | ||
<input type="text" name="cfClasses" id="advanced" class="form-control" ng-change="updateClassContext()" ng-model="selectedMethod.advanced_class" placeholder=""> | ||
<div class="form-group condition-form" ng-class="{'has-error':selectedMethod.advanced_class.indexOf(' ')>0}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With angular validation you don't need to have the ng-class
<div class="form-group condition-form" ng-class="{'has-error':selectedMethod.advanced_class.indexOf(' ')>0}"> | ||
<label class="control-label" for="advanced">Other CFEngine classes:</label> | ||
<input type="text" class="form-control" name="cfClasses" id="advanced" aria-describedby="helpBlock" ng-change="updateClassContext()" ng-model="selectedMethod.advanced_class" > | ||
<span id="helpBlock" class="help-block" ng-show="selectedMethod.advanced_class.indexOf(' ')>0"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you use a ng-message here
…he generated file is invalid
5a52f4b
to
8e39272
Compare
PR updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greate ! Merging this PR!
OK, merging this PR |
https://www.rudder-project.org/redmine/issues/8763