{"action":"created","comment":{"url":"https://api.github.com/repos/civicrm/civihr/pulls/comments/187058322","pull_request_review_id":118760733,"id":187058322,"diff_hunk":"@@ -135,14 +135,23 @@ public static function validateDefaultWorkPattern($params) {\n       );\n     }\n \n-    if($isUpdate && $isToBeDisabled) {\n-      $isDefaultWorkPattern = self::isDefault($params['id']);\n+    if(!$isUpdate) {\n+      return;\n+    }\n \n-      if ($isDefaultWorkPattern) {\n-        throw new CRM_HRLeaveAndAbsences_Exception_InvalidWorkPatternException(\n-          'You cannot disable the default Work Pattern'\n-        );\n-      }\n+    $isDefaultWorkPattern = self::isDefault($params['id']);\n+\n+    if($isToBeDisabled && $isDefaultWorkPattern) {\n+      throw new CRM_HRLeaveAndAbsences_Exception_InvalidWorkPatternException(\n+        'You cannot disable the default Work Pattern'\n+      );\n+    }\n+\n+    $isToBeUncheckedAsDefault = isset($params['is_default']) && !$params['is_default'];\n+    if($isToBeUncheckedAsDefault && $isDefaultWorkPattern) {\n+      throw new CRM_HRLeaveAndAbsences_Exception_InvalidWorkPatternException(\n+        'It is not possible to have no default Work Pattern'","path":"uk.co.compucorp.civicrm.hrleaveandabsences/CRM/HRLeaveAndAbsences/BAO/WorkPattern.php","position":26,"original_position":26,"commit_id":"36145ddf8fe0e664621797baa4fabe966d0303ec","original_commit_id":"36145ddf8fe0e664621797baa4fabe966d0303ec","user":{"login":"ajesamson","id":1507645,"avatar_url":"https://avatars2.githubusercontent.com/u/1507645?v=4","gravatar_id":"","url":"https://api.github.com/users/ajesamson","html_url":"https://github.com/ajesamson","followers_url":"https://api.github.com/users/ajesamson/followers","following_url":"https://api.github.com/users/ajesamson/following{/other_user}","gists_url":"https://api.github.com/users/ajesamson/gists{/gist_id}","starred_url":"https://api.github.com/users/ajesamson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajesamson/subscriptions","organizations_url":"https://api.github.com/users/ajesamson/orgs","repos_url":"https://api.github.com/users/ajesamson/repos","events_url":"https://api.github.com/users/ajesamson/events{/privacy}","received_events_url":"https://api.github.com/users/ajesamson/received_events","type":"User","site_admin":false},"body":"Does this also implies `Default Work Pattern required.`? Guess it will be more simplified if it means same thing.","created_at":"2018-05-09T14:26:36Z","updated_at":"2018-05-09T14:26:37Z","html_url":"https://github.com/civicrm/civihr/pull/2604#discussion_r187058322","pull_request_url":"https://api.github.com/repos/civicrm/civihr/pulls/2604","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/comments/187058322"},"html":{"href":"https://github.com/civicrm/civihr/pull/2604#discussion_r187058322"},"pull_request":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/2604"}}},"pull_request":{"url":"https://api.github.com/repos/civicrm/civihr/pulls/2604","id":186921048,"html_url":"https://github.com/civicrm/civihr/pull/2604","diff_url":"https://github.com/civicrm/civihr/pull/2604.diff","patch_url":"https://github.com/civicrm/civihr/pull/2604.patch","issue_url":"https://api.github.com/repos/civicrm/civihr/issues/2604","number":2604,"state":"open","locked":false,"title":"PCHR-3654: Make it Impossible to Uncheck Work pattern As Default ","user":{"login":"tunbola","id":6951813,"avatar_url":"https://avatars1.githubusercontent.com/u/6951813?v=4","gravatar_id":"","url":"https://api.github.com/users/tunbola","html_url":"https://github.com/tunbola","followers_url":"https://api.github.com/users/tunbola/followers","following_url":"https://api.github.com/users/tunbola/following{/other_user}","gists_url":"https://api.github.com/users/tunbola/gists{/gist_id}","starred_url":"https://api.github.com/users/tunbola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tunbola/subscriptions","organizations_url":"https://api.github.com/users/tunbola/orgs","repos_url":"https://api.github.com/users/tunbola/repos","events_url":"https://api.github.com/users/tunbola/events{/privacy}","received_events_url":"https://api.github.com/users/tunbola/received_events","type":"User","site_admin":false},"body":"## Overview\r\nCurrently, It is possible to unselect a work pattern as default, leaving a CiviHR site without a default work pattern which breaks many things. This PR fixes the issue and makes sure that the default work pattern can not be unselected to make it non default, rather default work pattern change should happen from edit/create screen of a new work pattern (This is the current behaviour).\r\n\r\n## Before\r\n- It is possible to unselect a work pattern as default.\r\n\r\n![defaultworkpatternbefore](https://user-images.githubusercontent.com/6951813/39816898-86eba8ea-5394-11e8-8726-b43b8184efc4.gif)\r\n\r\n\r\n## After\r\n- It is not possible to unselect the default work pattern and make it non-default\r\n\r\n![defaultworkpattern](https://user-images.githubusercontent.com/6951813/39816929-9dfd4f66-5394-11e8-8975-ca8d8cbd120d.gif)\r\n\r\n","created_at":"2018-05-09T13:25:14Z","updated_at":"2018-05-09T14:26:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7322a5521b4bd75957df14e494f3a1124495c36c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":712229315,"url":"https://api.github.com/repos/civicrm/civihr/labels/ready%20to%20test","name":"ready to test","color":"0052cc","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/civicrm/civihr/pulls/2604/commits","review_comments_url":"https://api.github.com/repos/civicrm/civihr/pulls/2604/comments","review_comment_url":"https://api.github.com/repos/civicrm/civihr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/civicrm/civihr/issues/2604/comments","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/36145ddf8fe0e664621797baa4fabe966d0303ec","head":{"label":"civicrm:PCHR-3654-not-uncheck-default-work-pattern","ref":"PCHR-3654-not-uncheck-default-work-pattern","sha":"36145ddf8fe0e664621797baa4fabe966d0303ec","user":{"login":"civicrm","id":136373,"avatar_url":"https://avatars2.githubusercontent.com/u/136373?v=4","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"repo":{"id":10086903,"name":"civihr","full_name":"civicrm/civihr","owner":{"login":"civicrm","id":136373,"avatar_url":"https://avatars2.githubusercontent.com/u/136373?v=4","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/civicrm/civihr","description":"CiviHR","fork":false,"url":"https://api.github.com/repos/civicrm/civihr","forks_url":"https://api.github.com/repos/civicrm/civihr/forks","keys_url":"https://api.github.com/repos/civicrm/civihr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/civicrm/civihr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/civicrm/civihr/teams","hooks_url":"https://api.github.com/repos/civicrm/civihr/hooks","issue_events_url":"https://api.github.com/repos/civicrm/civihr/issues/events{/number}","events_url":"https://api.github.com/repos/civicrm/civihr/events","assignees_url":"https://api.github.com/repos/civicrm/civihr/assignees{/user}","branches_url":"https://api.github.com/repos/civicrm/civihr/branches{/branch}","tags_url":"https://api.github.com/repos/civicrm/civihr/tags","blobs_url":"https://api.github.com/repos/civicrm/civihr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/civicrm/civihr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/civicrm/civihr/git/refs{/sha}","trees_url":"https://api.github.com/repos/civicrm/civihr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/{sha}","languages_url":"https://api.github.com/repos/civicrm/civihr/languages","stargazers_url":"https://api.github.com/repos/civicrm/civihr/stargazers","contributors_url":"https://api.github.com/repos/civicrm/civihr/contributors","subscribers_url":"https://api.github.com/repos/civicrm/civihr/subscribers","subscription_url":"https://api.github.com/repos/civicrm/civihr/subscription","commits_url":"https://api.github.com/repos/civicrm/civihr/commits{/sha}","git_commits_url":"https://api.github.com/repos/civicrm/civihr/git/commits{/sha}","comments_url":"https://api.github.com/repos/civicrm/civihr/comments{/number}","issue_comment_url":"https://api.github.com/repos/civicrm/civihr/issues/comments{/number}","contents_url":"https://api.github.com/repos/civicrm/civihr/contents/{+path}","compare_url":"https://api.github.com/repos/civicrm/civihr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/civicrm/civihr/merges","archive_url":"https://api.github.com/repos/civicrm/civihr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/civicrm/civihr/downloads","issues_url":"https://api.github.com/repos/civicrm/civihr/issues{/number}","pulls_url":"https://api.github.com/repos/civicrm/civihr/pulls{/number}","milestones_url":"https://api.github.com/repos/civicrm/civihr/milestones{/number}","notifications_url":"https://api.github.com/repos/civicrm/civihr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/civicrm/civihr/labels{/name}","releases_url":"https://api.github.com/repos/civicrm/civihr/releases{/id}","deployments_url":"https://api.github.com/repos/civicrm/civihr/deployments","created_at":"2013-05-15T20:06:06Z","updated_at":"2018-05-09T13:47:24Z","pushed_at":"2018-05-09T13:47:32Z","git_url":"git://github.com/civicrm/civihr.git","ssh_url":"git@github.com:civicrm/civihr.git","clone_url":"https://github.com/civicrm/civihr.git","svn_url":"https://github.com/civicrm/civihr","homepage":null,"size":63777,"stargazers_count":27,"watchers_count":27,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"archived":false,"open_issues_count":14,"license":null,"forks":39,"open_issues":14,"watchers":27,"default_branch":"staging"}},"base":{"label":"civicrm:staging","ref":"staging","sha":"70a7b87c6ee7fdcc242a4c8486b73dc320be4a2c","user":{"login":"civicrm","id":136373,"avatar_url":"https://avatars2.githubusercontent.com/u/136373?v=4","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"repo":{"id":10086903,"name":"civihr","full_name":"civicrm/civihr","owner":{"login":"civicrm","id":136373,"avatar_url":"https://avatars2.githubusercontent.com/u/136373?v=4","gravatar_id":"","url":"https://api.github.com/users/civicrm","html_url":"https://github.com/civicrm","followers_url":"https://api.github.com/users/civicrm/followers","following_url":"https://api.github.com/users/civicrm/following{/other_user}","gists_url":"https://api.github.com/users/civicrm/gists{/gist_id}","starred_url":"https://api.github.com/users/civicrm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/civicrm/subscriptions","organizations_url":"https://api.github.com/users/civicrm/orgs","repos_url":"https://api.github.com/users/civicrm/repos","events_url":"https://api.github.com/users/civicrm/events{/privacy}","received_events_url":"https://api.github.com/users/civicrm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/civicrm/civihr","description":"CiviHR","fork":false,"url":"https://api.github.com/repos/civicrm/civihr","forks_url":"https://api.github.com/repos/civicrm/civihr/forks","keys_url":"https://api.github.com/repos/civicrm/civihr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/civicrm/civihr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/civicrm/civihr/teams","hooks_url":"https://api.github.com/repos/civicrm/civihr/hooks","issue_events_url":"https://api.github.com/repos/civicrm/civihr/issues/events{/number}","events_url":"https://api.github.com/repos/civicrm/civihr/events","assignees_url":"https://api.github.com/repos/civicrm/civihr/assignees{/user}","branches_url":"https://api.github.com/repos/civicrm/civihr/branches{/branch}","tags_url":"https://api.github.com/repos/civicrm/civihr/tags","blobs_url":"https://api.github.com/repos/civicrm/civihr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/civicrm/civihr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/civicrm/civihr/git/refs{/sha}","trees_url":"https://api.github.com/repos/civicrm/civihr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/civicrm/civihr/statuses/{sha}","languages_url":"https://api.github.com/repos/civicrm/civihr/languages","stargazers_url":"https://api.github.com/repos/civicrm/civihr/stargazers","contributors_url":"https://api.github.com/repos/civicrm/civihr/contributors","subscribers_url":"https://api.github.com/repos/civicrm/civihr/subscribers","subscription_url":"https://api.github.com/repos/civicrm/civihr/subscription","commits_url":"https://api.github.com/repos/civicrm/civihr/commits{/sha}","git_commits_url":"https://api.github.com/repos/civicrm/civihr/git/commits{/sha}","comments_url":"https://api.github.com/repos/civicrm/civihr/comments{/number}","issue_comment_url":"https://api.github.com/repos/civicrm/civihr/issues/comments{/number}","contents_url":"https://api.github.com/repos/civicrm/civihr/contents/{+path}","compare_url":"https://api.github.com/repos/civicrm/civihr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/civicrm/civihr/merges","archive_url":"https://api.github.com/repos/civicrm/civihr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/civicrm/civihr/downloads","issues_url":"https://api.github.com/repos/civicrm/civihr/issues{/number}","pulls_url":"https://api.github.com/repos/civicrm/civihr/pulls{/number}","milestones_url":"https://api.github.com/repos/civicrm/civihr/milestones{/number}","notifications_url":"https://api.github.com/repos/civicrm/civihr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/civicrm/civihr/labels{/name}","releases_url":"https://api.github.com/repos/civicrm/civihr/releases{/id}","deployments_url":"https://api.github.com/repos/civicrm/civihr/deployments","created_at":"2013-05-15T20:06:06Z","updated_at":"2018-05-09T13:47:24Z","pushed_at":"2018-05-09T13:47:32Z","git_url":"git://github.com/civicrm/civihr.git","ssh_url":"git@github.com:civicrm/civihr.git","clone_url":"https://github.com/civicrm/civihr.git","svn_url":"https://github.com/civicrm/civihr","homepage":null,"size":63777,"stargazers_count":27,"watchers_count":27,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"archived":false,"open_issues_count":14,"license":null,"forks":39,"open_issues":14,"watchers":27,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/2604"},"html":{"href":"https://github.com/civicrm/civihr/pull/2604"},"issue":{"href":"https://api.github.com/repos/civicrm/civihr/issues/2604"},"comments":{"href":"https://api.github.com/repos/civicrm/civihr/issues/2604/comments"},"review_comments":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/2604/comments"},"review_comment":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/civicrm/civihr/pulls/2604/commits"},"statuses":{"href":"https://api.github.com/repos/civicrm/civihr/statuses/36145ddf8fe0e664621797baa4fabe966d0303ec"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"ajesamson"}}