Skip to content

Commit

Permalink
F#1208 improve auto completion (#1257)
Browse files Browse the repository at this point in the history
* change rule-condition-input to rule-suggest-input : delete, derive, keep, replace and set .

* add 'antlr4' package.

* #1208 remove attributes(funcType, isEmptyViewAll) in ths set rule

* #1208 change isAutoCompleteSuggestionListOpen to isSuggestOpen.
  • Loading branch information
nowone123 authored and joohokim1 committed Jan 16, 2019
1 parent 3938c9e commit a8437b2
Show file tree
Hide file tree
Showing 35 changed files with 4,428 additions and 179 deletions.
1 change: 1 addition & 0 deletions discovery-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"sql-formatter": "^2.1.0",
"stompjs": "^2.3.3",
"string-pixel-width": "^1.4.0",
"antlr4": "^4.7.2",
"zone.js": "^0.8.17"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import { EditRuleDropComponent } from './dataflow/dataflow-detail/component/edit
import { CreateSnapshotPopup } from './component/create-snapshot-popup.component';
import { SnapshotLoadingComponent } from './component/snapshot-loading.component';
import { RuleConditionInputComponent } from "./dataflow/dataflow-detail/component/edit-dataflow-rule/edit-rule/rule-condition-input.component";
import { RuleSuggestInputComponent } from "./dataflow/dataflow-detail/component/edit-dataflow-rule/edit-rule/rule-suggest-input.component";
import { EditRuleFieldComboComponent } from './dataflow/dataflow-detail/component/edit-dataflow-rule/edit-rule/edit-rule-field-combo.component';
import { EditRuleDeriveComponent } from './dataflow/dataflow-detail/component/edit-dataflow-rule/edit-rule/edit-rule-derive.component';
import { EditRuleSetComponent } from './dataflow/dataflow-detail/component/edit-dataflow-rule/edit-rule/edit-rule-set.component';
Expand Down Expand Up @@ -162,6 +163,7 @@ const dataPreparationRoutes: Routes = [
CreateSnapshotPopup,
SnapshotLoadingComponent,
RuleConditionInputComponent,
RuleSuggestInputComponent,
PrepSelectBoxComponent,
PrepSelectBoxCustomComponent,
RadioSelectDatasetComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ export class EditDataflowRule2Component extends AbstractPopupComponent implement
* Open advanced formula input popup (set, keep, derive, delete)
* @param {string} command
*/
public openPopupFormulaInput(data: {command : string, val : string}) {
public openPopupFormulaInput(data: {command : string, val : string, needCol?:boolean}) {
const fields: Field[] = this.selectedDataSet.gridData.fields;

// variables vary according to the rule name
Expand All @@ -1156,21 +1156,19 @@ export class EditDataflowRule2Component extends AbstractPopupComponent implement
// val = 'keepRow';
// }

this.extendInputFormulaComponent.open(fields, data.command, this._editRuleComp.getValue( data.val ));

//this.extendInputFormulaComponent.open(fields, data.command, this._editRuleComp.getValue( data.val ));

data.val = this._editRuleComp.getValue( data.val );
this.extendInputFormulaComponent.open(fields, data);
}

/**
* Apply formula using Advanced formula popup
* @param {{command: string, formula: string}} data
*/
public doneInputFormula(data: { command: string, formula: string }) {

if (data.command === 'setCondition') {
this._editRuleComp.setValue( 'forceCondition', data.formula );
} else {
this._editRuleComp.setValue( 'forceFormula', data.formula );
}

this._editRuleComp.doneInputFormula(data);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
{{'msg.dp.th.condition' | translate}}<em class="ddp-icon-essential"></em>
</div>
<div class="ddp-wrap-datainput">
<rule-condition-input
[formula]="rowNum" [forceFormula]="forceFormula" [command]="'delete'" [fields]="fields" [tabIndex]="2"
(onChange)="rowNum = $event"></rule-condition-input>
<rule-suggest-input #delete_row_input
[formula]="rowNum"
[command]="'delete'" [cmdArg]="'row'"
[tabIndex]="2"
[fields]="fields"
(onChange)="rowNum = $event" ></rule-suggest-input>
</div>
<a href="javascript:" class="ddp-btn-bg" (click)="openPopupFormulaInput()"><em class="ddp-icon-editor"></em>{{'msg.dp.btn.advanced.editor' | translate }}</a>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import {
OnInit,
Output, ViewChild,
} from '@angular/core';
import { StringUtil } from '../../../../../../common/util/string.util';

import { Alert } from '../../../../../../common/util/alert.util';
import { isUndefined } from "util";
import { RuleConditionInputComponent } from './rule-condition-input.component';
import { RuleSuggestInputComponent } from './rule-suggest-input.component';
import * as _ from 'lodash';
import {PreparationCommonUtil} from "../../../../../util/preparation-common.util";

Expand All @@ -39,9 +39,13 @@ export class EditRuleDeleteComponent extends EditRuleComponent implements OnInit
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Private Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@ViewChild('delete_row_input')
private rowInput : RuleSuggestInputComponent;

/*
@ViewChild(RuleConditionInputComponent)
private ruleConditionInputComponent : RuleConditionInputComponent;
*/
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Protected Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
Expand Down Expand Up @@ -99,30 +103,18 @@ export class EditRuleDeleteComponent extends EditRuleComponent implements OnInit
*/
public getRuleData(): { command: string, ruleString:string} {

if (this.ruleConditionInputComponent.autoCompleteSuggestions_selectedIdx == -1) {
this.rowNum = this.ruleConditionInputComponent.getCondition();
let val = _.cloneDeep(this.rowNum);
if (isUndefined(val) || '' === val || '\'\'' === val) {
Alert.warning(this.translateService.instant('msg.dp.alert.keep.warn'));
return undefined
}

if (!isUndefined(val) && '' !== val.trim() && '\'\'' !== val.trim()) {
let check = StringUtil.checkSingleQuote(val, { isPairQuote: true });
if (check[0] === false) {
Alert.warning(this.translateService.instant('msg.dp.alert.check.condition'));
return undefined
} else {
val = check[1];
}
}
return {
command: 'delete',
ruleString: 'delete row: ' + val
};
} else {
return undefined;
this.rowNum = this.rowInput.getFormula();
let val = _.cloneDeep(this.rowNum);
if (isUndefined(val) || '' === val || '\'\'' === val) {
Alert.warning(this.translateService.instant('msg.dp.alert.keep.warn'));
return undefined
}

return {
command: 'delete',
ruleString: 'delete row: ' + val
};

} // function - getRuleData

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Expand All @@ -133,10 +125,18 @@ export class EditRuleDeleteComponent extends EditRuleComponent implements OnInit
* @param {string} command 수식 입력 실행 커맨드
*/
public openPopupFormulaInput() {
this.rowNum = this.ruleConditionInputComponent.getCondition();
this.rowNum = this.rowInput.getFormula();
this.advancedEditorClickEvent.emit({command :'delete', val : 'rowNum' });
} // function - openPopupFormulaInput

/**
* Apply formula using Advanced formula popup
* @param {{command: string, formula: string}} data
*/
public doneInputFormula(data: { command: string, formula: string }) {
this.rowNum = data.formula;
this.rowInput.setFormula(this.rowNum);
}

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Protected Method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
{{'msg.dp.th.expression' | translate}}<em class="ddp-icon-essential"></em>
</div>
<div class="ddp-wrap-datainput">
<rule-condition-input
[formula]="deriveVal" [command]="'derive'"
[forceFormula]="forceFormula" [fields]="fields"
<rule-suggest-input #derive_value_input
[formula]="deriveVal"
[command]="'derive'" [cmdArg]="'value'"
[tabIndex]="2" [placeholder]="'msg.dp.th.expression.ph' | translate"
(onChange)="deriveVal = $event"></rule-condition-input>
[fields]="fields"
(onChange)="deriveVal = $event" ></rule-suggest-input>
</div>
<a href="javascript:" class="ddp-btn-bg" (click)="openPopupFormulaInput()"><em class="ddp-icon-editor"></em>{{'msg.dp.btn.advanced.editor' | translate }}</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import {
import { EditRuleComponent } from './edit-rule.component';
import { Alert } from '../../../../../../common/util/alert.util';
import {isNullOrUndefined, isUndefined} from "util";
import { StringUtil } from '../../../../../../common/util/string.util';
import { PreparationCommonUtil } from '../../../../../util/preparation-common.util';
import { RuleConditionInputComponent } from './rule-condition-input.component';
import { RuleSuggestInputComponent } from './rule-suggest-input.component';
import * as _ from 'lodash';

@Component({
Expand All @@ -32,8 +31,10 @@ export class EditRuleDeriveComponent extends EditRuleComponent implements OnInit
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Private Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@ViewChild(RuleConditionInputComponent)
private ruleConditionInputComponent : RuleConditionInputComponent;

@ViewChild('derive_value_input')
private valueInput : RuleSuggestInputComponent;

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Protected Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
Expand Down Expand Up @@ -95,43 +96,32 @@ export class EditRuleDeriveComponent extends EditRuleComponent implements OnInit
* @return
*/
public getRuleData(): { command: string, ruleString:string} {
if (this.ruleConditionInputComponent.autoCompleteSuggestions_selectedIdx == -1) {
this.deriveVal = this.ruleConditionInputComponent.getCondition();
let val = _.cloneDeep(this.deriveVal);

if (isUndefined(val) || '' === val || '\'\'' === val) {
Alert.warning(this.translateService.instant('msg.dp.alert.insert.expression'));
return undefined
}
if (!isUndefined(val) && '' !== val.trim()) {
let check = StringUtil.checkSingleQuote(val, { isPairQuote: true });
if (check[0] === false) {
Alert.warning(this.translateService.instant('msg.dp.alert.check.expression'));
return undefined
} else {
val = check[1];
}
}
if (isUndefined(this.deriveAs) || '' === this.deriveAs) {
Alert.warning(this.translateService.instant('msg.dp.alert.insert.new.col'));
return undefined
}

let deriveAs : string = '';
if (this.deriveAs.indexOf(' ') === -1) {
deriveAs = `'${this.deriveAs}'`;
} else {
deriveAs = '`' +this.deriveAs + '`';
}

return {
command: 'derive',
ruleString: 'derive value: ' + val + ' as: ' + deriveAs
}

this.deriveVal = this.valueInput.getFormula();
let val = _.cloneDeep(this.deriveVal);

if (isUndefined(val) || '' === val || '\'\'' === val) {
Alert.warning(this.translateService.instant('msg.dp.alert.insert.expression'));
return undefined
}

if (isUndefined(this.deriveAs) || '' === this.deriveAs) {
Alert.warning(this.translateService.instant('msg.dp.alert.insert.new.col'));
return undefined
}

let deriveAs : string = '';
if (this.deriveAs.indexOf(' ') === -1) {
deriveAs = `'${this.deriveAs}'`;
} else {
return undefined;
deriveAs = '`' +this.deriveAs + '`';
}

return {
command: 'derive',
ruleString: 'derive value: ' + val + ' as: ' + deriveAs
}

} // function - getRuleData

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Expand All @@ -141,10 +131,19 @@ export class EditRuleDeriveComponent extends EditRuleComponent implements OnInit
` * Open advanced editor popup
*/
public openPopupFormulaInput() {
this.deriveVal = this.ruleConditionInputComponent.getCondition();
this.deriveVal = this.valueInput.getFormula();
this.advancedEditorClickEvent.emit({command :'derive', val : 'deriveVal' });
} // function - openPopupFormulaInput

/**
* Apply formula using Advanced formula popup
* @param {{command: string, formula: string}} data
*/
public doneInputFormula(data: { command: string, formula: string }) {
this.deriveVal = data.formula;
this.valueInput.setFormula(this.deriveVal);
}

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Protected Method
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
{{'msg.dp.th.condition' | translate}}<em class="ddp-icon-essential"></em>
</div>
<div class="ddp-wrap-datainput">
<rule-condition-input
[formula]="keepRow" [forceFormula]="forceFormula" [command]="'keep'" [fields]="fields" [tabIndex]="2"
(onChange)="keepRow = $event"></rule-condition-input>
<rule-suggest-input #keep_row_input
[formula]="keepRow"
[command]="'keep'" [cmdArg]="'row'"
[tabIndex]="2"
[fields]="fields"
(onChange)="keepRow = $event" ></rule-suggest-input>
</div>
<a href="javascript:" class="ddp-btn-bg" (click)="openPopupFormulaInput()"><em class="ddp-icon-editor"></em>{{'msg.dp.btn.advanced.editor' | translate }}</a>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import { EditRuleComponent } from './edit-rule.component';
import { Alert } from '../../../../../../common/util/alert.util';
import { isUndefined } from "util";
import * as _ from 'lodash';
import { StringUtil } from '../../../../../../common/util/string.util';
import { RuleConditionInputComponent } from './rule-condition-input.component';
import { RuleSuggestInputComponent } from './rule-suggest-input.component';
import {PreparationCommonUtil} from "../../../../../util/preparation-common.util";

@Component({
Expand All @@ -32,8 +31,8 @@ export class EditRuleKeepComponent extends EditRuleComponent implements OnInit,
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Private Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@ViewChild(RuleConditionInputComponent)
private ruleConditionInputComponent : RuleConditionInputComponent;
@ViewChild('keep_row_input')
private rowInput : RuleSuggestInputComponent;
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Protected Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
Expand Down Expand Up @@ -93,30 +92,18 @@ export class EditRuleKeepComponent extends EditRuleComponent implements OnInit,
* @return
*/
public getRuleData(): { command: string, ruleString:string} {
if (this.ruleConditionInputComponent.autoCompleteSuggestions_selectedIdx == -1) {
this.keepRow = this.ruleConditionInputComponent.getCondition();

this.keepRow = this.rowInput.getFormula();
let val = _.cloneDeep(this.keepRow);
if (isUndefined(val) || '' === val || '\'\'' === val) {
Alert.warning(this.translateService.instant('msg.dp.alert.keep.warn'));
return undefined
}

if (!isUndefined(val) && '' !== val.trim() && '\'\'' !== val.trim()) {
let check = StringUtil.checkSingleQuote(val, { isPairQuote: true });
if (check[0] === false) {
Alert.warning(this.translateService.instant('msg.dp.alert.check.condition'));
return undefined
} else {
val = check[1];
}
}
return {
command: 'keep',
ruleString: 'keep row: ' + val
};
} else {
return undefined;
}
} // function - getRuleData

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Expand All @@ -126,10 +113,19 @@ export class EditRuleKeepComponent extends EditRuleComponent implements OnInit,
* Open advanced formula popup
*/
public openPopupFormulaInput() {
this.keepRow = this.ruleConditionInputComponent.getCondition();
this.keepRow = this.rowInput.getFormula();;
this.advancedEditorClickEvent.emit({command : 'keep', val : 'keepRow'});
} // function - openPopupFormulaInput

/**
* Apply formula using Advanced formula popup
* @param {{command: string, formula: string}} data
*/
public doneInputFormula(data: { command: string, formula: string }) {
this.keepRow = data.formula;
this.rowInput.setFormula(this.keepRow);
}

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Protected Method
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
Expand Down
Loading

0 comments on commit a8437b2

Please sign in to comment.