' +
'' +
'
' +
'Field type: ' +
'
' +
'
' + // contains the elements that depend on the field type
'
' +
'
');
fieldBlock.$fieldBlock = $fieldBlock;
if (fieldBlockPos >= this.fieldBlocks.length) {
this.$fieldBlocks.append($fieldBlock); }
else {
this.fieldBlocks[fieldBlockPos].$fieldBlock.before($fieldBlock); }
fieldBlock.$fieldBlockId = $fieldBlock.find(".sgpFieldBlockId");
fieldBlock.$fieldTypeControl = $fieldBlock.find(".sgpFieldTypeControl");
let fieldType: FieldType = (initParms != null && initParms.fieldType != null) ? initParms.fieldType : defaultFieldType;
Utils.loadSelectElementOptionsEnum(fieldBlock.$fieldTypeControl, FieldType, fieldType);
fieldBlock.$fieldTypeControl.change(() => {this.buildFieldParmsBlock(fieldBlock); this.onFieldBlockUpdate(fieldBlock); });
let $delFieldBlockButton = $fieldBlock.find(".sgpDelFieldBlockButton");
$delFieldBlockButton.click(() => {this.reset(); this.deleteFieldBlock(fieldBlock.position); });
let $addFieldBlockButton = $fieldBlock.find(".sgpAddFieldBlockButton");
$addFieldBlockButton.click(() => {this.reset(); this.addFieldBlock(undefined, fieldBlock.position + 1); });
this.buildFieldParmsBlock(fieldBlock, initParms);
this.updateFieldInfo(fieldBlock);
this.fieldBlocks.splice(fieldBlockPos, 0, fieldBlock);
this.renumberFieldBlocks();
return fieldBlock; }
deleteFieldBlocks() {
this.fieldBlocks = [];
this.$fieldBlocks.html(""); }
deleteFieldBlock (fieldBlockPos: number) {
let fieldBlock = this.fieldBlocks[fieldBlockPos];
fieldBlock.$fieldBlock.remove();
this.fieldBlocks.splice(fieldBlockPos, 1);
this.renumberFieldBlocks();
if (this.fieldBlocks.length == 0) {
this.addFieldBlock(); }}
renumberFieldBlocks() {
let n = this.fieldBlocks.length;
for (let i = 0; i < n; i++) {
let fieldBlock = this.fieldBlocks[i];
fieldBlock.position = i;
fieldBlock.$fieldBlockId.html((i + 1).toString()); }
// Side effect:
this.$aggregateFunctionLabel.toggle(n > 1); }
buildFieldParmsBlock (fieldBlock: FieldBlock, initParms?: FieldBlockInitParms) {
let fieldType = fieldBlock.getFieldType();
let $parmsBlock = fieldBlock.$fieldBlock.find(".sgpFieldParmsBlock");
$parmsBlock.html(
'