mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
ACS-8404: Introduce App Settings service (#3939)
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
/*!
|
||||
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export interface MimeType {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
@@ -28,7 +28,6 @@ import { CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DebugElement } from '@angular/core';
|
||||
import { tagMock, mimeTypeMock, simpleConditionUnknownFieldMock, categoriesListMock } from '../../mock/conditions.mock';
|
||||
import { MimeType } from './rule-mime-types';
|
||||
import { CategoryService, TagService } from '@alfresco/adf-content-services';
|
||||
import { of } from 'rxjs';
|
||||
import { RuleSimpleCondition } from '../../model/rule-simple-condition.model';
|
||||
@@ -38,6 +37,7 @@ import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { MatSelectHarness } from '@angular/material/select/testing';
|
||||
import { MatAutocompleteHarness } from '@angular/material/autocomplete/testing';
|
||||
import { AlfrescoMimeType } from '@alfresco/aca-shared';
|
||||
|
||||
describe('RuleSimpleConditionUiComponent', () => {
|
||||
let fixture: ComponentFixture<RuleSimpleConditionUiComponent>;
|
||||
@@ -100,7 +100,7 @@ describe('RuleSimpleConditionUiComponent', () => {
|
||||
});
|
||||
|
||||
it('should hide the comparator select box if the type of the field is mimeType', async () => {
|
||||
fixture.componentInstance.mimeTypes = [{ value: '', label: '' } as MimeType];
|
||||
fixture.componentInstance.mimeTypes = [{ value: '', label: '' } as AlfrescoMimeType];
|
||||
fixture.detectChanges();
|
||||
const comparatorFormField = getByDataAutomationId('comparator-form-field').nativeElement;
|
||||
|
||||
@@ -152,7 +152,7 @@ describe('RuleSimpleConditionUiComponent', () => {
|
||||
});
|
||||
|
||||
it('should provide select option when mimeType is selected and value filled', () => {
|
||||
const mockMimeTypes: MimeType[] = [
|
||||
const mockMimeTypes: AlfrescoMimeType[] = [
|
||||
{
|
||||
value: 'video/3gpp',
|
||||
label: '3G Video'
|
||||
|
@@ -22,13 +22,11 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Component, forwardRef, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, forwardRef, inject, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { AbstractControl, ControlValueAccessor, FormControl, FormGroup, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
|
||||
import { RuleSimpleCondition } from '../../model/rule-simple-condition.model';
|
||||
import { comparatorHiddenForConditionFieldType, RuleConditionField, ruleConditionFields } from './rule-condition-fields';
|
||||
import { RuleConditionComparator, ruleConditionComparators } from './rule-condition-comparators';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { MimeType } from './rule-mime-types';
|
||||
import { AsyncPipe, CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
@@ -41,6 +39,7 @@ import { Subject, Subscription } from 'rxjs';
|
||||
import { MatOptionModule } from '@angular/material/core';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { CategoryEntry } from '@alfresco/js-api';
|
||||
import { AlfrescoMimeType, AppSettingsService } from '@alfresco/aca-shared';
|
||||
|
||||
interface AutoCompleteOption {
|
||||
displayLabel: string;
|
||||
@@ -77,21 +76,24 @@ const AUTOCOMPLETE_OPTIONS_DEBOUNCE_TIME = 500;
|
||||
]
|
||||
})
|
||||
export class RuleSimpleConditionUiComponent implements OnInit, ControlValueAccessor, OnDestroy {
|
||||
private appSettings = inject(AppSettingsService);
|
||||
private categoryService = inject(CategoryService);
|
||||
private tagService = inject(TagService);
|
||||
|
||||
form = new FormGroup({
|
||||
field: new FormControl('cm:name'),
|
||||
comparator: new FormControl('equals'),
|
||||
parameter: new FormControl()
|
||||
});
|
||||
|
||||
mimeTypes: MimeType[] = [];
|
||||
|
||||
mimeTypes: AlfrescoMimeType[] = [];
|
||||
autoCompleteOptions: AutoCompleteOption[] = [];
|
||||
|
||||
showLoadingSpinner: boolean;
|
||||
|
||||
private onDestroy$ = new Subject<void>();
|
||||
private autoCompleteOptionsSubscription: Subscription;
|
||||
private _readOnly = false;
|
||||
|
||||
@Input()
|
||||
get readOnly(): boolean {
|
||||
return this._readOnly;
|
||||
@@ -107,9 +109,10 @@ export class RuleSimpleConditionUiComponent implements OnInit, ControlValueAcces
|
||||
(condition) => !((this.disabledTags && condition.name === 'tag') || (this.disabledCategories && condition.name === 'category'))
|
||||
);
|
||||
|
||||
constructor(config: AppConfigService, private categoryService: CategoryService, private tagService: TagService) {
|
||||
this.mimeTypes = config.get<Array<MimeType>>('mimeTypes');
|
||||
constructor() {
|
||||
this.mimeTypes = this.appSettings.mimeTypes;
|
||||
}
|
||||
|
||||
get isSelectedFieldKnown(): boolean {
|
||||
const selectedFieldName = this.form.get('field').value;
|
||||
return this.fields.findIndex((field: RuleConditionField) => selectedFieldName === field.name) > -1;
|
||||
|
Reference in New Issue
Block a user