ux: new metric segment is starting to work

This commit is contained in:
Torkel Ödegaard 2017-06-15 14:03:26 -04:00
parent 5f3b5fdcb2
commit 76c4bfe268
2 changed files with 11 additions and 13 deletions

View File

@ -20,7 +20,9 @@ export class FormDropdownCtrl {
text: any; text: any;
options: any; options: any;
cssClass: any; cssClass: any;
cssClasses: any;
allowCustom: any; allowCustom: any;
labelMode: boolean;
linkMode: boolean; linkMode: boolean;
cancelBlur: any; cancelBlur: any;
onChange: any; onChange: any;
@ -33,15 +35,15 @@ export class FormDropdownCtrl {
this.linkMode = true; this.linkMode = true;
this.cancelBlur = null; this.cancelBlur = null;
if (!this.getOptions) {
this.getOptions = () => {
return Promise.resolve(this.options);
};
}
// listen to model changes // listen to model changes
$scope.$watch("ctrl.model", this.modelChanged.bind(this)); $scope.$watch("ctrl.model", this.modelChanged.bind(this));
if (this.labelMode) {
this.cssClasses = 'gf-form-label ' + this.cssClass;
} else {
this.cssClasses = 'gf-form-input gf-form-input--dropdown ' + this.cssClass;
}
this.inputElement.attr('data-provide', 'typeahead'); this.inputElement.attr('data-provide', 'typeahead');
this.inputElement.typeahead({ this.inputElement.typeahead({
source: this.typeaheadSource.bind(this), source: this.typeaheadSource.bind(this),
@ -199,9 +201,7 @@ const template = `
spellcheck="false" spellcheck="false"
style="display:none"> style="display:none">
</input> </input>
<a ng-class="ctrl.cssClasses"
<a class="gf-form-label"
ng-class="ctrl.cssClass"
tabindex="1" tabindex="1"
ng-click="ctrl.open()" ng-click="ctrl.open()"
give-focus="ctrl.focus" give-focus="ctrl.focus"
@ -218,12 +218,11 @@ export function formDropdownDirective() {
controllerAs: 'ctrl', controllerAs: 'ctrl',
scope: { scope: {
model: "=", model: "=",
options: "=",
getOptions: "&", getOptions: "&",
onChange: "&", onChange: "&",
cssClass: "@", cssClass: "@",
allowCustom: "@", allowCustom: "@",
selectMode: "@", labelMode: "@",
}, },
link: function() { link: function() {
} }

View File

@ -36,8 +36,7 @@
<label class="gf-form-label">Panel Data Source</label> <label class="gf-form-label">Panel Data Source</label>
<gf-form-dropdown model="ctrl.panelDsValue" <gf-form-dropdown model="ctrl.panelDsValue"
get-options="ctrl.getOptions(true)" get-options="ctrl.getOptions(true)"
on-change="ctrl.datasourceChanged($option)" on-change="ctrl.datasourceChanged($option)">
css-class="width-10">
</gf-form-dropdown> </gf-form-dropdown>
</div> </div>
</div> </div>