Skip to content

Commit

Permalink
wip: project types, publication consents for images and contact mail
Browse files Browse the repository at this point in the history
  • Loading branch information
vktrrdk committed Oct 29, 2024
1 parent 6fd0970 commit 7c8f0ec
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 38 deletions.
16 changes: 11 additions & 5 deletions src/app/api-connector/news.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ export class NewsService {
image_url: string,
project_application_id: string,
soc_consents: SocialConsent[],
file: File
soc_photo_consents: SocialConsent[],
file: File,
contact_mail: string
): Observable<any> {
const consents_list = soc_consents.map(soc => soc.id)
const photo_consents_list = soc_photo_consents.map(soc => soc.id)
const consents = JSON.stringify(consents_list)

const photo_consents = JSON.stringify(photo_consents_list)
const formData: FormData = new FormData()
formData.append('file', file)
formData.append('title', title)
Expand All @@ -135,7 +138,8 @@ export class NewsService {
formData.append('simple_vm', JSON.stringify(simple_vm))
formData.append('project_application_id', project_application_id)
formData.append('consents', consents)
console.log(formData)
formData.append('photo_consents', photo_consents)
formData.append('contact_mail', contact_mail)

return this.http.post<any>(`${ApiSettings.getApiBaseURL()}wagtail-management/testimonial/`, formData, {
withCredentials: true
Expand All @@ -151,7 +155,8 @@ export class NewsService {
workgroup: string,
simple_vm: boolean,
project_application_id: string,
soc_consents: SocialConsent[]
soc_consents: SocialConsent[],
photo_consents: SocialConsent[]
): Observable<any> {
const consents_list = soc_consents.map(soc => soc.id)
const consents = JSON.stringify(consents_list)
Expand All @@ -165,7 +170,8 @@ export class NewsService {
workgroup,
simple_vm,
project_application_id,
consents
consents,
photo_consents
}

return this.http.post<any>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h5 class="card-title">Add testimonial draft</h5>
type="text"
[ngClass]="{
'is-invalid': testimonialFormGroup.controls.testimonial_title?.invalid,
'is-valid': testimonialFormGroup.controls.testimonial_title?.valid
'is-valid': testimonialFormGroup.controls.testimonial_title?.valid,
}"
/>
</div>
Expand All @@ -81,7 +81,7 @@ <h5 class="card-title">Add testimonial draft</h5>
rows="20"
[ngClass]="{
'is-invalid': testimonialFormGroup.controls.testimonial_text?.invalid,
'is-valid': testimonialFormGroup.controls.testimonial_text?.valid
'is-valid': testimonialFormGroup.controls.testimonial_text?.valid,
}"
class="form-control"
name="testimonial_text"
Expand Down Expand Up @@ -119,7 +119,7 @@ <h5 class="card-title">Add testimonial draft</h5>
rows="4"
[ngClass]="{
'is-invalid': testimonialFormGroup.controls.testimonial_excerpt?.invalid,
'is-valid': testimonialFormGroup.controls.testimonial_excerpt?.valid
'is-valid': testimonialFormGroup.controls.testimonial_excerpt?.valid,
}"
></textarea>
</div>
Expand Down Expand Up @@ -157,7 +157,7 @@ <h5 class="card-title">Add testimonial draft</h5>
required
[ngClass]="{
'is-invalid': testimonialFormGroup.controls.testimonial_contributor?.invalid,
'is-valid': testimonialFormGroup.controls.testimonial_contributor?.valid
'is-valid': testimonialFormGroup.controls.testimonial_contributor?.valid,
}"
/>
</div>
Expand Down Expand Up @@ -195,7 +195,7 @@ <h5 class="card-title">Add testimonial draft</h5>
required
[ngClass]="{
'is-invalid': testimonialFormGroup.controls.testimonial_instituton?.invalid,
'is-valid': testimonialFormGroup.controls.testimonial_institution?.valid
'is-valid': testimonialFormGroup.controls.testimonial_institution?.valid,
}"
/>
</div>
Expand Down Expand Up @@ -225,7 +225,7 @@ <h5 class="card-title">Add testimonial draft</h5>
required
[ngClass]="{
'is-invalid': testimonialFormGroup.controls.testimonial_workgroup?.invalid,
'is-valid': testimonialFormGroup.controls.testimonial_workgroup?.valid
'is-valid': testimonialFormGroup.controls.testimonial_workgroup?.valid,
}"
/>
</div>
Expand Down Expand Up @@ -272,7 +272,7 @@ <h5 class="card-title">Add testimonial draft</h5>
<div class="col-md-3">
<label class="form-control-label">
<strong>
Publication Consent*
Testimonial Publication Consent*
<i
class="icon-question"
data-toggle="tooltip"
Expand Down Expand Up @@ -309,7 +309,54 @@ <h5 class="card-title">Add testimonial draft</h5>
</div>
<div class="form-text">
Please indicate here on which channels/platforms we may publish your testimonial or information about your
testimonial. The website channels are selected by default and cannot be deselected as a channel.
testimonial. Please consider allowing the testimonial and testimonial information to be published on channels
where you do not authorize the use of the photo. The websites channel is selected by default and cannot be
deselected as a channel.
</div>
</div>
</div>
<div class="form-group row">
<div class="col-md-3">
<label class="form-control-label">
<strong>
Photography Publication Consent*
<i
class="icon-question"
data-toggle="tooltip"
title="Specifies which channels we can use to publish the submitted testimonial."
>
</i>
</strong>
</label>
</div>
<div class="col-md-9">
<div class="input-group">
<div class="form-check mx-2">
<input class="form-check-input" type="checkbox" disabled checked id="website_checkbox" />
<label class="form-check-label" for="website_checkbox"
>Website
<i class="icon-question" data-toggle="tooltip" title="Any content on the de.NBI and de.NBI Cloud Website">
</i
></label>
</div>
<div class="form-check mx-2" *ngFor="let socialPhotoConsent of possibleSocialConsents">
<input
class="form-check-input"
type="checkbox"
[value]="socialPhotoConsent.id"
[checked]="selectedSocialPhotoConsents | socialConsentGiven: socialPhotoConsent"
[id]="'checkbox_' + socialPhotoConsent.id"
(change)="updateSelectedPhotoOptions(socialConsent)"
/>
<label class="form-check-label" for="checkbox_{{ socialPhotoConsent.id }}"
>{{ socialPhotoConsent.name }}
<i class="icon-question" data-toggle="tooltip" title="{{ socialPhotoConsent.description }}"> </i
></label>
</div>
</div>
<div class="form-text">
Please indicate here on which channels/platforms we may publish the photography uploaded for the testimonial.
The websites channel is selected by default and cannot be deselected as a channel.
</div>
</div>
</div>
Expand Down Expand Up @@ -359,6 +406,18 @@ <h5 class="card-title">Add testimonial draft</h5>
</ul>
</div>
<div class="card-footer">
<div class="row my-2">
<div class="col-auto">
<div class="alert alert-info mx-auto">
<strong>Please consider:</strong>
<p>
By submitting the testimonial, the e-mail-adress that is stated as <i>prefered</i> in your account will be
stored on our servers to enable us to contact you directly if we have any questions. By submitting the
testimonial, you explicitly consent to this storage!
</p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-auto">
<div class="btn-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ModalDirective } from 'ngx-bootstrap/modal'
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'
import { TESTIMONIAL_PAGE_LINK, CLOUD_PORTAL_SUPPORT_MAIL, SINGLE_TESTIMONIAL_PAGE_LINK } from '../../../../links/links'
import { NewsService } from '../../../api-connector/news.service'
import { UserService } from 'app/api-connector/user.service'
import { Application } from '../../../applications/application.model/application.model'
import { SocialConsent } from './social-consent.model'

Expand Down Expand Up @@ -43,6 +44,7 @@ export class TestimonialFormComponent implements OnInit, OnDestroy {
image_url: string = ''
possibleSocialConsents: SocialConsent[] = []
selectedSocialConsents: SocialConsent[] = []
selectedSocialPhotoConsents: SocialConsent[] = []
submissionSuccessful: boolean = false
autosaveTimer: ReturnType<typeof setTimeout>
autosaveTimeout: number = 60000
Expand All @@ -54,10 +56,10 @@ export class TestimonialFormComponent implements OnInit, OnDestroy {
file: File = null
hideTestimonialForm: boolean = false

constructor(private newsService: NewsService) {
}
constructor(
private newsService: NewsService,
private userService: UserService
) {}

ngOnInit(): void {
this.setInitialData()
Expand Down Expand Up @@ -120,6 +122,15 @@ export class TestimonialFormComponent implements OnInit, OnDestroy {
}
}

updateSelectedPhotoOptions(socialPhotoConsent: SocialConsent): void {
const idx: number = this.selectedSocialPhotoConsents.findIndex(consent => consent.id === socialPhotoConsent.id)
if (idx !== -1) {
this.selectedSocialPhotoConsents.splice(idx, 1)
} else {
this.selectedSocialPhotoConsents.push(socialPhotoConsent)
}
}

setInitialData(): void {
this.initialTitle = this.title
this.initialText = this.text
Expand Down Expand Up @@ -191,6 +202,7 @@ export class TestimonialFormComponent implements OnInit, OnDestroy {
this.workgroup = result['workgroup']
this.contributor = result['contributor']
this.selectedSocialConsents = result['publication_channels']
this.selectedSocialPhotoConsents = result['photography_publication_channels']
}

stopAutosaveTimer(): void {
Expand Down Expand Up @@ -230,7 +242,8 @@ export class TestimonialFormComponent implements OnInit, OnDestroy {
this.workgroup,
this.simple_vm,
this.project_application.project_application_id.toString(),
this.selectedSocialConsents
this.selectedSocialConsents,
this.selectedSocialPhotoConsents
)
.subscribe(
(): void => {
Expand Down Expand Up @@ -267,26 +280,31 @@ export class TestimonialFormComponent implements OnInit, OnDestroy {
sendTestimonial(): void {
this.testimonialSent = true
this.subscription.add(
this.newsService
.sendTestimonialDraft(
`${this.title} FINAL DRAFT`,
this.text,
this.excerpt,
this.contributor,
this.institution,
this.workgroup,
this.simple_vm,
this.image_url,
this.project_application.project_application_id.toString(),
this.selectedSocialConsents,
this.file
)
.subscribe((result: any): any => {
this.submissionSuccessful = result['created']
this.project_application.project_application_testimonial_submitted = true
this.stopAutosaveTimer()
this.testimonialModal.show()
})
this.userService.getPreferredMailUser().subscribe((result: any): any => {
const contact_mail: string = result['value']
this.newsService
.sendTestimonialDraft(
`${this.title} FINAL DRAFT`,
this.text,
this.excerpt,
this.contributor,
this.institution,
this.workgroup,
this.simple_vm,
this.image_url,
this.project_application.project_application_id.toString(),
this.selectedSocialConsents,
this.selectedSocialPhotoConsents,
this.file,
contact_mail
)
.subscribe((result: any): any => {

Check warning on line 301 in src/app/shared/shared_modules/testimonial-forms/testimonial-form.component.ts

View workflow job for this annotation

GitHub Actions / tslinting-check

'result' is already declared in the upper scope on line 283 column 55

Check warning on line 301 in src/app/shared/shared_modules/testimonial-forms/testimonial-form.component.ts

View workflow job for this annotation

GitHub Actions / tslinting-check

'result' is already declared in the upper scope on line 283 column 55
this.submissionSuccessful = result['created']
this.project_application.project_application_testimonial_submitted = true
this.stopAutosaveTimer()
this.testimonialModal.show()
})
})
)
}

Expand Down

0 comments on commit 7c8f0ec

Please sign in to comment.