remove dead code, make label more flexible

This commit is contained in:
Sven Klemm 2018-07-06 10:38:18 +02:00
parent 85ab1cfa8f
commit 8ed210c8d5
2 changed files with 11 additions and 27 deletions

View File

@ -42,7 +42,8 @@ export class SqlPart {
part: any;
def: SqlPartDef;
params: any[];
text: string;
label: string;
name: string;
constructor(part: any, def: any) {
this.part = part;
@ -51,38 +52,21 @@ export class SqlPart {
throw { message: 'Could not find sql part ' + part.type };
}
if (part.name) {
this.name = part.name;
this.label = def.label + ' ' + part.name;
} else {
this.name = '';
this.label = def.label;
}
part.params = part.params || _.clone(this.def.defaultParams);
this.params = part.params;
this.updateText();
}
render(innerExpr: string) {
return this.def.renderer(this, innerExpr);
}
updateParam(strValue, index) {
if (strValue === '' && this.def.params[index].optional) {
// XXX check if this is still required
this.params.splice(index, 1);
} else {
this.params[index] = strValue;
}
this.part.params = this.params;
this.updateText();
}
updateText() {
if (this.params.length === 0) {
this.text = this.def.type + '()';
return;
}
var text = this.def.type + '(';
text += this.params.join(', ');
text += ')';
this.text = text;
}
}
export function functionRenderer(part, innerExpr) {

View File

@ -4,7 +4,7 @@ import coreModule from 'app/core/core_module';
var template = `
<div class="dropdown cascade-open">
<a ng-click="showActionsMenu()" class="query-part-name pointer dropdown-toggle" data-toggle="dropdown">{{part.def.label}}</a>
<a ng-click="showActionsMenu()" class="query-part-name pointer dropdown-toggle" data-toggle="dropdown">{{part.label}}</a>
<span>{{part.def.wrapOpen}}</span><span class="query-part-parameters"></span><span>{{part.def.wrapClose}}</span>
<ul class="dropdown-menu">
<li ng-repeat="action in partActions">