[ACA-3683] - implement started date process filter (#6093)

* [ACA-3583] - implement created date process filter

* [ACA-3683] - add started date process filter

* remove unused property input

* rebase

* fix unit test

Co-authored-by: Silviu Popa <p3701014@L3700101120.ness.com>
This commit is contained in:
Silviu Popa
2020-09-23 15:42:21 +03:00
committed by GitHub
parent 3f1a9f4853
commit 902b863172
10 changed files with 77 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ import { DateRangeFilterService } from './date-range-filter.service';
import { DateRangeFilter, DateCloudFilterType } from '../../models/date-cloud-filter.model';
const DEFAULT_DATE_RANGE_OPTIONS = [
DateCloudFilterType.NO_DATE,
DateCloudFilterType.TODAY,
DateCloudFilterType.WEEK,
DateCloudFilterType.MONTH,

View File

@@ -31,3 +31,7 @@ export interface DateRangeFilter {
startDate: Date;
endDate: Date;
}
export interface RangeKeys {
from: string;
to: string;
}

View File

@@ -66,6 +66,9 @@
</div>
</div>
</mat-form-field>
<adf-cloud-date-range-filter *ngIf="isDateRangeType(processFilterProperty)"
[processFilterProperty]="processFilterProperty"
(dateChanged)="onDateRangeFilterChanged($event, processFilterProperty)"></adf-cloud-date-range-filter>
</ng-container>
</div>
</form>

View File

@@ -32,6 +32,7 @@ import { ProcessFilterDialogCloudComponent } from './process-filter-dialog-cloud
import { ApplicationInstanceModel } from '../../../app/models/application-instance.model';
import { ProcessCloudService } from '../../services/process-cloud.service';
import { ProcessDefinitionCloud } from '../../../models/process-definition-cloud.model';
import { DateRangeFilter } from '../../../models/date-cloud-filter.model';
@Component({
selector: 'adf-cloud-edit-process-filter',
@@ -164,7 +165,14 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
getFormControlsConfig(processFilterProperties: ProcessFilterProperties[]): any {
const properties = processFilterProperties.map((property: ProcessFilterProperties) => {
return { [property.key]: property.value };
if (!property.rangeKeys) {
return { [property.key]: property.value };
} else {
return {
[property.rangeKeys.from]: property.value[property.rangeKeys.from],
[property.rangeKeys.to]: property.value[property.rangeKeys.to]
};
}
});
return properties.reduce(((result, current) => Object.assign(result, current)), {});
}
@@ -447,10 +455,23 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
this.toggleFilterActions = false;
}
onDateRangeFilterChanged(dateRange: DateRangeFilter, property: ProcessFilterProperties) {
this.editProcessFilterForm.get(property.rangeKeys.from).setValue(
dateRange.startDate ? dateRange.startDate.toISOString() : null
);
this.editProcessFilterForm.get(property.rangeKeys.to).setValue(
dateRange.endDate ? dateRange.endDate.toISOString() : null
);
}
isDateType(property: ProcessFilterProperties): boolean {
return property.type === 'date';
}
isDateRangeType(property: ProcessFilterProperties): boolean {
return property.type === 'date-range';
}
isSelectType(property: ProcessFilterProperties): boolean {
return property.type === 'select';
}
@@ -674,8 +695,17 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
key: 'order',
value: currentProcessFilter.order || this.directions[0].value,
options: this.directions
}),
new ProcessFilterProperties({
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.START_DATE',
type: 'date-range',
key: 'startDateRange',
rangeKeys: { from: 'startFrom', to: 'startTo'},
values: {
from: currentProcessFilter.startFrom || null,
to: currentProcessFilter.startTo || null
}
})
];
}
}

View File

@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DateCloudFilterType, RangeKeys } from '../../../models/date-cloud-filter.model';
export class ProcessFilterCloudModel {
id: string;
@@ -35,6 +36,9 @@ export class ProcessFilterCloudModel {
lastModified: Date;
lastModifiedTo: Date;
lastModifiedFrom: Date;
startedDate: Date;
startFrom: Date;
startTo: Date;
constructor(obj?: any) {
if (obj) {
@@ -57,6 +61,9 @@ export class ProcessFilterCloudModel {
this.lastModified = obj.lastModified || null;
this.lastModifiedTo = obj.lastModifiedTo || null;
this.lastModifiedFrom = obj.lastModifiedFrom || null;
this.startedDate = obj.startedDate || null;
this.startFrom = obj.startFrom || null;
this.startTo = obj.startTo || null;
}
}
}
@@ -88,6 +95,8 @@ export class ProcessFilterProperties {
value: string;
key: string;
options: ProcessFilterOptions[];
rangeKeys?: RangeKeys;
dateFilterOptions?: DateCloudFilterType[];
constructor(obj?: any) {
if (obj) {
@@ -96,6 +105,8 @@ export class ProcessFilterProperties {
this.value = obj.value || '';
this.key = obj.key || null;
this.options = obj.options || null;
this.rangeKeys = obj.rangeKeys || null;
this.dateFilterOptions = obj.dateFilterOptions || [];
}
}
}

View File

@@ -58,7 +58,10 @@ describe('ProcessFilterCloudService', () => {
processDefinitionKey: 'processDefKey',
lastModified: null,
lastModifiedTo: null,
lastModifiedFrom: null
lastModifiedFrom: null,
startedDate: null,
startFrom: null,
startTo: null
};
const fakeProcessCloudFilterEntries = {

View File

@@ -91,6 +91,14 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
@Input()
lastModifiedTo: string = '';
/** Filter the processes. Display only process with startedDate greater then the supplied date. */
@Input()
startFrom: string = '';
/** Filter the processes. Display only process with startedDate less than the supplied date. */
@Input()
startTo: string = '';
/**
* Row selection mode. Can be "none", "single" or "multiple".
* For multiple mode, you can use Cmd (macOS) or Ctrl (Win) modifier
@@ -318,6 +326,8 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
businessKey: this.businessKey,
lastModifiedFrom: this.lastModifiedFrom,
lastModifiedTo: this.lastModifiedTo,
startFrom: this.startFrom,
startTo: this.startTo,
sorting: this.sorting
};
return new ProcessQueryCloudRequestModel(requestNode);

View File

@@ -32,6 +32,8 @@ export class ProcessQueryCloudRequestModel {
lastModified?: string;
lastModifiedTo?: string;
lastModifiedFrom?: string;
startFrom?: string;
startTo?: string;
maxItems: number;
skipCount: number;
sorting?: ProcessListCloudSortingModel[];
@@ -51,6 +53,8 @@ export class ProcessQueryCloudRequestModel {
this.lastModified = obj.lastModified;
this.lastModifiedTo = obj.lastModifiedTo;
this.lastModifiedFrom = obj.lastModifiedFrom;
this.startFrom = obj.startFrom;
this.startTo = obj.startTo;
this.maxItems = obj.maxItems;
this.skipCount = obj.skipCount;
this.sorting = obj.sorting;

View File

@@ -639,6 +639,12 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
key: 'createdDate',
value: ''
}),
new TaskFilterProperties({
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.DUE_DATE',
type: 'date',
key: 'dueDate',
value: ''
}),
new TaskFilterProperties({
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.SORT',
type: 'select',
@@ -662,7 +668,7 @@ export class EditTaskFilterCloudComponent implements OnInit, OnChanges, OnDestro
new TaskFilterProperties({
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.DUE_DATE',
type: 'date-range',
key: 'dueDate',
key: 'dueDateRange',
rangeKeys: { from: 'dueDateFrom', to: 'dueDateTo'},
value: currentTaskFilter.dueDate || false,
dateFilterOptions: [

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { DateCloudFilterType } from '../../../models/date-cloud-filter.model';
import { DateCloudFilterType, RangeKeys } from '../../../models/date-cloud-filter.model';
export class TaskFilterCloudModel {
id: string;
@@ -112,11 +112,6 @@ export interface FilterOptions {
value?: string;
}
export interface RangeKeys {
from: string;
to: string;
}
export class TaskFilterProperties {
label: string;
type: string;