diff --git a/resources/i18n/en.json b/resources/i18n/en.json index c0a213fe1b..963dfae80f 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -13,6 +13,23 @@ "head": "Recent Submissions" } } + }, + "edit": { + "name": "Name", + "description": "Short Description", + "introductory": "Introductory text (HTML)", + "copyright": "Copyright text (HTML)", + "news": "News (HTML)", + "license": "License", + "provenance": "Provenance", + "submit": "Submit", + "cancel": "Cancel", + "required": { + "name": "Please enter a collection name" + } + }, + "create": { + "head": "Create a Collection" } }, "community": { diff --git a/src/app/+collection-page/collection-form/collection-form.component.html b/src/app/+collection-page/collection-form/collection-form.component.html new file mode 100644 index 0000000000..307d7406ed --- /dev/null +++ b/src/app/+collection-page/collection-form/collection-form.component.html @@ -0,0 +1,35 @@ +
+
+ + +
{{ 'collection.edit.required.name' | translate }}
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
diff --git a/src/app/+collection-page/collection-form/collection-form.component.scss b/src/app/+collection-page/collection-form/collection-form.component.scss new file mode 100644 index 0000000000..d5811186e7 --- /dev/null +++ b/src/app/+collection-page/collection-form/collection-form.component.scss @@ -0,0 +1,7 @@ +@import '../../../styles/variables.scss'; + +// temporary fix for bootstrap 4 beta btn color issue +.btn-secondary { + background-color: $input-bg; + color: $input-color; +} diff --git a/src/app/+collection-page/collection-form/collection-form.component.ts b/src/app/+collection-page/collection-form/collection-form.component.ts new file mode 100644 index 0000000000..c51633dfb6 --- /dev/null +++ b/src/app/+collection-page/collection-form/collection-form.component.ts @@ -0,0 +1,32 @@ +import { Component, EventEmitter, Output } from '@angular/core'; +import { isNotEmpty } from '../../shared/empty.util'; + +@Component({ + selector: 'ds-collection-form', + styleUrls: ['./collection-form.component.scss'], + templateUrl: './collection-form.component.html' +}) +export class CollectionFormComponent { + + name: string; + description: string; + introductory: string; + copyright: string; + news: string; + license: string; + provenance: string; + + nameRequiredError = false; + + @Output() submitted: EventEmitter = new EventEmitter(); + + onSubmit(data: any) { + if (isNotEmpty(data.name)) { + this.submitted.emit(data); + this.nameRequiredError = false; + } else { + this.nameRequiredError = true; + } + } + +} diff --git a/src/app/+collection-page/collection-page-routing.module.ts b/src/app/+collection-page/collection-page-routing.module.ts index c886aa655c..1bd53dd2b3 100644 --- a/src/app/+collection-page/collection-page-routing.module.ts +++ b/src/app/+collection-page/collection-page-routing.module.ts @@ -2,10 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { CollectionPageComponent } from './collection-page.component'; +import { CreateCollectionPageComponent } from './create-collection-page/create-collection-page.component'; @NgModule({ imports: [ RouterModule.forChild([ + { path: 'create', component: CreateCollectionPageComponent }, { path: ':id', component: CollectionPageComponent, pathMatch: 'full' } ]) ] diff --git a/src/app/+collection-page/collection-page.module.ts b/src/app/+collection-page/collection-page.module.ts index d0bc918b22..3ce3b66d05 100644 --- a/src/app/+collection-page/collection-page.module.ts +++ b/src/app/+collection-page/collection-page.module.ts @@ -5,6 +5,8 @@ import { SharedModule } from '../shared/shared.module'; import { CollectionPageComponent } from './collection-page.component'; import { CollectionPageRoutingModule } from './collection-page-routing.module'; +import { CreateCollectionPageComponent } from './create-collection-page/create-collection-page.component'; +import { CollectionFormComponent } from './collection-form/collection-form.component'; @NgModule({ imports: [ @@ -14,6 +16,8 @@ import { CollectionPageRoutingModule } from './collection-page-routing.module'; ], declarations: [ CollectionPageComponent, + CreateCollectionPageComponent, + CollectionFormComponent ] }) export class CollectionPageModule { diff --git a/src/app/+collection-page/create-collection-page/create-collection-page.component.html b/src/app/+collection-page/create-collection-page/create-collection-page.component.html new file mode 100644 index 0000000000..53a55571f6 --- /dev/null +++ b/src/app/+collection-page/create-collection-page/create-collection-page.component.html @@ -0,0 +1,8 @@ +
+
+
+ +
+
+ +
diff --git a/src/app/+collection-page/create-collection-page/create-collection-page.component.scss b/src/app/+collection-page/create-collection-page/create-collection-page.component.scss new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/src/app/+collection-page/create-collection-page/create-collection-page.component.scss @@ -0,0 +1 @@ + diff --git a/src/app/+collection-page/create-collection-page/create-collection-page.component.ts b/src/app/+collection-page/create-collection-page/create-collection-page.component.ts new file mode 100644 index 0000000000..689bd30dfc --- /dev/null +++ b/src/app/+collection-page/create-collection-page/create-collection-page.component.ts @@ -0,0 +1,27 @@ +import { Component } from '@angular/core'; +import { Community } from '../../core/shared/community.model'; +import { ComColDataService } from '../../core/data/comcol-data.service'; +import { NormalizedCommunity } from '../../core/cache/models/normalized-community.model'; +import { CommunityDataService } from '../../core/data/community-data.service'; +import { CollectionDataService } from '../../core/data/collection-data.service'; +import { Collection } from '../../core/shared/collection.model'; + +@Component({ + selector: 'ds-create-collection', + styleUrls: ['./create-collection-page.component.scss'], + templateUrl: './create-collection-page.component.html' +}) +export class CreateCollectionPageComponent { + + public constructor(private collectionDataService: CollectionDataService) { + + } + + onSubmit(data: any) { + const collection = Object.assign(new Collection(), { + name: data.name + }); + this.collectionDataService.create(collection); + } + +} diff --git a/src/app/core/data/collection-data.service.ts b/src/app/core/data/collection-data.service.ts index 6e06a600cf..765cba0a8b 100644 --- a/src/app/core/data/collection-data.service.ts +++ b/src/app/core/data/collection-data.service.ts @@ -31,7 +31,8 @@ export class CollectionDataService extends ComColDataService