+
-
0" class="q-inline-block-display">
+
@@ -179,4 +179,4 @@
-
\ No newline at end of file
+
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.scss b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.scss
similarity index 99%
rename from projects/angular2-query-builder/src/lib/query-builder/query-builder.component.scss
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.scss
index 2d9208a4..68ea1678 100644
--- a/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.scss
+++ b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.scss
@@ -78,6 +78,7 @@
border-radius: 4px;
box-sizing: border-box;
width: auto;
+ min-width: 180px;
&:disabled {
border-color: transparent;
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.spec.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.spec.ts
similarity index 100%
rename from projects/angular2-query-builder/src/lib/query-builder/query-builder.component.spec.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.spec.ts
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.ts
similarity index 80%
rename from projects/angular2-query-builder/src/lib/query-builder/query-builder.component.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.ts
index 418a0298..6a2b1e18 100644
--- a/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.ts
+++ b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.component.ts
@@ -68,7 +68,7 @@ export const VALIDATOR: any = {
styleUrls: ['./query-builder.component.scss'],
providers: [CONTROL_VALUE_ACCESSOR, VALIDATOR]
})
-export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAccessor, Validator {
+export class QueryBuilderComponent implements OnChanges, ControlValueAccessor, Validator {
public fields: Field[];
public filterFields: Field[];
public entities: Entity[];
@@ -111,64 +111,68 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
category: ['=', '!=', 'in', 'not in'],
boolean: ['=']
};
- @Input() disabled: boolean;
- @Input() data: RuleSet = { condition: 'and', rules: [] };
+ @Input() disabled = false;
+ @Input() data: RuleSet = { condition: 'add', rules: [] };
// For ControlValueAccessor interface
- public onChangeCallback: () => void;
- public onTouchedCallback: () => any;
-
- @Input() allowRuleset: boolean = true;
- @Input() allowCollapse: boolean = false;
- @Input() emptyMessage: string = 'A ruleset cannot be empty. Please add a rule or remove it all together.';
- @Input() classNames: QueryBuilderClassNames;
- @Input() operatorMap: { [key: string]: string[] };
- @Input() parentValue: RuleSet;
+ public onChangeCallback!: () => void;
+ public onTouchedCallback!: () => any;
+
+ @Input() allowRuleset = true;
+ @Input() allowCollapse = false;
+ @Input() emptyMessage = 'A ruleset cannot be empty. Please add a rule or remove it all together.';
+ @Input() classNames: QueryBuilderClassNames = {};
+ @Input() operatorMap: { [key: string]: string[] } = {};
+ @Input() parentValue: RuleSet = { condition: 'add', rules: [] };
@Input() config: QueryBuilderConfig = { fields: {} };
- @Input() parentArrowIconTemplate: QueryArrowIconDirective;
- @Input() parentInputTemplates: QueryList
;
- @Input() parentOperatorTemplate: QueryOperatorDirective;
- @Input() parentFieldTemplate: QueryFieldDirective;
- @Input() parentEntityTemplate: QueryEntityDirective;
- @Input() parentSwitchGroupTemplate: QuerySwitchGroupDirective;
- @Input() parentButtonGroupTemplate: QueryButtonGroupDirective;
- @Input() parentRemoveButtonTemplate: QueryRemoveButtonDirective;
- @Input() parentEmptyWarningTemplate: QueryEmptyWarningDirective;
- @Input() parentChangeCallback: () => void;
- @Input() parentTouchedCallback: () => void;
- @Input() persistValueOnFieldChange: boolean = false;
-
- @ViewChild('treeContainer', {static: true}) treeContainer: ElementRef;
-
- @ContentChild(QueryButtonGroupDirective) buttonGroupTemplate: QueryButtonGroupDirective;
- @ContentChild(QuerySwitchGroupDirective) switchGroupTemplate: QuerySwitchGroupDirective;
- @ContentChild(QueryFieldDirective) fieldTemplate: QueryFieldDirective;
- @ContentChild(QueryEntityDirective) entityTemplate: QueryEntityDirective;
- @ContentChild(QueryOperatorDirective) operatorTemplate: QueryOperatorDirective;
- @ContentChild(QueryRemoveButtonDirective) removeButtonTemplate: QueryRemoveButtonDirective;
- @ContentChild(QueryEmptyWarningDirective) emptyWarningTemplate: QueryEmptyWarningDirective;
- @ContentChildren(QueryInputDirective) inputTemplates: QueryList;
- @ContentChild(QueryArrowIconDirective) arrowIconTemplate: QueryArrowIconDirective;
+ @Input() parentArrowIconTemplate!: QueryArrowIconDirective;
+ @Input() parentInputTemplates!: QueryList;
+ @Input() parentOperatorTemplate!: QueryOperatorDirective;
+ @Input() parentFieldTemplate!: QueryFieldDirective;
+ @Input() parentEntityTemplate!: QueryEntityDirective;
+ @Input() parentSwitchGroupTemplate!: QuerySwitchGroupDirective;
+ @Input() parentButtonGroupTemplate!: QueryButtonGroupDirective;
+ @Input() parentRemoveButtonTemplate!: QueryRemoveButtonDirective;
+ @Input() parentEmptyWarningTemplate!: QueryEmptyWarningDirective;
+ @Input() parentChangeCallback!: () => void;
+ @Input() parentTouchedCallback!: () => void;
+ @Input() persistValueOnFieldChange = false;
+
+ @ViewChild('treeContainer', {static: true}) treeContainer!: ElementRef;
+
+ @ContentChild(QueryButtonGroupDirective) buttonGroupTemplate!: QueryButtonGroupDirective;
+ @ContentChild(QuerySwitchGroupDirective) switchGroupTemplate!: QuerySwitchGroupDirective;
+ @ContentChild(QueryFieldDirective) fieldTemplate!: QueryFieldDirective;
+ @ContentChild(QueryEntityDirective) entityTemplate!: QueryEntityDirective;
+ @ContentChild(QueryOperatorDirective) operatorTemplate!: QueryOperatorDirective;
+ @ContentChild(QueryRemoveButtonDirective) removeButtonTemplate!: QueryRemoveButtonDirective;
+ @ContentChild(QueryEmptyWarningDirective) emptyWarningTemplate!: QueryEmptyWarningDirective;
+ @ContentChildren(QueryInputDirective) inputTemplates!: QueryList;
+ @ContentChild(QueryArrowIconDirective) arrowIconTemplate!: QueryArrowIconDirective;
private defaultTemplateTypes: string[] = [
'string', 'number', 'time', 'date', 'category', 'boolean', 'multiselect'];
private defaultPersistValueTypes: string[] = [
'string', 'number', 'time', 'date', 'boolean'];
private defaultEmptyList: any[] = [];
- private operatorsCache: { [key: string]: string[] };
+ private operatorsCache: { [key: string]: string[] } = {};
private inputContextCache = new Map();
private operatorContextCache = new Map();
private fieldContextCache = new Map();
private entityContextCache = new Map();
private removeButtonContextCache = new Map();
- private buttonGroupContext: ButtonGroupContext;
+ private buttonGroupContext!: ButtonGroupContext;
- constructor(private changeDetectorRef: ChangeDetectorRef) { }
+ constructor(
+ private changeDetectorRef: ChangeDetectorRef
+ ) {
+ this.fields = [];
+ this.filterFields = [];
+ this.entities = [];
+ }
// ----------OnInit Implementation----------
- ngOnInit() { }
-
// ----------OnChanges Implementation----------
ngOnChanges(changes: SimpleChanges) {
@@ -182,12 +186,12 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
});
if (config.entities) {
this.entities = Object.keys(config.entities).map((value) => {
- const entity = config.entities[value];
+ const entity = config.entities ? config.entities[value]: [] as any;
entity.value = entity.value || value;
return entity;
});
} else {
- this.entities = null;
+ this.entities = [];
}
this.operatorsCache = {};
} else {
@@ -199,7 +203,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
validate(control: AbstractControl): ValidationErrors | null {
const errors: { [key: string]: any } = {};
- const ruleErrorStore = [];
+ const ruleErrorStore = [] as any;
let hasErrors = false;
if (!this.config.allowEmptyRulesets && this.checkEmptyRuleInRuleset(this.data)) {
@@ -224,7 +228,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
}
set value(value: RuleSet) {
// When component is initialized without a formControl, null is passed to value
- this.data = value || { condition: 'and', rules: [] };
+ this.data = value || { condition: 'add', rules: [] };
this.handleDataChange();
}
@@ -248,8 +252,8 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
return this.disabled;
}
- findTemplateForRule(rule: Rule): TemplateRef {
- const type = this.getInputType(rule.field, rule.operator);
+ findTemplateForRule(rule: Rule): TemplateRef | any {
+ const type = this.getInputType(rule.field, rule.operator as string);
if (type) {
const queryInput = this.findQueryInput(type);
if (queryInput) {
@@ -265,7 +269,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
findQueryInput(type: string): QueryInputDirective {
const templates = this.parentInputTemplates || this.inputTemplates;
- return templates.find((item) => item.queryInputType === type);
+ return templates.find((item) => item.queryInputType === type) as QueryInputDirective;
}
getOperators(field: string): string[] {
@@ -303,7 +307,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
}
getFields(entity: string): Field[] {
- if (this.entities && entity) {
+ if (this.entities.length && entity) {
return this.fields.filter((field) => {
return field && field.entity === entity;
});
@@ -312,7 +316,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
}
}
- getInputType(field: string, operator: string): string {
+ getInputType(field: string, operator: string): string | null {
if (this.config.getInputType) {
return this.config.getInputType(field, operator);
}
@@ -341,13 +345,14 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
return this.config.fields[field].options || this.defaultEmptyList;
}
- getClassNames(...args): string {
- const clsLookup = this.classNames ? this.classNames : this.defaultClassNames;
- const classNames = args.map((id) => clsLookup[id] || this.defaultClassNames[id]).filter((c) => !!c);
- return classNames.length ? classNames.join(' ') : null;
+ getClassNames(...args: string[]): any | string[] {
+ const clsLookup = this.classNames ? this.classNames : this.defaultClassNames as any;
+ const defaultClassNames = this.defaultClassNames as any;
+ const classNames = args.map((id: any) => clsLookup[id] || defaultClassNames[id]).filter((c: any) => !!c);
+ return classNames.length ? classNames.join(' ') : [];
}
- getDefaultField(entity: Entity): Field {
+ getDefaultField(entity: Entity): Field | null {
if (!entity) {
return null;
} else if (entity.defaultField !== undefined) {
@@ -366,11 +371,11 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
}
}
- getDefaultOperator(field: Field): string {
+ getDefaultOperator(field: Field): string | null {
if (field && field.defaultOperator !== undefined) {
return this.getDefaultValue(field.defaultOperator);
} else {
- const operators = this.getOperators(field.value);
+ const operators = this.getOperators(field.value as string);
if (operators && operators.length) {
return operators[0];
} else {
@@ -392,8 +397,8 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
} else {
const field = this.fields[0];
parent.rules = parent.rules.concat([{
- field: field.value,
- operator: this.getDefaultOperator(field),
+ field: field.value as string,
+ operator: this.getDefaultOperator(field) as string,
value: this.getDefaultValue(field.defaultValue),
entity: field.entity
}]);
@@ -433,7 +438,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
if (this.config.addRuleSet) {
this.config.addRuleSet(parent);
} else {
- parent.rules = parent.rules.concat([{ condition: 'and', rules: [] }]);
+ parent.rules = parent.rules.concat([{ condition: 'add', rules: [] }]);
}
this.handleTouched();
@@ -491,9 +496,9 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
}
if (this.config.coerceValueForOperator) {
- rule.value = this.config.coerceValueForOperator(rule.operator, rule.value, rule);
+ rule.value = this.config.coerceValueForOperator(rule.operator as string, rule.value, rule);
} else {
- rule.value = this.coerceValueForOperator(rule.operator, rule.value, rule);
+ rule.value = this.coerceValueForOperator(rule.operator as string, rule.value, rule);
}
this.handleTouched();
@@ -501,7 +506,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
}
coerceValueForOperator(operator: string, value: any, rule: Rule): any {
- const inputType: string = this.getInputType(rule.field, operator);
+ const inputType: string | null = this.getInputType(rule.field, operator);
if (inputType === 'multiselect' && !Array.isArray(value)) {
return [value];
}
@@ -528,7 +533,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
const nextField: Field = this.config.fields[fieldValue];
const nextValue = this.calculateFieldChangeValue(
- currentField, nextField, rule.value);
+ currentField as Field, nextField, rule.value);
if (nextValue !== undefined) {
rule.value = nextValue;
@@ -536,7 +541,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
delete rule.value;
}
- rule.operator = this.getDefaultOperator(nextField);
+ rule.operator = this.getDefaultOperator(nextField) as string;
// Create new context objects so templates will automatically update
this.inputContextCache.delete(rule);
@@ -558,16 +563,16 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
}
let i = index;
let rs = data;
- const entity: Entity = this.entities.find((e) => e.value === entityValue);
- const defaultField: Field = this.getDefaultField(entity);
+ const entity: Entity = this.entities.find((e) => e.value === entityValue) as Entity;
+ const defaultField: Field = this.getDefaultField(entity) as Field;
if (!rs) {
rs = this.data;
i = rs.rules.findIndex((x) => x === rule);
}
- rule.field = defaultField.value;
+ rule.field = defaultField.value as string;
rs.rules[i] = rule;
if (defaultField) {
- this.changeField(defaultField.value, rule);
+ this.changeField(defaultField.value as string, rule);
} else {
this.handleTouched();
this.handleDataChange();
@@ -583,42 +588,42 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
}
}
- getOperatorTemplate(): TemplateRef {
+ getOperatorTemplate(): TemplateRef | null {
const t = this.parentOperatorTemplate || this.operatorTemplate;
return t ? t.template : null;
}
- getFieldTemplate(): TemplateRef {
+ getFieldTemplate(): TemplateRef | null {
const t = this.parentFieldTemplate || this.fieldTemplate;
return t ? t.template : null;
}
- getEntityTemplate(): TemplateRef {
+ getEntityTemplate(): TemplateRef | null {
const t = this.parentEntityTemplate || this.entityTemplate;
return t ? t.template : null;
}
- getArrowIconTemplate(): TemplateRef {
+ getArrowIconTemplate(): TemplateRef | null {
const t = this.parentArrowIconTemplate || this.arrowIconTemplate;
return t ? t.template : null;
}
- getButtonGroupTemplate(): TemplateRef {
+ getButtonGroupTemplate(): TemplateRef | null {
const t = this.parentButtonGroupTemplate || this.buttonGroupTemplate;
return t ? t.template : null;
}
- getSwitchGroupTemplate(): TemplateRef {
+ getSwitchGroupTemplate(): TemplateRef | null {
const t = this.parentSwitchGroupTemplate || this.switchGroupTemplate;
return t ? t.template : null;
}
- getRemoveButtonTemplate(): TemplateRef {
+ getRemoveButtonTemplate(): TemplateRef | null {
const t = this.parentRemoveButtonTemplate || this.removeButtonTemplate;
return t ? t.template : null;
}
- getEmptyWarningTemplate(): TemplateRef {
+ getEmptyWarningTemplate(): TemplateRef | null {
const t = this.parentEmptyWarningTemplate || this.emptyWarningTemplate;
return t ? t.template : null;
}
@@ -629,15 +634,15 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
if (local.invalid) {
cls += ' ' + this.getClassNames('invalidRuleSet');
}
- return cls;
+ return cls as string;
}
getButtonGroupContext(): ButtonGroupContext {
if (!this.buttonGroupContext) {
this.buttonGroupContext = {
addRule: this.addRule.bind(this),
- addRuleSet: this.allowRuleset && this.addRuleSet.bind(this),
- removeRuleSet: this.allowRuleset && this.parentValue && this.removeRuleSet.bind(this),
+ addRuleSet: this.allowRuleset && this.addRuleSet.bind(this) as any,
+ removeRuleSet: this.allowRuleset && this.parentValue && this.removeRuleSet.bind(this) as any,
getDisabledState: this.getDisabledState,
$implicit: this.data
};
@@ -653,7 +658,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
$implicit: rule
});
}
- return this.removeButtonContextCache.get(rule);
+ return this.removeButtonContextCache.get(rule) as RemoveButtonContext;
}
getFieldContext(rule: Rule): FieldContext {
@@ -666,19 +671,19 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
$implicit: rule
});
}
- return this.fieldContextCache.get(rule);
+ return this.fieldContextCache.get(rule) as FieldContext;
}
getEntityContext(rule: Rule): EntityContext {
if (!this.entityContextCache.has(rule)) {
this.entityContextCache.set(rule, {
- onChange: this.changeEntity.bind(this),
+ onChange: this.changeEntity.bind(this) as any,
getDisabledState: this.getDisabledState,
entities: this.entities,
$implicit: rule
});
}
- return this.entityContextCache.get(rule);
+ return this.entityContextCache.get(rule) as EntityContext;
}
getSwitchGroupContext(): SwitchGroupContext {
@@ -707,13 +712,13 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
getOperatorContext(rule: Rule): OperatorContext {
if (!this.operatorContextCache.has(rule)) {
this.operatorContextCache.set(rule, {
- onChange: this.changeOperator.bind(this),
+ onChange: this.changeOperator.bind(this) as any,
getDisabledState: this.getDisabledState,
operators: this.getOperators(rule.field),
$implicit: rule
});
}
- return this.operatorContextCache.get(rule);
+ return this.operatorContextCache.get(rule) as OperatorContext;
}
getInputContext(rule: Rule): InputContext {
@@ -726,7 +731,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
$implicit: rule
});
}
- return this.inputContextCache.get(rule);
+ return this.inputContextCache.get(rule) as InputContext;
}
private calculateFieldChangeValue(
@@ -763,7 +768,7 @@ export class QueryBuilderComponent implements OnInit, OnChanges, ControlValueAcc
if (!ruleset || !ruleset.rules || ruleset.rules.length === 0) {
return true;
} else {
- return ruleset.rules.some((item: RuleSet) => {
+ return ruleset.rules.some((item: RuleSet | any) => {
if (item.rules) {
return this.checkEmptyRuleInRuleset(item);
} else {
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-builder.interfaces.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.interfaces.ts
similarity index 98%
rename from projects/angular2-query-builder/src/lib/query-builder/query-builder.interfaces.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.interfaces.ts
index c47a622b..f4405bbf 100644
--- a/projects/angular2-query-builder/src/lib/query-builder/query-builder.interfaces.ts
+++ b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-builder.interfaces.ts
@@ -2,7 +2,7 @@ import { ValidationErrors } from '@angular/forms';
export interface RuleSet {
condition: string;
- rules: Array;
+ rules: Array;
collapsed?: boolean;
isChild?: boolean;
}
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-button-group.directive.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-button-group.directive.ts
similarity index 100%
rename from projects/angular2-query-builder/src/lib/query-builder/query-button-group.directive.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-button-group.directive.ts
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-empty-warning.directive.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-empty-warning.directive.ts
similarity index 100%
rename from projects/angular2-query-builder/src/lib/query-builder/query-empty-warning.directive.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-empty-warning.directive.ts
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-entity.directive.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-entity.directive.ts
similarity index 100%
rename from projects/angular2-query-builder/src/lib/query-builder/query-entity.directive.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-entity.directive.ts
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-field.directive.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-field.directive.ts
similarity index 100%
rename from projects/angular2-query-builder/src/lib/query-builder/query-field.directive.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-field.directive.ts
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-input.directive.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-input.directive.ts
similarity index 95%
rename from projects/angular2-query-builder/src/lib/query-builder/query-input.directive.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-input.directive.ts
index cccccc86..e6407506 100644
--- a/projects/angular2-query-builder/src/lib/query-builder/query-input.directive.ts
+++ b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-input.directive.ts
@@ -11,7 +11,7 @@ export class QueryInputDirective {
if (!value) { return; }
this._type = value;
}
- private _type: string;
+ private _type!: string;
constructor(public template: TemplateRef) {}
}
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-operator.directive.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-operator.directive.ts
similarity index 100%
rename from projects/angular2-query-builder/src/lib/query-builder/query-operator.directive.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-operator.directive.ts
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-remove-button.directive.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-remove-button.directive.ts
similarity index 100%
rename from projects/angular2-query-builder/src/lib/query-builder/query-remove-button.directive.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-remove-button.directive.ts
diff --git a/projects/angular2-query-builder/src/lib/query-builder/query-switch-group.directive.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-switch-group.directive.ts
similarity index 100%
rename from projects/angular2-query-builder/src/lib/query-builder/query-switch-group.directive.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/lib/query-builder/query-switch-group.directive.ts
diff --git a/projects/angular2-query-builder/src/public-api.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/public-api.ts
similarity index 100%
rename from projects/angular2-query-builder/src/public-api.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/public-api.ts
diff --git a/projects/angular2-query-builder/src/test.ts b/Angular-QueryBuilder/projects/angular2-query-builder/src/test.ts
similarity index 75%
rename from projects/angular2-query-builder/src/test.ts
rename to Angular-QueryBuilder/projects/angular2-query-builder/src/test.ts
index 978c64fb..52e55168 100644
--- a/projects/angular2-query-builder/src/test.ts
+++ b/Angular-QueryBuilder/projects/angular2-query-builder/src/test.ts
@@ -1,14 +1,19 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
-import 'zone.js/dist/zone';
-import 'zone.js/dist/zone-testing';
+import 'zone.js';
+import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
-declare const require: any;
+declare const require: {
+ context(path: string, deep?: boolean, filter?: RegExp): {
+ keys(): string[];
+ (id: string): T;
+ };
+};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
diff --git a/Angular-QueryBuilder/projects/angular2-query-builder/tsconfig.lib.json b/Angular-QueryBuilder/projects/angular2-query-builder/tsconfig.lib.json
new file mode 100644
index 00000000..1407202d
--- /dev/null
+++ b/Angular-QueryBuilder/projects/angular2-query-builder/tsconfig.lib.json
@@ -0,0 +1,20 @@
+/* To learn more about this file see: https://angular.io/config/tsconfig. */
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../out-tsc/lib",
+ "target": "es2015",
+ "declaration": true,
+ "declarationMap": true,
+ "inlineSources": true,
+ "types": [],
+ "lib": [
+ "dom",
+ "es2018"
+ ]
+ },
+ "exclude": [
+ "src/test.ts",
+ "**/*.spec.ts"
+ ]
+}
diff --git a/Angular-QueryBuilder/projects/angular2-query-builder/tsconfig.lib.prod.json b/Angular-QueryBuilder/projects/angular2-query-builder/tsconfig.lib.prod.json
new file mode 100644
index 00000000..06de549e
--- /dev/null
+++ b/Angular-QueryBuilder/projects/angular2-query-builder/tsconfig.lib.prod.json
@@ -0,0 +1,10 @@
+/* To learn more about this file see: https://angular.io/config/tsconfig. */
+{
+ "extends": "./tsconfig.lib.json",
+ "compilerOptions": {
+ "declarationMap": false
+ },
+ "angularCompilerOptions": {
+ "compilationMode": "partial"
+ }
+}
diff --git a/projects/angular2-query-builder/tsconfig.spec.json b/Angular-QueryBuilder/projects/angular2-query-builder/tsconfig.spec.json
similarity index 69%
rename from projects/angular2-query-builder/tsconfig.spec.json
rename to Angular-QueryBuilder/projects/angular2-query-builder/tsconfig.spec.json
index 16da33db..715dd0a5 100644
--- a/projects/angular2-query-builder/tsconfig.spec.json
+++ b/Angular-QueryBuilder/projects/angular2-query-builder/tsconfig.spec.json
@@ -1,10 +1,10 @@
+/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": [
- "jasmine",
- "node"
+ "jasmine"
]
},
"files": [
diff --git a/Angular-QueryBuilder/projects/demo/.browserslistrc b/Angular-QueryBuilder/projects/demo/.browserslistrc
new file mode 100644
index 00000000..427441dc
--- /dev/null
+++ b/Angular-QueryBuilder/projects/demo/.browserslistrc
@@ -0,0 +1,17 @@
+# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
+# For additional information regarding the format and rule options, please see:
+# https://github.com/browserslist/browserslist#queries
+
+# For the full list of supported browsers by the Angular framework, please see:
+# https://angular.io/guide/browser-support
+
+# You can see what browsers were selected by your queries by running:
+# npx browserslist
+
+last 1 Chrome version
+last 1 Firefox version
+last 2 Edge major versions
+last 2 Safari major versions
+last 2 iOS major versions
+Firefox ESR
+not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
diff --git a/demo/src/karma.conf.js b/Angular-QueryBuilder/projects/demo/karma.conf.js
similarity index 51%
rename from demo/src/karma.conf.js
rename to Angular-QueryBuilder/projects/demo/karma.conf.js
index b6e00421..9486318a 100644
--- a/demo/src/karma.conf.js
+++ b/Angular-QueryBuilder/projects/demo/karma.conf.js
@@ -9,16 +9,28 @@ module.exports = function (config) {
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
- require('karma-coverage-istanbul-reporter'),
+ require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
+ jasmine: {
+ // you can add configuration options for Jasmine here
+ // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
+ // for example, you can disable the random execution with `random: false`
+ // or set a specific seed with `seed: 4321`
+ },
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
- coverageIstanbulReporter: {
- dir: require('path').join(__dirname, '../coverage'),
- reports: ['html', 'lcovonly'],
- fixWebpackSourcePaths: true
+ jasmineHtmlReporter: {
+ suppressAll: true // removes the duplicated traces
+ },
+ coverageReporter: {
+ dir: require('path').join(__dirname, '../../coverage/demo'),
+ subdir: '.',
+ reporters: [
+ { type: 'html' },
+ { type: 'text-summary' }
+ ]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
@@ -26,6 +38,7 @@ module.exports = function (config) {
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
- singleRun: false
+ singleRun: false,
+ restartOnFileChange: true
});
-};
\ No newline at end of file
+};
diff --git a/Angular-QueryBuilder/projects/demo/src/app/app.component.html b/Angular-QueryBuilder/projects/demo/src/app/app.component.html
new file mode 100644
index 00000000..5ba9eea3
--- /dev/null
+++ b/Angular-QueryBuilder/projects/demo/src/app/app.component.html
@@ -0,0 +1 @@
+App Component works!
diff --git a/demo/src/assets/.gitkeep b/Angular-QueryBuilder/projects/demo/src/app/app.component.scss
similarity index 100%
rename from demo/src/assets/.gitkeep
rename to Angular-QueryBuilder/projects/demo/src/app/app.component.scss
diff --git a/Angular-QueryBuilder/projects/demo/src/app/app.component.spec.ts b/Angular-QueryBuilder/projects/demo/src/app/app.component.spec.ts
new file mode 100644
index 00000000..3a9dc2a0
--- /dev/null
+++ b/Angular-QueryBuilder/projects/demo/src/app/app.component.spec.ts
@@ -0,0 +1,31 @@
+import { TestBed } from '@angular/core/testing';
+import { AppComponent } from './app.component';
+
+describe('AppComponent', () => {
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [
+ AppComponent
+ ],
+ }).compileComponents();
+ });
+
+ it('should create the app', () => {
+ const fixture = TestBed.createComponent(AppComponent);
+ const app = fixture.componentInstance;
+ expect(app).toBeTruthy();
+ });
+
+ it(`should have as title 'demo'`, () => {
+ const fixture = TestBed.createComponent(AppComponent);
+ const app = fixture.componentInstance;
+ expect(app.title).toEqual('demo');
+ });
+
+ it('should render title', () => {
+ const fixture = TestBed.createComponent(AppComponent);
+ fixture.detectChanges();
+ const compiled = fixture.nativeElement;
+ expect(compiled.querySelector('.content span').textContent).toContain('demo app is running!');
+ });
+});
diff --git a/demo/src/app/app.component.ts b/Angular-QueryBuilder/projects/demo/src/app/app.component.ts
similarity index 98%
rename from demo/src/app/app.component.ts
rename to Angular-QueryBuilder/projects/demo/src/app/app.component.ts
index 9ad6f48d..06d338ea 100644
--- a/demo/src/app/app.component.ts
+++ b/Angular-QueryBuilder/projects/demo/src/app/app.component.ts
@@ -1,6 +1,9 @@
import { FormBuilder, FormControl } from '@angular/forms';
import { Component } from '@angular/core';
-import { QueryBuilderClassNames, QueryBuilderConfig } from 'angular2-query-builder';
+import {
+ QueryBuilderClassNames,
+ QueryBuilderConfig
+} from "../../../angular2-query-builder/src/lib/query-builder/query-builder.interfaces";
@Component({
selector: 'app-root',
@@ -38,7 +41,6 @@ import { QueryBuilderClassNames, QueryBuilderConfig } from 'angular2-query-build
-