-
Notifications
You must be signed in to change notification settings - Fork 649
add showConditional expressions and conditional disabling #180
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
Closed
littlemaneuver
wants to merge
1
commit into
json-schema-form:development
from
littlemaneuver:feature/conditional-questions
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
coverage | ||
bower_components | ||
./idea |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,10 @@ | |
{ | ||
"key": "comment", | ||
"type": "textarea", | ||
"placeholder": "Make a comment" | ||
"placeholder": "Make a comment", | ||
"dependencies": ["name", "email"], | ||
"expression": "name === 'secret'", | ||
"disabledExpression": "email === '[email protected]'" | ||
}, | ||
{ | ||
"type": "submit", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var gulp = require('gulp'), | ||
karma = require('gulp-karma'); | ||
|
||
gulp.task('test', function() { | ||
return gulp.src([ | ||
'bower_components/jquery/dist/jquery.min.js', | ||
'test/lib/angular.js', | ||
'test/lib/angular-mocks.js', | ||
'bower_components/tv4/tv4.js', | ||
'bower_components/objectpath/lib/ObjectPath.js', | ||
'src/module.js', | ||
'src/sfPath.js', | ||
'src/services/*.js', | ||
'src/directives/*.js', | ||
'src/directives/decorators/bootstrap/*.js', | ||
'src/**/*.html', | ||
'test/services/schema-form-test.js', | ||
'test/services/decorators-test.js', | ||
'test/directives/schema-form-test.js']) | ||
.pipe(karma({ | ||
configFile: 'karma.conf.js', | ||
action: 'run' | ||
})) | ||
.on('error', function(err) { | ||
throw err; | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<div class="btn-group"> | ||
<div class="btn-group" ng-show="showCondition()"> | ||
<input ng-repeat-start="item in form.items" | ||
type="submit" | ||
class="btn {{ item.style || 'btn-primary' }}" | ||
value="{{item.title}}" | ||
ng-if="item.type === 'submit'"> | ||
<button ng-repeat-end class="btn {{ item.style || 'btn-default' }}" | ||
type="button" | ||
ng-disabled="form.readonly" | ||
ng-disabled="form.readonly || disabledElement()" | ||
ng-if="item.type !== 'submit'" | ||
ng-click="buttonClick($event,item)">{{item.title}}</button> | ||
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<div class="helpvalue" ng-bind-html="form.helpvalue"></div> | ||
<div class="helpvalue" ng-bind-html="form.helpvalue" ng-show="showCondition()"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Changing the actual schema is not something we can do, either it is required or it's not.
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.
Yes, I fill awkward for this part. But maybe you can give me an advice, how to handle better situation when field is required only if it is visible. Don't you?
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.
This is kind of a restriction we have by using JSON Schema. It becomes a bit complicated when your validation scenario is hard to describe with a JSON Schema.
What you can do is to re-redraw the form by changing the schema or the form definition, but change the entire schema/form instance (i.e. use angular.copy), otherwise it won't trigger a redraw of the form.
A bit more correct solution would be to use
oneOf
,anyOf
etc and that way you might be able to describe the validation you need from within the schema, but sadly we lack support for those.Could you give some more specifics on what such a situation might be? There might be some other way to solve it.