query_editor_row.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { coreModule } from 'app/angular/core_module';
  2. export class QueryRowCtrl {
  3. target: any;
  4. queryCtrl: any;
  5. panelCtrl: any;
  6. panel: any;
  7. hasTextEditMode = false;
  8. $onInit() {
  9. this.panelCtrl = this.queryCtrl.panelCtrl;
  10. this.target = this.queryCtrl.target;
  11. this.panel = this.panelCtrl.panel;
  12. if (this.hasTextEditMode && this.queryCtrl.toggleEditorMode) {
  13. // expose this function to react parent component
  14. this.panelCtrl.toggleEditorMode = this.queryCtrl.toggleEditorMode.bind(this.queryCtrl);
  15. }
  16. if (this.queryCtrl.getCollapsedText) {
  17. // expose this function to react parent component
  18. this.panelCtrl.getCollapsedText = this.queryCtrl.getCollapsedText.bind(this.queryCtrl);
  19. }
  20. }
  21. }
  22. /** @ngInject */
  23. function queryEditorRowDirective() {
  24. return {
  25. restrict: 'E',
  26. controller: QueryRowCtrl,
  27. bindToController: true,
  28. controllerAs: 'ctrl',
  29. templateUrl: 'public/app/angular/panel/partials/query_editor_row.html',
  30. transclude: true,
  31. scope: {
  32. queryCtrl: '=',
  33. canCollapse: '=',
  34. hasTextEditMode: '=',
  35. },
  36. };
  37. }
  38. coreModule.directive('queryEditorRow', queryEditorRowDirective);