mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-04-16 22:24:49 +00:00
ACS-8395: remove old and unused search picker components (#11573)
This commit is contained in:
@@ -118,7 +118,6 @@ A collection of Angular components for generic use.
|
||||
| [Sidebar action menu component](core/components/sidebar-action-menu.component.md) | Displays a sidebar-action menu information panel. | [Source](../lib/core/src/lib/layout/components/sidebar-action/sidebar-action-menu.component.ts) |
|
||||
| [Sidenav Layout component](core/components/sidenav-layout.component.md) | Displays the standard three-region ADF application layout. | [Source](../lib/core/src/lib/layout/components/sidenav-layout/sidenav-layout.component.ts) |
|
||||
| [Snackbar Content Component](core/components/snackbar-content.component.md) | Custom content for Snackbar which allows use icon as action. | [Source](../lib/core/src/lib/snackbar-content/snackbar-content.component.ts) |
|
||||
| [Sorting Picker Component](core/components/sorting-picker.component.md) | Selects from a set of predefined sorting definitions and directions. | [Source](../lib/core/src/lib/sorting-picker/sorting-picker.component.ts) |
|
||||
| [Start Form component](core/components/start-form.component.md) | Displays the Start Form for a process. | [Source](../lib/process-services/src/lib/form/start-form/start-form.component.ts) |
|
||||
| [Text Mask directive](core/components/text-mask.component.md) | Implements text field input masks. | [Source](../lib/core/src/lib/form/components/widgets/text/text-mask.component.ts) |
|
||||
| [Toolbar Divider Component](core/components/toolbar-divider.component.md) | Divides groups of elements in a Toolbar with a visual separator. | [Source](../lib/core/src/lib/toolbar/toolbar-divider.component.ts) |
|
||||
@@ -293,7 +292,6 @@ for more information about installing and using the source code.
|
||||
| [Search number range component](content-services/components/search-number-range.component.md) | Implements a number range widget for the Search Filter component. | [Source](../lib/content-services/src/lib/search/components/search-number-range/search-number-range.component.ts) |
|
||||
| [Search radio component](content-services/components/search-radio.component.md) | Implements a radio button list widget for the Search Filter component. | [Source](../lib/content-services/src/lib/search/components/search-radio/search-radio.component.ts) |
|
||||
| [Search slider component](content-services/components/search-slider.component.md) | Implements a numeric slider widget for the Search Filter component. | [Source](../lib/content-services/src/lib/search/components/search-slider/search-slider.component.ts) |
|
||||
| [Search Sorting Picker Component](content-services/components/search-sorting-picker.component.md) | Provides an ability to select one of the predefined sorting definitions for search results: | [Source](../lib/content-services/src/lib/search/components/search-sorting-picker/search-sorting-picker.component.ts) |
|
||||
| [Search text component](content-services/components/search-text.component.md) | Implements a text input widget for the Search Filter component. | [Source](../lib/content-services/src/lib/search/components/search-text/search-text.component.ts) |
|
||||
| [Search component](content-services/components/search.component.md) | Searches items for supplied search terms. | [Source](../lib/content-services/src/lib/search/components/search.component.ts) |
|
||||
| [Sites Dropdown component](content-services/components/sites-dropdown.component.md) | Displays a dropdown menu to show and interact with the sites of the current user. | [Source](../lib/content-services/src/lib/content-node-selector/site-dropdown/sites-dropdown.component.ts) |
|
||||
|
||||
@@ -33,7 +33,6 @@ to build and execute the query.
|
||||
- [Search Query Builder service](../services/search-query-builder.service.md)
|
||||
- [Search filter chips component](./search-filter-chips.component.md)
|
||||
- [Search Chip List Component](search-chip-list.component.md)
|
||||
- [Search Sorting Picker Component](search-sorting-picker.component.md)
|
||||
- [Search Widget Interface](../interfaces/search-widget.interface.md)
|
||||
- [Search check list component](search-check-list.component.md)
|
||||
- [Search date range tabbed component](search-date-range-tabbed.component.md)
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
---
|
||||
Title: Search Sorting Picker Component
|
||||
Added: v2.3.0
|
||||
Status: Active
|
||||
---
|
||||
|
||||
# [Search Sorting Picker Component](../../../lib/content-services/src/lib/search/components/search-sorting-picker/search-sorting-picker.component.ts "Defined in search-sorting-picker.component.ts")
|
||||
|
||||
Provides an ability to select one of the predefined sorting definitions for search results:
|
||||
|
||||
```html
|
||||
<adf-search-sorting-picker></adf-search-sorting-picker>
|
||||
<adf-search-filter></adf-search-filter>
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [Search Configuration Guide](../../user-guide/search-configuration-guide.md)
|
||||
- [Search filter chips component](search-filter-chips.component.md)
|
||||
@@ -1 +0,0 @@
|
||||
../../../lib/core/src/lib/progress/progress.component.md
|
||||
@@ -1,67 +0,0 @@
|
||||
---
|
||||
Title: Sorting Picker Component
|
||||
Added: v2.4.0
|
||||
Status: Active
|
||||
Last reviewed: 2018-06-08
|
||||
---
|
||||
|
||||
# [Sorting Picker Component](../../../lib/core/src/lib/sorting-picker/sorting-picker.component.ts "Defined in sorting-picker.component.ts")
|
||||
|
||||
Selects from a set of predefined sorting definitions and directions.
|
||||
|
||||

|
||||
|
||||
## Basic Usage
|
||||
|
||||
```html
|
||||
<adf-sorting-picker
|
||||
[options]="options"
|
||||
[selected]="value"
|
||||
[ascending]="ascending"
|
||||
(change)="onChanged($event)">
|
||||
</adf-sorting-picker>
|
||||
```
|
||||
|
||||
## Class members
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| ---- | ---- | ------------- | ----------- |
|
||||
| ascending | `boolean` | true | Current sorting direction |
|
||||
| options | `Array<Function>` | \[] | Available sorting options |
|
||||
| selected | `string` | | Currently selected option key |
|
||||
|
||||
### Events
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| sortingChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<boolean>` | Raised each time direction gets changed. |
|
||||
| valueChange | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<string>` | Raised each time sorting key gets changed. |
|
||||
|
||||
## Details
|
||||
|
||||
The picker shows the user a menu of sorting options (which could be data columns to sort on
|
||||
alphabetical vs numerical search, etc) and the choice of ascending vs descending sort order.
|
||||
Note that picker only implements the menu, so you are responsible for implementing the sorting
|
||||
options yourself.
|
||||
|
||||
The `options` property contains an array of any objects that expose the following properties:
|
||||
|
||||
```ts
|
||||
{
|
||||
key: string;
|
||||
label: string;
|
||||
}
|
||||
```
|
||||
|
||||
The `key` is an identifying value and the `label` is the text that the user will see in the
|
||||
picker. The selected `key` is reported by the `change` event, which passes an object like the
|
||||
following as its parameter:
|
||||
|
||||
```ts
|
||||
{
|
||||
key: string,
|
||||
ascending: boolean
|
||||
}
|
||||
```
|
||||
@@ -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';
|
||||
@@ -1,6 +0,0 @@
|
||||
<adf-sorting-picker
|
||||
[options]="options"
|
||||
[selected]="value"
|
||||
[ascending]="ascending"
|
||||
(valueChange)="onValueChanged($event)"
|
||||
(sortingChange)="onSortingChanged($event)" />
|
||||
@@ -1,5 +0,0 @@
|
||||
.adf-search-sorting-picker {
|
||||
.adf-sorting-picker-button {
|
||||
color: var(--adf-theme-foreground-text-color-064);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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,
|
||||
|
||||
@@ -41,7 +41,6 @@ import { SEARCH_TEXT_INPUT_DIRECTIVES } from './search-text/search-text-input.mo
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { AppConfigPipe } from './app-config';
|
||||
import { IconComponent } from './icon';
|
||||
import { SortingPickerComponent } from './sorting-picker';
|
||||
import { DynamicChipListComponent } from './dynamic-chip-list';
|
||||
import { IdentityUserInfoComponent } from './identity-user-info';
|
||||
import { UnsavedChangesDialogComponent } from './dialogs';
|
||||
@@ -82,7 +81,6 @@ import { provideAppConfig } from './app-config/provide-app-config';
|
||||
...DATATABLE_DIRECTIVES,
|
||||
...TEMPLATE_DIRECTIVES,
|
||||
IconComponent,
|
||||
SortingPickerComponent,
|
||||
...NOTIFICATION_HISTORY_DIRECTIVES,
|
||||
...SEARCH_TEXT_INPUT_DIRECTIVES,
|
||||
UnsavedChangesDialogComponent,
|
||||
@@ -111,7 +109,6 @@ import { provideAppConfig } from './app-config/provide-app-config';
|
||||
...INFO_DRAWER_DIRECTIVES,
|
||||
...DATATABLE_DIRECTIVES,
|
||||
...TEMPLATE_DIRECTIVES,
|
||||
SortingPickerComponent,
|
||||
IconComponent,
|
||||
...NOTIFICATION_HISTORY_DIRECTIVES,
|
||||
...SEARCH_TEXT_INPUT_DIRECTIVES,
|
||||
|
||||
@@ -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 './public-api';
|
||||
@@ -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 './sorting-picker.component';
|
||||
@@ -1,13 +0,0 @@
|
||||
<mat-form-field floatLabel="always">
|
||||
<mat-label>{{'CORE.SEARCH.SORT_BY' | translate}}</mat-label>
|
||||
<mat-select [(value)]="selected" (selectionChange)="onOptionChanged($event)">
|
||||
<mat-option *ngFor="let option of options" [value]="option.key">
|
||||
{{ option.label | translate }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<button *ngIf="selected" class="adf-sorting-picker-button" mat-icon-button (click)="toggleSortDirection()" aria-label="'CORE.SEARCH.TOGGLE_ASC_DESC_ORDER' | translate">
|
||||
<mat-icon *ngIf="ascending" adf-icon="arrow_upward" />
|
||||
<mat-icon *ngIf="!ascending" adf-icon="arrow_downward" />
|
||||
</button>
|
||||
@@ -1,46 +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 { SortingPickerComponent } from './sorting-picker.component';
|
||||
|
||||
describe('SortingPickerComponent', () => {
|
||||
let component: SortingPickerComponent;
|
||||
|
||||
beforeEach(() => {
|
||||
component = new SortingPickerComponent();
|
||||
});
|
||||
|
||||
it('should raise changed event on changing value', (done) => {
|
||||
component.selected = 'key1';
|
||||
|
||||
component.valueChange.subscribe((key: string) => {
|
||||
expect(key).toBe('key2');
|
||||
done();
|
||||
});
|
||||
component.onOptionChanged({ value: 'key2' } as any);
|
||||
});
|
||||
|
||||
it('should raise changed event on changing direction', (done) => {
|
||||
component.ascending = false;
|
||||
|
||||
component.sortingChange.subscribe((ascending: boolean) => {
|
||||
expect(ascending).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
component.toggleSortDirection();
|
||||
});
|
||||
});
|
||||
@@ -1,108 +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 { applicationConfig, Meta, StoryObj, moduleMetadata } from '@storybook/angular';
|
||||
import { SortingPickerComponent } from './sorting-picker.component';
|
||||
import { provideStoryCore } from '../stories/core-story.providers';
|
||||
|
||||
const initialSortingTypes: Array<{ key: string; label: string }> = [
|
||||
{ key: 'sortByFirstName', label: 'First Name' },
|
||||
{ key: 'sortByLastName', label: 'Last Name' },
|
||||
{ key: 'sortByBirthDate', label: 'Birth Date' }
|
||||
];
|
||||
|
||||
const initialOptionKeys = [...initialSortingTypes.map((type) => type.key.toString())];
|
||||
|
||||
const meta: Meta<SortingPickerComponent> = {
|
||||
component: SortingPickerComponent,
|
||||
title: 'Core/Sorting Picker/Sorting Picker',
|
||||
decorators: [
|
||||
moduleMetadata({
|
||||
imports: [SortingPickerComponent]
|
||||
}),
|
||||
applicationConfig({
|
||||
providers: [...provideStoryCore()]
|
||||
})
|
||||
],
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
component: `The picker shows the user a menu of sorting options (which could be data columns to sort on alphabetical vs numerical search, etc)
|
||||
and the choice of ascending vs descending sort order.
|
||||
Note that picker only implements the menu, so you are responsible for implementing the sorting options yourself.`
|
||||
}
|
||||
}
|
||||
},
|
||||
argTypes: {
|
||||
selected: {
|
||||
control: 'select',
|
||||
options: initialOptionKeys,
|
||||
description: 'Currently selected option key',
|
||||
table: {
|
||||
type: { summary: 'string' },
|
||||
defaultValue: { summary: 'undefined' }
|
||||
}
|
||||
},
|
||||
ascending: {
|
||||
control: 'boolean',
|
||||
description: 'Current sorting direction',
|
||||
table: {
|
||||
type: { summary: 'boolean' },
|
||||
defaultValue: { summary: 'true' }
|
||||
}
|
||||
},
|
||||
options: {
|
||||
description: 'Available sorting options',
|
||||
table: {
|
||||
type: { summary: 'Array<{key: string; label: string}>' },
|
||||
defaultValue: { summary: '[]' }
|
||||
}
|
||||
},
|
||||
valueChange: {
|
||||
action: 'valueChange',
|
||||
description: 'Raised each time sorting key gets changed',
|
||||
table: {
|
||||
type: { summary: 'EventEmitter <string>' },
|
||||
category: 'Actions'
|
||||
}
|
||||
},
|
||||
sortingChange: {
|
||||
action: 'sortingChange',
|
||||
description: 'Raised each time direction gets changed',
|
||||
table: {
|
||||
type: { summary: 'EventEmitter <boolean>' },
|
||||
category: 'Actions'
|
||||
}
|
||||
}
|
||||
},
|
||||
args: {
|
||||
ascending: true,
|
||||
options: []
|
||||
}
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<SortingPickerComponent>;
|
||||
|
||||
export const SortingPicker: Story = {
|
||||
render: (args) => ({
|
||||
props: args
|
||||
}),
|
||||
args: {
|
||||
options: initialSortingTypes
|
||||
}
|
||||
};
|
||||
@@ -1,63 +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, ViewEncapsulation, Input, EventEmitter, Output } from '@angular/core';
|
||||
import { MatSelectChange, MatSelectModule } from '@angular/material/select';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { IconModule } from '../icon/icon.module';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-sorting-picker',
|
||||
imports: [CommonModule, TranslatePipe, MatFormFieldModule, MatSelectModule, MatButtonModule, IconModule],
|
||||
templateUrl: './sorting-picker.component.html',
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
host: { class: 'adf-sorting-picker' }
|
||||
})
|
||||
export class SortingPickerComponent {
|
||||
/** Available sorting options */
|
||||
@Input()
|
||||
options: Array<{ key: string; label: string }> = [];
|
||||
|
||||
/** Currently selected option key */
|
||||
@Input()
|
||||
selected: string;
|
||||
|
||||
/** Current sorting direction */
|
||||
@Input()
|
||||
ascending = true;
|
||||
|
||||
/** Raised each time sorting key gets changed. */
|
||||
@Output()
|
||||
valueChange = new EventEmitter<string>();
|
||||
|
||||
/** Raised each time direction gets changed. */
|
||||
@Output()
|
||||
sortingChange = new EventEmitter<boolean>();
|
||||
|
||||
onOptionChanged(event: MatSelectChange) {
|
||||
this.selected = event.value;
|
||||
this.valueChange.emit(this.selected);
|
||||
}
|
||||
|
||||
toggleSortDirection() {
|
||||
this.ascending = !this.ascending;
|
||||
this.sortingChange.emit(this.ascending);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,6 @@ export * from './lib/app-config/index';
|
||||
export * from './lib/form/index';
|
||||
export * from './lib/layout/index';
|
||||
export * from './lib/comments/index';
|
||||
export * from './lib/sorting-picker/index';
|
||||
export * from './lib/templates/index';
|
||||
export * from './lib/pipes/index';
|
||||
export * from './lib/directives/index';
|
||||
|
||||
Reference in New Issue
Block a user