teaScopeDecorator

This is a service available in the module tea.services. The teaScopeDecorator service decorates the scope with a TeaObject based on the current URL. It also attaches several utility methods that are useful in the teaMasthead directive and elsewhere.

Dependencies

  • teaLocation
  • teaObjectService
  • $q
  • $http
  • $modal

Methods

goto
The goto function offers a simplified way to call teaLocation.goto.
Parameters

object {TeaObject} – The object to navigate to.

reload
The reload function causes the scope's TeaObject to be reloaded from scratch. This can be important in an "onSuccess" function as passed to openOperation.
Parameters

object {TeaObject} – The object to navigate to.

goToProduct
The goToProduct function navigates to the current product's top-level object.
getStatusClass
The getStatusClass function should be used to set the class for styling object.status. If the state is "running" or "started" (case insensitive), the function returns tea-status-ok, otherwise it returns tea-status-error.

Parameters

object {TeaObject} – The object whose status is to be displayed

Returns

{String} – tea-status-ok or tea-status-error

openOperation
The openOperation function opens a modal dialog with a form for invoking an operation on the current object.
Parameters
  • operationName {String} – Name of the operation
  • defaultValues {String[]} – (optional) default values for the operation parameters
  • onSuccess {Function} – A function to call upon successful completion of the operation call. By default, scope.reload is called.
  • validatorfn {Function(paramName, paramValue)} – (optional) A function which validates the form's parameter values. This function takes two parameters, name and value, to be validated. The function returns an error message in case the validation fails. If the validation passes, it does not return anything.
openOperationWithResponseHeaders
The openOperationWithResponseHeaders function opens a modal dialog with a form for invoking an operation on the current object.
Parameters
  • operationName {String} – Name of the operation
  • defaultValues {String[]} – (optional) default values for the operation parameters
  • onSuccess {Function} – A function to call upon successful completion of the operation call. By default, scope.reload is called.
getReference
The getReference function offers a simplified way to call teaObjectService.getReference.
Parameters
  • object {TeaObject} – The object containing the reference
  • refName {String} – The name of the reference
  • onReferenceDo {Function} – The function that will be executed as a promise, passed the Array<TeaObject> returned by teaObjectService.getReference

Usage

myModule.controller('MyController', function ($scope, teaScopeDecorator) {
    teaScopeDecorator($scope);

    // TeaObject now available under $scope.object

    // functions $scope.openOperation, $scope.goto, $scope.goToProduct,
    //     $scope.getReference, and $scope.getStatusClass available
});