{"action":"created","comment":{"url":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/comments/24244220","id":24244220,"diff_hunk":"@@ -226,6 +231,67 @@ angular.module('schemaForm').provider('schemaFormDecorators',\n               }\n             };\n \n+            var evalExpression = function (expression) {\n+              angular.forEach(scope.form.dependencies, function (key) {\n+                expression = expression.replace(key, lookupForKey(key));\n+              });\n+\n+              return scope.$eval(expression);\n+            };\n+\n+\n+            var resetModelValue = function () {\n+              if (scope.ngModel) {\n+                scope.ngModel.$setViewValue(undefined);\n+                scope.ngModel.$render();\n+                scope.ngModel.$setPristine();\n+              }\n+            };\n+\n+            scope.showCondition = function () {\n+              var expressionString = scope.form.expression;\n+              if (angular.isUndefined(expressionString)) {\n+                return true;\n+              }\n+\n+              var show = evalExpression(expressionString);\n+\n+              if (angular.isDefined(scope.form.required)) {\n+                scope.form.required = show;\n+                scope.form.schema.required = show;\n+              }\n+\n+\n+              if (scope.form.key && !show) {\n+                resetModelValue();\n+              }\n+\n+              return show;\n+\n+            };\n+\n+\n+            scope.disabledElement = function () {\n+              var expressionString = scope.form.disabledExpression;\n+\n+              if (angular.isUndefined(expressionString)) {\n+                return false;\n+              }\n+\n+              var disabled = evalExpression(expressionString);\n+\n+              if (angular.isDefined(scope.form.required)) {\n+                scope.form.required = !disabled;\n+                scope.form.schema.required = !disabled;","path":"dist/schema-form.js","position":67,"original_position":67,"commit_id":"6ce423d2aacf4c8a9a66ba7aeceffada929ecb04","original_commit_id":"6ce423d2aacf4c8a9a66ba7aeceffada929ecb04","user":{"login":"davidlgj","id":151694,"avatar_url":"https://avatars.githubusercontent.com/u/151694?v=3","gravatar_id":"","url":"https://api.github.com/users/davidlgj","html_url":"https://github.com/davidlgj","followers_url":"https://api.github.com/users/davidlgj/followers","following_url":"https://api.github.com/users/davidlgj/following{/other_user}","gists_url":"https://api.github.com/users/davidlgj/gists{/gist_id}","starred_url":"https://api.github.com/users/davidlgj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidlgj/subscriptions","organizations_url":"https://api.github.com/users/davidlgj/orgs","repos_url":"https://api.github.com/users/davidlgj/repos","events_url":"https://api.github.com/users/davidlgj/events{/privacy}","received_events_url":"https://api.github.com/users/davidlgj/received_events","type":"User","site_admin":false},"body":"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.\r\n\r\nWhat 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. \r\n\r\nA 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. \r\n\r\nCould you give some more specifics on what such a situation might be? There might be some other way to solve it.","created_at":"2015-02-06T14:47:20Z","updated_at":"2015-02-06T14:47:20Z","html_url":"https://github.com/Textalk/angular-schema-form/pull/180#discussion_r24244220","pull_request_url":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/180","_links":{"self":{"href":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/comments/24244220"},"html":{"href":"https://github.com/Textalk/angular-schema-form/pull/180#discussion_r24244220"},"pull_request":{"href":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/180"}}},"pull_request":{"url":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/180","id":25439976,"html_url":"https://github.com/Textalk/angular-schema-form/pull/180","diff_url":"https://github.com/Textalk/angular-schema-form/pull/180.diff","patch_url":"https://github.com/Textalk/angular-schema-form/pull/180.patch","issue_url":"https://api.github.com/repos/Textalk/angular-schema-form/issues/180","number":180,"state":"closed","locked":false,"title":"add showConditional expressions and conditional disabling","user":{"login":"antoniopuero","id":1562509,"avatar_url":"https://avatars.githubusercontent.com/u/1562509?v=3","gravatar_id":"","url":"https://api.github.com/users/antoniopuero","html_url":"https://github.com/antoniopuero","followers_url":"https://api.github.com/users/antoniopuero/followers","following_url":"https://api.github.com/users/antoniopuero/following{/other_user}","gists_url":"https://api.github.com/users/antoniopuero/gists{/gist_id}","starred_url":"https://api.github.com/users/antoniopuero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antoniopuero/subscriptions","organizations_url":"https://api.github.com/users/antoniopuero/orgs","repos_url":"https://api.github.com/users/antoniopuero/repos","events_url":"https://api.github.com/users/antoniopuero/events{/privacy}","received_events_url":"https://api.github.com/users/antoniopuero/received_events","type":"User","site_admin":false},"body":"Added more complex logic for hiding or showing any element of the form. Also conditional disabling, not only through static readonly property.\r\nBut there're two lines which were unexpectedly added to the pr,\r\n+              if (part.key && part.schema && angular.isDefined(part.schema['default'])) {\r\n-                sfSelect(part.key, scope.model, part['default']);\t\t\r\n+                sfSelect(part.key, scope.model, part.schema['default']);\r\n and I can't figure out why they are there.\r\n\r\nAlso, it's kinda hard to write/read your spec :(","created_at":"2014-12-03T18:22:02Z","updated_at":"2015-02-06T14:47:20Z","closed_at":"2015-02-06T08:34:56Z","merged_at":null,"merge_commit_sha":"5cff107f577d97d0560a13079f5e7d8a51b8a963","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/180/commits","review_comments_url":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/180/comments","review_comment_url":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Textalk/angular-schema-form/issues/180/comments","statuses_url":"https://api.github.com/repos/Textalk/angular-schema-form/statuses/6ce423d2aacf4c8a9a66ba7aeceffada929ecb04","head":{"label":"antoniopuero:feature/conditional-questions","ref":"feature/conditional-questions","sha":"6ce423d2aacf4c8a9a66ba7aeceffada929ecb04","user":{"login":"antoniopuero","id":1562509,"avatar_url":"https://avatars.githubusercontent.com/u/1562509?v=3","gravatar_id":"","url":"https://api.github.com/users/antoniopuero","html_url":"https://github.com/antoniopuero","followers_url":"https://api.github.com/users/antoniopuero/followers","following_url":"https://api.github.com/users/antoniopuero/following{/other_user}","gists_url":"https://api.github.com/users/antoniopuero/gists{/gist_id}","starred_url":"https://api.github.com/users/antoniopuero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antoniopuero/subscriptions","organizations_url":"https://api.github.com/users/antoniopuero/orgs","repos_url":"https://api.github.com/users/antoniopuero/repos","events_url":"https://api.github.com/users/antoniopuero/events{/privacy}","received_events_url":"https://api.github.com/users/antoniopuero/received_events","type":"User","site_admin":false},"repo":{"id":27496907,"name":"angular-schema-form","full_name":"antoniopuero/angular-schema-form","owner":{"login":"antoniopuero","id":1562509,"avatar_url":"https://avatars.githubusercontent.com/u/1562509?v=3","gravatar_id":"","url":"https://api.github.com/users/antoniopuero","html_url":"https://github.com/antoniopuero","followers_url":"https://api.github.com/users/antoniopuero/followers","following_url":"https://api.github.com/users/antoniopuero/following{/other_user}","gists_url":"https://api.github.com/users/antoniopuero/gists{/gist_id}","starred_url":"https://api.github.com/users/antoniopuero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antoniopuero/subscriptions","organizations_url":"https://api.github.com/users/antoniopuero/orgs","repos_url":"https://api.github.com/users/antoniopuero/repos","events_url":"https://api.github.com/users/antoniopuero/events{/privacy}","received_events_url":"https://api.github.com/users/antoniopuero/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/antoniopuero/angular-schema-form","description":"Generate forms from a JSON schema, with AngularJS!","fork":true,"url":"https://api.github.com/repos/antoniopuero/angular-schema-form","forks_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/forks","keys_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/keys{/key_id}","collaborators_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/teams","hooks_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/hooks","issue_events_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/issues/events{/number}","events_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/events","assignees_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/assignees{/user}","branches_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/branches{/branch}","tags_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/tags","blobs_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/git/refs{/sha}","trees_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/git/trees{/sha}","statuses_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/statuses/{sha}","languages_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/languages","stargazers_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/stargazers","contributors_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/contributors","subscribers_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/subscribers","subscription_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/subscription","commits_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/commits{/sha}","git_commits_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/git/commits{/sha}","comments_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/comments{/number}","issue_comment_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/issues/comments/{number}","contents_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/contents/{+path}","compare_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/compare/{base}...{head}","merges_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/merges","archive_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/downloads","issues_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/issues{/number}","pulls_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/pulls{/number}","milestones_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/milestones{/number}","notifications_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/labels{/name}","releases_url":"https://api.github.com/repos/antoniopuero/angular-schema-form/releases{/id}","created_at":"2014-12-03T16:42:29Z","updated_at":"2014-12-03T16:42:29Z","pushed_at":"2014-12-03T18:11:44Z","git_url":"git://github.com/antoniopuero/angular-schema-form.git","ssh_url":"git@github.com:antoniopuero/angular-schema-form.git","clone_url":"https://github.com/antoniopuero/angular-schema-form.git","svn_url":"https://github.com/antoniopuero/angular-schema-form","homepage":null,"size":7100,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Textalk:development","ref":"development","sha":"84a2b04ade36dc90de903cb2b4db472c4cbdba07","user":{"login":"Textalk","id":1212324,"avatar_url":"https://avatars.githubusercontent.com/u/1212324?v=3","gravatar_id":"","url":"https://api.github.com/users/Textalk","html_url":"https://github.com/Textalk","followers_url":"https://api.github.com/users/Textalk/followers","following_url":"https://api.github.com/users/Textalk/following{/other_user}","gists_url":"https://api.github.com/users/Textalk/gists{/gist_id}","starred_url":"https://api.github.com/users/Textalk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Textalk/subscriptions","organizations_url":"https://api.github.com/users/Textalk/orgs","repos_url":"https://api.github.com/users/Textalk/repos","events_url":"https://api.github.com/users/Textalk/events{/privacy}","received_events_url":"https://api.github.com/users/Textalk/received_events","type":"Organization","site_admin":false},"repo":{"id":18065797,"name":"angular-schema-form","full_name":"Textalk/angular-schema-form","owner":{"login":"Textalk","id":1212324,"avatar_url":"https://avatars.githubusercontent.com/u/1212324?v=3","gravatar_id":"","url":"https://api.github.com/users/Textalk","html_url":"https://github.com/Textalk","followers_url":"https://api.github.com/users/Textalk/followers","following_url":"https://api.github.com/users/Textalk/following{/other_user}","gists_url":"https://api.github.com/users/Textalk/gists{/gist_id}","starred_url":"https://api.github.com/users/Textalk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Textalk/subscriptions","organizations_url":"https://api.github.com/users/Textalk/orgs","repos_url":"https://api.github.com/users/Textalk/repos","events_url":"https://api.github.com/users/Textalk/events{/privacy}","received_events_url":"https://api.github.com/users/Textalk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Textalk/angular-schema-form","description":"Generate forms from a JSON schema, with AngularJS! ","fork":false,"url":"https://api.github.com/repos/Textalk/angular-schema-form","forks_url":"https://api.github.com/repos/Textalk/angular-schema-form/forks","keys_url":"https://api.github.com/repos/Textalk/angular-schema-form/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Textalk/angular-schema-form/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Textalk/angular-schema-form/teams","hooks_url":"https://api.github.com/repos/Textalk/angular-schema-form/hooks","issue_events_url":"https://api.github.com/repos/Textalk/angular-schema-form/issues/events{/number}","events_url":"https://api.github.com/repos/Textalk/angular-schema-form/events","assignees_url":"https://api.github.com/repos/Textalk/angular-schema-form/assignees{/user}","branches_url":"https://api.github.com/repos/Textalk/angular-schema-form/branches{/branch}","tags_url":"https://api.github.com/repos/Textalk/angular-schema-form/tags","blobs_url":"https://api.github.com/repos/Textalk/angular-schema-form/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Textalk/angular-schema-form/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Textalk/angular-schema-form/git/refs{/sha}","trees_url":"https://api.github.com/repos/Textalk/angular-schema-form/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Textalk/angular-schema-form/statuses/{sha}","languages_url":"https://api.github.com/repos/Textalk/angular-schema-form/languages","stargazers_url":"https://api.github.com/repos/Textalk/angular-schema-form/stargazers","contributors_url":"https://api.github.com/repos/Textalk/angular-schema-form/contributors","subscribers_url":"https://api.github.com/repos/Textalk/angular-schema-form/subscribers","subscription_url":"https://api.github.com/repos/Textalk/angular-schema-form/subscription","commits_url":"https://api.github.com/repos/Textalk/angular-schema-form/commits{/sha}","git_commits_url":"https://api.github.com/repos/Textalk/angular-schema-form/git/commits{/sha}","comments_url":"https://api.github.com/repos/Textalk/angular-schema-form/comments{/number}","issue_comment_url":"https://api.github.com/repos/Textalk/angular-schema-form/issues/comments/{number}","contents_url":"https://api.github.com/repos/Textalk/angular-schema-form/contents/{+path}","compare_url":"https://api.github.com/repos/Textalk/angular-schema-form/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Textalk/angular-schema-form/merges","archive_url":"https://api.github.com/repos/Textalk/angular-schema-form/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Textalk/angular-schema-form/downloads","issues_url":"https://api.github.com/repos/Textalk/angular-schema-form/issues{/number}","pulls_url":"https://api.github.com/repos/Textalk/angular-schema-form/pulls{/number}","milestones_url":"https://api.github.com/repos/Textalk/angular-schema-form/milestones{/number}","notifications_url":"https://api.github.com/repos/Textalk/angular-schema-form/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Textalk/angular-schema-form/labels{/name}","releases_url":"https://api.github.com/repos/Textalk/angular-schema-form/releases{/id}","created_at":"2014-03-24T14:42:43Z","updated_at":"2015-02-06T14:34:38Z","pushed_at":"2015-02-06T14:34:42Z","git_url":"git://github.com/Textalk/angular-schema-form.git","ssh_url":"git@github.com:Textalk/angular-schema-form.git","clone_url":"https://github.com/Textalk/angular-schema-form.git","svn_url":"https://github.com/Textalk/angular-schema-form","homepage":"http://textalk.github.io/angular-schema-form/","size":8445,"stargazers_count":456,"watchers_count":456,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":126,"mirror_url":null,"open_issues_count":49,"forks":126,"open_issues":49,"watchers":456,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/180"},"html":{"href":"https://github.com/Textalk/angular-schema-form/pull/180"},"issue":{"href":"https://api.github.com/repos/Textalk/angular-schema-form/issues/180"},"comments":{"href":"https://api.github.com/repos/Textalk/angular-schema-form/issues/180/comments"},"review_comments":{"href":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/180/comments"},"review_comment":{"href":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Textalk/angular-schema-form/pulls/180/commits"},"statuses":{"href":"https://api.github.com/repos/Textalk/angular-schema-form/statuses/6ce423d2aacf4c8a9a66ba7aeceffada929ecb04"}}}}