From: Tim Otten Date: Thu, 22 May 2014 01:51:29 +0000 (-0700) Subject: CRM-14725 - Load case-type based on ID in URL ("/civicrm/a/#/caseType/123") X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4d74de55423ff5e3afa8e814b6e404ee64503b2b;p=civicrm-core.git CRM-14725 - Load case-type based on ID in URL ("/civicrm/a/#/caseType/123") --- diff --git a/js/angular-crmCaseType.js b/js/angular-crmCaseType.js index c400ae61ff..35037757b3 100644 --- a/js/angular-crmCaseType.js +++ b/js/angular-crmCaseType.js @@ -6,11 +6,37 @@ var crmCaseType = angular.module('crmCaseType', ['ngRoute', 'ui.utils']); + var newCaseTypeDefinitionTemplate = { + activityTypes: [ + {name: 'Open Case', max_instances: 1 }, + {name: 'Example activity'} + ], + activitySets: [ + { + name: 'standard_timeline', + label: 'Standard Timeline', + timeline: '1', // Angular won't bind checkbox correctly with numeric 1 + activityTypes: [ + {name: 'Open Case', status: 'Completed' }, + {name: 'Example activity', reference_activity: 'Open Case', reference_offset: 3, reference_select: 'newest'} + ] + } + ], + caseRoles: [ + { name: 'Case Coordinator', creator: '1', manager: '1'} + ] + }; + crmCaseType.config(['$routeProvider', function($routeProvider) { $routeProvider.when('/caseType/:id', { templateUrl: partialUrl('edit.html'), - controller: 'CaseTypeCtrl' + controller: 'CaseTypeCtrl', + resolve: { + selectedCaseType: function($route, crmApi) { + return crmApi('CaseType', 'getsingle', {id: $route.current.params.id}); + } + } }); } ]); @@ -29,7 +55,7 @@ }; }); - crmCaseType.controller('CaseTypeCtrl', function($scope, crmApi) { + crmCaseType.controller('CaseTypeCtrl', function($scope, crmApi, selectedCaseType) { $scope.partialUrl = partialUrl; $scope.activityStatuses = CRM.crmCaseType.actStatuses; @@ -41,46 +67,11 @@ 'pipeline': 'Sequence' }; - $scope.caseType = { - id: 123, - label: 'Adult Day Care Referral', - description: 'Superkalafragalisticexpialitotious', - is_active: '1', // Angular won't bind checkbox correctly with numeric 1 - definition: { // This is the serialized field - name: 'Adult Day Care Referral', - activityTypes: [ - {name: 'Open Case', max_instances: 1 }, - {name: 'Medical evaluation'} - ], - activitySets: [ - { - name: 'standard_timeline', - label: 'Standard Timeline', - timeline: '1', // Angular won't bind checkbox correctly with numeric 1 - activityTypes: [ - {name: 'Open Case', status: 'Completed' }, - {name: 'Medical evaluation', reference_activity: 'Open Case', reference_offset: 3, reference_select: 'newest'} - ] - }, - { - name: 'my_sequence', - label: 'My Sequence', - pipeline: '1', // Angular won't bind checkbox correctly with numeric 1 - activityTypes: [ - {name: 'Medical evaluation'}, - {name: 'Meeting'}, - {name: 'Phone Call'} - ] - } - - ], - caseRoles: [ - { name: 'Senior Services Coordinator', creator: '1', manager: '1' }, - { name: 'Health Services Coordinator' }, - { name: 'Benefits Specialist' } - ] - } - }; + $scope.caseType = selectedCaseType; + $scope.caseType.definition = $scope.caseType.definition || _.extend({}, newCaseTypeDefinitionTemplate); + $scope.caseType.definition.activityTypes = $scope.caseType.definition.activityTypes || []; + $scope.caseType.definition.activitySets = $scope.caseType.definition.activitySets || []; + $scope.caseType.definition.caseRoles = $scope.caseType.definition.caseRoles || []; window.ct = $scope.caseType; $scope.addActivitySet = function(workflow) { diff --git a/partials/crmCaseType/caseTypeDetails.html b/partials/crmCaseType/caseTypeDetails.html index c7f89b5dce..912b40745a 100644 --- a/partials/crmCaseType/caseTypeDetails.html +++ b/partials/crmCaseType/caseTypeDetails.html @@ -9,13 +9,13 @@ The original form used table layout; don't know if we have an alternative, CSS-b Label - + Name - +