mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
ACS-8395: remove old and unused search picker components (#11573)
This commit is contained in:
@@ -34,7 +34,6 @@ export * from './search-panel';
|
||||
export * from './search-properties';
|
||||
export * from './search-radio';
|
||||
export * from './search-slider';
|
||||
export * from './search-sorting-picker';
|
||||
export * from './search-text';
|
||||
export * from './search-widget-container';
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './search-sorting-picker.component';
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
<adf-sorting-picker
|
||||
[options]="options"
|
||||
[selected]="value"
|
||||
[ascending]="ascending"
|
||||
(valueChange)="onValueChanged($event)"
|
||||
(sortingChange)="onSortingChanged($event)" />
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
.adf-search-sorting-picker {
|
||||
.adf-sorting-picker-button {
|
||||
color: var(--adf-theme-foreground-text-color-064);
|
||||
}
|
||||
}
|
||||
-96
@@ -1,96 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { SearchSortingPickerComponent } from './search-sorting-picker.component';
|
||||
import { SearchQueryBuilderService } from '../../services/search-query-builder.service';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SearchConfiguration } from '../../models';
|
||||
import { BaseQueryBuilderService } from '../../services/base-query-builder.service';
|
||||
|
||||
describe('SearchSortingPickerComponent', () => {
|
||||
let fixture: ComponentFixture<SearchSortingPickerComponent>;
|
||||
let component: SearchSortingPickerComponent;
|
||||
|
||||
const config: SearchConfiguration = {
|
||||
sorting: {
|
||||
options: [
|
||||
{ key: 'name', label: 'Name', type: 'FIELD', field: 'cm:name', ascending: true },
|
||||
{ key: 'content.sizeInBytes', label: 'Size', type: 'FIELD', field: 'content.size', ascending: true },
|
||||
{ key: 'description', label: 'Description', type: 'FIELD', field: 'cm:description', ascending: true }
|
||||
],
|
||||
defaults: [{ key: 'name', type: 'FIELD', field: 'cm:name', ascending: false } as any]
|
||||
},
|
||||
categories: [{ id: 'cat1', enabled: true } as any]
|
||||
};
|
||||
|
||||
const queryBuilder: Partial<BaseQueryBuilderService> = {
|
||||
getSortingOptions: () => config.sorting.options,
|
||||
getPrimarySorting: () => config.sorting.defaults[0],
|
||||
sorting: config.sorting.options,
|
||||
update: jasmine.createSpy('update')
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [],
|
||||
providers: [
|
||||
{
|
||||
provide: SearchQueryBuilderService,
|
||||
useValue: queryBuilder
|
||||
}
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(SearchSortingPickerComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
it('should load options from query builder', () => {
|
||||
component.ngOnInit();
|
||||
|
||||
expect(component.options.length).toBe(3);
|
||||
expect(component.options[0].key).toEqual('name');
|
||||
expect(component.options[1].key).toEqual('content.sizeInBytes');
|
||||
expect(component.options[2].key).toEqual('description');
|
||||
});
|
||||
|
||||
it('should pre-select the primary sorting definition', () => {
|
||||
component.ngOnInit();
|
||||
|
||||
expect(component.value).toEqual('name');
|
||||
expect(component.ascending).toBe(false);
|
||||
});
|
||||
|
||||
it('should update query builder each time selection is changed', () => {
|
||||
component.ngOnInit();
|
||||
component.onValueChanged('description');
|
||||
|
||||
expect(queryBuilder.update).toHaveBeenCalled();
|
||||
expect(queryBuilder.sorting.length).toBe(1);
|
||||
expect(queryBuilder.sorting[0].key).toEqual('description');
|
||||
expect(queryBuilder.sorting[0].ascending).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should update query builder each time sorting is changed', () => {
|
||||
component.ngOnInit();
|
||||
component.onSortingChanged(false);
|
||||
|
||||
expect(queryBuilder.update).toHaveBeenCalled();
|
||||
expect(queryBuilder.sorting.length).toBe(1);
|
||||
expect(queryBuilder.sorting[0].key).toEqual('name');
|
||||
expect(queryBuilder.sorting[0].ascending).toBeFalsy();
|
||||
});
|
||||
});
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { SearchQueryBuilderService } from '../../services/search-query-builder.service';
|
||||
import { SearchSortingDefinition } from '../../models/search-sorting-definition.interface';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { SortingPickerComponent } from '@alfresco/adf-core';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-sorting-picker',
|
||||
imports: [CommonModule, SortingPickerComponent],
|
||||
templateUrl: './search-sorting-picker.component.html',
|
||||
styleUrls: ['./search-sorting-picker.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-search-sorting-picker' }
|
||||
})
|
||||
export class SearchSortingPickerComponent implements OnInit {
|
||||
options: SearchSortingDefinition[] = [];
|
||||
value: string;
|
||||
ascending: boolean;
|
||||
|
||||
constructor(private queryBuilder: SearchQueryBuilderService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.options = this.queryBuilder.getSortingOptions();
|
||||
|
||||
const primary = this.queryBuilder.getPrimarySorting();
|
||||
if (primary) {
|
||||
this.value = primary.key;
|
||||
this.ascending = primary.ascending;
|
||||
}
|
||||
}
|
||||
|
||||
onValueChanged(key: string) {
|
||||
this.value = key;
|
||||
this.ascending = this.getSortingOrder();
|
||||
this.applySorting();
|
||||
}
|
||||
|
||||
onSortingChanged(ascending: boolean) {
|
||||
this.ascending = ascending;
|
||||
this.applySorting();
|
||||
}
|
||||
|
||||
private findOptionByKey(key: string): SearchSortingDefinition {
|
||||
if (key) {
|
||||
return this.options.find((opt) => opt.key === key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private applySorting() {
|
||||
const option = this.findOptionByKey(this.value);
|
||||
if (option) {
|
||||
this.queryBuilder.sorting = [
|
||||
{
|
||||
...option,
|
||||
ascending: this.ascending
|
||||
}
|
||||
];
|
||||
this.queryBuilder.update();
|
||||
}
|
||||
}
|
||||
|
||||
private getSortingOrder(): boolean {
|
||||
const option = this.findOptionByKey(this.value);
|
||||
if (option) {
|
||||
return option.ascending;
|
||||
}
|
||||
|
||||
return this.queryBuilder.getPrimarySorting().ascending;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ import { SearchSliderComponent } from './components/search-slider/search-slider.
|
||||
import { SearchNumberRangeComponent } from './components/search-number-range/search-number-range.component';
|
||||
import { SearchPanelComponent } from './components/search-panel/search-panel.component';
|
||||
import { SearchCheckListComponent } from './components/search-check-list/search-check-list.component';
|
||||
import { SearchSortingPickerComponent } from './components/search-sorting-picker/search-sorting-picker.component';
|
||||
import { SearchFilterContainerComponent } from './components/search-filter-container/search-filter-container.component';
|
||||
import { SearchDatetimeRangeComponent } from './components/search-datetime-range/search-datetime-range.component';
|
||||
import { SearchFormComponent } from './components/search-form/search-form.component';
|
||||
@@ -70,7 +69,6 @@ export const CONTENT_SEARCH_DIRECTIVES = [
|
||||
SearchFilterTabbedComponent,
|
||||
SearchFilterTabDirective,
|
||||
SearchDateRangeTabbedComponent,
|
||||
SearchSortingPickerComponent,
|
||||
SearchSliderComponent,
|
||||
SearchNumberRangeComponent,
|
||||
SearchPanelComponent,
|
||||
|
||||
Reference in New Issue
Block a user