feat: filtering by reference to Variables as well as Values

This commit is contained in:
Mihajlo Medjedovic 2023-12-26 21:08:58 +01:00
parent 09022c995f
commit 6eb1aa85d2
7 changed files with 53 additions and 6 deletions

View File

@ -413,7 +413,9 @@
>
<app-soft-select
label="Value"
[secondLabel]="query.type === 'char' ? 'Variable' : undefined"
[inputId]="'vals_' + queryIndex + '_' + clauseIndex"
(selectedLabelChange)="selectedLabelChange($event, query)"
[(value)]="query.value"
[enableLoadMore]="query.nobs > query.values.length"
(onInputEvent)="

View File

@ -95,6 +95,7 @@ export class QueryComponent
variable: null,
operator: null,
value: null,
valueVariable: false,
startrow: 0,
rows: 0,
nobs: 0,
@ -750,6 +751,11 @@ export class QueryComponent
)
}
public selectedLabelChange(label: string, query: any) {
query.valueVariable = label === 'Variable'
this.whereClauseFn()
}
public variableInputChange(
queryVariable: any,
index: number,

View File

@ -408,14 +408,18 @@ export class SasStoreService {
for (let index = 0; index < clauses.queryObj.length; index++) {
let string = ''
let clause = clauses.queryObj[index]
for (let ind = 0; ind < clause.elements.length; ind++) {
let query = clause.elements[ind]
if (ind < clause.elements.length - 1) {
opr = clause.clauseLogic
} else {
opr = ''
}
let val: any
for (let k = 0; k < query.values.length; k++) {
if (
typeof query.value === 'string' &&
@ -486,6 +490,8 @@ export class SasStoreService {
}
let type = query.type
//if the value is variable, omit quotes in the 'where' string
const isValueVariable = query.valueVariable
let variable = query.variable === null ? '' : query.variable
let oper = query.operator === null ? '' : query.operator
// let value = val === null ? "''" : val;
@ -499,10 +505,14 @@ export class SasStoreService {
if (type === 'char' && oper !== 'IN' && oper !== 'NOT IN') {
if (typeof value === 'undefined') {
value = ''
value = " '" + value + "' "
} else {
value = " '" + value + "' "
}
if (isValueVariable) {
value = " " + value + " " //without quotes, with spaces
} else {
value = " '" + value + "' " //with quotes and spaces
}
string = string + ' ' + variable + ' ' + oper + value + opr
} else {
if (type === 'num' && typeof value === 'undefined') {

View File

@ -1,4 +1,10 @@
<label *ngIf="label" class="clr-control-label">{{ label }}</label>
<label *ngIf="label" [class.secondLabelActive]="secondLabel && secondLabel.length > 0" class="clr-control-label">
<span (click)="onChangeLabel('first')" [class.value-type-selected]="labelSelected === 'first'">{{ label }}</span>
<ng-container *ngIf="secondLabel">
/
<span (click)="onChangeLabel('second')" [class.value-type-selected]="labelSelected === 'second'">{{ secondLabel }}</span>
</ng-container>
</label>
<ng-container [ngSwitch]="type">
<ng-container *ngSwitchCase="'date'">
<clr-date-container>

View File

@ -28,4 +28,12 @@ clr-date-container {
margin-top: -5px;
}
}
}
label.secondLabelActive span {
&:not(.value-type-selected) {
text-decoration: line-through;
cursor: pointer;
opacity: 0.6;
}
}

View File

@ -18,6 +18,7 @@ import { OnLoadingMoreEvent } from '../autocomplete/autocomplete.component'
export class SoftSelectComponent implements OnInit, OnChanges {
@Input() inputId: string = ''
@Input() label: string | undefined
@Input() secondLabel: string | undefined
@Input() value: Date | string | null = ''
@Input() disabled: boolean = false
@Input() type: string = 'text'
@ -30,20 +31,24 @@ export class SoftSelectComponent implements OnInit, OnChanges {
@Output() focusinInput: EventEmitter<any> = new EventEmitter()
@Output() onAutocompleteLoadingMore: EventEmitter<OnLoadingMoreEvent> =
new EventEmitter()
@Output() selectedLabelChange: EventEmitter<string> = new EventEmitter()
@ViewChild('input') inputElement: any
temp: Date | string | null = ''
inputFocused: boolean = false
labelSelected: LabelTypes = 'first'
constructor() {}
ngOnChanges(changes: SimpleChanges): void {
if (
changes.value &&
changes.value.currentValue !== changes.value.previousValue
)
) {
this.valueChange.emit(changes.value.currentValue)
}
}
ngOnInit(): void {}
@ -85,4 +90,14 @@ export class SoftSelectComponent implements OnInit, OnChanges {
onFocusinInput(event: any) {
this.focusinInput.emit(event)
}
onChangeLabel(label: LabelTypes) {
this.labelSelected = label
const selectedLabelText = label === 'first' ? this.label : this.secondLabel
this.selectedLabelChange.emit(selectedLabelText)
}
}
export type LabelTypes = 'first' | 'second'

View File

@ -18,4 +18,4 @@ In any case, you must not make any such use of this software as to develop softw
UNLESS EXPRESSLY AGREED OTHERWISE, 4GL APPS PROVIDES THIS SOFTWARE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, AND IN NO EVENT AND UNDER NO LEGAL THEORY, SHALL 4GL APPS BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM USE OR INABILITY TO USE THIS SOFTWARE.
`
`