mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
chore: remove Toggle Icon directive and related references
- Deleted the Toggle Icon directive implementation and its associated tests. - Updated documentation to reflect the removal of the directive. - Adjusted components to eliminate dependencies on the Toggle Icon directive.
This commit is contained in:
@@ -323,7 +323,6 @@ for more information about installing and using the source code.
|
|||||||
| [Node Favorite directive](content-services/directives/node-favorite.directive.md) | Selectively toggles nodes as favorites. | [Source](../lib/content-services/src/lib/directives/node-favorite.directive.ts) |
|
| [Node Favorite directive](content-services/directives/node-favorite.directive.md) | Selectively toggles nodes as favorites. | [Source](../lib/content-services/src/lib/directives/node-favorite.directive.ts) |
|
||||||
| [Node Lock directive](content-services/directives/node-lock.directive.md) | Locks or unlocks a node. | [Source](../lib/content-services/src/lib/directives/node-lock.directive.ts) |
|
| [Node Lock directive](content-services/directives/node-lock.directive.md) | Locks or unlocks a node. | [Source](../lib/content-services/src/lib/directives/node-lock.directive.ts) |
|
||||||
| [Node Restore directive](content-services/directives/node-restore.directive.md) | Restores deleted nodes to their original location. | [Source](../lib/content-services/src/lib/directives/node-restore.directive.ts) |
|
| [Node Restore directive](content-services/directives/node-restore.directive.md) | Restores deleted nodes to their original location. | [Source](../lib/content-services/src/lib/directives/node-restore.directive.ts) |
|
||||||
| [Toggle Icon directive](content-services/directives/toggle-icon.directive.md) | Toggle icon on mouse or keyboard event for a selectable element. | [Source](../lib/content-services/src/lib/upload/directives/toggle-icon.directive.ts) |
|
|
||||||
| [Version Compatibility Directive](content-services/directives/version-compatibility.directive.md) | Enables/disables components based on ACS version in use. | [Source](../lib/content-services/src/lib/version-compatibility/version-compatibility.directive.ts) |
|
| [Version Compatibility Directive](content-services/directives/version-compatibility.directive.md) | Enables/disables components based on ACS version in use. | [Source](../lib/content-services/src/lib/version-compatibility/version-compatibility.directive.ts) |
|
||||||
|
|
||||||
### Dialogs
|
### Dialogs
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
---
|
|
||||||
Title: Toggle Icon directive
|
|
||||||
Added: v2.0.0
|
|
||||||
Status: Active
|
|
||||||
Last reviewed: 2019-04-09
|
|
||||||
---
|
|
||||||
|
|
||||||
# [Toggle Icon directive](../../../lib/content-services/src/lib/upload/directives/toggle-icon.directive.ts "Defined in toggle-icon.directive.ts")
|
|
||||||
|
|
||||||
Toggle icon on mouse or keyboard event for a selectable element.
|
|
||||||
|
|
||||||
## Example Usage
|
|
||||||
|
|
||||||
```html
|
|
||||||
<button mat-icon-button adf-toggle-icon #toggle="toggleIcon">
|
|
||||||
<mat-icon *ngIf="!toggle.isToggled">
|
|
||||||
check_circle
|
|
||||||
</mat-icon>
|
|
||||||
|
|
||||||
<mat-icon *ngIf="toggle.isToggled">
|
|
||||||
remove_circle
|
|
||||||
</mat-icon>
|
|
||||||
<button></button>
|
|
||||||
</button>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Class members
|
|
||||||
@@ -663,7 +663,6 @@ backend services have been tested with each released version of ADF.
|
|||||||
- [Text mask component](core/components/text-mask.component.md)
|
- [Text mask component](core/components/text-mask.component.md)
|
||||||
- [Thumbnail service](core/services/thumbnail.service.md)
|
- [Thumbnail service](core/services/thumbnail.service.md)
|
||||||
- [Time ago pipe](core/pipes/time-ago.pipe.md)
|
- [Time ago pipe](core/pipes/time-ago.pipe.md)
|
||||||
- [Toggle icon directive](content-services/directives/toggle-icon.directive.md)
|
|
||||||
- [Toolbar divider component](core/components/toolbar-divider.component.md)
|
- [Toolbar divider component](core/components/toolbar-divider.component.md)
|
||||||
- [Toolbar title component](core/components/toolbar-title.component.md)
|
- [Toolbar title component](core/components/toolbar-title.component.md)
|
||||||
- [Toolbar component](core/components/toolbar.component.md)
|
- [Toolbar component](core/components/toolbar.component.md)
|
||||||
|
|||||||
+16
-10
@@ -26,20 +26,22 @@
|
|||||||
<div
|
<div
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
role="button"
|
role="button"
|
||||||
#toggleIcon="toggleIcon"
|
(mouseenter)="onToggleMouseEnter(toggleIconState)"
|
||||||
adf-toggle-icon
|
(mouseleave)="onToggleMouseLeave(toggleIconState)"
|
||||||
|
(focus)="onToggleFocus(toggleIconState)"
|
||||||
|
(blur)="onToggleBlur(toggleIconState)"
|
||||||
(keyup.enter)="onCancel(file)"
|
(keyup.enter)="onCancel(file)"
|
||||||
(click)="onCancel(file)"
|
(click)="onCancel(file)"
|
||||||
data-automation-id="cancel-upload-progress"
|
data-automation-id="cancel-upload-progress"
|
||||||
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.STOP_FILE_UPLOAD' | translate: { file: file.name }"
|
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.STOP_FILE_UPLOAD' | translate: { file: file.name }"
|
||||||
class="adf-file-uploading-row__group adf-file-uploading-row__group--toggle"
|
class="adf-file-uploading-row__group adf-file-uploading-row__group--toggle"
|
||||||
title="{{ 'ADF_FILE_UPLOAD.BUTTON.STOP_FILE' | translate }}">
|
title="{{ 'ADF_FILE_UPLOAD.BUTTON.STOP_FILE' | translate }}">
|
||||||
@if (!toggleIcon.isToggled) {
|
@if (!toggleIconState.isToggled) {
|
||||||
<span class="adf-file-uploading-row__status">
|
<span class="adf-file-uploading-row__status">
|
||||||
{{ file.progress.loaded | adfFileSize }} / {{ file.progress.total | adfFileSize }}
|
{{ file.progress.loaded | adfFileSize }} / {{ file.progress.total | adfFileSize }}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
@if (toggleIcon.isToggled) {
|
@if (toggleIconState.isToggled) {
|
||||||
<mat-icon class="adf-file-uploading-row__action adf-file-uploading-row__action--cancel" adf-icon="clear" />
|
<mat-icon class="adf-file-uploading-row__action adf-file-uploading-row__action--cancel" adf-icon="clear" />
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -47,8 +49,10 @@
|
|||||||
|
|
||||||
@if (isUploadComplete()) {
|
@if (isUploadComplete()) {
|
||||||
<button mat-icon-button
|
<button mat-icon-button
|
||||||
adf-toggle-icon
|
(mouseenter)="onToggleMouseEnter(toggleIconState)"
|
||||||
#toggleIcon="toggleIcon"
|
(mouseleave)="onToggleMouseLeave(toggleIconState)"
|
||||||
|
(focus)="onToggleFocus(toggleIconState)"
|
||||||
|
(blur)="onToggleBlur(toggleIconState)"
|
||||||
class="adf-file-uploading-row__group"
|
class="adf-file-uploading-row__group"
|
||||||
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.UPLOAD_SUCCESSFUL' | translate: { file: file.name }"
|
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.UPLOAD_SUCCESSFUL' | translate: { file: file.name }"
|
||||||
title="{{ 'ADF_FILE_UPLOAD.BUTTON.UPLOAD_SUCCESSFUL' | translate }}">
|
title="{{ 'ADF_FILE_UPLOAD.BUTTON.UPLOAD_SUCCESSFUL' | translate }}">
|
||||||
@@ -67,18 +71,20 @@
|
|||||||
|
|
||||||
@if (canCancelUpload()) {
|
@if (canCancelUpload()) {
|
||||||
<button
|
<button
|
||||||
adf-toggle-icon
|
(mouseenter)="onToggleMouseEnter(toggleIconCancelState)"
|
||||||
#toggleIconCancel="toggleIcon"
|
(mouseleave)="onToggleMouseLeave(toggleIconCancelState)"
|
||||||
|
(focus)="onToggleFocus(toggleIconCancelState)"
|
||||||
|
(blur)="onToggleBlur(toggleIconCancelState)"
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
(click)="onCancel(file)"
|
(click)="onCancel(file)"
|
||||||
data-automation-id="cancel-upload-queue"
|
data-automation-id="cancel-upload-queue"
|
||||||
class="adf-file-uploading-row__group"
|
class="adf-file-uploading-row__group"
|
||||||
title="{{ 'ADF_FILE_UPLOAD.BUTTON.STOP_FILE' | translate }}"
|
title="{{ 'ADF_FILE_UPLOAD.BUTTON.STOP_FILE' | translate }}"
|
||||||
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.STOP_FILE' | translate: { file: file.name }">
|
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.STOP_FILE' | translate: { file: file.name }">
|
||||||
@if (!toggleIconCancel.isToggled) {
|
@if (!toggleIconCancelState.isToggled) {
|
||||||
<mat-icon class="adf-file-uploading-row__status adf-file-uploading-row__status--pending" adf-icon="schedule" />
|
<mat-icon class="adf-file-uploading-row__status adf-file-uploading-row__status--pending" adf-icon="schedule" />
|
||||||
}
|
}
|
||||||
@if (toggleIconCancel.isToggled) {
|
@if (toggleIconCancelState.isToggled) {
|
||||||
<mat-icon class="adf-file-uploading-row__action adf-file-uploading-row__action--remove" adf-icon="remove_circle" />
|
<mat-icon class="adf-file-uploading-row__action adf-file-uploading-row__action--remove" adf-icon="remove_circle" />
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
+36
-2
@@ -22,12 +22,16 @@ import { MatListModule } from '@angular/material/list';
|
|||||||
import { FileSizePipe, IconModule } from '@alfresco/adf-core';
|
import { FileSizePipe, IconModule } from '@alfresco/adf-core';
|
||||||
import { MatChipsModule } from '@angular/material/chips';
|
import { MatChipsModule } from '@angular/material/chips';
|
||||||
import { TranslatePipe } from '@ngx-translate/core';
|
import { TranslatePipe } from '@ngx-translate/core';
|
||||||
import { ToggleIconDirective } from '../directives/toggle-icon.directive';
|
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
|
||||||
|
interface ToggleIconState {
|
||||||
|
isFocused: boolean;
|
||||||
|
isToggled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-file-uploading-list-row',
|
selector: 'adf-file-uploading-list-row',
|
||||||
imports: [IconModule, MatListModule, MatChipsModule, TranslatePipe, ToggleIconDirective, FileSizePipe, MatButtonModule],
|
imports: [IconModule, MatListModule, MatChipsModule, TranslatePipe, FileSizePipe, MatButtonModule],
|
||||||
templateUrl: './file-uploading-list-row.component.html',
|
templateUrl: './file-uploading-list-row.component.html',
|
||||||
styleUrls: ['./file-uploading-list-row.component.scss'],
|
styleUrls: ['./file-uploading-list-row.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
@@ -39,10 +43,40 @@ export class FileUploadingListRowComponent {
|
|||||||
@Output()
|
@Output()
|
||||||
cancel = new EventEmitter<FileModel>();
|
cancel = new EventEmitter<FileModel>();
|
||||||
|
|
||||||
|
toggleIconState: ToggleIconState = { isFocused: false, isToggled: false };
|
||||||
|
toggleIconCancelState: ToggleIconState = { isFocused: false, isToggled: false };
|
||||||
|
|
||||||
onCancel(file: FileModel): void {
|
onCancel(file: FileModel): void {
|
||||||
this.cancel.emit(file);
|
this.cancel.emit(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onToggleMouseEnter(state: ToggleIconState): void {
|
||||||
|
if (!state.isFocused) {
|
||||||
|
state.isToggled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onToggleMouseLeave(state: ToggleIconState): void {
|
||||||
|
if (!state.isFocused) {
|
||||||
|
state.isToggled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.isFocused && state.isToggled) {
|
||||||
|
state.isFocused = false;
|
||||||
|
state.isToggled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onToggleFocus(state: ToggleIconState): void {
|
||||||
|
state.isFocused = true;
|
||||||
|
state.isToggled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
onToggleBlur(state: ToggleIconState): void {
|
||||||
|
state.isFocused = false;
|
||||||
|
state.isToggled = false;
|
||||||
|
}
|
||||||
|
|
||||||
showCancelledStatus(): boolean {
|
showCancelledStatus(): boolean {
|
||||||
return (
|
return (
|
||||||
this.file.status === FileUploadStatus.Cancelled ||
|
this.file.status === FileUploadStatus.Cancelled ||
|
||||||
|
|||||||
@@ -1,86 +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, ViewChild } from '@angular/core';
|
|
||||||
import { ToggleIconDirective } from './toggle-icon.directive';
|
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'adf-test-component',
|
|
||||||
imports: [ToggleIconDirective],
|
|
||||||
template: ` <button id="testButton" adf-toggle-icon>test</button> `
|
|
||||||
})
|
|
||||||
class TestComponent {
|
|
||||||
@ViewChild(ToggleIconDirective)
|
|
||||||
directive: ToggleIconDirective;
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('ToggleIconDirective', () => {
|
|
||||||
let fixture: ComponentFixture<TestComponent>;
|
|
||||||
let component: TestComponent;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
imports: [TestComponent]
|
|
||||||
});
|
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set toggle to true on mouseenter', () => {
|
|
||||||
const button: HTMLElement = fixture.nativeElement.querySelector('#testButton');
|
|
||||||
button.dispatchEvent(new MouseEvent('mouseenter'));
|
|
||||||
|
|
||||||
expect(component.directive.isToggled).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set toggle to false on mouseleave if element is not focused', () => {
|
|
||||||
const button: HTMLElement = fixture.nativeElement.querySelector('#testButton');
|
|
||||||
button.dispatchEvent(new MouseEvent('mouseleave'));
|
|
||||||
|
|
||||||
expect(component.directive.isToggled).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set toggle and focus to false on mouseleave when element is focused', () => {
|
|
||||||
const button: HTMLElement = fixture.nativeElement.querySelector('#testButton');
|
|
||||||
button.dispatchEvent(new Event('focus'));
|
|
||||||
expect(component.directive.isToggled).toBe(true);
|
|
||||||
|
|
||||||
button.dispatchEvent(new MouseEvent('mouseleave'));
|
|
||||||
|
|
||||||
expect(component.directive.isToggled).toBe(false);
|
|
||||||
expect(component.directive.isFocused).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set toggle and focus to true when element is focused', () => {
|
|
||||||
const button: HTMLElement = fixture.nativeElement.querySelector('#testButton');
|
|
||||||
button.dispatchEvent(new Event('focus'));
|
|
||||||
|
|
||||||
expect(component.directive.isToggled).toBe(true);
|
|
||||||
expect(component.directive.isFocused).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set toggle and focus to true when element blur event', () => {
|
|
||||||
const button: HTMLElement = fixture.nativeElement.querySelector('#testButton');
|
|
||||||
button.dispatchEvent(new Event('focus'));
|
|
||||||
button.dispatchEvent(new Event('blur'));
|
|
||||||
|
|
||||||
expect(component.directive.isToggled).toBe(false);
|
|
||||||
expect(component.directive.isFocused).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,62 +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 { Directive, HostListener } from '@angular/core';
|
|
||||||
|
|
||||||
@Directive({
|
|
||||||
selector: '[adf-toggle-icon]',
|
|
||||||
exportAs: 'toggleIcon'
|
|
||||||
})
|
|
||||||
export class ToggleIconDirective {
|
|
||||||
private isFocus: boolean = false;
|
|
||||||
private toggle: boolean = false;
|
|
||||||
|
|
||||||
@HostListener('mouseenter') onMouseEnter() {
|
|
||||||
if (!this.isFocus) {
|
|
||||||
this.toggle = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostListener('mouseleave') onMouseLeave() {
|
|
||||||
if (!this.isFocus) {
|
|
||||||
this.toggle = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isFocus && this.toggle) {
|
|
||||||
this.isFocus = false;
|
|
||||||
this.toggle = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostListener('focus') onFocus() {
|
|
||||||
this.isFocus = true;
|
|
||||||
this.toggle = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostListener('blur') onBlur() {
|
|
||||||
this.isFocus = false;
|
|
||||||
this.toggle = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
get isToggled(): boolean {
|
|
||||||
return this.toggle;
|
|
||||||
}
|
|
||||||
|
|
||||||
get isFocused(): boolean {
|
|
||||||
return this.isFocus;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,6 @@ export * from './components/file-uploading-list-row.component';
|
|||||||
export * from './components/upload-files.event';
|
export * from './components/upload-files.event';
|
||||||
|
|
||||||
export * from './directives/file-draggable.directive';
|
export * from './directives/file-draggable.directive';
|
||||||
export * from './directives/toggle-icon.directive';
|
|
||||||
|
|
||||||
export * from './components/base-upload/upload-base';
|
export * from './components/base-upload/upload-base';
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,9 @@ import { UploadButtonComponent } from './components/upload-button.component';
|
|||||||
import { UploadVersionButtonComponent } from './components/upload-version-button.component';
|
import { UploadVersionButtonComponent } from './components/upload-version-button.component';
|
||||||
import { UploadDragAreaComponent } from './components/upload-drag-area.component';
|
import { UploadDragAreaComponent } from './components/upload-drag-area.component';
|
||||||
import { FileDraggableDirective } from './directives/file-draggable.directive';
|
import { FileDraggableDirective } from './directives/file-draggable.directive';
|
||||||
import { ToggleIconDirective } from './directives/toggle-icon.directive';
|
|
||||||
|
|
||||||
export const CONTENT_UPLOAD_DIRECTIVES = [
|
export const CONTENT_UPLOAD_DIRECTIVES = [
|
||||||
FileDraggableDirective,
|
FileDraggableDirective,
|
||||||
ToggleIconDirective,
|
|
||||||
UploadDragAreaComponent,
|
UploadDragAreaComponent,
|
||||||
UploadButtonComponent,
|
UploadButtonComponent,
|
||||||
UploadVersionButtonComponent,
|
UploadVersionButtonComponent,
|
||||||
|
|||||||
Reference in New Issue
Block a user