refactoring: slight changes to PR #13247

This commit is contained in:
Torkel Ödegaard
2018-09-27 14:50:14 +02:00
parent f2307f92de
commit 7d44aacf4a
4 changed files with 11 additions and 11 deletions
@@ -4,8 +4,8 @@
<label class="gf-form-label template-variable" ng-hide="variable.hide === 1">
{{variable.label || variable.name}}
</label>
<value-select-dropdown ng-if="variable.type !== 'adhoc' && variable.type !== 'text'" variable="variable" on-updated="ctrl.variableUpdated(variable)"></value-select-dropdown>
<input type="text" ng-if="variable.type === 'text'" ng-model="variable.query" class="gf-form-input width-9" ng-blur="variable.current.value != variable.query && variable.updateOptions() && ctrl.variableUpdated(variable);" ng-keydown="$event.keyCode === 13 && variable.current.value != variable.query && variable.updateOptions() && ctrl.variableUpdated(variable);" ></input>
<value-select-dropdown ng-if="variable.type !== 'adhoc' && variable.type !== 'textbox'" variable="variable" on-updated="ctrl.variableUpdated(variable)"></value-select-dropdown>
<input type="text" ng-if="variable.type === 'textbox'" ng-model="variable.query" class="gf-form-input width-12" ng-blur="variable.current.value != variable.query && variable.updateOptions() && ctrl.variableUpdated(variable);" ng-keydown="$event.keyCode === 13 && variable.current.value != variable.query && variable.updateOptions() && ctrl.variableUpdated(variable);" ></input>
</div>
<ad-hoc-filters ng-if="variable.type === 'adhoc'" variable="variable"></ad-hoc-filters>
</div>
@@ -1,13 +1,13 @@
import { Variable, assignModelProperties, variableTypes } from './variable';
export class TextVariable implements Variable {
export class TextBoxVariable implements Variable {
query: string;
current: any;
options: any[];
skipUrlSync: boolean;
defaults = {
type: 'text',
type: 'textbox',
name: '',
hide: 2,
label: '',
@@ -51,8 +51,8 @@ export class TextVariable implements Variable {
}
}
variableTypes['text'] = {
name: 'Text',
ctor: TextVariable,
variableTypes['textbox'] = {
name: 'Text box',
ctor: TextBoxVariable,
description: 'Define a textbox variable, where users can enter any arbitrary string',
};
+2 -2
View File
@@ -9,7 +9,7 @@ import { DatasourceVariable } from './datasource_variable';
import { CustomVariable } from './custom_variable';
import { ConstantVariable } from './constant_variable';
import { AdhocVariable } from './adhoc_variable';
import { TextVariable } from './text_variable';
import { TextBoxVariable } from './TextBoxVariable';
coreModule.factory('templateSrv', () => {
return templateSrv;
@@ -23,5 +23,5 @@ export {
CustomVariable,
ConstantVariable,
AdhocVariable,
TextVariable
TextBoxVariable,
};
@@ -155,10 +155,10 @@
</div>
</div>
<div ng-if="current.type === 'text'" class="gf-form-group">
<div ng-if="current.type === 'textbox'" class="gf-form-group">
<h5 class="section-heading">Text options</h5>
<div class="gf-form">
<span class="gf-form-label">Value</span>
<span class="gf-form-label">Default value</span>
<input type="text" class="gf-form-input" ng-model='current.query' ng-blur="runQuery()" placeholder="default value, if any"></input>
</div>
</div>