From a568b8762ce0257648aece8c36b0d34a5a08f23e Mon Sep 17 00:00:00 2001 From: Martin Markov Date: Sun, 11 Oct 2020 18:13:42 +0200 Subject: [PATCH 001/141] Added edit highlight functionality --- package-lock.json | 5 ++ package.json | 1 + .../project/details/details.component.html | 11 ++- .../project/details/details.component.scss | 5 +- .../project/details/details.component.ts | 86 +++++++++++-------- .../modal-highlight-delete.component.html | 18 +--- .../modal-highlight-delete.component.scss | 32 +++---- .../modal-highlight-edit.component.html | 15 ++++ .../modal-highlight-edit.component.scss | 9 ++ .../modal-highlight-edit.component.ts | 20 +++++ .../modal-highlight-form.component.html} | 0 .../modal-highlight-form.component.scss} | 0 .../modal-highlight-form.component.ts} | 34 +++++--- src/app/modules/project/project.module.ts | 10 ++- src/app/utils/format-date.pipe.ts | 11 +++ 15 files changed, 171 insertions(+), 86 deletions(-) create mode 100644 src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html create mode 100644 src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss create mode 100644 src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts rename src/app/modules/project/{modal-highlight/modal-highlight.component.html => modal-highlight-form/modal-highlight-form.component.html} (100%) rename src/app/modules/project/{modal-highlight/modal-highlight.component.scss => modal-highlight-form/modal-highlight-form.component.scss} (100%) rename src/app/modules/project/{modal-highlight/modal-highlight.component.ts => modal-highlight-form/modal-highlight-form.component.ts} (76%) create mode 100644 src/app/utils/format-date.pipe.ts diff --git a/package-lock.json b/package-lock.json index 820eefbc..221db494 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9328,6 +9328,11 @@ } } }, + "moment": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" + }, "move-concurrently": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", diff --git a/package.json b/package.json index 98eefedc..ea7ea18c 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@webcomponents/webcomponentsjs": "^2.0.0", "bootstrap": "^4.4.1", "dotenv": "^5.0.0", + "moment": "^2.29.1", "ngx-bootstrap": "^5.6.1", "ngx-quill": "^11.0.0", "oidc-client": "^1.10.1", diff --git a/src/app/modules/project/details/details.component.html b/src/app/modules/project/details/details.component.html index 01e651c5..dc971376 100644 --- a/src/app/modules/project/details/details.component.html +++ b/src/app/modules/project/details/details.component.html @@ -55,7 +55,7 @@

Collaborators

-
+

{{ project.name }}

@@ -101,12 +101,19 @@

{{ project.name }}

- +
+ +
+ +
+ +
+ diff --git a/src/app/modules/project/details/details.component.scss b/src/app/modules/project/details/details.component.scss index a9cd53d6..30633081 100644 --- a/src/app/modules/project/details/details.component.scss +++ b/src/app/modules/project/details/details.component.scss @@ -91,11 +91,8 @@ max-width: 800px; } -.project-highlighted-div { - float: left; -} - #project-share-buttons { + display: flex; margin-top: 60px; button:first-child { diff --git a/src/app/modules/project/details/details.component.ts b/src/app/modules/project/details/details.component.ts index 105a9a58..dfd2da6b 100644 --- a/src/app/modules/project/details/details.component.ts +++ b/src/app/modules/project/details/details.component.ts @@ -24,7 +24,7 @@ import { AuthService } from 'src/app/services/auth.service'; import { HighlightService } from 'src/app/services/highlight.service'; import { HighlightAdd } from 'src/app/models/resources/highlight-add'; import { BsModalService, ModalOptions } from 'ngx-bootstrap/modal'; -import { ModalHighlightComponent, HighlightFormResult } from 'src/app/modules/project/modal-highlight/modal-highlight.component'; +import { ModalHighlightFormComponent, HighlightFormResult } from 'src/app/modules/project/modal-highlight-form/modal-highlight-form.component'; import { AlertConfig } from 'src/app/models/internal/alert-config'; import { AlertType } from 'src/app/models/internal/alert-type'; import { AlertService } from 'src/app/services/alert.service'; @@ -37,6 +37,8 @@ import { Highlight } from 'src/app/models/domain/hightlight'; import { ModalDeleteGenericComponent } from 'src/app/components/modals/modal-delete-generic/modal-delete-generic.component'; import { scopes } from 'src/app/models/domain/scopes'; import { SEOService } from 'src/app/services/seo.service'; +import { ModalHighlightEditComponent } from 'src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component'; +import { HighlightUpdate } from 'src/app/models/resources/highlight-update'; /** * Overview of a single project @@ -148,7 +150,7 @@ export class DetailsComponent implements OnInit { this.alertService.pushAlert(alertConfig); return; } - const modalRef = this.modalService.show(ModalHighlightComponent); + const modalRef = this.modalService.show(ModalHighlightFormComponent); modalRef.content.confirm .pipe( @@ -185,27 +187,55 @@ export class DetailsComponent implements OnInit { * Method to delete a highlight. */ public onClickDeleteHighlightButton(): void { - if (this.project == null || this.project.id === 0) { - return; - } - this.highlightByProjectIdService.getHighlightsByProjectId(this.project.id).subscribe( - (results: Highlight[]) => { - if (results == null) { - return; - } - results.forEach(highlight => { - if (highlight.startDate != null && highlight.endDate != null) { - highlight.startDate = this.formatTimestamps(highlight.startDate); - highlight.endDate = this.formatTimestamps(highlight.endDate); - } else { - highlight.startDate = 'Never Ending'; - highlight.endDate = 'Never Ending'; - } + this.highlightByProjectIdService + .getHighlightsByProjectId(this.project.id) + .subscribe((results: Highlight[]) => { + const options = { initialState: { highlights: results }, class: "modal-lg" }; + this.modalService.show(ModalHighlightDeleteComponent, options); + }); + } + + /** + * Method to first open a modal to select project highlight to edit and then the highlight modal form + */ + public onClickEditHighlightButton(): void { + this.highlightByProjectIdService + .getHighlightsByProjectId(this.project.id) + .subscribe((results: Highlight[]) => { + const options = { initialState: { highlights: results }, class: "modal-lg" }; + const modalHighlightEditRef = this.modalService.show(ModalHighlightEditComponent, options); + + return modalHighlightEditRef.content.selectHighlightToEdit.subscribe(highlight => { + const formModalRef = this.modalService.show(ModalHighlightFormComponent, { initialState: { highlight } }); + + formModalRef.content.confirm.pipe( + switchMap((highlightFormResult: HighlightFormResult) => { + const highlightAddResource: HighlightUpdate = { + projectId: this.project.id, + startDate: highlightFormResult.startDate, + description: highlightFormResult.description, + endDate: highlightFormResult.endDate + }; + + if (highlightFormResult.indeterminate) { + highlightAddResource.startDate = null; + highlightAddResource.endDate = null; + } + + return this.highlightService.put(highlight.id, highlightAddResource); + }) + ).subscribe(() => { + const alertConfig: AlertConfig = { + type: AlertType.success, + mainMessage: 'Highlight was successfully updated', + dismissible: true, + timeout: this.alertService.defaultTimeout + }; + this.alertService.pushAlert(alertConfig); + this.isProjectHighlighted = true; + }); }); - const initialState = { highlights: results }; - this.modalService.show(ModalHighlightDeleteComponent, { initialState }); - } - ); + }); } /** @@ -316,16 +346,4 @@ export class DetailsComponent implements OnInit { } this.displayEmbedButton = this.project.user.id === this.currentUser.id; } - - private formatTimestamps(highlightTimestamp: string): string { - const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; - const dayOfTheWeek = days[new Date(highlightTimestamp).getDay()]; - const dateStamp = new Date(highlightTimestamp).getUTCDate() + '-' + (new Date(highlightTimestamp).getUTCMonth() + 1) - + '-' + new Date(highlightTimestamp).getUTCFullYear(); - const timeStamp = new Date(highlightTimestamp).getUTCHours() + ':' + ('0' + new Date(highlightTimestamp).getUTCMinutes()).slice(-2); - const timeZone = 'GMT'; - return dayOfTheWeek + ', ' + dateStamp + ', ' + timeStamp + ' ' + timeZone; - } - - } diff --git a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html index 457b0d3a..f0697d9a 100644 --- a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html +++ b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html @@ -23,25 +23,15 @@

Delete highlight

-
- - - -
-
- -
- -
-
diff --git a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss index 52d5ca15..df515cef 100644 --- a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss +++ b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss @@ -17,7 +17,7 @@ @import "assets/styles/variables"; -.modal-body{ +.modal-body { position: unset; h2 { @@ -27,21 +27,21 @@ .modal-delete-container { background: #f8f8f8; - width: 700px; border-radius: 6px; border: none; outline: none; box-shadow: $box-shadow; padding: 15px; color: $light-mode-grey-primary; - button.close{ + button.close { border: none; background: none; display: flex; float: right; - &:focus, &:active{ - border:none; - outline:none; + &:focus, + &:active { + border: none; + outline: none; } } } @@ -70,15 +70,16 @@ display: flex; align-items: center; margin-top: 10px; - input[type="checkbox"] { - border: solid 1px $light-mode-grey-primary; - margin-right: 15px; - } - - h4 { - margin: 0; - } } + + h4 { + margin: 0; + } +} + +input[type="checkbox"] { + border: solid 1px $light-mode-grey-primary; + margin-right: 15px; } .modal-buttons { @@ -95,7 +96,8 @@ align-items: center; margin-bottom: 10px; - #neverEndingCheckbox, #checkbox { + #neverEndingCheckbox, + #checkbox { width: 16px; height: 16px; margin-right: 10px; diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html new file mode 100644 index 00000000..6e849ca9 --- /dev/null +++ b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html @@ -0,0 +1,15 @@ + diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss new file mode 100644 index 00000000..6cbae4ee --- /dev/null +++ b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss @@ -0,0 +1,9 @@ +.modal-highlight-edit-container { + .list-group-item-action { + cursor: pointer; + + .date { + padding-left: 10px; + } + } +} \ No newline at end of file diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts new file mode 100644 index 00000000..74bfab92 --- /dev/null +++ b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts @@ -0,0 +1,20 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { BsModalRef } from 'ngx-bootstrap/modal'; +import { Highlight } from 'src/app/models/domain/hightlight'; + +@Component({ + selector: 'app-modal-highlight-edit', + templateUrl: './modal-highlight-edit.component.html', + styleUrls: ['./modal-highlight-edit.component.scss'] +}) +export class ModalHighlightEditComponent { + @Input() highlights: Highlight[]; + @Output() selectHighlightToEdit = new EventEmitter(); + + constructor(public bsModalRef: BsModalRef) {} + + selectHighlight(selectedHighlight: Highlight) { + this.selectHighlightToEdit.emit(selectedHighlight); + this.bsModalRef.hide(); + } +} diff --git a/src/app/modules/project/modal-highlight/modal-highlight.component.html b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.html similarity index 100% rename from src/app/modules/project/modal-highlight/modal-highlight.component.html rename to src/app/modules/project/modal-highlight-form/modal-highlight-form.component.html diff --git a/src/app/modules/project/modal-highlight/modal-highlight.component.scss b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.scss similarity index 100% rename from src/app/modules/project/modal-highlight/modal-highlight.component.scss rename to src/app/modules/project/modal-highlight-form/modal-highlight-form.component.scss diff --git a/src/app/modules/project/modal-highlight/modal-highlight.component.ts b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts similarity index 76% rename from src/app/modules/project/modal-highlight/modal-highlight.component.ts rename to src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts index 4872d6c1..fb7bb435 100644 --- a/src/app/modules/project/modal-highlight/modal-highlight.component.ts +++ b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts @@ -16,9 +16,11 @@ * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt * */ -import { Component, Output, EventEmitter } from '@angular/core'; +import { Component, Output, EventEmitter, Input, OnInit } from '@angular/core'; import { BsModalRef } from 'ngx-bootstrap/modal'; import { FormBuilder, FormGroup } from '@angular/forms'; +import { Highlight } from 'src/app/models/domain/hightlight'; +import * as moment from 'moment'; export interface HighlightFormResult { startDate?: Date; @@ -31,32 +33,36 @@ export interface HighlightFormResult { * Pop-up modal with duration settings for highlighting a project. */ @Component({ - selector: 'app-modal-highlight', - templateUrl: './modal-highlight.component.html', - styleUrls: ['./modal-highlight.component.scss'] + selector: 'app-modal-highlight-form', + templateUrl: './modal-highlight-form.component.html', + styleUrls: ['./modal-highlight-form.component.scss'] }) -export class ModalHighlightComponent { - +export class ModalHighlightFormComponent implements OnInit { + @Input() highlight: Highlight; @Output() confirm = new EventEmitter(); public highlightProjectForm: FormGroup; public dateFieldsEnabled = true; public validationErrorMessage: string = null; - constructor( - public bsModalRef: BsModalRef, - private formBuilder: FormBuilder, - ) { + constructor(public bsModalRef: BsModalRef, private formBuilder: FormBuilder) { } + + ngOnInit() { this.highlightProjectForm = this.formBuilder.group({ - startDate: [null], - endDate: [null], - description: [null], - indeterminate: [false], + startDate: [this.highlight?.startDate ? moment(this.highlight?.startDate).format("YYYY-MM-DD") : null], + endDate: [this.highlight?.endDate ? moment(this.highlight?.endDate).format("YYYY-MM-DD") : null], + description: [this.highlight?.description], + indeterminate: [this.highlight?.startDate === null && this.highlight?.endDate === null], }); this.highlightProjectForm.get('indeterminate').valueChanges.subscribe(value => { this.onChangeCheckbox(value); }); + + if (this.highlightProjectForm.get('indeterminate').value === true) { + this.highlightProjectForm.get('startDate').disable(); + this.highlightProjectForm.get('endDate').disable(); + } } /** diff --git a/src/app/modules/project/project.module.ts b/src/app/modules/project/project.module.ts index a7c90403..228942c5 100644 --- a/src/app/modules/project/project.module.ts +++ b/src/app/modules/project/project.module.ts @@ -27,11 +27,12 @@ import { EmbedComponent } from './embed/embed.component'; import { PaginationModule } from 'ngx-bootstrap/pagination'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; import { ModalHighlightDeleteComponent } from 'src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component'; -import { ModalHighlightComponent } from 'src/app/modules/project/modal-highlight/modal-highlight.component'; +import { ModalHighlightFormComponent } from 'src/app/modules/project/modal-highlight-form/modal-highlight-form.component'; import { SharedModule } from './../shared/shared.module'; import { QuillModule } from 'ngx-quill'; import { Meta } from '@angular/platform-browser'; - +import { ModalHighlightEditComponent } from './modal-highlight-edit/modal-highlight-edit.component'; +import { FormatDatePipe } from 'src/app/utils/format-date.pipe'; @NgModule({ declarations: [ @@ -41,7 +42,10 @@ import { Meta } from '@angular/platform-browser'; EmbedButtonComponent, EmbedComponent, ModalHighlightDeleteComponent, - ModalHighlightComponent], + ModalHighlightFormComponent, + ModalHighlightEditComponent, + FormatDatePipe + ], imports: [ CommonModule, FormsModule, diff --git a/src/app/utils/format-date.pipe.ts b/src/app/utils/format-date.pipe.ts new file mode 100644 index 00000000..f0666201 --- /dev/null +++ b/src/app/utils/format-date.pipe.ts @@ -0,0 +1,11 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import * as moment from 'moment'; + +@Pipe({ + name: 'formatDate' +}) +export class FormatDatePipe implements PipeTransform { + public transform(date: string): string { + return date ? moment(date).format('dddd, DD-MM-YYYY') : 'Never ending'; + } +} From c3b130413ff24139ec05b05072f80efa0b8ae765 Mon Sep 17 00:00:00 2001 From: Martin Markov Date: Sun, 11 Oct 2020 18:15:40 +0200 Subject: [PATCH 002/141] Added missing empty line --- .../modal-highlight-edit/modal-highlight-edit.component.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss index 6cbae4ee..a6aceba2 100644 --- a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss +++ b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss @@ -6,4 +6,4 @@ padding-left: 10px; } } -} \ No newline at end of file +} From 48a03880acc3e31f775cd70dbdf9afe3b7df7c63 Mon Sep 17 00:00:00 2001 From: Martin Markov Date: Sun, 11 Oct 2020 18:19:01 +0200 Subject: [PATCH 003/141] Updated the changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0acf50f..78ea7493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added update highlight functionality - [#294](https://github.com/DigitalExcellence/dex-frontend/issues/294) + ### Changed ### Deprecated From ccca0bdf7c515db07cfa6182e3b3a10f00d7a8b8 Mon Sep 17 00:00:00 2001 From: Martin Markov Date: Sun, 11 Oct 2020 18:34:23 +0200 Subject: [PATCH 004/141] Fixed linting issues --- src/app/modules/project/details/details.component.ts | 10 +++++----- .../modal-highlight-form.component.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/modules/project/details/details.component.ts b/src/app/modules/project/details/details.component.ts index dfd2da6b..d437adb7 100644 --- a/src/app/modules/project/details/details.component.ts +++ b/src/app/modules/project/details/details.component.ts @@ -190,7 +190,7 @@ export class DetailsComponent implements OnInit { this.highlightByProjectIdService .getHighlightsByProjectId(this.project.id) .subscribe((results: Highlight[]) => { - const options = { initialState: { highlights: results }, class: "modal-lg" }; + const options = { initialState: { highlights: results }, class: 'modal-lg' }; this.modalService.show(ModalHighlightDeleteComponent, options); }); } @@ -202,12 +202,12 @@ export class DetailsComponent implements OnInit { this.highlightByProjectIdService .getHighlightsByProjectId(this.project.id) .subscribe((results: Highlight[]) => { - const options = { initialState: { highlights: results }, class: "modal-lg" }; + const options = { initialState: { highlights: results }, class: 'modal-lg' }; const modalHighlightEditRef = this.modalService.show(ModalHighlightEditComponent, options); return modalHighlightEditRef.content.selectHighlightToEdit.subscribe(highlight => { const formModalRef = this.modalService.show(ModalHighlightFormComponent, { initialState: { highlight } }); - + formModalRef.content.confirm.pipe( switchMap((highlightFormResult: HighlightFormResult) => { const highlightAddResource: HighlightUpdate = { @@ -216,12 +216,12 @@ export class DetailsComponent implements OnInit { description: highlightFormResult.description, endDate: highlightFormResult.endDate }; - + if (highlightFormResult.indeterminate) { highlightAddResource.startDate = null; highlightAddResource.endDate = null; } - + return this.highlightService.put(highlight.id, highlightAddResource); }) ).subscribe(() => { diff --git a/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts index fb7bb435..c987a782 100644 --- a/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts +++ b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts @@ -49,8 +49,8 @@ export class ModalHighlightFormComponent implements OnInit { ngOnInit() { this.highlightProjectForm = this.formBuilder.group({ - startDate: [this.highlight?.startDate ? moment(this.highlight?.startDate).format("YYYY-MM-DD") : null], - endDate: [this.highlight?.endDate ? moment(this.highlight?.endDate).format("YYYY-MM-DD") : null], + startDate: [this.highlight?.startDate ? moment(this.highlight?.startDate).format('YYYY-MM-DD') : null], + endDate: [this.highlight?.endDate ? moment(this.highlight?.endDate).format('YYYY-MM-DD') : null], description: [this.highlight?.description], indeterminate: [this.highlight?.startDate === null && this.highlight?.endDate === null], }); From 0ce5cfc665105fde65fa8d9a083697bfe04fb6f6 Mon Sep 17 00:00:00 2001 From: Ruben Date: Tue, 27 Oct 2020 14:59:50 +0100 Subject: [PATCH 005/141] Added CallToAction model --- src/app/models/domain/call-to-action.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/app/models/domain/call-to-action.ts diff --git a/src/app/models/domain/call-to-action.ts b/src/app/models/domain/call-to-action.ts new file mode 100644 index 00000000..a8bf755d --- /dev/null +++ b/src/app/models/domain/call-to-action.ts @@ -0,0 +1,22 @@ +/* + * Digital Excellence Copyright (C) 2020 Brend Smits + * + * This program 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 version 3 of the License. + * + * This program 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 can find a copy of the GNU Lesser General Public License + * along with this program, in the LICENSE.md file in the root project directory. + * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt + */ + +export interface CallToAction { + id: number; + name: string; + redirectUrl: string; +} From 5f070ed246dbfae5e79b6ed5cb36c34a22fd8cc5 Mon Sep 17 00:00:00 2001 From: Devon Cavis Date: Fri, 30 Oct 2020 14:18:51 +0100 Subject: [PATCH 006/141] Added cta-dropdown current value detection --- .../project/add/manual/manual.component.html | 26 +++++++++++++++++++ .../project/add/manual/manual.component.ts | 18 +++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/app/modules/project/add/manual/manual.component.html b/src/app/modules/project/add/manual/manual.component.html index f0482ba1..0bc6ed43 100644 --- a/src/app/modules/project/add/manual/manual.component.html +++ b/src/app/modules/project/add/manual/manual.component.html @@ -68,6 +68,32 @@

Description*

+
+ +
+
+

Call to action

+
+
+
+

Text

+ +

You selected: {{selectedCallToAction}}

+
+
+ +
+
+

Link

+ +
+
+
+
+
diff --git a/src/app/modules/project/add/manual/manual.component.ts b/src/app/modules/project/add/manual/manual.component.ts index 74a03ab4..100ea71d 100644 --- a/src/app/modules/project/add/manual/manual.component.ts +++ b/src/app/modules/project/add/manual/manual.component.ts @@ -44,8 +44,14 @@ export class ManualComponent implements OnInit { * Formgroup for entering project details. */ public newProjectForm: FormGroup; + public newCallToActionForm: FormGroup; public newCollaboratorForm: FormGroup; + /** + * Projects selected call to action + */ + public selectedCallToAction = 'None'; + /** * Project's collaborators. */ @@ -61,6 +67,11 @@ export class ManualComponent implements OnInit { */ public modulesConfigration = QuillUtils.getDefaultModulesConfiguration(); + selectChangeHandler (event: any) { + // Allow the frontend to check if it needs to activate the link input + this.selectedCallToAction = event.target.value; + } + constructor( private router: Router, private formBuilder: FormBuilder, @@ -75,6 +86,11 @@ export class ManualComponent implements OnInit { description: [null], }); + this.newCallToActionForm = this.formBuilder.group({ + name: [null, Validators.required], + redirectUrl: [null, Validators.required], + }); + this.newCollaboratorForm = this.formBuilder.group({ fullName: [null, Validators.required], role: [null, Validators.required], @@ -103,6 +119,8 @@ export class ManualComponent implements OnInit { this.seoService.updateDescription('Create a new project in DeX'); } + + /** * Method which triggers when the submit button is pressed. * Creates a new project. From 037ebcbb26e194109c77a326602764e3c4200b94 Mon Sep 17 00:00:00 2001 From: Ruben Date: Fri, 30 Oct 2020 14:24:40 +0100 Subject: [PATCH 007/141] Show options in select input form model list --- .../project/add/manual/manual.component.html | 4 ++-- .../project/add/manual/manual.component.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/app/modules/project/add/manual/manual.component.html b/src/app/modules/project/add/manual/manual.component.html index 0bc6ed43..82b0d46c 100644 --- a/src/app/modules/project/add/manual/manual.component.html +++ b/src/app/modules/project/add/manual/manual.component.html @@ -77,9 +77,9 @@

Call to action

Text

- - +

You selected: {{selectedCallToAction}}

diff --git a/src/app/modules/project/add/manual/manual.component.ts b/src/app/modules/project/add/manual/manual.component.ts index 100ea71d..315c2ff4 100644 --- a/src/app/modules/project/add/manual/manual.component.ts +++ b/src/app/modules/project/add/manual/manual.component.ts @@ -30,6 +30,7 @@ import { QuillUtils } from 'src/app/utils/quill.utils'; import { SEOService} from 'src/app/services/seo.service'; // Import showdown for markdown to html conversion. import * as showdown from 'showdown'; +import { CallToAction } from 'src/app/models/domain/call-to-action'; /** * Component for manually adding a project. @@ -67,6 +68,8 @@ export class ManualComponent implements OnInit { */ public modulesConfigration = QuillUtils.getDefaultModulesConfiguration(); + public callToActions: CallToAction[] = []; + selectChangeHandler (event: any) { // Allow the frontend to check if it needs to activate the link input this.selectedCallToAction = event.target.value; @@ -79,6 +82,18 @@ export class ManualComponent implements OnInit { private wizardService: WizardService, private alertService: AlertService, private seoService: SEOService) { + this.callToActions.push({ + id: 1, + name: 'testname', + redirectUrl: 'google.nl', + }); + + this.callToActions.push({ + id: 2, + name: 'testname2', + redirectUrl: 'google.be', + }) + this.newProjectForm = this.formBuilder.group({ name: [null, Validators.required], uri: [null, Validators.required], From 3997393dcbef13b1ffbdb102d1c065844104d461 Mon Sep 17 00:00:00 2001 From: Ruben Date: Fri, 30 Oct 2020 14:31:45 +0100 Subject: [PATCH 008/141] Remove browser error --- src/app/modules/project/add/manual/manual.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/modules/project/add/manual/manual.component.html b/src/app/modules/project/add/manual/manual.component.html index 82b0d46c..876667fc 100644 --- a/src/app/modules/project/add/manual/manual.component.html +++ b/src/app/modules/project/add/manual/manual.component.html @@ -88,7 +88,7 @@

Text

Link

- +
From 13e7cd1051655c6f58ad6ad96b8faa9a898fa377 Mon Sep 17 00:00:00 2001 From: Martin Markov Date: Sun, 11 Oct 2020 18:13:42 +0200 Subject: [PATCH 009/141] Added edit highlight functionality --- package-lock.json | 5 ++ package.json | 1 + .../project/details/details.component.html | 11 ++- .../project/details/details.component.scss | 5 +- .../project/details/details.component.ts | 86 +++++++++++-------- .../modal-highlight-delete.component.html | 18 +--- .../modal-highlight-delete.component.scss | 32 +++---- .../modal-highlight-edit.component.html | 15 ++++ .../modal-highlight-edit.component.scss | 9 ++ .../modal-highlight-edit.component.ts | 20 +++++ .../modal-highlight-form.component.html} | 0 .../modal-highlight-form.component.scss} | 0 .../modal-highlight-form.component.ts} | 34 +++++--- src/app/modules/project/project.module.ts | 10 ++- src/app/utils/format-date.pipe.ts | 11 +++ 15 files changed, 171 insertions(+), 86 deletions(-) create mode 100644 src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html create mode 100644 src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss create mode 100644 src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts rename src/app/modules/project/{modal-highlight/modal-highlight.component.html => modal-highlight-form/modal-highlight-form.component.html} (100%) rename src/app/modules/project/{modal-highlight/modal-highlight.component.scss => modal-highlight-form/modal-highlight-form.component.scss} (100%) rename src/app/modules/project/{modal-highlight/modal-highlight.component.ts => modal-highlight-form/modal-highlight-form.component.ts} (76%) create mode 100644 src/app/utils/format-date.pipe.ts diff --git a/package-lock.json b/package-lock.json index 2e71c05b..5c343c68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9093,6 +9093,11 @@ } } }, + "moment": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" + }, "move-concurrently": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", diff --git a/package.json b/package.json index bbd7b054..d50c9306 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "dotenv": "^5.0.0", "ngx-bootstrap": "^5.6.2", "ngx-quill": "^11.1.0", + "moment": "^2.29.1", "oidc-client": "^1.10.1", "quill": "^1.3.7", "quill-markdown-shortcuts": "0.0.10", diff --git a/src/app/modules/project/details/details.component.html b/src/app/modules/project/details/details.component.html index bd933f7a..b48e8932 100644 --- a/src/app/modules/project/details/details.component.html +++ b/src/app/modules/project/details/details.component.html @@ -55,7 +55,7 @@

Collaborators

-
+

{{ project.name }}

@@ -101,12 +101,19 @@

{{ project.name }}

- +
+ +
+ +
+ +
+ diff --git a/src/app/modules/project/details/details.component.scss b/src/app/modules/project/details/details.component.scss index a9cd53d6..30633081 100644 --- a/src/app/modules/project/details/details.component.scss +++ b/src/app/modules/project/details/details.component.scss @@ -91,11 +91,8 @@ max-width: 800px; } -.project-highlighted-div { - float: left; -} - #project-share-buttons { + display: flex; margin-top: 60px; button:first-child { diff --git a/src/app/modules/project/details/details.component.ts b/src/app/modules/project/details/details.component.ts index 6e12639a..e0fa5860 100644 --- a/src/app/modules/project/details/details.component.ts +++ b/src/app/modules/project/details/details.component.ts @@ -24,7 +24,7 @@ import { AuthService } from 'src/app/services/auth.service'; import { HighlightService } from 'src/app/services/highlight.service'; import { HighlightAdd } from 'src/app/models/resources/highlight-add'; import { BsModalService, ModalOptions } from 'ngx-bootstrap/modal'; -import { ModalHighlightComponent, HighlightFormResult } from 'src/app/modules/project/modal-highlight/modal-highlight.component'; +import { ModalHighlightFormComponent, HighlightFormResult } from 'src/app/modules/project/modal-highlight-form/modal-highlight-form.component'; import { AlertConfig } from 'src/app/models/internal/alert-config'; import { AlertType } from 'src/app/models/internal/alert-type'; import { AlertService } from 'src/app/services/alert.service'; @@ -37,6 +37,8 @@ import { Highlight } from 'src/app/models/domain/highlight'; import { ModalDeleteGenericComponent } from 'src/app/components/modals/modal-delete-generic/modal-delete-generic.component'; import { scopes } from 'src/app/models/domain/scopes'; import { SEOService } from 'src/app/services/seo.service'; +import { ModalHighlightEditComponent } from 'src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component'; +import { HighlightUpdate } from 'src/app/models/resources/highlight-update'; /** * Overview of a single project @@ -148,7 +150,7 @@ export class DetailsComponent implements OnInit { this.alertService.pushAlert(alertConfig); return; } - const modalRef = this.modalService.show(ModalHighlightComponent); + const modalRef = this.modalService.show(ModalHighlightFormComponent); modalRef.content.confirm .pipe( @@ -185,27 +187,55 @@ export class DetailsComponent implements OnInit { * Method to delete a highlight. */ public onClickDeleteHighlightButton(): void { - if (this.project == null || this.project.id === 0) { - return; - } - this.highlightByProjectIdService.getHighlightsByProjectId(this.project.id).subscribe( - (results: Highlight[]) => { - if (results == null) { - return; - } - results.forEach(highlight => { - if (highlight.startDate != null && highlight.endDate != null) { - highlight.startDate = this.formatTimestamps(highlight.startDate); - highlight.endDate = this.formatTimestamps(highlight.endDate); - } else { - highlight.startDate = 'Never Ending'; - highlight.endDate = 'Never Ending'; - } + this.highlightByProjectIdService + .getHighlightsByProjectId(this.project.id) + .subscribe((results: Highlight[]) => { + const options = { initialState: { highlights: results }, class: "modal-lg" }; + this.modalService.show(ModalHighlightDeleteComponent, options); + }); + } + + /** + * Method to first open a modal to select project highlight to edit and then the highlight modal form + */ + public onClickEditHighlightButton(): void { + this.highlightByProjectIdService + .getHighlightsByProjectId(this.project.id) + .subscribe((results: Highlight[]) => { + const options = { initialState: { highlights: results }, class: "modal-lg" }; + const modalHighlightEditRef = this.modalService.show(ModalHighlightEditComponent, options); + + return modalHighlightEditRef.content.selectHighlightToEdit.subscribe(highlight => { + const formModalRef = this.modalService.show(ModalHighlightFormComponent, { initialState: { highlight } }); + + formModalRef.content.confirm.pipe( + switchMap((highlightFormResult: HighlightFormResult) => { + const highlightAddResource: HighlightUpdate = { + projectId: this.project.id, + startDate: highlightFormResult.startDate, + description: highlightFormResult.description, + endDate: highlightFormResult.endDate + }; + + if (highlightFormResult.indeterminate) { + highlightAddResource.startDate = null; + highlightAddResource.endDate = null; + } + + return this.highlightService.put(highlight.id, highlightAddResource); + }) + ).subscribe(() => { + const alertConfig: AlertConfig = { + type: AlertType.success, + mainMessage: 'Highlight was successfully updated', + dismissible: true, + timeout: this.alertService.defaultTimeout + }; + this.alertService.pushAlert(alertConfig); + this.isProjectHighlighted = true; + }); }); - const initialState = { highlights: results }; - this.modalService.show(ModalHighlightDeleteComponent, { initialState }); - } - ); + }); } /** @@ -316,16 +346,4 @@ export class DetailsComponent implements OnInit { } this.displayEmbedButton = this.project.user.id === this.currentUser.id; } - - private formatTimestamps(highlightTimestamp: string): string { - const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; - const dayOfTheWeek = days[new Date(highlightTimestamp).getDay()]; - const dateStamp = new Date(highlightTimestamp).getUTCDate() + '-' + (new Date(highlightTimestamp).getUTCMonth() + 1) - + '-' + new Date(highlightTimestamp).getUTCFullYear(); - const timeStamp = new Date(highlightTimestamp).getUTCHours() + ':' + ('0' + new Date(highlightTimestamp).getUTCMinutes()).slice(-2); - const timeZone = 'GMT'; - return dayOfTheWeek + ', ' + dateStamp + ', ' + timeStamp + ' ' + timeZone; - } - - } diff --git a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html index 457b0d3a..f0697d9a 100644 --- a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html +++ b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html @@ -23,25 +23,15 @@

Delete highlight

-
- - - -
-
- -
- -
-
diff --git a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss index 52d5ca15..df515cef 100644 --- a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss +++ b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss @@ -17,7 +17,7 @@ @import "assets/styles/variables"; -.modal-body{ +.modal-body { position: unset; h2 { @@ -27,21 +27,21 @@ .modal-delete-container { background: #f8f8f8; - width: 700px; border-radius: 6px; border: none; outline: none; box-shadow: $box-shadow; padding: 15px; color: $light-mode-grey-primary; - button.close{ + button.close { border: none; background: none; display: flex; float: right; - &:focus, &:active{ - border:none; - outline:none; + &:focus, + &:active { + border: none; + outline: none; } } } @@ -70,15 +70,16 @@ display: flex; align-items: center; margin-top: 10px; - input[type="checkbox"] { - border: solid 1px $light-mode-grey-primary; - margin-right: 15px; - } - - h4 { - margin: 0; - } } + + h4 { + margin: 0; + } +} + +input[type="checkbox"] { + border: solid 1px $light-mode-grey-primary; + margin-right: 15px; } .modal-buttons { @@ -95,7 +96,8 @@ align-items: center; margin-bottom: 10px; - #neverEndingCheckbox, #checkbox { + #neverEndingCheckbox, + #checkbox { width: 16px; height: 16px; margin-right: 10px; diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html new file mode 100644 index 00000000..6e849ca9 --- /dev/null +++ b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html @@ -0,0 +1,15 @@ + diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss new file mode 100644 index 00000000..6cbae4ee --- /dev/null +++ b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss @@ -0,0 +1,9 @@ +.modal-highlight-edit-container { + .list-group-item-action { + cursor: pointer; + + .date { + padding-left: 10px; + } + } +} \ No newline at end of file diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts new file mode 100644 index 00000000..74bfab92 --- /dev/null +++ b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts @@ -0,0 +1,20 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { BsModalRef } from 'ngx-bootstrap/modal'; +import { Highlight } from 'src/app/models/domain/hightlight'; + +@Component({ + selector: 'app-modal-highlight-edit', + templateUrl: './modal-highlight-edit.component.html', + styleUrls: ['./modal-highlight-edit.component.scss'] +}) +export class ModalHighlightEditComponent { + @Input() highlights: Highlight[]; + @Output() selectHighlightToEdit = new EventEmitter(); + + constructor(public bsModalRef: BsModalRef) {} + + selectHighlight(selectedHighlight: Highlight) { + this.selectHighlightToEdit.emit(selectedHighlight); + this.bsModalRef.hide(); + } +} diff --git a/src/app/modules/project/modal-highlight/modal-highlight.component.html b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.html similarity index 100% rename from src/app/modules/project/modal-highlight/modal-highlight.component.html rename to src/app/modules/project/modal-highlight-form/modal-highlight-form.component.html diff --git a/src/app/modules/project/modal-highlight/modal-highlight.component.scss b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.scss similarity index 100% rename from src/app/modules/project/modal-highlight/modal-highlight.component.scss rename to src/app/modules/project/modal-highlight-form/modal-highlight-form.component.scss diff --git a/src/app/modules/project/modal-highlight/modal-highlight.component.ts b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts similarity index 76% rename from src/app/modules/project/modal-highlight/modal-highlight.component.ts rename to src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts index 4872d6c1..fb7bb435 100644 --- a/src/app/modules/project/modal-highlight/modal-highlight.component.ts +++ b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts @@ -16,9 +16,11 @@ * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt * */ -import { Component, Output, EventEmitter } from '@angular/core'; +import { Component, Output, EventEmitter, Input, OnInit } from '@angular/core'; import { BsModalRef } from 'ngx-bootstrap/modal'; import { FormBuilder, FormGroup } from '@angular/forms'; +import { Highlight } from 'src/app/models/domain/hightlight'; +import * as moment from 'moment'; export interface HighlightFormResult { startDate?: Date; @@ -31,32 +33,36 @@ export interface HighlightFormResult { * Pop-up modal with duration settings for highlighting a project. */ @Component({ - selector: 'app-modal-highlight', - templateUrl: './modal-highlight.component.html', - styleUrls: ['./modal-highlight.component.scss'] + selector: 'app-modal-highlight-form', + templateUrl: './modal-highlight-form.component.html', + styleUrls: ['./modal-highlight-form.component.scss'] }) -export class ModalHighlightComponent { - +export class ModalHighlightFormComponent implements OnInit { + @Input() highlight: Highlight; @Output() confirm = new EventEmitter(); public highlightProjectForm: FormGroup; public dateFieldsEnabled = true; public validationErrorMessage: string = null; - constructor( - public bsModalRef: BsModalRef, - private formBuilder: FormBuilder, - ) { + constructor(public bsModalRef: BsModalRef, private formBuilder: FormBuilder) { } + + ngOnInit() { this.highlightProjectForm = this.formBuilder.group({ - startDate: [null], - endDate: [null], - description: [null], - indeterminate: [false], + startDate: [this.highlight?.startDate ? moment(this.highlight?.startDate).format("YYYY-MM-DD") : null], + endDate: [this.highlight?.endDate ? moment(this.highlight?.endDate).format("YYYY-MM-DD") : null], + description: [this.highlight?.description], + indeterminate: [this.highlight?.startDate === null && this.highlight?.endDate === null], }); this.highlightProjectForm.get('indeterminate').valueChanges.subscribe(value => { this.onChangeCheckbox(value); }); + + if (this.highlightProjectForm.get('indeterminate').value === true) { + this.highlightProjectForm.get('startDate').disable(); + this.highlightProjectForm.get('endDate').disable(); + } } /** diff --git a/src/app/modules/project/project.module.ts b/src/app/modules/project/project.module.ts index a7c90403..228942c5 100644 --- a/src/app/modules/project/project.module.ts +++ b/src/app/modules/project/project.module.ts @@ -27,11 +27,12 @@ import { EmbedComponent } from './embed/embed.component'; import { PaginationModule } from 'ngx-bootstrap/pagination'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; import { ModalHighlightDeleteComponent } from 'src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component'; -import { ModalHighlightComponent } from 'src/app/modules/project/modal-highlight/modal-highlight.component'; +import { ModalHighlightFormComponent } from 'src/app/modules/project/modal-highlight-form/modal-highlight-form.component'; import { SharedModule } from './../shared/shared.module'; import { QuillModule } from 'ngx-quill'; import { Meta } from '@angular/platform-browser'; - +import { ModalHighlightEditComponent } from './modal-highlight-edit/modal-highlight-edit.component'; +import { FormatDatePipe } from 'src/app/utils/format-date.pipe'; @NgModule({ declarations: [ @@ -41,7 +42,10 @@ import { Meta } from '@angular/platform-browser'; EmbedButtonComponent, EmbedComponent, ModalHighlightDeleteComponent, - ModalHighlightComponent], + ModalHighlightFormComponent, + ModalHighlightEditComponent, + FormatDatePipe + ], imports: [ CommonModule, FormsModule, diff --git a/src/app/utils/format-date.pipe.ts b/src/app/utils/format-date.pipe.ts new file mode 100644 index 00000000..f0666201 --- /dev/null +++ b/src/app/utils/format-date.pipe.ts @@ -0,0 +1,11 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import * as moment from 'moment'; + +@Pipe({ + name: 'formatDate' +}) +export class FormatDatePipe implements PipeTransform { + public transform(date: string): string { + return date ? moment(date).format('dddd, DD-MM-YYYY') : 'Never ending'; + } +} From 95cd9ba7475b08de4a73fe53ca991a1737eb0973 Mon Sep 17 00:00:00 2001 From: Martin Markov Date: Sun, 11 Oct 2020 18:15:40 +0200 Subject: [PATCH 010/141] Added missing empty line --- .../modal-highlight-edit/modal-highlight-edit.component.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss index 6cbae4ee..a6aceba2 100644 --- a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss +++ b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss @@ -6,4 +6,4 @@ padding-left: 10px; } } -} \ No newline at end of file +} From 797e66cfad33e41e8158e8c5b934703a56b50956 Mon Sep 17 00:00:00 2001 From: Martin Markov Date: Sun, 11 Oct 2020 18:19:01 +0200 Subject: [PATCH 011/141] Updated the changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0acf50f..78ea7493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added update highlight functionality - [#294](https://github.com/DigitalExcellence/dex-frontend/issues/294) + ### Changed ### Deprecated From a38ecca8ba66d0eef1da811fc699e54e740f305c Mon Sep 17 00:00:00 2001 From: Martin Markov Date: Sun, 11 Oct 2020 18:34:23 +0200 Subject: [PATCH 012/141] Fixed linting issues --- src/app/modules/project/details/details.component.ts | 10 +++++----- .../modal-highlight-form.component.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/modules/project/details/details.component.ts b/src/app/modules/project/details/details.component.ts index e0fa5860..13e7fce2 100644 --- a/src/app/modules/project/details/details.component.ts +++ b/src/app/modules/project/details/details.component.ts @@ -190,7 +190,7 @@ export class DetailsComponent implements OnInit { this.highlightByProjectIdService .getHighlightsByProjectId(this.project.id) .subscribe((results: Highlight[]) => { - const options = { initialState: { highlights: results }, class: "modal-lg" }; + const options = { initialState: { highlights: results }, class: 'modal-lg' }; this.modalService.show(ModalHighlightDeleteComponent, options); }); } @@ -202,12 +202,12 @@ export class DetailsComponent implements OnInit { this.highlightByProjectIdService .getHighlightsByProjectId(this.project.id) .subscribe((results: Highlight[]) => { - const options = { initialState: { highlights: results }, class: "modal-lg" }; + const options = { initialState: { highlights: results }, class: 'modal-lg' }; const modalHighlightEditRef = this.modalService.show(ModalHighlightEditComponent, options); return modalHighlightEditRef.content.selectHighlightToEdit.subscribe(highlight => { const formModalRef = this.modalService.show(ModalHighlightFormComponent, { initialState: { highlight } }); - + formModalRef.content.confirm.pipe( switchMap((highlightFormResult: HighlightFormResult) => { const highlightAddResource: HighlightUpdate = { @@ -216,12 +216,12 @@ export class DetailsComponent implements OnInit { description: highlightFormResult.description, endDate: highlightFormResult.endDate }; - + if (highlightFormResult.indeterminate) { highlightAddResource.startDate = null; highlightAddResource.endDate = null; } - + return this.highlightService.put(highlight.id, highlightAddResource); }) ).subscribe(() => { diff --git a/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts index fb7bb435..c987a782 100644 --- a/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts +++ b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.ts @@ -49,8 +49,8 @@ export class ModalHighlightFormComponent implements OnInit { ngOnInit() { this.highlightProjectForm = this.formBuilder.group({ - startDate: [this.highlight?.startDate ? moment(this.highlight?.startDate).format("YYYY-MM-DD") : null], - endDate: [this.highlight?.endDate ? moment(this.highlight?.endDate).format("YYYY-MM-DD") : null], + startDate: [this.highlight?.startDate ? moment(this.highlight?.startDate).format('YYYY-MM-DD') : null], + endDate: [this.highlight?.endDate ? moment(this.highlight?.endDate).format('YYYY-MM-DD') : null], description: [this.highlight?.description], indeterminate: [this.highlight?.startDate === null && this.highlight?.endDate === null], }); From 0556992d376003702f2b57809171110ae4aa7201 Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 5 Nov 2020 09:11:59 +0100 Subject: [PATCH 013/141] Updated API Config for call to action route --- src/app/config/api-config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/config/api-config.ts b/src/app/config/api-config.ts index faff60fa..6709416d 100644 --- a/src/app/config/api-config.ts +++ b/src/app/config/api-config.ts @@ -26,6 +26,7 @@ export interface ApiConfig { internalSearchRoute: string; externalSearchRoute: string; wizardRoute: string; + callToActionRoute: string; } export const API_CONFIG: ApiConfig = { @@ -36,5 +37,6 @@ export const API_CONFIG: ApiConfig = { internalSearchRoute: 'search/internal', externalSearchRoute: 'search/external', embeddedProjectRoute: 'embed', - wizardRoute: 'wizard' + wizardRoute: 'wizard', + callToActionRoute: 'callToAction' }; From 8f7990a299061bde48962905a9f57ec091418a2e Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 5 Nov 2020 09:13:01 +0100 Subject: [PATCH 014/141] Created CallToActionAdd resource --- src/app/models/resources/calltoaction-add.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/app/models/resources/calltoaction-add.ts diff --git a/src/app/models/resources/calltoaction-add.ts b/src/app/models/resources/calltoaction-add.ts new file mode 100644 index 00000000..eff80845 --- /dev/null +++ b/src/app/models/resources/calltoaction-add.ts @@ -0,0 +1,20 @@ +/* + * Digital Excellence Copyright (C) 2020 Brend Smits + * + * This program 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 version 3 of the License. + * + * This program 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 can find a copy of the GNU Lesser General Public License + * along with this program, in the LICENSE.md file in the root project directory. + * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt + */ + +export interface CallToActionAdd { + +} From b276281f8f437b1ea831f7f24e0a7a18a123e817 Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 5 Nov 2020 09:13:13 +0100 Subject: [PATCH 015/141] Created CallToActionUpdate resource --- .../models/resources/calltoaction-update.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/app/models/resources/calltoaction-update.ts diff --git a/src/app/models/resources/calltoaction-update.ts b/src/app/models/resources/calltoaction-update.ts new file mode 100644 index 00000000..7686f554 --- /dev/null +++ b/src/app/models/resources/calltoaction-update.ts @@ -0,0 +1,20 @@ +/* + * Digital Excellence Copyright (C) 2020 Brend Smits + * + * This program 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 version 3 of the License. + * + * This program 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 can find a copy of the GNU Lesser General Public License + * along with this program, in the LICENSE.md file in the root project directory. + * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt + */ + +export interface CallToActionUpdate { + +} From 60c6d8ee094aaaee49768e6e40ee4954994c830f Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 5 Nov 2020 09:13:33 +0100 Subject: [PATCH 016/141] Created basic Call to action service --- src/app/services/call-to-action.service.ts | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/app/services/call-to-action.service.ts diff --git a/src/app/services/call-to-action.service.ts b/src/app/services/call-to-action.service.ts new file mode 100644 index 00000000..a5136f05 --- /dev/null +++ b/src/app/services/call-to-action.service.ts @@ -0,0 +1,33 @@ +/* + * Digital Excellence Copyright (C) 2020 Brend Smits + * + * This program 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 version 3 of the License. + * + * This program 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 can find a copy of the GNU Lesser General Public License + * along with this program, in the LICENSE.md file in the root project directory. + * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt + */ + +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { API_CONFIG } from '../config/api-config'; +import { CallToAction } from '../models/domain/call-to-action'; +import { CallToActionAdd } from '../models/resources/calltoaction-add'; +import { CallToActionUpdate } from '../models/resources/calltoaction-update'; +import { HttpBaseService } from './http-base.service'; + +@Injectable({ + providedIn: 'root' +}) +export class CallToActionService extends HttpBaseService { + constructor(http: HttpClient) { + super(http, API_CONFIG.url + API_CONFIG.callToActionRoute); + } + } From 318138faa3e6efd2178b26b1b7eaac751912fe9c Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 5 Nov 2020 09:15:48 +0100 Subject: [PATCH 017/141] Filled call to action resources --- src/app/models/resources/calltoaction-add.ts | 3 ++- src/app/models/resources/calltoaction-update.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/models/resources/calltoaction-add.ts b/src/app/models/resources/calltoaction-add.ts index eff80845..b0955bf4 100644 --- a/src/app/models/resources/calltoaction-add.ts +++ b/src/app/models/resources/calltoaction-add.ts @@ -16,5 +16,6 @@ */ export interface CallToActionAdd { - + name: string; + redirectUrl: string; } diff --git a/src/app/models/resources/calltoaction-update.ts b/src/app/models/resources/calltoaction-update.ts index 7686f554..c3b70c1c 100644 --- a/src/app/models/resources/calltoaction-update.ts +++ b/src/app/models/resources/calltoaction-update.ts @@ -16,5 +16,7 @@ */ export interface CallToActionUpdate { - + id: number; + name: string; + redirectUrl: string; } From f759de5da441c5f6cae5889b833b20b61602bcbb Mon Sep 17 00:00:00 2001 From: Devon Cavis Date: Thu, 5 Nov 2020 09:17:53 +0100 Subject: [PATCH 018/141] Fixed disabling of Call to action link when no CTA is selected --- src/app/modules/project/add/manual/manual.component.html | 2 +- src/app/modules/project/add/manual/manual.component.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/modules/project/add/manual/manual.component.html b/src/app/modules/project/add/manual/manual.component.html index 876667fc..23d44787 100644 --- a/src/app/modules/project/add/manual/manual.component.html +++ b/src/app/modules/project/add/manual/manual.component.html @@ -88,7 +88,7 @@

Text

Link

- +
diff --git a/src/app/modules/project/add/manual/manual.component.ts b/src/app/modules/project/add/manual/manual.component.ts index 315c2ff4..65d31576 100644 --- a/src/app/modules/project/add/manual/manual.component.ts +++ b/src/app/modules/project/add/manual/manual.component.ts @@ -51,7 +51,7 @@ export class ManualComponent implements OnInit { /** * Projects selected call to action */ - public selectedCallToAction = 'None'; + public selectedCallToAction = 0; /** * Project's collaborators. @@ -72,7 +72,7 @@ export class ManualComponent implements OnInit { selectChangeHandler (event: any) { // Allow the frontend to check if it needs to activate the link input - this.selectedCallToAction = event.target.value; + this.selectedCallToAction = event.target.selectedIndex; } constructor( @@ -92,7 +92,7 @@ export class ManualComponent implements OnInit { id: 2, name: 'testname2', redirectUrl: 'google.be', - }) + }); this.newProjectForm = this.formBuilder.group({ name: [null, Validators.required], From d69f79a0617756db66ac53ed84ac6b36c4d6c095 Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 5 Nov 2020 09:34:14 +0100 Subject: [PATCH 019/141] Implemented call to action service --- .../project/add/manual/manual.component.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/app/modules/project/add/manual/manual.component.ts b/src/app/modules/project/add/manual/manual.component.ts index 65d31576..20c75524 100644 --- a/src/app/modules/project/add/manual/manual.component.ts +++ b/src/app/modules/project/add/manual/manual.component.ts @@ -31,6 +31,7 @@ import { SEOService} from 'src/app/services/seo.service'; // Import showdown for markdown to html conversion. import * as showdown from 'showdown'; import { CallToAction } from 'src/app/models/domain/call-to-action'; +import { CallToActionService } from 'src/app/services/call-to-action.service'; /** * Component for manually adding a project. @@ -75,24 +76,16 @@ export class ManualComponent implements OnInit { this.selectedCallToAction = event.target.selectedIndex; } + public callToActionsLoading = true; + constructor( private router: Router, private formBuilder: FormBuilder, private projectService: ProjectService, private wizardService: WizardService, private alertService: AlertService, - private seoService: SEOService) { - this.callToActions.push({ - id: 1, - name: 'testname', - redirectUrl: 'google.nl', - }); - - this.callToActions.push({ - id: 2, - name: 'testname2', - redirectUrl: 'google.be', - }); + private seoService: SEOService, + private callToActionService: CallToActionService) { this.newProjectForm = this.formBuilder.group({ name: [null, Validators.required], @@ -129,6 +122,14 @@ export class ManualComponent implements OnInit { this.fillFormWithProject(project); }); + // Retrieve the available call to actions + this.callToActionService + .getAll() + .pipe(finalize(() => (this.callToActionsLoading = false))) + .subscribe((result) => { + this.callToActions = result; + }); + // Updates meta and title tags this.seoService.updateTitle('Add new project'); this.seoService.updateDescription('Create a new project in DeX'); From 84c7da0d5991f443360c561c60ee0bad8c377855 Mon Sep 17 00:00:00 2001 From: Devon Cavis Date: Thu, 5 Nov 2020 09:39:07 +0100 Subject: [PATCH 020/141] Improved styling of Call to action selection dropdown --- src/app/modules/project/add/manual/manual.component.html | 1 - src/app/modules/project/add/manual/manual.component.scss | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/modules/project/add/manual/manual.component.html b/src/app/modules/project/add/manual/manual.component.html index 23d44787..22ed2a8f 100644 --- a/src/app/modules/project/add/manual/manual.component.html +++ b/src/app/modules/project/add/manual/manual.component.html @@ -81,7 +81,6 @@

Text

-

You selected: {{selectedCallToAction}}

diff --git a/src/app/modules/project/add/manual/manual.component.scss b/src/app/modules/project/add/manual/manual.component.scss index 73057378..31da427e 100644 --- a/src/app/modules/project/add/manual/manual.component.scss +++ b/src/app/modules/project/add/manual/manual.component.scss @@ -39,6 +39,11 @@ outline: auto #e4e4e4; } + select { + height: 45px; + box-shadow: 0px 3px 6px #0000001a; + } + .form-footnote { margin-top: -15px; } From ccb8cb0208b0266f4eb2bf522bd0761843f6f28b Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 5 Nov 2020 09:55:55 +0100 Subject: [PATCH 021/141] Updated project service models --- src/app/models/domain/project.ts | 2 ++ src/app/models/resources/project-add.ts | 2 ++ src/app/models/resources/project-update.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/app/models/domain/project.ts b/src/app/models/domain/project.ts index 77331a2b..c47d2e44 100644 --- a/src/app/models/domain/project.ts +++ b/src/app/models/domain/project.ts @@ -17,6 +17,7 @@ import { User } from './user'; import { Collaborator } from './collaborator'; +import { CallToAction } from './call-to-action'; export interface Project { id: number; @@ -28,4 +29,5 @@ export interface Project { updated: Date; uri?: string; collaborators?: Collaborator[]; + callToAction?: CallToAction; } diff --git a/src/app/models/resources/project-add.ts b/src/app/models/resources/project-add.ts index 86f83386..ecb3abbb 100644 --- a/src/app/models/resources/project-add.ts +++ b/src/app/models/resources/project-add.ts @@ -15,6 +15,7 @@ * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt */ +import { CallToAction } from '../domain/call-to-action'; import { CollaboratorAdd } from './collaborator-add'; export interface ProjectAdd { userId: number; @@ -23,4 +24,5 @@ export interface ProjectAdd { shortDescription: string; description?: string; url: string; + callToAction: CallToAction; } diff --git a/src/app/models/resources/project-update.ts b/src/app/models/resources/project-update.ts index ca9bd09b..08a107e9 100644 --- a/src/app/models/resources/project-update.ts +++ b/src/app/models/resources/project-update.ts @@ -15,6 +15,7 @@ * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt */ +import { CallToAction } from '../domain/call-to-action'; import { CollaboratorUpdate } from './collaborator-update'; export interface ProjectUpdate { @@ -25,4 +26,5 @@ export interface ProjectUpdate { shortDescription: string; description: string; url: string; + callToAction: CallToAction; } From 7888bad63106869aa8da21f13509ec6fa16e7f5f Mon Sep 17 00:00:00 2001 From: Devon Cavis Date: Thu, 5 Nov 2020 09:58:12 +0100 Subject: [PATCH 022/141] Remove unnecessary code, added some temporary testing code --- .../project/add/manual/manual.component.html | 4 ++-- .../project/add/manual/manual.component.ts | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/app/modules/project/add/manual/manual.component.html b/src/app/modules/project/add/manual/manual.component.html index 22ed2a8f..cd4aad22 100644 --- a/src/app/modules/project/add/manual/manual.component.html +++ b/src/app/modules/project/add/manual/manual.component.html @@ -77,9 +77,9 @@

Call to action

Text

- - +
diff --git a/src/app/modules/project/add/manual/manual.component.ts b/src/app/modules/project/add/manual/manual.component.ts index 20c75524..b4c9f631 100644 --- a/src/app/modules/project/add/manual/manual.component.ts +++ b/src/app/modules/project/add/manual/manual.component.ts @@ -74,6 +74,7 @@ export class ManualComponent implements OnInit { selectChangeHandler (event: any) { // Allow the frontend to check if it needs to activate the link input this.selectedCallToAction = event.target.selectedIndex; + console.log(event.target); } public callToActionsLoading = true; @@ -123,12 +124,18 @@ export class ManualComponent implements OnInit { }); // Retrieve the available call to actions - this.callToActionService - .getAll() - .pipe(finalize(() => (this.callToActionsLoading = false))) - .subscribe((result) => { - this.callToActions = result; - }); + // this.callToActionService + // .getAll() + // .pipe(finalize(() => (this.callToActionsLoading = false))) + // .subscribe((result) => { + // this.callToActions = result; + // }); + + this.callToActions.push({ + id: 2, + name: 'testname2', + redirectUrl: 'google.be', + }); // Updates meta and title tags this.seoService.updateTitle('Add new project'); From 09cfd1659d6c3d0f92fdd11e32edd6e1fd812a54 Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 5 Nov 2020 10:39:35 +0100 Subject: [PATCH 023/141] Fixed storing selected call to action --- src/app/modules/project/add/add.module.ts | 15 +++--- .../project/add/manual/manual.component.html | 5 +- .../project/add/manual/manual.component.ts | 49 ++++++++++--------- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/app/modules/project/add/add.module.ts b/src/app/modules/project/add/add.module.ts index 4b303adf..89b5bbda 100644 --- a/src/app/modules/project/add/add.module.ts +++ b/src/app/modules/project/add/add.module.ts @@ -17,7 +17,7 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { AddRoutingModule } from './add-routing.module'; import { ManualComponent } from './manual/manual.component'; import { SourceComponent } from './source/source.component'; @@ -28,11 +28,12 @@ import { QuillModule } from 'ngx-quill'; SourceComponent, ManualComponent ], - imports: [ - CommonModule, - AddRoutingModule, - ReactiveFormsModule, - QuillModule - ], + imports: [ + CommonModule, + AddRoutingModule, + ReactiveFormsModule, + QuillModule, + FormsModule + ], }) export class AddModule { } diff --git a/src/app/modules/project/add/manual/manual.component.html b/src/app/modules/project/add/manual/manual.component.html index cd4aad22..cddf6537 100644 --- a/src/app/modules/project/add/manual/manual.component.html +++ b/src/app/modules/project/add/manual/manual.component.html @@ -77,8 +77,7 @@

Call to action

Text

-
@@ -87,7 +86,7 @@

Text

Link

- +
diff --git a/src/app/modules/project/add/manual/manual.component.ts b/src/app/modules/project/add/manual/manual.component.ts index b4c9f631..bb03db16 100644 --- a/src/app/modules/project/add/manual/manual.component.ts +++ b/src/app/modules/project/add/manual/manual.component.ts @@ -52,7 +52,11 @@ export class ManualComponent implements OnInit { /** * Projects selected call to action */ - public selectedCallToAction = 0; + public selectedCallToAction: CallToAction = { + id: 0, + name: 'None', + redirectUrl: '', + }; /** * Project's collaborators. @@ -71,12 +75,6 @@ export class ManualComponent implements OnInit { public callToActions: CallToAction[] = []; - selectChangeHandler (event: any) { - // Allow the frontend to check if it needs to activate the link input - this.selectedCallToAction = event.target.selectedIndex; - console.log(event.target); - } - public callToActionsLoading = true; constructor( @@ -123,27 +121,26 @@ export class ManualComponent implements OnInit { this.fillFormWithProject(project); }); - // Retrieve the available call to actions - // this.callToActionService - // .getAll() - // .pipe(finalize(() => (this.callToActionsLoading = false))) - // .subscribe((result) => { - // this.callToActions = result; - // }); - - this.callToActions.push({ - id: 2, - name: 'testname2', - redirectUrl: 'google.be', - }); + /** + * Retrieve the available call to actions + */ + this.callToActionService + .getAll() + .pipe(finalize(() => (this.callToActionsLoading = false))) + .subscribe((result) => { + this.callToActions = result; + }); + + /** + * Add the none option to the dropdown + */ + this.callToActions.unshift(this.selectedCallToAction); // Updates meta and title tags this.seoService.updateTitle('Add new project'); this.seoService.updateDescription('Create a new project in DeX'); } - - /** * Method which triggers when the submit button is pressed. * Creates a new project. @@ -165,6 +162,14 @@ export class ManualComponent implements OnInit { const newProject: ProjectAdd = this.newProjectForm.value; newProject.collaborators = this.collaborators; + /* + * Whenever a call to action is selected, this value + * should be sent to to the API. + */ + if(this.selectedCallToAction.id > 0){ + newProject.callToAction = this.selectedCallToAction; + } + this.projectService .post(newProject) .pipe(finalize(() => (this.submitEnabled = false))) From 804f1e56dc5af8c5a2950b7c247277adb1de5fd4 Mon Sep 17 00:00:00 2001 From: Devon Cavis Date: Fri, 6 Nov 2020 11:58:19 +0100 Subject: [PATCH 024/141] Added Call to action button to project details page This includes the check of whether or not there is a call to action set for that specific project. --- .../project/add/manual/manual.component.ts | 2 +- .../project/details/details.component.html | 4 ++++ .../project/details/details.component.ts | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/app/modules/project/add/manual/manual.component.ts b/src/app/modules/project/add/manual/manual.component.ts index bb03db16..28e1c168 100644 --- a/src/app/modules/project/add/manual/manual.component.ts +++ b/src/app/modules/project/add/manual/manual.component.ts @@ -166,7 +166,7 @@ export class ManualComponent implements OnInit { * Whenever a call to action is selected, this value * should be sent to to the API. */ - if(this.selectedCallToAction.id > 0){ + if (this.selectedCallToAction.id > 0) { newProject.callToAction = this.selectedCallToAction; } diff --git a/src/app/modules/project/details/details.component.html b/src/app/modules/project/details/details.component.html index bd933f7a..4faa6391 100644 --- a/src/app/modules/project/details/details.component.html +++ b/src/app/modules/project/details/details.component.html @@ -99,6 +99,10 @@

{{ project.name }}

+ + + +
diff --git a/src/app/modules/project/details/details.component.ts b/src/app/modules/project/details/details.component.ts index 6e12639a..19885408 100644 --- a/src/app/modules/project/details/details.component.ts +++ b/src/app/modules/project/details/details.component.ts @@ -56,6 +56,7 @@ export class DetailsComponent implements OnInit { public displayEditButton = false; public displayDeleteProjectButton = false; + public displayCallToActionButton = false; public displayHighlightButton = false; public displayEmbedButton = false; @@ -109,6 +110,7 @@ export class DetailsComponent implements OnInit { const desc = (this.project.shortDescription) ? this.project.shortDescription : this.project.description; this.determineDisplayEditProjectButton(); this.determineDisplayDeleteProjectButton(); + this.determineDisplayCallToActionButton(); this.determineDisplayEmbedButton(); this.determineDisplayHighlightButton(); @@ -131,6 +133,10 @@ export class DetailsComponent implements OnInit { } } + public onClickCallToActionButton(): void { + window.open(this.project.callToAction.redirectUrl, '_blank'); + } + /** * Highlight a project by calling the API * When Indeterminate checkbox is checked start date and end date fields are disabled and will be null, @@ -287,6 +293,19 @@ export class DetailsComponent implements OnInit { this.displayDeleteProjectButton = this.project.user.id === this.currentUser.id; } + /** + * Method to display the project's call to action button based on whether or not the project has a set call to action. + */ + private determineDisplayCallToActionButton(): void { + if (this.project != null && this.project.callToAction != null) { + this.displayCallToActionButton = true; + return; + } else { + this.displayCallToActionButton = false; + return; + } + } + /** * Method to display the highlight buttons based on the current user. * If the user either has the HighlightWrite scope. From d07aaa54f18f326396f88a30dc4e9433490d41f9 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 30 Nov 2020 10:23:00 +0100 Subject: [PATCH 025/141] Added call to action option model --- .../models/domain/call-to-action-option.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/app/models/domain/call-to-action-option.ts diff --git a/src/app/models/domain/call-to-action-option.ts b/src/app/models/domain/call-to-action-option.ts new file mode 100644 index 00000000..3c66b9b3 --- /dev/null +++ b/src/app/models/domain/call-to-action-option.ts @@ -0,0 +1,22 @@ +/* + * Digital Excellence Copyright (C) 2020 Brend Smits + * + * This program 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 version 3 of the License. + * + * This program 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 can find a copy of the GNU Lesser General Public License + * along with this program, in the LICENSE.md file in the root project directory. + * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt + */ + +export interface CallToActionOption { + id: number; + type: string; + value: string; +} From 9c700c4106b7dba857e71140551634727ee716c0 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 30 Nov 2020 10:49:41 +0100 Subject: [PATCH 026/141] Retrieve call to action options --- src/app/config/api-config.ts | 4 +-- .../project/add/manual/manual.component.html | 7 ++-- .../project/add/manual/manual.component.ts | 36 ++++++++++--------- ...ce.ts => call-to-action-option.service.ts} | 6 ++-- 4 files changed, 28 insertions(+), 25 deletions(-) rename src/app/services/{call-to-action.service.ts => call-to-action-option.service.ts} (81%) diff --git a/src/app/config/api-config.ts b/src/app/config/api-config.ts index 6709416d..4a0e0c42 100644 --- a/src/app/config/api-config.ts +++ b/src/app/config/api-config.ts @@ -26,7 +26,7 @@ export interface ApiConfig { internalSearchRoute: string; externalSearchRoute: string; wizardRoute: string; - callToActionRoute: string; + callToActionOptionRoute: string; } export const API_CONFIG: ApiConfig = { @@ -38,5 +38,5 @@ export const API_CONFIG: ApiConfig = { externalSearchRoute: 'search/external', embeddedProjectRoute: 'embed', wizardRoute: 'wizard', - callToActionRoute: 'callToAction' + callToActionOptionRoute: 'callToActionOption' }; diff --git a/src/app/modules/project/add/manual/manual.component.html b/src/app/modules/project/add/manual/manual.component.html index cddf6537..6031362d 100644 --- a/src/app/modules/project/add/manual/manual.component.html +++ b/src/app/modules/project/add/manual/manual.component.html @@ -17,7 +17,6 @@ --> -

Add new project

@@ -77,8 +76,8 @@

Call to action

Text

- +
@@ -86,7 +85,7 @@

Text

Link

- +
diff --git a/src/app/modules/project/add/manual/manual.component.ts b/src/app/modules/project/add/manual/manual.component.ts index 28e1c168..54763c3a 100644 --- a/src/app/modules/project/add/manual/manual.component.ts +++ b/src/app/modules/project/add/manual/manual.component.ts @@ -14,6 +14,7 @@ * along with this program, in the LICENSE.md file in the root project directory. * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt */ + import { AlertType } from 'src/app/models/internal/alert-type'; import { AlertConfig } from 'src/app/models/internal/alert-config'; import { AlertService } from 'src/app/services/alert.service'; @@ -31,7 +32,8 @@ import { SEOService} from 'src/app/services/seo.service'; // Import showdown for markdown to html conversion. import * as showdown from 'showdown'; import { CallToAction } from 'src/app/models/domain/call-to-action'; -import { CallToActionService } from 'src/app/services/call-to-action.service'; +import { CallToActionOptionService } from 'src/app/services/call-to-action-option.service'; +import { CallToActionOption } from 'src/app/models/domain/call-to-action-option'; /** * Component for manually adding a project. @@ -52,10 +54,10 @@ export class ManualComponent implements OnInit { /** * Projects selected call to action */ - public selectedCallToAction: CallToAction = { + public selectedCallToActionOption: CallToActionOption = { id: 0, - name: 'None', - redirectUrl: '', + type: 'title', + value: 'None', }; /** @@ -74,6 +76,8 @@ export class ManualComponent implements OnInit { public modulesConfigration = QuillUtils.getDefaultModulesConfiguration(); public callToActions: CallToAction[] = []; + public callToActionOptions: CallToActionOption[] = []; + public callToActionsLoading = true; @@ -84,7 +88,7 @@ export class ManualComponent implements OnInit { private wizardService: WizardService, private alertService: AlertService, private seoService: SEOService, - private callToActionService: CallToActionService) { + private callToActionOptionService: CallToActionOptionService) { this.newProjectForm = this.formBuilder.group({ name: [null, Validators.required], @@ -94,8 +98,8 @@ export class ManualComponent implements OnInit { }); this.newCallToActionForm = this.formBuilder.group({ - name: [null, Validators.required], - redirectUrl: [null, Validators.required], + type: [null, Validators.required], + value: [null, Validators.required], }); this.newCollaboratorForm = this.formBuilder.group({ @@ -124,17 +128,17 @@ export class ManualComponent implements OnInit { /** * Retrieve the available call to actions */ - this.callToActionService + this.callToActionOptionService .getAll() .pipe(finalize(() => (this.callToActionsLoading = false))) .subscribe((result) => { - this.callToActions = result; - }); + this.callToActionOptions = result; - /** - * Add the none option to the dropdown - */ - this.callToActions.unshift(this.selectedCallToAction); + /** + * Add the none option to the dropdown + */ + this.callToActionOptions.unshift(this.selectedCallToActionOption); + }); // Updates meta and title tags this.seoService.updateTitle('Add new project'); @@ -166,8 +170,8 @@ export class ManualComponent implements OnInit { * Whenever a call to action is selected, this value * should be sent to to the API. */ - if (this.selectedCallToAction.id > 0) { - newProject.callToAction = this.selectedCallToAction; + if (this.selectedCallToActionOption.id > 0) { + // newProject.callToAction = this.selectedCallToAction; } this.projectService diff --git a/src/app/services/call-to-action.service.ts b/src/app/services/call-to-action-option.service.ts similarity index 81% rename from src/app/services/call-to-action.service.ts rename to src/app/services/call-to-action-option.service.ts index a5136f05..54b0fde1 100644 --- a/src/app/services/call-to-action.service.ts +++ b/src/app/services/call-to-action-option.service.ts @@ -18,7 +18,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { API_CONFIG } from '../config/api-config'; -import { CallToAction } from '../models/domain/call-to-action'; +import { CallToActionOption } from '../models/domain/call-to-action-option'; import { CallToActionAdd } from '../models/resources/calltoaction-add'; import { CallToActionUpdate } from '../models/resources/calltoaction-update'; import { HttpBaseService } from './http-base.service'; @@ -26,8 +26,8 @@ import { HttpBaseService } from './http-base.service'; @Injectable({ providedIn: 'root' }) -export class CallToActionService extends HttpBaseService { +export class CallToActionOptionService extends HttpBaseService { constructor(http: HttpClient) { - super(http, API_CONFIG.url + API_CONFIG.callToActionRoute); + super(http, API_CONFIG.url + API_CONFIG.callToActionOptionRoute); } } From 35af8cbd9aefe8d1c9de7877842dd8fbb8045c16 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 30 Nov 2020 11:33:35 +0100 Subject: [PATCH 027/141] Resolved naming errors --- src/app/models/domain/call-to-action.ts | 4 ++-- .../project/add/manual/manual.component.html | 2 +- .../project/add/manual/manual.component.ts | 17 +++++++++++++---- .../project/details/details.component.html | 4 ++-- .../project/details/details.component.ts | 2 +- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/app/models/domain/call-to-action.ts b/src/app/models/domain/call-to-action.ts index a8bf755d..71173846 100644 --- a/src/app/models/domain/call-to-action.ts +++ b/src/app/models/domain/call-to-action.ts @@ -17,6 +17,6 @@ export interface CallToAction { id: number; - name: string; - redirectUrl: string; + optionValue: string; + value: string; } diff --git a/src/app/modules/project/add/manual/manual.component.html b/src/app/modules/project/add/manual/manual.component.html index 6031362d..941153fc 100644 --- a/src/app/modules/project/add/manual/manual.component.html +++ b/src/app/modules/project/add/manual/manual.component.html @@ -85,7 +85,7 @@

Text

Link

- +
diff --git a/src/app/modules/project/add/manual/manual.component.ts b/src/app/modules/project/add/manual/manual.component.ts index 54763c3a..a0d3b96e 100644 --- a/src/app/modules/project/add/manual/manual.component.ts +++ b/src/app/modules/project/add/manual/manual.component.ts @@ -31,9 +31,9 @@ import { QuillUtils } from 'src/app/utils/quill.utils'; import { SEOService} from 'src/app/services/seo.service'; // Import showdown for markdown to html conversion. import * as showdown from 'showdown'; -import { CallToAction } from 'src/app/models/domain/call-to-action'; import { CallToActionOptionService } from 'src/app/services/call-to-action-option.service'; import { CallToActionOption } from 'src/app/models/domain/call-to-action-option'; +import { CallToAction } from 'src/app/models/domain/call-to-action'; /** * Component for manually adding a project. @@ -60,6 +60,11 @@ export class ManualComponent implements OnInit { value: 'None', }; + /** + * The specified redirect url from the call to action + */ + public callToActionRedirectUrl: string; + /** * Project's collaborators. */ @@ -75,10 +80,11 @@ export class ManualComponent implements OnInit { */ public modulesConfigration = QuillUtils.getDefaultModulesConfiguration(); - public callToActions: CallToAction[] = []; + /** + * The available call to action options to select from + */ public callToActionOptions: CallToActionOption[] = []; - public callToActionsLoading = true; constructor( @@ -138,6 +144,8 @@ export class ManualComponent implements OnInit { * Add the none option to the dropdown */ this.callToActionOptions.unshift(this.selectedCallToActionOption); + + this.callToActionOptions.map(o => o.value = o.value.charAt(0).toUpperCase() + o.value.slice(1)); }); // Updates meta and title tags @@ -171,7 +179,8 @@ export class ManualComponent implements OnInit { * should be sent to to the API. */ if (this.selectedCallToActionOption.id > 0) { - // newProject.callToAction = this.selectedCallToAction; + let callToActionToSubmit = { optionValue: this.selectedCallToActionOption.value, value: this.callToActionRedirectUrl } as CallToAction; + newProject.callToAction = callToActionToSubmit; } this.projectService diff --git a/src/app/modules/project/details/details.component.html b/src/app/modules/project/details/details.component.html index 4faa6391..79c4cd38 100644 --- a/src/app/modules/project/details/details.component.html +++ b/src/app/modules/project/details/details.component.html @@ -100,7 +100,7 @@

{{ project.name }}

- +
@@ -128,4 +128,4 @@

Project details

- \ No newline at end of file + diff --git a/src/app/modules/project/details/details.component.ts b/src/app/modules/project/details/details.component.ts index 19885408..e676774e 100644 --- a/src/app/modules/project/details/details.component.ts +++ b/src/app/modules/project/details/details.component.ts @@ -134,7 +134,7 @@ export class DetailsComponent implements OnInit { } public onClickCallToActionButton(): void { - window.open(this.project.callToAction.redirectUrl, '_blank'); + window.open(this.project.callToAction.value, '_blank'); } /** From 69925e41c7928a5a7786085e3c54b59569336927 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 30 Nov 2020 11:37:46 +0100 Subject: [PATCH 028/141] Show correct value on call to action button --- src/app/modules/project/details/details.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/modules/project/details/details.component.html b/src/app/modules/project/details/details.component.html index 79c4cd38..cfa5a057 100644 --- a/src/app/modules/project/details/details.component.html +++ b/src/app/modules/project/details/details.component.html @@ -100,7 +100,7 @@

{{ project.name }}

- +
From 4a61d42fc7d28ea650cbf8c228d817f624862b2b Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 30 Nov 2020 11:48:40 +0100 Subject: [PATCH 029/141] Updated call to action option service models --- src/app/models/resources/calltoaction-add.ts | 6 +++--- src/app/models/resources/calltoaction-update.ts | 6 +++--- src/app/services/call-to-action-option.service.ts | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/models/resources/calltoaction-add.ts b/src/app/models/resources/calltoaction-add.ts index b0955bf4..a4ede41d 100644 --- a/src/app/models/resources/calltoaction-add.ts +++ b/src/app/models/resources/calltoaction-add.ts @@ -15,7 +15,7 @@ * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt */ -export interface CallToActionAdd { - name: string; - redirectUrl: string; +export interface CallToActionOptionAdd { + type: string; + value: string; } diff --git a/src/app/models/resources/calltoaction-update.ts b/src/app/models/resources/calltoaction-update.ts index c3b70c1c..2907f78c 100644 --- a/src/app/models/resources/calltoaction-update.ts +++ b/src/app/models/resources/calltoaction-update.ts @@ -15,8 +15,8 @@ * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt */ -export interface CallToActionUpdate { +export interface CallToActionOptionUpdate { id: number; - name: string; - redirectUrl: string; + type: string; + value: string; } diff --git a/src/app/services/call-to-action-option.service.ts b/src/app/services/call-to-action-option.service.ts index 54b0fde1..3ad61e69 100644 --- a/src/app/services/call-to-action-option.service.ts +++ b/src/app/services/call-to-action-option.service.ts @@ -19,14 +19,14 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { API_CONFIG } from '../config/api-config'; import { CallToActionOption } from '../models/domain/call-to-action-option'; -import { CallToActionAdd } from '../models/resources/calltoaction-add'; -import { CallToActionUpdate } from '../models/resources/calltoaction-update'; +import { CallToActionOptionAdd } from '../models/resources/calltoaction-add'; +import { CallToActionOptionUpdate } from '../models/resources/calltoaction-update'; import { HttpBaseService } from './http-base.service'; @Injectable({ providedIn: 'root' }) -export class CallToActionOptionService extends HttpBaseService { +export class CallToActionOptionService extends HttpBaseService { constructor(http: HttpClient) { super(http, API_CONFIG.url + API_CONFIG.callToActionOptionRoute); } From d42a9566ac83fbd73014ddc7807eef3947433d25 Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 30 Nov 2020 13:44:44 +0100 Subject: [PATCH 030/141] Filtered for title options --- src/app/modules/project/add/manual/manual.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/modules/project/add/manual/manual.component.ts b/src/app/modules/project/add/manual/manual.component.ts index a0d3b96e..73dccd32 100644 --- a/src/app/modules/project/add/manual/manual.component.ts +++ b/src/app/modules/project/add/manual/manual.component.ts @@ -138,7 +138,7 @@ export class ManualComponent implements OnInit { .getAll() .pipe(finalize(() => (this.callToActionsLoading = false))) .subscribe((result) => { - this.callToActionOptions = result; + this.callToActionOptions = result.filter(o => o.type === 'title'); /** * Add the none option to the dropdown From 2aae702cd8c91e296e58ad29c94fdcabcf103df4 Mon Sep 17 00:00:00 2001 From: Martin Markov Date: Tue, 1 Dec 2020 10:15:14 +0100 Subject: [PATCH 031/141] Implemented the new designs --- package-lock.json | 26 ++++ package.json | 5 +- src/app/app.module.ts | 4 +- .../project/details/details.component.html | 12 +- .../project/details/details.component.ts | 29 +++-- .../highlights-modal.component.html | 36 ++++++ .../highlights-modal.component.scss | 29 +++++ .../highlights-modal.component.ts | 49 ++++++++ .../modal-highlight-delete.component.html | 47 ------- .../modal-highlight-delete.component.scss | 118 ------------------ .../modal-highlight-delete.component.ts | 103 --------------- .../modal-highlight-edit.component.html | 15 --- .../modal-highlight-edit.component.scss | 9 -- .../modal-highlight-edit.component.ts | 20 --- .../modal-highlight-form.component.html | 26 ++-- .../modal-highlight-form.component.scss | 22 +++- .../modal-highlight-form.component.ts | 48 ++++++- src/app/modules/project/project.module.ts | 17 +-- src/app/utils/format-date.pipe.ts | 2 +- src/assets/images/dark-trash.svg | 7 ++ src/assets/images/plus-button.png | Bin 0 -> 711 bytes 21 files changed, 263 insertions(+), 361 deletions(-) create mode 100644 src/app/modules/project/highlights-modal/highlights-modal.component.html create mode 100644 src/app/modules/project/highlights-modal/highlights-modal.component.scss create mode 100644 src/app/modules/project/highlights-modal/highlights-modal.component.ts delete mode 100644 src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html delete mode 100644 src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss delete mode 100644 src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.ts delete mode 100644 src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html delete mode 100644 src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss delete mode 100644 src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts create mode 100644 src/assets/images/dark-trash.svg create mode 100644 src/assets/images/plus-button.png diff --git a/package-lock.json b/package-lock.json index 5c343c68..6adf16c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2854,6 +2854,32 @@ "to-fast-properties": "^2.0.0" } }, + "@fortawesome/angular-fontawesome": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/@fortawesome/angular-fontawesome/-/angular-fontawesome-0.6.1.tgz", + "integrity": "sha512-ARQjtRuT+ZskzJDJKPwuiGO3+7nS0iyNLU/uHVJHfG4LwGJxwVIGldwg1SU957sra0Z0OtWEajHMhiS4vB9LwQ==" + }, + "@fortawesome/fontawesome-common-types": { + "version": "0.2.32", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.32.tgz", + "integrity": "sha512-ux2EDjKMpcdHBVLi/eWZynnPxs0BtFVXJkgHIxXRl+9ZFaHPvYamAfCzeeQFqHRjuJtX90wVnMRaMQAAlctz3w==" + }, + "@fortawesome/fontawesome-svg-core": { + "version": "1.2.32", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.32.tgz", + "integrity": "sha512-XjqyeLCsR/c/usUpdWcOdVtWFVjPbDFBTQkn2fQRrWhhUoxriQohO2RWDxLyUM8XpD+Zzg5xwJ8gqTYGDLeGaQ==", + "requires": { + "@fortawesome/fontawesome-common-types": "^0.2.32" + } + }, + "@fortawesome/free-solid-svg-icons": { + "version": "5.15.1", + "resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.15.1.tgz", + "integrity": "sha512-EFMuKtzRMNbvjab/SvJBaOOpaqJfdSap/Nl6hst7CgrJxwfORR1drdTV6q1Ib/JVzq4xObdTDcT6sqTaXMqfdg==", + "requires": { + "@fortawesome/fontawesome-common-types": "^0.2.32" + } + }, "@istanbuljs/schema": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.2.tgz", diff --git a/package.json b/package.json index d50c9306..15fcd550 100644 --- a/package.json +++ b/package.json @@ -23,13 +23,16 @@ "@angular/platform-browser": "~9.1.12", "@angular/platform-browser-dynamic": "~9.1.12", "@angular/router": "~9.1.12", + "@fortawesome/angular-fontawesome": "^0.6.1", + "@fortawesome/fontawesome-svg-core": "^1.2.28", + "@fortawesome/free-solid-svg-icons": "^5.13.0", "@sentry/browser": "^5.24.2", "@webcomponents/webcomponentsjs": "^2.4.4", "bootstrap": "^4.5.2", "dotenv": "^5.0.0", + "moment": "^2.29.1", "ngx-bootstrap": "^5.6.2", "ngx-quill": "^11.1.0", - "moment": "^2.29.1", "oidc-client": "^1.10.1", "quill": "^1.3.7", "quill-markdown-shortcuts": "0.0.10", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 43247797..436491a1 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -38,6 +38,7 @@ import { PrivacyPolicyComponent } from './components/privacy-policy/privacy-poli import { ModalDeleteGenericComponent } from './components/modals/modal-delete-generic/modal-delete-generic.component'; import { StripHtmlPipe } from './utils/striptags.pipe'; import { QuillModule } from 'ngx-quill'; +import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; @NgModule({ declarations: [ @@ -62,7 +63,8 @@ import { QuillModule } from 'ngx-quill'; BrowserAnimationsModule, HttpClientModule, SharedModule, - QuillModule.forRoot() + QuillModule.forRoot(), + FontAwesomeModule ], providers: [ { diff --git a/src/app/modules/project/details/details.component.html b/src/app/modules/project/details/details.component.html index 3f0ef8c6..e583ca77 100644 --- a/src/app/modules/project/details/details.component.html +++ b/src/app/modules/project/details/details.component.html @@ -102,19 +102,9 @@

{{ project.name }}

-
- +
- -
- -
- -
- -
-
diff --git a/src/app/modules/project/details/details.component.ts b/src/app/modules/project/details/details.component.ts index 5cec3204..2f7aee10 100644 --- a/src/app/modules/project/details/details.component.ts +++ b/src/app/modules/project/details/details.component.ts @@ -30,16 +30,15 @@ import { AlertService } from 'src/app/services/alert.service'; import { User } from 'src/app/models/domain/user'; import { Observable, EMPTY } from 'rxjs'; import { HighlightByProjectIdService } from 'src/app/services/highlightid.service'; -import { ModalHighlightDeleteComponent } from 'src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component'; import { Highlight } from 'src/app/models/domain/highlight'; import { ModalDeleteGenericComponent } from 'src/app/components/modals/modal-delete-generic/modal-delete-generic.component'; import { scopes } from 'src/app/models/domain/scopes'; import { SEOService } from 'src/app/services/seo.service'; -import { ModalHighlightEditComponent } from 'src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component'; import { HighlightUpdate } from 'src/app/models/resources/highlight-update'; import { SafeUrl } from '@angular/platform-browser'; import { finalize, switchMap } from 'rxjs/operators'; import { FileRetrieverService } from 'src/app/services/file-retriever.service'; +import { HighlightsModalComponent } from '../highlights-modal/highlights-modal.component'; /** * Overview of a single project @@ -183,18 +182,10 @@ export class DetailsComponent implements OnInit { this.alertService.pushAlert(alertConfig); this.isProjectHighlighted = true; }); - } - /** - * Method to delete a highlight. - */ - public onClickDeleteHighlightButton(): void { - this.highlightByProjectIdService - .getHighlightsByProjectId(this.project.id) - .subscribe((results: Highlight[]) => { - const options = { initialState: { highlights: results }, class: 'modal-lg' }; - this.modalService.show(ModalHighlightDeleteComponent, options); - }); + modalRef.content.goBack.subscribe(() => { + this.onClickEditHighlightButton(); + }); } /** @@ -205,9 +196,9 @@ export class DetailsComponent implements OnInit { .getHighlightsByProjectId(this.project.id) .subscribe((results: Highlight[]) => { const options = { initialState: { highlights: results }, class: 'modal-lg' }; - const modalHighlightEditRef = this.modalService.show(ModalHighlightEditComponent, options); + const highlightsModalComponentRef = this.modalService.show(HighlightsModalComponent, options); - return modalHighlightEditRef.content.selectHighlightToEdit.subscribe(highlight => { + highlightsModalComponentRef.content.selectHighlightToEdit.subscribe(highlight => { const formModalRef = this.modalService.show(ModalHighlightFormComponent, { initialState: { highlight } }); formModalRef.content.confirm.pipe( @@ -236,6 +227,14 @@ export class DetailsComponent implements OnInit { this.alertService.pushAlert(alertConfig); this.isProjectHighlighted = true; }); + + formModalRef.content.goBack.subscribe(() => { + this.onClickEditHighlightButton(); + }); + }); + + highlightsModalComponentRef.content.selectAddHighlight.subscribe(() => { + this.onClickHighlightButton(); }); }); } diff --git a/src/app/modules/project/highlights-modal/highlights-modal.component.html b/src/app/modules/project/highlights-modal/highlights-modal.component.html new file mode 100644 index 00000000..aba22da6 --- /dev/null +++ b/src/app/modules/project/highlights-modal/highlights-modal.component.html @@ -0,0 +1,36 @@ +
+

Project highlights

+
+
Start date
+
End date
+
Description
+
+
+
+
+
+
{{highlight.startDate | formatDate}}
+
{{highlight.endDate | formatDate}}
+
+ +
+
+ {{highlight.description}}
+
+ Delete highlight +
+
+
+
+
+
+ Add highlight + Add highlight +
+
+
+
\ No newline at end of file diff --git a/src/app/modules/project/highlights-modal/highlights-modal.component.scss b/src/app/modules/project/highlights-modal/highlights-modal.component.scss new file mode 100644 index 00000000..7877f7c1 --- /dev/null +++ b/src/app/modules/project/highlights-modal/highlights-modal.component.scss @@ -0,0 +1,29 @@ +.highligts-modal-container { + padding: 35px; + + .heading-row { + padding: 0.75rem 0; + } + + .highlight-wrapper:hover { + background-color: #f8f9fa; + cursor: pointer; + } + + .list-group-item { + border-left: none; + border-right: none; + cursor: pointer; + } + + .delete img:hover { + opacity: 0.7; + } + + .add-button { + span { + vertical-align: bottom; + line-height: 30px; + } + } +} diff --git a/src/app/modules/project/highlights-modal/highlights-modal.component.ts b/src/app/modules/project/highlights-modal/highlights-modal.component.ts new file mode 100644 index 00000000..623f9fc4 --- /dev/null +++ b/src/app/modules/project/highlights-modal/highlights-modal.component.ts @@ -0,0 +1,49 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { BsModalRef } from 'ngx-bootstrap/modal'; +import { Highlight } from '../../../models/domain/highlight'; +import { HighlightService } from 'src/app/services/highlight.service'; +import { AlertService } from 'src/app/services/alert.service'; +import { AlertType } from 'src/app/models/internal/alert-type'; +import { AlertConfig } from 'src/app/models/internal/alert-config'; + +@Component({ + selector: 'app-highlights-modal', + templateUrl: './highlights-modal.component.html', + styleUrls: ['./highlights-modal.component.scss'] +}) +export class HighlightsModalComponent { + @Input() highlights: Highlight[]; + @Output() selectHighlightToEdit = new EventEmitter(); + @Output() selectAddHighlight = new EventEmitter(); + + constructor( + private bsModalRef: BsModalRef, + private highlightService: HighlightService, + private alertService: AlertService + ) { } + + selectHighlight(selectedHighlight: Highlight) { + this.selectHighlightToEdit.emit(selectedHighlight); + this.bsModalRef.hide(); + } + + deleteHighlight(selectedHighlight: Highlight) { + this.highlightService.delete(selectedHighlight.id) + .subscribe(() => { + const alertConfig: AlertConfig = { + type: AlertType.success, + mainMessage: 'The highlight was succesfully deleted', + dismissible: true, + timeout: this.alertService.defaultTimeout + }; + + this.alertService.pushAlert(alertConfig); + this.bsModalRef.hide(); + }); + } + + addHighlight() { + this.selectAddHighlight.emit(); + this.bsModalRef.hide(); + } +} diff --git a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html deleted file mode 100644 index f0697d9a..00000000 --- a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.html +++ /dev/null @@ -1,47 +0,0 @@ - - - diff --git a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss deleted file mode 100644 index df515cef..00000000 --- a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.scss +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Digital Excellence Copyright (C) 2020 Brend Smits - * - * This program 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 version 3 of the License. - * - * This program 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 can find a copy of the GNU Lesser General Public License - * along with this program, in the LICENSE.md file in the root project directory. - * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt - */ - -@import "assets/styles/variables"; - -.modal-body { - position: unset; - - h2 { - margin-bottom: 20px; - } -} - -.modal-delete-container { - background: #f8f8f8; - border-radius: 6px; - border: none; - outline: none; - box-shadow: $box-shadow; - padding: 15px; - color: $light-mode-grey-primary; - button.close { - border: none; - background: none; - display: flex; - float: right; - &:focus, - &:active { - border: none; - outline: none; - } - } -} - -.delete-form { - margin-top: 20px; - input[type="date"] { - border: none; - border-radius: 6px; - box-shadow: $box-shadow; - height: 45px; - width: 100%; - margin-bottom: 25px; - padding: 0 15px; - &:focus { - outline: none; - border: 1px solid $light-mode-grey-primary; - } - } - - p.date-error-message { - color: $accent-color-red-primary; - } - - &__checkbox { - display: flex; - align-items: center; - margin-top: 10px; - } - - h4 { - margin: 0; - } -} - -input[type="checkbox"] { - border: solid 1px $light-mode-grey-primary; - margin-right: 15px; -} - -.modal-buttons { - display: flex; - justify-content: flex-end; - - button:nth-child(1) { - margin-right: 15px; - } -} - -.highlight-wrapper { - display: flex; - align-items: center; - margin-bottom: 10px; - - #neverEndingCheckbox, - #checkbox { - width: 16px; - height: 16px; - margin-right: 10px; - } - - label { - margin-bottom: 0px; - width: 100%; - } - - .date-spacing { - margin-left: 15px; - } - - strong { - margin-right: 10px; - } -} diff --git a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.ts b/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.ts deleted file mode 100644 index 9d040690..00000000 --- a/src/app/modules/project/modal-highlight-delete/modal-highlight-delete.component.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { AlertService } from './../../../services/alert.service'; -/* - * Digital Excellence Copyright (C) 2020 Brend Smits - * - * This program 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 version 3 of the License. - * - * This program 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 can find a copy of the GNU Lesser General Public License - * along with this program, in the LICENSE.md file in the root project directory. - * If not, see https://www.gnu.org/licenses/lgpl-3.0.txt - */ - -import { Component, Output, EventEmitter, OnInit } from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { FormBuilder, FormGroup } from '@angular/forms'; -import { Highlight } from 'src/app/models/domain/highlight'; -import { HighlightService } from 'src/app/services/highlight.service'; -import { AlertType } from 'src/app/models/internal/alert-type'; -import { AlertConfig } from 'src/app/models/internal/alert-config'; - -/** - * Pop-up modal where you can select a highlight that - * you want to delete. - */ -@Component({ - selector: 'app-modal-highlight-delete', - templateUrl: './modal-highlight-delete.component.html', - styleUrls: ['./modal-highlight-delete.component.scss'] -}) -export class ModalHighlightDeleteComponent implements OnInit { - - @Output() confirm = new EventEmitter(); - - public deleteHighlightForm: FormGroup; - public highlights: Highlight[]; - public isNeverEnding = false; - public defaultTimeStamp = 'Thu, 01 Jan 1970 00:00:00 GMT'; - - constructor( - public bsModalRef: BsModalRef, - private formBuilder: FormBuilder, - private highlightService: HighlightService, - private alertService: AlertService - ) { } - - ngOnInit(): void { - this.deleteHighlightForm = this.formBuilder.group(this.generateFormFields()); - if (this.highlights == null) { - return; - } - this.highlights.forEach(highlight => { - if (highlight.startDate === this.defaultTimeStamp && highlight.endDate === this.defaultTimeStamp) { - highlight.isNeverEnding = true; - } - }); - } - - /** - * Method to dynamically create the form fields - */ - public generateFormFields(): Object { - const empObj = {}; - for (const highlight of this.highlights) { - empObj[highlight.id.toString()] = ''; - } - return empObj; - } - - /** - * Method which triggers when the confirm button is clicked. On confirm values are checked. - * Error message is shown if there is no field selected. - */ - public onClickConfirm(): void { - for (const key of Object.keys(this.deleteHighlightForm.value)) { - const value = this.deleteHighlightForm.value[key]; - if (value != null && value !== '') { - this.highlightService.delete(+key).subscribe(); - } - } - const alertConfig: AlertConfig = { - type: AlertType.success, - mainMessage: 'The highlight was succesfully deleted', - dismissible: true, - timeout: this.alertService.defaultTimeout - }; - this.alertService.pushAlert(alertConfig); - this.confirm.emit(); - this.bsModalRef.hide(); - } - - /** - * Method which triggers when the deny button is clicked. - */ - public onClickDeny(): void { - this.bsModalRef.hide(); - } -} diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html deleted file mode 100644 index 6e849ca9..00000000 --- a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.html +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss deleted file mode 100644 index a6aceba2..00000000 --- a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.scss +++ /dev/null @@ -1,9 +0,0 @@ -.modal-highlight-edit-container { - .list-group-item-action { - cursor: pointer; - - .date { - padding-left: 10px; - } - } -} diff --git a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts b/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts deleted file mode 100644 index 74bfab92..00000000 --- a/src/app/modules/project/modal-highlight-edit/modal-highlight-edit.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component, EventEmitter, Input, Output } from '@angular/core'; -import { BsModalRef } from 'ngx-bootstrap/modal'; -import { Highlight } from 'src/app/models/domain/hightlight'; - -@Component({ - selector: 'app-modal-highlight-edit', - templateUrl: './modal-highlight-edit.component.html', - styleUrls: ['./modal-highlight-edit.component.scss'] -}) -export class ModalHighlightEditComponent { - @Input() highlights: Highlight[]; - @Output() selectHighlightToEdit = new EventEmitter(); - - constructor(public bsModalRef: BsModalRef) {} - - selectHighlight(selectedHighlight: Highlight) { - this.selectHighlightToEdit.emit(selectedHighlight); - this.bsModalRef.hide(); - } -} diff --git a/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.html b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.html index 199a6cd5..c164e91a 100644 --- a/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.html +++ b/src/app/modules/project/modal-highlight-form/modal-highlight-form.component.html @@ -22,7 +22,10 @@