From 76e4acb89a8529d382ddf067d674483614c26601 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 19 Apr 2014 18:11:14 -0700 Subject: [PATCH] CRM-14480 - Allow creation/deletion of activity sets --- css/angular-crmCaseType.css | 12 ++++++++++ js/angular-crmCaseType.js | 41 +++++++++++++++++++++++++++++----- partials/crmCaseType/edit.html | 13 ++++++++--- 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/css/angular-crmCaseType.css b/css/angular-crmCaseType.css index e69de29bb2..294049f27a 100644 --- a/css/angular-crmCaseType.css +++ b/css/angular-crmCaseType.css @@ -0,0 +1,12 @@ +.crmCaseType .ui-icon { + margin: 0.4em 0.2em 0 0; + cursor: pointer; +} + +.crmCaseType .ui-tabs-nav li .ui-icon { + float: left; +} + +.crmCaseType .ui-tabs-nav select { + float: right; +} diff --git a/js/angular-crmCaseType.js b/js/angular-crmCaseType.js index 1fbd474620..60f74762d1 100644 --- a/js/angular-crmCaseType.js +++ b/js/angular-crmCaseType.js @@ -14,6 +14,12 @@ crmCaseType.controller('CaseTypeCtrl', function($scope) { $scope.partialsUrl = partialsUrl; + + $scope.workflows = { + 'timeline': 'Timeline', + 'pipeline': 'Sequence' + }; + $scope.caseType = { id: 123, label: 'Adult Day Care Referral', @@ -37,7 +43,7 @@ }, { name: 'my_sequence', - label: 'Sequence', + label: 'My Sequence', pipeline: '1', // Angular won't bind checkbox correctly with numeric 1 activityTypes: [ {name: 'Medical evaluation'}, @@ -55,6 +61,23 @@ } }; + $scope.addActivitySet = function(workflow) { + var activitySet = {}; + activitySet[workflow] = '1'; + activitySet.activityTypes = []; + + var offset = 1; + var names = _.pluck($scope.caseType.definition.activitySets, 'name'); + while (_.contains(names, workflow + '_' + offset)) offset++; + activitySet.name = workflow + '_' + offset; + activitySet.label = (offset == 1 ) ? $scope.workflows[workflow] : ($scope.workflows[workflow] + ' #' + offset); + + $scope.caseType.definition.activitySets.push(activitySet); + _.defer(function() { + $('.crmCaseType-acttab').tabs('refresh').tabs({active: -1}); + }); + }; + $scope.onManagerChange = function(managerRole) { angular.forEach($scope.caseType.definition.caseRoles, function(caseRole) { if (caseRole != managerRole) { @@ -71,9 +94,11 @@ }; $scope.getWorkflowName = function(activitySet) { - if (activitySet.timeline) return "Timeline"; - if (activitySet.pipeline) return "Sequence"; - return "Unknown"; + var result = 'Unknown'; + _.each($scope.workflows, function(value, key) { + if (activitySet[key]) result = value; + }); + return result; }; /** @@ -93,7 +118,13 @@ $scope.dump = function() { console.log($scope.caseType); - } + }; + + $scope.$watchCollection('caseType.definition.activitySets', function() { + _.defer(function() { + $('.crmCaseType-acttab').tabs('refresh'); + }); + }); }); })(angular, CRM.$, CRM._); \ No newline at end of file diff --git a/partials/crmCaseType/edit.html b/partials/crmCaseType/edit.html index e7f989f120..599fe03b41 100644 --- a/partials/crmCaseType/edit.html +++ b/partials/crmCaseType/edit.html @@ -2,7 +2,7 @@ Controller: CaseTypeCtrl Required vars: caseType --> -
+

Roles

@@ -11,12 +11,19 @@ Required vars: caseType

Activities

-
+
@@ -26,7 +33,7 @@ Required vars: caseType
-
+

Advanced

-- 2.25.1