<commit_before>import {Component, Inject, Input, OnInit} from '@angular/core';
import {Event, GroupEventService} from "../../../../services/group-event.service";
import {ErrorHandlingService} from "../../../../services/error-handling.service";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material";
import {Group} from "../../../../services/organisation-groups.service";

@Component({
  selector: 'app-create-group-event',
  templateUrl: './create-group-event.component.html',
  styleUrls: ['./create-group-event.component.css']
})
export class CreateGroupEventComponent implements OnInit {

  details: Event = <Event>{};
  submitText = 'Test';
  editMode = false;

  group: Group;

  constructor(
    public groupEventService: GroupEventService,
    private errorHandlingService: ErrorHandlingService,
    public dialogRef: MatDialogRef<CreateGroupEventComponent>,
    @Inject(MAT_DIALOG_DATA) public data: any) {
  }

  ngOnInit() {
    this.group = this.data.group;
  }


  makeUserChange() {
    let user: Event = {
      id: this.details.id,
      name: this.details.name
    };

    if (this.editMode === true) {
      this.editUser(user);
    } else {
      this.addUser(user);
    }
  }

  addUser(user) {
    this.groupEventService.createOne(this.group.id, user)
      .subscribe(success => {
        if (success) {
          this.closeWindow(true);
        }
      }, err => {
        this.errorHandlingService.handleError(err);
      });
  }

  editUser(user) {
    this.groupEventService.updateOne(this.group.id, user.id, user)
      .subscribe(success => {
        if (success) {
          this.closeWindow(true);
        }
      }, err => {
        this.errorHandlingService.handleError(err);<commit_msg>corrected Event assignment - type is a requried field<commit_after>import {Component, Inject, OnInit} from '@angular/core';
import {Event, GroupEventService} from "../../../../services/group-event.service";
import {ErrorHandlingService} from "../../../../services/error-handling.service";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material";
import {Group} from "../../../../services/organisation-groups.service";

@Component({
  selector: 'app-create-group-event',
  templateUrl: './create-group-event.component.html',
  styleUrls: ['./create-group-event.component.css']
})
export class CreateGroupEventComponent implements OnInit {

  details: Event = <Event>{};
  submitText = 'Test';
  editMode = false;

  group: Group;

  constructor(
    public groupEventService: GroupEventService,
    private errorHandlingService: ErrorHandlingService,
    public dialogRef: MatDialogRef<CreateGroupEventComponent>,
    @Inject(MAT_DIALOG_DATA) public data: any) {
  }

  ngOnInit() {
    this.group = this.data.group;
  }


  makeUserChange() {
    let user: Event = {
      id: this.details.id,
      name: this.details.name,
      type: this.details.type
    };

    if (this.editMode === true) {
      this.editUser(user);
    } else {
      this.addUser(user);
    }
  }

  addUser(user) {
    this.groupEventService.createOne(this.group.id, user)
      .subscribe(success => {
        if (success) {
          this.closeWindow(true);
        }
      }, err => {
        this.errorHandlingService.handleError(err);
      });
  }

  editUser(user) {
    this.groupEventService.updateOne(this.group.id, user.id, user)
      .subscribe(success => {
        if (success) {
          this.closeWindow(true);
        }
      }, err => {
        this.errorHandlingService.handleError(err);
{'fraction_non_alphanumeric': 0.15, 'fraction_numerical': 0.0, 'mean_word_length': 2.9695603156708006, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2411333', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1072, 'n_words': 199}