ACS-7404: tag as standalone

This commit is contained in:
Denys Vuika
2024-07-25 13:31:05 -04:00
parent f85957c892
commit 857e22d811
10 changed files with 76 additions and 80 deletions

View File

@@ -20,7 +20,7 @@ import { NgModule, ModuleWithProviders, APP_INITIALIZER } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CoreModule, SearchTextModule, provideTranslations } from '@alfresco/adf-core'; import { CoreModule, SearchTextModule, provideTranslations } from '@alfresco/adf-core';
import { MaterialModule } from './material.module'; import { MaterialModule } from './material.module';
import { TagModule } from './tag/tag.module'; import { CONTENT_TAG_DIRECTIVES } from './tag/tag.module';
import { DocumentListModule } from './document-list/document-list.module'; import { DocumentListModule } from './document-list/document-list.module';
import { SearchModule } from './search/search.module'; import { SearchModule } from './search/search.module';
import { BREADCRUMB_DIRECTIVES } from './breadcrumb/breadcrumb.module'; import { BREADCRUMB_DIRECTIVES } from './breadcrumb/breadcrumb.module';
@@ -52,7 +52,7 @@ import { CONTENT_UPLOAD_DIRECTIVES } from './upload';
imports: [ imports: [
...CONTENT_PIPES, ...CONTENT_PIPES,
CoreModule, CoreModule,
TagModule, ...CONTENT_TAG_DIRECTIVES,
CommonModule, CommonModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
@@ -83,7 +83,7 @@ import { CONTENT_UPLOAD_DIRECTIVES } from './upload';
providers: [provideTranslations('adf-content-services', 'assets/adf-content-services')], providers: [provideTranslations('adf-content-services', 'assets/adf-content-services')],
exports: [ exports: [
...CONTENT_PIPES, ...CONTENT_PIPES,
TagModule, ...CONTENT_TAG_DIRECTIVES,
DocumentListModule, DocumentListModule,
...CONTENT_UPLOAD_DIRECTIVES, ...CONTENT_UPLOAD_DIRECTIVES,
SearchModule, SearchModule,

View File

@@ -50,7 +50,7 @@ describe('TagActionsComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ContentTestingModule] imports: [ContentTestingModule, TagActionsComponent]
}); });
fixture = TestBed.createComponent(TagActionsComponent); fixture = TestBed.createComponent(TagActionsComponent);
tagService = TestBed.inject(TagService); tagService = TestBed.inject(TagService);

View File

@@ -21,6 +21,14 @@ import { TagService } from './services/tag.service';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { TagPaging } from '@alfresco/js-api'; import { TagPaging } from '@alfresco/js-api';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { CommonModule } from '@angular/common';
import { MatListModule } from '@angular/material/list';
import { MatIconModule } from '@angular/material/icon';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { TranslateModule } from '@ngx-translate/core';
import { FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
/** /**
* *
@@ -29,13 +37,14 @@ import { takeUntil } from 'rxjs/operators';
@Component({ @Component({
selector: 'adf-tag-node-actions-list', selector: 'adf-tag-node-actions-list',
standalone: true,
imports: [CommonModule, MatListModule, MatIconModule, MatFormFieldModule, MatInputModule, TranslateModule, FormsModule, MatButtonModule],
templateUrl: './tag-actions.component.html', templateUrl: './tag-actions.component.html',
styleUrls: ['./tag-actions.component.scss'], styleUrls: ['./tag-actions.component.scss'],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
host: { class: 'adf-tag-node-actions-list' } host: { class: 'adf-tag-node-actions-list' }
}) })
export class TagActionsComponent implements OnChanges, OnInit, OnDestroy { export class TagActionsComponent implements OnChanges, OnInit, OnDestroy {
/** The identifier of a node. */ /** The identifier of a node. */
@Input() @Input()
nodeId: string; nodeId: string;
@@ -59,13 +68,10 @@ export class TagActionsComponent implements OnChanges, OnInit, OnDestroy {
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
constructor(private tagService: TagService, private translateService: TranslationService) { constructor(private tagService: TagService, private translateService: TranslationService) {}
}
ngOnInit() { ngOnInit() {
this.tagService.refresh this.tagService.refresh.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.refreshTag());
.pipe(takeUntil(this.onDestroy$))
.subscribe(() => this.refreshTag());
} }
ngOnChanges() { ngOnChanges() {
@@ -79,15 +85,18 @@ export class TagActionsComponent implements OnChanges, OnInit, OnDestroy {
refreshTag() { refreshTag() {
if (this.nodeId) { if (this.nodeId) {
this.tagService.getTagsByNodeId(this.nodeId).subscribe((tagPaging: TagPaging) => { this.tagService.getTagsByNodeId(this.nodeId).subscribe(
(tagPaging: TagPaging) => {
this.tagsEntries = tagPaging.list.entries; this.tagsEntries = tagPaging.list.entries;
this.disableAddTag = false; this.disableAddTag = false;
this.result.emit(this.tagsEntries); this.result.emit(this.tagsEntries);
}, () => { },
() => {
this.tagsEntries = null; this.tagsEntries = null;
this.disableAddTag = true; this.disableAddTag = true;
this.result.emit(this.tagsEntries); this.result.emit(this.tagsEntries);
}); }
);
} }
} }
@@ -105,7 +114,7 @@ export class TagActionsComponent implements OnChanges, OnInit, OnDestroy {
searchTag(searchTagName: string) { searchTag(searchTagName: string) {
if (this.tagsEntries) { if (this.tagsEntries) {
return this.tagsEntries.find((currentTag) => (searchTagName === currentTag.entry.tag)); return this.tagsEntries.find((currentTag) => searchTagName === currentTag.entry.tag);
} }
} }

View File

@@ -50,7 +50,7 @@ describe('TagList', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ContentTestingModule] imports: [ContentTestingModule, TagListComponent]
}); });
tagService = TestBed.inject(TagService); tagService = TestBed.inject(TagService);

View File

@@ -21,19 +21,24 @@ import { PaginationModel } from '@alfresco/adf-core';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { TagEntry } from '@alfresco/js-api'; import { TagEntry } from '@alfresco/js-api';
import { CommonModule } from '@angular/common';
import { MatChipsModule } from '@angular/material/chips';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
/** /**
* This component provide a list of all the tag inside the ECM * This component provide a list of all the tag inside the ECM
*/ */
@Component({ @Component({
selector: 'adf-tag-list', selector: 'adf-tag-list',
standalone: true,
imports: [CommonModule, MatChipsModule, MatButtonModule, MatIconModule],
templateUrl: './tag-list.component.html', templateUrl: './tag-list.component.html',
styleUrls: ['./tag-list.component.scss'], styleUrls: ['./tag-list.component.scss'],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
host: { class: 'adf-tag-list' } host: { class: 'adf-tag-list' }
}) })
export class TagListComponent implements OnInit, OnDestroy { export class TagListComponent implements OnInit, OnDestroy {
/** Emitted when a tag is selected. */ /** Emitted when a tag is selected. */
@Output() @Output()
result = new EventEmitter(); result = new EventEmitter();
@@ -57,7 +62,6 @@ export class TagListComponent implements OnInit, OnDestroy {
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
constructor(private tagService: TagService) { constructor(private tagService: TagService) {
this.defaultPagination = { this.defaultPagination = {
skipCount: 0, skipCount: 0,
maxItems: this.size, maxItems: this.size,
@@ -66,9 +70,7 @@ export class TagListComponent implements OnInit, OnDestroy {
this.pagination = this.defaultPagination; this.pagination = this.defaultPagination;
this.tagService.refresh this.tagService.refresh.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
.pipe(takeUntil(this.onDestroy$))
.subscribe(() => {
this.tagsEntries = []; this.tagsEntries = [];
this.refreshTag(this.defaultPagination); this.refreshTag(this.defaultPagination);
}); });

View File

@@ -30,7 +30,7 @@ describe('TagNodeList', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ContentTestingModule] imports: [ContentTestingModule, TagNodeListComponent]
}); });
fixture = TestBed.createComponent(TagNodeListComponent); fixture = TestBed.createComponent(TagNodeListComponent);
component = fixture.componentInstance; component = fixture.componentInstance;

View File

@@ -20,7 +20,7 @@ import { TagService } from './services/tag.service';
import { TagEntry } from '@alfresco/js-api'; import { TagEntry } from '@alfresco/js-api';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { Chip } from '@alfresco/adf-core'; import { Chip, DynamicChipListComponent } from '@alfresco/adf-core';
/** /**
* *
@@ -29,6 +29,8 @@ import { Chip } from '@alfresco/adf-core';
@Component({ @Component({
selector: 'adf-tag-node-list', selector: 'adf-tag-node-list',
standalone: true,
imports: [DynamicChipListComponent],
templateUrl: './tag-node-list.component.html', templateUrl: './tag-node-list.component.html',
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
@@ -63,9 +65,7 @@ export class TagNodeListComponent implements OnChanges, OnDestroy, OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
this.tagService.refresh this.tagService.refresh.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.refreshTag());
.pipe(takeUntil(this.onDestroy$))
.subscribe(() => this.refreshTag());
} }
ngOnDestroy(): void { ngOnDestroy(): void {

View File

@@ -15,34 +15,17 @@
* limitations under the License. * limitations under the License.
*/ */
import { CommonModule, NgForOf } from '@angular/common';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MaterialModule } from '../material.module';
import { TagActionsComponent } from './tag-actions.component'; import { TagActionsComponent } from './tag-actions.component';
import { TagListComponent } from './tag-list.component'; import { TagListComponent } from './tag-list.component';
import { TagNodeListComponent } from './tag-node-list.component'; import { TagNodeListComponent } from './tag-node-list.component';
import { TagsCreatorComponent } from './tags-creator/tags-creator.component'; import { TagsCreatorComponent } from './tags-creator/tags-creator.component';
import { ContentDirectiveModule } from '../directives/content-directive.module';
import { MatChipsModule } from '@angular/material/chips';
import { MatIconModule } from '@angular/material/icon';
import { TranslateModule } from '@ngx-translate/core';
import { DynamicChipListModule } from '@alfresco/adf-core';
export const CONTENT_TAG_DIRECTIVES = [TagsCreatorComponent, TagActionsComponent, TagListComponent, TagNodeListComponent] as const;
/** @deprecated use `...CONTENT_TAG_DIRECTIVES` instead or import standalone components directly */
@NgModule({ @NgModule({
imports: [ imports: [...CONTENT_TAG_DIRECTIVES],
CommonModule, exports: [...CONTENT_TAG_DIRECTIVES]
ContentDirectiveModule,
MaterialModule,
FormsModule,
ReactiveFormsModule,
TranslateModule,
DynamicChipListModule,
MatChipsModule,
MatIconModule,
NgForOf
],
exports: [TagActionsComponent, TagListComponent, TagNodeListComponent, TagsCreatorComponent],
declarations: [TagActionsComponent, TagListComponent, TagNodeListComponent, TagsCreatorComponent]
}) })
export class TagModule {} export class TagModule {}

View File

@@ -20,22 +20,15 @@ import { TagsCreatorComponent } from './tags-creator.component';
import { NotificationService } from '@alfresco/adf-core'; import { NotificationService } from '@alfresco/adf-core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { MatIconModule } from '@angular/material/icon'; import { MatError } from '@angular/material/form-field';
import { MatError, MatFormFieldModule } from '@angular/material/form-field'; import { TagsCreatorMode, TagService } from '@alfresco/adf-content-services';
import { MatInputModule } from '@angular/material/input';
import { ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { ContentDirectiveModule, TagsCreatorMode, TagService } from '@alfresco/adf-content-services';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { EMPTY, of, throwError } from 'rxjs'; import { EMPTY, of, throwError } from 'rxjs';
import { DebugElement } from '@angular/core'; import { DebugElement } from '@angular/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MatListModule } from '@angular/material/list';
import { HarnessLoader } from '@angular/cdk/testing'; import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing'; import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing';
import { MatChipOptionHarness } from '@angular/material/chips/testing'; import { MatChipOptionHarness } from '@angular/material/chips/testing';
import { MatChipsModule } from '@angular/material/chips';
describe('TagsCreatorComponent', () => { describe('TagsCreatorComponent', () => {
let fixture: ComponentFixture<TagsCreatorComponent>; let fixture: ComponentFixture<TagsCreatorComponent>;
@@ -46,20 +39,7 @@ describe('TagsCreatorComponent', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [TagsCreatorComponent], imports: [NoopAnimationsModule, TranslateModule.forRoot(), TagsCreatorComponent],
imports: [
ContentDirectiveModule,
MatButtonModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
MatProgressSpinnerModule,
MatListModule,
MatChipsModule,
NoopAnimationsModule,
ReactiveFormsModule,
TranslateModule.forRoot()
],
providers: [ providers: [
{ {
provide: TagService, provide: TagService,

View File

@@ -17,12 +17,21 @@
import { TagEntry, TagPaging } from '@alfresco/js-api'; import { TagEntry, TagPaging } from '@alfresco/js-api';
import { Component, ElementRef, EventEmitter, HostBinding, Input, OnDestroy, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core'; import { Component, ElementRef, EventEmitter, HostBinding, Input, OnDestroy, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
import { FormControl, Validators } from '@angular/forms'; import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
import { debounce, distinctUntilChanged, finalize, first, map, takeUntil, tap } from 'rxjs/operators'; import { debounce, distinctUntilChanged, finalize, first, map, takeUntil, tap } from 'rxjs/operators';
import { EMPTY, forkJoin, Observable, Subject, timer } from 'rxjs'; import { EMPTY, forkJoin, Observable, Subject, timer } from 'rxjs';
import { NotificationService } from '@alfresco/adf-core'; import { NotificationService } from '@alfresco/adf-core';
import { TagsCreatorMode } from './tags-creator-mode'; import { TagsCreatorMode } from './tags-creator-mode';
import { TagService } from '../services/tag.service'; import { TagService } from '../services/tag.service';
import { CommonModule } from '@angular/common';
import { MatInputModule } from '@angular/material/input';
import { AutoFocusDirective } from '../../directives';
import { TranslateModule } from '@ngx-translate/core';
import { MatChipsModule } from '@angular/material/chips';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatListModule } from '@angular/material/list';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
interface TagNameControlErrors { interface TagNameControlErrors {
duplicatedExistingTag?: boolean; duplicatedExistingTag?: boolean;
@@ -42,6 +51,19 @@ const DEFAULT_TAGS_SORTING = {
*/ */
@Component({ @Component({
selector: 'adf-tags-creator', selector: 'adf-tags-creator',
standalone: true,
imports: [
CommonModule,
MatInputModule,
ReactiveFormsModule,
AutoFocusDirective,
TranslateModule,
MatChipsModule,
MatButtonModule,
MatIconModule,
MatListModule,
MatProgressSpinnerModule
],
templateUrl: './tags-creator.component.html', templateUrl: './tags-creator.component.html',
styleUrls: ['./tags-creator.component.scss'], styleUrls: ['./tags-creator.component.scss'],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None