Project

General

Profile

« Previous | Next » 

Revision 58983

[Monitor | Trunk]: 1. Add new assets. 2. Add a new css for theme-changes. 3. Changes on home, about, contact-us

View differences:

contact.component.ts
9 9
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
10 10
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
11 11
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
12
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
12
import {AbstractControl, FormBuilder, FormGroup, ValidatorFn, Validators} from "@angular/forms";
13 13

  
14 14
@Component({
15 15
    selector: 'contact',
16 16
    templateUrl: './contact.component.html',
17 17
})
18

  
19 18
export class ContactComponent implements OnInit {
20 19
    public url: string = null;
21 20
    public pageTitle: string = "OpenAIRE - Monitor | Contact Us";
......
26 25
    public properties: EnvProperties = null;
27 26
    public pageContents = null;
28 27
    public divContents = null;
28
    public organizationTypes: string[] = [
29
        'Funding agency', 'University / Research Center',
30
        'Research Infrastructure', 'Government',
31
        'Non-profit', 'Industry', 'Other'
32
    ];
29 33

  
30 34
    public contactForm: FormGroup;
31 35
    @ViewChild('AlertModal') modal;
......
47 51
        this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
48 52
            this.properties = data.envSpecific;
49 53
            this.email = {body: '', subject: '', recipients: []};
50

  
51 54
            if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
52 55
                this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.properties.piwikSiteId).subscribe();
53 56
            }
......
84 87
            this.errorMessage = 'Please fill in all the required fields!';
85 88
        }
86 89
    }
90
    
91
    private validatorType(options: string[]): ValidatorFn  {
92
        return  (control: AbstractControl): { [key: string]: boolean } | null => {
93
            if (options.filter(type => type === control.value).length === 0) {
94
                return {'type': false};
95
            }
96
            return null;
97
        }
98
    }
87 99

  
88 100
    public reset() {
89 101
        this.contactForm = this.fb.group( {
90 102
            name: this.fb.control('', Validators.required),
91 103
            surname: this.fb.control('', Validators.required),
92 104
            email: this.fb.control('', [Validators.required, Validators.email]),
93
            affiliation: this.fb.control('', Validators.required),
94
            stakeholder: this.fb.control('', Validators.required),
105
            job: this.fb.control('', Validators.required),
106
            organization: this.fb.control('', Validators.required),
107
            organizationType: this.fb.control('', [Validators.required, this.validatorType(this.organizationTypes)]),
95 108
            subject: this.fb.control('', Validators.required),
96 109
            message: this.fb.control('', Validators.required),
97 110
            recaptcha: this.fb.control('', Validators.required),
98 111
        });
99 112
        this.errorMessage = '';
100 113
    }
101

  
114
    
102 115
    private sendMail(admins: any) {
103 116
        this.showLoading = true;
104 117
        this._emailService.contact(this.properties,
105
            Composer.composeEmailForNewStakeholder(this.contactForm.value, admins),
118
            Composer.composeEmailForMonitor(this.contactForm.value, admins),
106 119
            this.contactForm.value.recaptcha).subscribe(
107 120
            res => {
108 121
                if (res) {

Also available in: Unified diff