diff --git a/cypress/e2e/collection-create.cy.ts b/cypress/e2e/collection-create.cy.ts index 29f7dd5cacb..423464233f8 100644 --- a/cypress/e2e/collection-create.cy.ts +++ b/cypress/e2e/collection-create.cy.ts @@ -5,9 +5,9 @@ beforeEach(() => { it('should show loading component while saving', () => { const title = 'Test Collection Title'; - cy.get('#title').type(title); + cy.get('#title-en').type(title); - cy.get('button[type="submit"]').click(); + cy.get('button[type="button"].btn-primary').click(); cy.get('ds-loading').should('be.visible'); }); diff --git a/cypress/e2e/community-create.cy.ts b/cypress/e2e/community-create.cy.ts index 96bc003ba2a..205f270db14 100644 --- a/cypress/e2e/community-create.cy.ts +++ b/cypress/e2e/community-create.cy.ts @@ -5,9 +5,9 @@ beforeEach(() => { it('should show loading component while saving', () => { const title = 'Test Community Title'; - cy.get('#title').type(title); + cy.get('#title-en').type(title); - cy.get('button[type="submit"]').click(); + cy.get('button[type="button"].btn-primary').click(); cy.get('ds-loading').should('be.visible'); }); diff --git a/src/app/collection-page/collection-form/collection-form.component.ts b/src/app/collection-page/collection-form/collection-form.component.ts index 0758435db88..9338d744b37 100644 --- a/src/app/collection-page/collection-form/collection-form.component.ts +++ b/src/app/collection-page/collection-form/collection-form.component.ts @@ -1,6 +1,7 @@ import { AsyncPipe, NgClass, + NgForOf, NgIf, } from '@angular/common'; import { @@ -12,6 +13,7 @@ import { SimpleChange, SimpleChanges, } from '@angular/core'; +import { FormsModule } from '@angular/forms'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { DynamicFormControlModel, @@ -66,7 +68,9 @@ import { ComcolPageLogoComponent, NgIf, NgClass, + NgForOf, VarDirective, + FormsModule, ], }) export class CollectionFormComponent extends ComColFormComponent implements OnInit, OnChanges { @@ -101,11 +105,14 @@ export class CollectionFormComponent extends ComColFormComponent imp protected objectCache: ObjectCacheService, protected entityTypeService: EntityTypeDataService, protected chd: ChangeDetectorRef, - protected modalService: NgbModal) { - super(formService, translate, notificationsService, authService, requestService, objectCache, modalService); + protected modalService: NgbModal, + protected cdr: ChangeDetectorRef) { + super(formService, translate, notificationsService, authService, requestService, objectCache, modalService, cdr); } ngOnInit(): void { + this.initializeLanguage(); + if (hasNoValue(this.formModel) && isNotNull(this.dso)) { this.initializeForm(); } @@ -148,11 +155,23 @@ export class CollectionFormComponent extends ComColFormComponent imp } }); - this.formModel = entityTypes.length === 0 ? collectionFormModels : [...collectionFormModels, this.entityTypeSelection]; + this.formModels.set( + this.defaultLanguageCode, + this.getCollectionFormModels(entityTypes, collectionFormModels(this.defaultLanguageCode, true)), + ); + this.languages.forEach(lang => { + this.formModels.set( + lang.code, + this.getCollectionFormModels(entityTypes, collectionFormModels(lang.code, false)), + ); + }); super.ngOnInit(); this.chd.detectChanges(); }); + } + private getCollectionFormModels(entityTypes: ItemType[], dynamicCollectionFormModels: DynamicFormControlModel[]): DynamicFormControlModel[] { + return entityTypes.length === 0 ? dynamicCollectionFormModels : [...dynamicCollectionFormModels, this.entityTypeSelection]; } } diff --git a/src/app/collection-page/collection-form/collection-form.models.ts b/src/app/collection-page/collection-form/collection-form.models.ts index 22998af674e..f0c35270ebb 100644 --- a/src/app/collection-page/collection-form/collection-form.models.ts +++ b/src/app/collection-page/collection-form/collection-form.models.ts @@ -17,41 +17,43 @@ export const collectionFormEntityTypeSelectionConfig: DynamicSelectModelConfig { + return [ + new DynamicInputModel({ + id: `title-${lang}`, + name: 'dc.title', + required: isDefaultLanguage, + validators: { + required: null, + }, + errorMessages: { + required: 'Please enter a name for this title', + }, + }), + new DynamicTextAreaModel({ + id: `description-${lang}`, + name: 'dc.description', + spellCheck: environment.form.spellCheck, + }), + new DynamicTextAreaModel({ + id: `abstract-${lang}`, + name: 'dc.description.abstract', + spellCheck: environment.form.spellCheck, + }), + new DynamicTextAreaModel({ + id: `rights-${lang}`, + name: 'dc.rights', + spellCheck: environment.form.spellCheck, + }), + new DynamicTextAreaModel({ + id: `tableofcontents-${lang}`, + name: 'dc.description.tableofcontents', + spellCheck: environment.form.spellCheck, + }), + new DynamicTextAreaModel({ + id: `license-${lang}`, + name: 'dc.rights.license', + spellCheck: environment.form.spellCheck, + }), + ]; +}; diff --git a/src/app/collection-page/collection-page.component.html b/src/app/collection-page/collection-page.component.html index 4a3e28c6aad..1679ef54ae8 100644 --- a/src/app/collection-page/collection-page.component.html +++ b/src/app/collection-page/collection-page.component.html @@ -23,12 +23,12 @@ @@ -44,10 +44,10 @@ -