电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.7 KiB

  1. /* Copyright 2005-2015 Alfresco Software, Ltd.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. angular.module('flowableModeler')
  16. .controller('DecisionTableToolbarController', ['$scope', '$http', '$modal', '$q', '$rootScope', '$translate', '$location', 'DecisionTableService',
  17. function ($scope, $http, $modal, $q, $rootScope, $translate, $location, DecisionTableService) {
  18. var toolbarItems = DECISION_TABLE_TOOLBAR_CONFIG.items;
  19. $scope.items = [];
  20. for (var i = 0; i < toolbarItems.length; i++)
  21. {
  22. $scope.items.push(toolbarItems[i]);
  23. }
  24. $scope.secondaryItems = DECISION_TABLE_TOOLBAR_CONFIG.secondaryItems;
  25. // Call configurable click handler (From http://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string)
  26. var executeFunctionByName = function(functionName, context /*, args */) {
  27. var args = Array.prototype.slice.call(arguments).splice(2);
  28. var namespaces = functionName.split(".");
  29. var func = namespaces.pop();
  30. for(var i = 0; i < namespaces.length; i++) {
  31. context = context[namespaces[i]];
  32. }
  33. return context[func].apply(this, args);
  34. };
  35. // Click handler for toolbar buttons
  36. $scope.toolbarButtonClicked = function(buttonIndex) {
  37. // Default behaviour
  38. var buttonClicked = $scope.items[buttonIndex];
  39. var services = { '$scope' : $scope, '$rootScope' : $rootScope, '$http' : $http, '$modal' : $modal, '$q' : $q, '$translate' : $translate, 'DecisionTableService': DecisionTableService};
  40. executeFunctionByName(buttonClicked.action, window, services);
  41. };
  42. // Click handler for secondary toolbar buttons
  43. $scope.toolbarSecondaryButtonClicked = function(buttonIndex) {
  44. var buttonClicked = $scope.secondaryItems[buttonIndex];
  45. var services = { '$scope' : $scope, '$rootScope' : $rootScope, '$http' : $http, '$modal' : $modal, '$q' : $q, '$translate' : $translate, '$location': $location, 'DecisionTableService': DecisionTableService };
  46. executeFunctionByName(buttonClicked.action, window, services);
  47. };
  48. }]);