repeat_option.ts 965 B

123456789101112131415161718192021222324252627282930313233343536
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import {coreModule} from 'app/core/core';
  3. var template = `
  4. <div class="gf-form-select-wrapper max-width-13">
  5. <select class="gf-form-input" ng-model="model.repeat" ng-options="f.value as f.text for f in variables">
  6. <option value=""></option>
  7. </div>
  8. `;
  9. /** @ngInject **/
  10. function dashRepeatOptionDirective(variableSrv) {
  11. return {
  12. restrict: 'E',
  13. template: template,
  14. scope: {
  15. model: "=",
  16. },
  17. link: function(scope, element) {
  18. element.css({display: 'block', width: '100%'});
  19. scope.variables = variableSrv.variables.map(item => {
  20. return {text: item.name, value: item.name};
  21. });
  22. if (scope.variables.length === 0) {
  23. scope.variables.unshift({text: 'No template variables found', value: null});
  24. }
  25. scope.variables.unshift({text: 'Disabled', value: null});
  26. }
  27. };
  28. }
  29. coreModule.directive('dashRepeatOption', dashRepeatOptionDirective);