mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ACA-3745] Folder - update metadata default copies the name in the title field (#5923)
* add title input * title form control * i18n * update tests
This commit is contained in:
@@ -23,8 +23,13 @@
|
|||||||
</mat-hint>
|
</mat-hint>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<br />
|
<mat-form-field class="adf-full-width">
|
||||||
<br />
|
<input
|
||||||
|
id="adf-folder-title-input"
|
||||||
|
matInput
|
||||||
|
placeholder="{{ 'CORE.FOLDER_DIALOG.FOLDER_TITLE.LABEL' | translate }}"
|
||||||
|
[formControl]="form.controls['title']"/>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field class="adf-full-width">
|
<mat-form-field class="adf-full-width">
|
||||||
<textarea
|
<textarea
|
||||||
|
@@ -62,6 +62,7 @@ describe('FolderDialogComponent', () => {
|
|||||||
id: 'node-id',
|
id: 'node-id',
|
||||||
name: 'folder-name',
|
name: 'folder-name',
|
||||||
properties: {
|
properties: {
|
||||||
|
['cm:title']: 'folder-title',
|
||||||
['cm:description']: 'folder-description'
|
['cm:description']: 'folder-description'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,6 +72,7 @@ describe('FolderDialogComponent', () => {
|
|||||||
|
|
||||||
it('should init form with folder name and description', () => {
|
it('should init form with folder name and description', () => {
|
||||||
expect(component.name).toBe('folder-name');
|
expect(component.name).toBe('folder-name');
|
||||||
|
expect(component.title).toBe('folder-title');
|
||||||
expect(component.description).toBe('folder-description');
|
expect(component.description).toBe('folder-description');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -82,9 +84,11 @@ describe('FolderDialogComponent', () => {
|
|||||||
|
|
||||||
it('should update form input', () => {
|
it('should update form input', () => {
|
||||||
component.form.controls['name'].setValue('folder-name-update');
|
component.form.controls['name'].setValue('folder-name-update');
|
||||||
|
component.form.controls['title'].setValue('folder-title-update');
|
||||||
component.form.controls['description'].setValue('folder-description-update');
|
component.form.controls['description'].setValue('folder-description-update');
|
||||||
|
|
||||||
expect(component.name).toBe('folder-name-update');
|
expect(component.name).toBe('folder-name-update');
|
||||||
|
expect(component.title).toBe('folder-title-update');
|
||||||
expect(component.description).toBe('folder-description-update');
|
expect(component.description).toBe('folder-description-update');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -92,6 +96,7 @@ describe('FolderDialogComponent', () => {
|
|||||||
spyOn(nodesApi, 'updateNode').and.returnValue(of({}));
|
spyOn(nodesApi, 'updateNode').and.returnValue(of({}));
|
||||||
|
|
||||||
component.form.controls['name'].setValue('folder-name-update');
|
component.form.controls['name'].setValue('folder-name-update');
|
||||||
|
component.form.controls['title'].setValue('folder-title-update');
|
||||||
component.form.controls['description'].setValue('folder-description-update');
|
component.form.controls['description'].setValue('folder-description-update');
|
||||||
|
|
||||||
component.submit();
|
component.submit();
|
||||||
@@ -101,7 +106,7 @@ describe('FolderDialogComponent', () => {
|
|||||||
{
|
{
|
||||||
name: 'folder-name-update',
|
name: 'folder-name-update',
|
||||||
properties: {
|
properties: {
|
||||||
'cm:title': 'folder-name-update',
|
'cm:title': 'folder-title-update',
|
||||||
'cm:description': 'folder-description-update'
|
'cm:description': 'folder-description-update'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,6 +194,7 @@ describe('FolderDialogComponent', () => {
|
|||||||
spyOn(nodesApi, 'createFolder').and.returnValue(of({}));
|
spyOn(nodesApi, 'createFolder').and.returnValue(of({}));
|
||||||
|
|
||||||
component.form.controls['name'].setValue('folder-name-update');
|
component.form.controls['name'].setValue('folder-name-update');
|
||||||
|
component.form.controls['title'].setValue('folder-title-update');
|
||||||
component.form.controls['description'].setValue('folder-description-update');
|
component.form.controls['description'].setValue('folder-description-update');
|
||||||
|
|
||||||
component.submit();
|
component.submit();
|
||||||
@@ -198,7 +204,7 @@ describe('FolderDialogComponent', () => {
|
|||||||
{
|
{
|
||||||
name: 'folder-name-update',
|
name: 'folder-name-update',
|
||||||
properties: {
|
properties: {
|
||||||
'cm:title': 'folder-name-update',
|
'cm:title': 'folder-title-update',
|
||||||
'cm:description': 'folder-description-update'
|
'cm:description': 'folder-description-update'
|
||||||
},
|
},
|
||||||
nodeType: 'cm:folder'
|
nodeType: 'cm:folder'
|
||||||
@@ -210,6 +216,7 @@ describe('FolderDialogComponent', () => {
|
|||||||
spyOn(nodesApi, 'createFolder').and.returnValue(of({}));
|
spyOn(nodesApi, 'createFolder').and.returnValue(of({}));
|
||||||
|
|
||||||
component.form.controls['name'].setValue('folder-name-update');
|
component.form.controls['name'].setValue('folder-name-update');
|
||||||
|
component.form.controls['title'].setValue('folder-title-update');
|
||||||
component.form.controls['description'].setValue('folder-description-update');
|
component.form.controls['description'].setValue('folder-description-update');
|
||||||
component.nodeType = 'cm:sushi';
|
component.nodeType = 'cm:sushi';
|
||||||
|
|
||||||
@@ -220,7 +227,7 @@ describe('FolderDialogComponent', () => {
|
|||||||
{
|
{
|
||||||
name: 'folder-name-update',
|
name: 'folder-name-update',
|
||||||
properties: {
|
properties: {
|
||||||
'cm:title': 'folder-name-update',
|
'cm:title': 'folder-title-update',
|
||||||
'cm:description': 'folder-description-update'
|
'cm:description': 'folder-description-update'
|
||||||
},
|
},
|
||||||
nodeType: 'cm:sushi'
|
nodeType: 'cm:sushi'
|
||||||
@@ -234,6 +241,7 @@ describe('FolderDialogComponent', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
component.form.controls['name'].setValue('name');
|
component.form.controls['name'].setValue('name');
|
||||||
|
component.form.controls['title'].setValue('title');
|
||||||
component.form.controls['description'].setValue('description');
|
component.form.controls['description'].setValue('description');
|
||||||
|
|
||||||
spyOn(nodesApi, 'createFolder').and.returnValue(of(folder));
|
spyOn(nodesApi, 'createFolder').and.returnValue(of(folder));
|
||||||
|
@@ -74,13 +74,15 @@ export class FolderDialogComponent implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
const { folder } = this.data;
|
const { folder } = this.data;
|
||||||
let name = '';
|
let name = '';
|
||||||
|
let title = '';
|
||||||
let description = '';
|
let description = '';
|
||||||
|
|
||||||
if (folder) {
|
if (folder) {
|
||||||
const { properties } = folder;
|
const { properties } = folder;
|
||||||
|
|
||||||
name = folder.name || '';
|
name = folder.name || '';
|
||||||
description = properties ? properties['cm:description'] : '';
|
title = properties?.['cm:title'] ?? '';
|
||||||
|
description = properties?.['cm:description'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const validators = {
|
const validators = {
|
||||||
@@ -94,6 +96,7 @@ export class FolderDialogComponent implements OnInit {
|
|||||||
|
|
||||||
this.form = this.formBuilder.group({
|
this.form = this.formBuilder.group({
|
||||||
name: [ name, validators.name ],
|
name: [ name, validators.name ],
|
||||||
|
title: [ title ],
|
||||||
description: [ description ]
|
description: [ description ]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -104,6 +107,12 @@ export class FolderDialogComponent implements OnInit {
|
|||||||
return (name || '').trim();
|
return (name || '').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get title(): string {
|
||||||
|
const { title } = this.form.value;
|
||||||
|
|
||||||
|
return (title || '').trim();
|
||||||
|
}
|
||||||
|
|
||||||
get description(): string {
|
get description(): string {
|
||||||
const { description } = this.form.value;
|
const { description } = this.form.value;
|
||||||
|
|
||||||
@@ -111,7 +120,7 @@ export class FolderDialogComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private get properties(): any {
|
private get properties(): any {
|
||||||
const { name: title, description } = this;
|
const { title, description } = this;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'cm:title': title,
|
'cm:title': title,
|
||||||
|
@@ -111,6 +111,9 @@
|
|||||||
"FOLDER_DESCRIPTION": {
|
"FOLDER_DESCRIPTION": {
|
||||||
"LABEL": "Description"
|
"LABEL": "Description"
|
||||||
},
|
},
|
||||||
|
"FOLDER_TITLE": {
|
||||||
|
"LABEL": "Title"
|
||||||
|
},
|
||||||
"CREATE_BUTTON": {
|
"CREATE_BUTTON": {
|
||||||
"LABEL": "Create"
|
"LABEL": "Create"
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user