Skip to content

Commit

Permalink
#747 add clean - replace/fill with custom value
Browse files Browse the repository at this point in the history
  • Loading branch information
paigechoi committed Nov 21, 2018
1 parent 232e974 commit 7ccd540
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,15 @@
<!-- //endHeader-->

<!--startKeep-->
<edit-rule-keep #editRule *ngIf="'keep' === ruleVO.command" (advancedEditorClickEvent)="openPopupFormulaInput('keep')"></edit-rule-keep>
<edit-rule-keep #editRule *ngIf="'keep' === ruleVO.command"
(advancedEditorClickEvent)="openPopupFormulaInput($event)">
</edit-rule-keep>
<!-- //endKeep-->

<!-- startReplace -->
<edit-rule-replace #editRule *ngIf="'replace' === ruleVO.command" (advancedEditorClickEvent)="openPopupFormulaInput('replace')"></edit-rule-replace>
<edit-rule-replace #editRule *ngIf="'replace' === ruleVO.command"
(advancedEditorClickEvent)="openPopupFormulaInput($event)">
</edit-rule-replace>
<!-- // endReplace -->

<!-- startRename -->
Expand All @@ -182,8 +186,9 @@
<!-- // endRename -->

<!--startSet-->
<edit-rule-set #editRule *ngIf="'set' === ruleVO.command" (advancedEditorClickEvent)="openPopupFormulaInput('set')"
(conditionClickEvent)="openPopupFormulaInput('setCondition')"></edit-rule-set>
<edit-rule-set #editRule *ngIf="'set' === ruleVO.command"
(advancedEditorClickEvent)="openPopupFormulaInput($event)">
</edit-rule-set>
<!--//endSet-->

<!--startSettype-->
Expand All @@ -199,11 +204,15 @@
<!--//endSplit-->

<!--startDerive-->
<edit-rule-derive #editRule *ngIf="'derive' === ruleVO.command" (advancedEditorClickEvent)="openPopupFormulaInput('derive')"></edit-rule-derive>
<edit-rule-derive #editRule *ngIf="'derive' === ruleVO.command"
(advancedEditorClickEvent)="openPopupFormulaInput($event)">
</edit-rule-derive>
<!--//endDerive-->

<!--startDelete-->
<edit-rule-delete #editRule *ngIf="'delete' === ruleVO.command" (advancedEditorClickEvent)="openPopupFormulaInput('delete')"></edit-rule-delete>
<edit-rule-delete #editRule *ngIf="'delete' === ruleVO.command"
(advancedEditorClickEvent)="openPopupFormulaInput($event)">
</edit-rule-delete>
<!--//endDelete-->

<!--startDrop-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,23 +1119,23 @@ export class EditDataflowRule2Component extends AbstractPopupComponent implement
* Open advanced formula input popup (set, keep, derive, delete)
* @param {string} command
*/
public openPopupFormulaInput(command: string) {
public openPopupFormulaInput(data: {command : string, val : string}) {
const fields: Field[] = this.selectedDataSet.gridData.fields;

// variables vary according to the rule name
// use this._editRuleComp.getValue({}) to get condition of each rule
let val : string = 'rowNum';
if (command === 'derive') {
val = 'deriveVal';
} else if (command === 'set') {
val = 'inputValue';
} else if (command === 'replace' || command === 'setCondition') {
val = 'condition';
} else if (command === 'keep') {
val = 'keepRow';
}
// let val : string = 'rowNum';
// if (command === 'derive') {
// val = 'deriveVal';
// } else if (command === 'set') {
// val = 'inputValue';
// } else if (command === 'replace' || command === 'setCondition') {
// val = 'condition';
// } else if (command === 'keep') {
// val = 'keepRow';
// }

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

/**
Expand Down Expand Up @@ -1445,7 +1445,7 @@ export class EditDataflowRule2Component extends AbstractPopupComponent implement
this._editRuleComp.init(this.selectedDataSet.gridData.fields, this.selectedDataSet.gridData.fields.filter( item => -1 < data.more.col.value.indexOf( item.uuid ) ), {ruleString : '', jsonRuleString : data.more});
break;
case 'set':
this._editRuleComp.init(this.selectedDataSet.gridData.fields, this.selectedDataSet.gridData.fields.filter( item => -1 < data.more.col.value.indexOf( item.uuid ) ));
this._editRuleComp.init(this.selectedDataSet.gridData.fields, this.selectedDataSet.gridData.fields.filter( item => -1 < data.more.col.value.indexOf( item.uuid ) ), {ruleString : '', jsonRuleString : data.more});
break;
case 'derive':
this._editRuleComp.init(this.selectedDataSet.gridData.fields, []);
Expand Down Expand Up @@ -1479,13 +1479,11 @@ export class EditDataflowRule2Component extends AbstractPopupComponent implement
if (this.inputRuleCmd !== '') {
this.inputRuleCmd = ''; // Empty builder rule string
} else {
return;
}

if (!this.editorUseFlag) {
// If no command is selected nothing happens
if (this.ruleVO.command === '' || isNullOrUndefined(this.ruleVO.command)) {
return;
if (!this.editorUseFlag) {
// If no command is selected nothing happens
if (this.ruleVO.command === '' || isNullOrUndefined(this.ruleVO.command)) {
return;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
* limitations under the License.
*/

import { AfterViewInit, Component, ElementRef, Injector, OnDestroy, OnInit } from '@angular/core';
import {AfterViewInit, Component, ElementRef, Injector, OnDestroy, OnInit, ViewChildren} from '@angular/core';
import { Field } from '../../../../../../domain/data-preparation/dataset';
import { EditRuleComponent } from './edit-rule.component';
import { Alert } from '../../../../../../common/util/alert.util';
import { StringUtil } from '../../../../../../common/util/string.util';
import { Filter } from '../../../../../../domain/workbook/configurations/filter/filter';
import {PreparationCommonUtil} from "../../../../../util/preparation-common.util";
import {RuleConditionInputComponent} from "./rule-condition-input.component";

@Component({
selector: 'edit-rule-aggregate',
Expand All @@ -28,7 +29,8 @@ export class EditRuleAggregateComponent extends EditRuleComponent implements OnI
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Private Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

@ViewChildren(RuleConditionInputComponent)
private ruleConditionInputComponent : RuleConditionInputComponent;
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Protected Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
Expand Down Expand Up @@ -105,7 +107,10 @@ export class EditRuleAggregateComponent extends EditRuleComponent implements OnI
}

const validFormulaList:string[] = [];
const invalidFormula:boolean = this.formulaList.some( formula => {
const invalidFormula:boolean = this.formulaList.some( (formula, index) => {

formula = this.ruleConditionInputComponent['_results'][index].getCondition();

if( StringUtil.checkSingleQuote(formula, { isWrapQuote: false, isAllowBlank: false })[0] ) {
if( StringUtil.checkFormula( formula ) ) {
validFormulaList.push( '\'' + formula + '\'' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ export class EditRuleDeleteComponent extends EditRuleComponent implements OnInit
* 수식 입력 팝업 오픈
* @param {string} command 수식 입력 실행 커맨드
*/
public openPopupFormulaInput(command: string) {
this.advancedEditorClickEvent.emit();
public openPopupFormulaInput() {
this.rowNum = this.ruleConditionInputComponent.getCondition();
this.advancedEditorClickEvent.emit({command :'delete', val : 'rowNum' });
} // function - openPopupFormulaInput


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ export class EditRuleDeriveComponent extends EditRuleComponent implements OnInit
| Public Method
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/**
* 수식 입력 팝업 오픈
* @param {string} command 수식 입력 실행 커맨드
` * Open advanced editor popup
*/
public openPopupFormulaInput(command: string) {
this.advancedEditorClickEvent.emit();
public openPopupFormulaInput() {
this.deriveVal = this.ruleConditionInputComponent.getCondition();
this.advancedEditorClickEvent.emit({command :'derive', val : 'deriveVal' });
} // function - openPopupFormulaInput

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ export class EditRuleKeepComponent extends EditRuleComponent implements OnInit,
| Public Method
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/**
* 수식 입력 팝업 오픈
* @param {string} command 수식 입력 실행 커맨드
* Open advanced formula popup
*/
public openPopupFormulaInput(command: string) {
this.advancedEditorClickEvent.emit();
public openPopupFormulaInput() {
this.keepRow = this.ruleConditionInputComponent.getCondition();
this.advancedEditorClickEvent.emit({command : 'keep', val : 'keepRow'});
} // function - openPopupFormulaInput

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
* limitations under the License.
*/

import { AfterViewInit, Component, ElementRef, Injector, OnDestroy, OnInit } from '@angular/core';
import {AfterViewInit, Component, ElementRef, Injector, OnDestroy, OnInit, ViewChildren} from '@angular/core';
import { Field } from '../../../../../../domain/data-preparation/dataset';
import { EditRuleComponent } from './edit-rule.component';
import { Alert } from '../../../../../../common/util/alert.util';
import { StringUtil } from '../../../../../../common/util/string.util';
import * as _ from 'lodash';
import {RuleConditionInputComponent} from "./rule-condition-input.component";

@Component({
selector: 'edit-rule-pivot',
Expand All @@ -27,7 +28,8 @@ export class EditRulePivotComponent extends EditRuleComponent implements OnInit,
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Private Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

@ViewChildren(RuleConditionInputComponent)
private ruleConditionInputComponent : RuleConditionInputComponent;
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Protected Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
Expand Down Expand Up @@ -106,7 +108,8 @@ export class EditRulePivotComponent extends EditRuleComponent implements OnInit,
}

const validFormulaList:string[] = [];
const invalidFormula:boolean = this.formulaList.some( formula => {
const invalidFormula:boolean = this.formulaList.some( (formula, index) => {
formula = this.ruleConditionInputComponent['_results'][index].getCondition();
if( StringUtil.checkSingleQuote(formula, { isWrapQuote: false, isAllowBlank: false })[0] ) {
if( StringUtil.checkFormula( formula ) ) {
validFormulaList.push( '\'' + formula + '\'' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { StringUtil } from '../../../../../../common/util/string.util';
import { isUndefined } from "util";
import { EventBroadcaster } from '../../../../../../common/event/event.broadcaster';
import { PreparationCommonUtil } from '../../../../../util/preparation-common.util';
import {RuleConditionInputComponent} from "./rule-condition-input.component";

@Component({
selector : 'edit-rule-replace',
Expand All @@ -34,6 +35,9 @@ export class EditRuleReplaceComponent extends EditRuleComponent implements OnIni
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@ViewChild('patternValue')
private _patternValue: ElementRef;

@ViewChild(RuleConditionInputComponent)
private ruleConditionInputComponent : RuleConditionInputComponent;
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Protected Variables
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
Expand Down Expand Up @@ -144,6 +148,7 @@ export class EditRuleReplaceComponent extends EditRuleComponent implements OnIni
}

// condition
this.condition = this.ruleConditionInputComponent.getCondition();
let clonedCondition = this.condition;
if (!isUndefined(clonedCondition) && '' !== clonedCondition.trim() && '\'\'' !== clonedCondition.trim()) {
let check = StringUtil.checkSingleQuote(clonedCondition, { isPairQuote: true });
Expand Down Expand Up @@ -186,7 +191,8 @@ export class EditRuleReplaceComponent extends EditRuleComponent implements OnIni
* open advanced formula popup
*/
public openPopupFormulaInput() {
this.advancedEditorClickEvent.emit();
this.condition = this.ruleConditionInputComponent.getCondition();
this.advancedEditorClickEvent.emit({command : 'replace', val : 'condition'});
} // function - openPopupFormulaInput


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
<rule-condition-input
[formula]="inputValue" [command]="'keep'"
[forceFormula]="forceFormula" [fields]="fields"
[tabIndex]="2" [placeholder]="'msg.dp.th.expression.ph' | translate"
[tabIndex]="3" [placeholder]="'msg.dp.th.expression.ph' | translate"
(onChange)="inputValue = $event"></rule-condition-input>
</div>
<a href="javascript:" class="ddp-btn-bg" (click)="openPopupFormulaInput()"><em class="ddp-icon-editor"></em>{{'msg.dp.btn.advanced.editor' | translate }}</a>
<a href="javascript:" class="ddp-btn-bg" (click)="openPopupFormulaInput('inputValue')"><em class="ddp-icon-editor"></em>{{'msg.dp.btn.advanced.editor' | translate }}</a>
</div>
<!-- //part -->
<!-- part -->
Expand All @@ -48,8 +48,8 @@
[forceCondition]="forceCondition"
[formula]="condition" [command]="'keep'"
[fields]="fields"
[tabIndex]="6" [placeholder]="'msg.dp.ui.cond.ph' | translate"
[tabIndex]="4" [placeholder]="'msg.dp.ui.cond.ph' | translate"
(onChange)="condition = $event"></rule-condition-input>
</div>
<a href="javascript:" class="ddp-btn-bg" (click)="conditionClickEvent.emit()"><em class="ddp-icon-editor"></em>{{'msg.dp.btn.advanced.editor' | translate }}</a>
<a href="javascript:" class="ddp-btn-bg" (click)="openPopupFormulaInput('condition')"><em class="ddp-icon-editor"></em>{{'msg.dp.btn.advanced.editor' | translate }}</a>
</div>

0 comments on commit 7ccd540

Please sign in to comment.