Commit 9ff2d237 authored by Siedschlag, Lennart's avatar Siedschlag, Lennart
Browse files

Appointment notes + neues migrationfile

parent fd065d45
Pipeline #6248 passed with stage
in 5 minutes and 20 seconds
class Appointment {
// constructor
Appointment(this.id, this.name, this.year, this.month, this.day, this.time,
this.duration, this.location);
this.duration, this.location, this.note);
// leeres Appointment
Appointment.zero();
......@@ -14,7 +14,8 @@ class Appointment {
appointment['day'] as int,
appointment['time'] as String,
appointment['duration'] as String,
appointment['location'] as String);
appointment['location'] as String,
appointment['note'] as String);
List<String> contactCodes = [];
int id;
......@@ -25,6 +26,7 @@ class Appointment {
String time = "";
String duration = "";
String location;
String note = "";
Map<String,dynamic> toJson() => {
'id' :id,
......@@ -34,7 +36,8 @@ class Appointment {
"day": day,
'time': time,
'duration': duration,
'location': location
'location': location,
'note': note
};
///date like 'yyyy-mm-dd'
......
......@@ -6,6 +6,15 @@
float: left;
}
#noteplain{
resize: none;
background-color: #C9D1C8;
border: none;
}
#note{
resize: none;
}
#delete {
color: red;
}
......
......@@ -49,7 +49,6 @@ class AppointmentComponent implements OnActivate {
Future<void> save() async {
appointment.date = dateString;
await _appointmentService.update(appointment);
goBack();
}
///Methode zum löschen von Terminen
......
......@@ -16,50 +16,49 @@
</div>
</div>
<div class="form-group">
<label for="date">Datum&nbsp;*</label>
<input type="text" class="form-control" id="date" required
[(ngModel)]="dateString"
#date="ngForm"
[class.is-valid]="date.valid"
[class.is-invalid]="!date.valid"
ngControl="date">
<div [hidden]="date.valid || date.pristine" class="invalid-feedback">
Date is required
<div class="form-group">
<label for="date">Datum&nbsp;*</label>
<input type="text" class="form-control" id="date" required
[(ngModel)]="dateString"
#date="ngForm"
[class.is-valid]="date.valid"
[class.is-invalid]="!date.valid"
ngControl="date">
<div [hidden]="date.valid || date.pristine" class="invalid-feedback">
Date is required
</div>
</div>
</div>
<div class="form-group">
<label for="time">Uhrzeit</label>
<input type="text" class="form-control" id="time" placeholder="00:00"
[(ngModel)]="appointment.time" ngControl="time">
</div>
<div class="form-group">
<label for="time">Uhrzeit</label>
<input type="text" class="form-control" id="time" placeholder="00:00"
[(ngModel)]="appointment.time" ngControl="time">
</div>
<div class="form-group">
<label for="duration">Dauer</label>
<input type="text" class="form-control" id="duration" placeholder="00:00"
[(ngModel)]="appointment.duration" ngControl="duration">
</div>
<div class="form-group">
<label for="duration">Dauer</label>
<input type="text" class="form-control" id="duration" placeholder="00:00"
[(ngModel)]="appointment.duration" ngControl="duration">
</div>
<div class="form-group">
<label for="location">Ort&nbsp;*</label>
<input type="text" class="form-control" id="location" required placeholder="Ort"
[(ngModel)]="appointment.location"
#location="ngForm"
[class.is-valid]="location.valid"
[class.is-invalid]="!location.valid"
ngControl="location">
<div [hidden]="location.valid || location.pristine" class="invalid-feedback">
Location is required
<div class="form-group">
<label for="location">Ort</label>
<input type="text" class="form-control" id="location" required placeholder="Ort"
[(ngModel)]="appointment.location" ngControl="location">
</div>
</div>
<button type="submit" [disabled]="!appointmentForm.form.valid"
class="btn btn-success" (click)="save()">Save</button>
<div class="form-group">
<label for="note">Note: </label>
<textarea type="text" class="form-control" id="note" placeholder="note"
[(ngModel)]="appointment.note" name="note" rows="4"></textarea>
</div>
<button type="submit" [disabled]="!appointmentForm.form.valid"
class="btn btn-success" (click)="save()">Save
</button>
</form>
</form>
</div>
<div [hidden]="!submitted">
......@@ -84,7 +83,14 @@
<th>Ort</th>
<td>{{appointment.location}}</td>
</tr>
<tr>
<th>Note</th>
</tr>
</table>
<div class="form-group">
<textarea disabled type="text" class="form-control" id="noteplain" placeholder="Note..."
[(ngModel)]="appointment.note" name="noteplain" rows="4"></textarea>
</div>
<button (click)="goBack()" class="btn">GoBack</button>
<button (click)="submitted=false" class="btn btn-primary">Edit</button>
......
......@@ -33,7 +33,7 @@ class AppointmentListComponent implements OnInit, OnActivate {
///Methode die eine Liste aller appointments zurückgibt
Future<void> _getAppointments() async {
appointments = await _appointmentService.getAll();
appointments.sort((a, b) => a.id.compareTo(b.id));
appointments.sort((a, b) => a.date.compareTo(b.date));
}
///Nachfolgender Code wird bei der inizialisierung der Klasse ausgeführt
......
<div *ngIf="appointment != null">
<h3>New Appointment</h3>
<form #newAppointmentForm="ngForm">
<div class="form-group">
<label for="name">Terminname&nbsp;*</label>
<input type="text" class="form-control" id="name" required
placeholder="Name"
[(ngModel)]="appointment.name"
#name="ngForm"
[class.is-valid]="name.valid"
[class.is-invalid]="!name.valid"
ngControl="name">
<div [hidden]="name.valid || name.pristine" class="invalid-feedback">
Name is required
<h3>New Appointment</h3>
<form #newAppointmentForm="ngForm">
<div class="form-group">
<label for="name">Terminname&nbsp;*</label>
<input type="text" class="form-control" id="name" required
placeholder="Name"
[(ngModel)]="appointment.name"
#name="ngForm"
[class.is-valid]="name.valid"
[class.is-invalid]="!name.valid"
ngControl="name">
<div [hidden]="name.valid || name.pristine" class="invalid-feedback">
Name is required
</div>
</div>
<div class="form-group">
<label for="date">Datum&nbsp;*</label>
<input type="date" class="form-control" id="date" required
[(ngModel)]="dateString"
#date="ngForm"
[class.is-valid]="date.valid"
[class.is-invalid]="!date.valid"
ngControl="date">
<div [hidden]="date.valid || date.pristine" class="invalid-feedback">
Date is required
</div>
</div>
</div>
<div class="form-group">
<label for="date">Datum&nbsp;*</label>
<input type="date" class="form-control" id="date" required
[(ngModel)]="dateString"
#date="ngForm"
[class.is-valid]="date.valid"
[class.is-invalid]="!date.valid"
ngControl="date">
<div [hidden]="date.valid || date.pristine" class="invalid-feedback">
Date is required
<div class="form-group">
<label for="time">Uhrzeit</label>
<input type="text" class="form-control" id="time" placeholder="00:00"
[(ngModel)]="appointment.time" ngControl="time">
</div>
<div class="form-group">
<label for="duration">Dauer</label>
<input type="text" class="form-control" id="duration" placeholder="00:00"
[(ngModel)]="appointment.duration" ngControl="duration">
</div>
</div>
<div class="form-group">
<label for="time">Uhrzeit</label>
<input type="text" class="form-control" id="time" placeholder="00:00"
[(ngModel)]="appointment.time" ngControl="time">
</div>
<div class="form-group">
<label for="duration">Dauer</label>
<input type="text" class="form-control" id="duration" placeholder="00:00"
[(ngModel)]="appointment.duration" ngControl="duration">
</div>
<div class="form-group">
<label for="location">Ort&nbsp;*</label>
<input type="text" class="form-control" id="location" required placeholder="Ort"
[(ngModel)]="appointment.location"
#location="ngForm"
[class.is-valid]="location.valid"
[class.is-invalid]="!location.valid"
ngControl="location">
<div [hidden]="location.valid || location.pristine" class="invalid-feedback">
Location is required
<div class="form-group">
<label for="location">Ort</label>
<input type="text" class="form-control" id="location" placeholder="Ort"
[(ngModel)]="appointment.location" ngControl="location">
</div>
<div class="form-group">
<label for="note">Note: </label>
<textarea type="text" class="form-control" id="note" placeholder="note"
[(ngModel)]="appointment.note" name="note" rows="4"></textarea>
</div>
<div>
* fields are required
</div>
</div>
<button type="submit" [disabled]="!newAppointmentForm.form.valid" class="btn btn-success" (click)="create()">Create</button>
<button type="submit" [disabled]="!newAppointmentForm.form.valid" class="btn btn-success" (click)="create()">
Create
</button>
</form>
</form>
</div>
\ No newline at end of file
@import url('https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css');
textarea{
#note{
resize : none;
}
.form-group {
......
......@@ -16,6 +16,7 @@
</tr>
</table>
<div class="form-group">
<label for="note">Note: </label>
<textarea type="text" class="form-control" id="note" required placeholder="note"
[(ngModel)]="contact.note" name="note" rows="4"></textarea>
</div>
......
......@@ -46,7 +46,7 @@ void main() {
///Tests for appointment.dart
Appointment appo =
Appointment(1, "Abifaier", 2019, 6, 4, "2", "4", "Lübeck");
Appointment(1, "Abifaier", 2019, 6, 4, "2", "4", "Lübeck", "hi");
Appointment json = Appointment.zero();
test("Appointment appointment.fromJson", () {
......
......@@ -25,6 +25,9 @@ class _Appointment {
@Column(unique: false)
String location;
@Column(unique: false)
String note;
@override
String toString() {
return "$id, $year-$month-$day";
......
......@@ -48,6 +48,12 @@ class Migration1 extends Migration {
isNullable: false,
isUnique: false),
SchemaColumn("location", ManagedPropertyType.string,
isPrimaryKey: false,
autoincrement: false,
isIndexed: false,
isNullable: false,
isUnique: false),
SchemaColumn("note", ManagedPropertyType.string,
isPrimaryKey: false,
autoincrement: false,
isIndexed: false,
......@@ -202,7 +208,8 @@ class Migration1 extends Migration {
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck"
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 2,
......@@ -212,7 +219,8 @@ class Migration1 extends Migration {
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck"
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 3,
......@@ -222,7 +230,8 @@ class Migration1 extends Migration {
"day": 24,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck"
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 4,
......@@ -232,7 +241,8 @@ class Migration1 extends Migration {
"day": 21,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck"
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 5,
......@@ -242,7 +252,8 @@ class Migration1 extends Migration {
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck"
"location": "Technischehochschule Lübeck",
"note": ""
},
];
......@@ -278,7 +289,7 @@ class Migration1 extends Migration {
_appointments.forEach((Map<String, dynamic> map) async =>
await database.store.execute(
"INSERT INTO _Appointment (name,time,year,month,day,duration,location) VALUES (@name,@time,@year,@month,@day,@duration,@location)",
"INSERT INTO _Appointment (name,time,year,month,day,duration,location,note) VALUES (@name,@time,@year,@month,@day,@duration,@location,@note)",
substitutionValues: {
"name": map['name'],
"time": map['time'],
......@@ -287,6 +298,7 @@ class Migration1 extends Migration {
"day": map['day'],
"duration": map['duration'],
"location": map['location'],
"note": map['note']
}));
_contacts.forEach((Map<String, String> map) async =>
......@@ -315,4 +327,5 @@ class Migration1 extends Migration {
}));
}
}
@override
Future seed() async {
final _appointments = [
{
"id": 1,
"name": "eins",
"year": 2019,
"month": 7,
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck"
},
{
"id": 2,
"name": "zwei",
"year": 2019,
"month": 5,
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck"
},
{
"id": 3,
"name": "drei",
"year": 2019,
"month": 5,
"day": 24,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck"
},
{
"id": 4,
"name": "vier",
"year": 2019,
"month": 5,
"day": 21,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck"
},
{
"id": 5,
"name": "fünf",
"year": 2019,
"month": 7,
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck"
},
];
@override
Future seed() async {
final _appointments = [
{
"id": 1,
"name": "eins",
"year": 2019,
"month": 7,
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 2,
"name": "zwei",
"year": 2019,
"month": 5,
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 3,
"name": "drei",
"year": 2019,
"month": 5,
"day": 24,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 4,
"name": "vier",
"year": 2019,
"month": 5,
"day": 21,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 5,
"name": "fünf",
"year": 2019,
"month": 7,
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck",
"note": ""
},
];
final _contacts = [
{
"nickname": "marius",
"surname": "Marius",
"name": "Mauritz",
"email": "hallo@hallo.gmx.de",
"contactCode": "ContactCode1",
"note": "Datenbank experte"
},
{
"nickname": "lauri",
"surname": "Laurenz",
"name": "Schindler",
"email": "hello@world.gmx.de",
"contactCode": "ContactCode2",
"note": "voll der pro"
}
];
final _contacts = [
{
"nickname": "marius",
"surname": "Marius",
"name": "Mauritz",
"email": "hallo@hallo.gmx.de",
"contactCode": "ContactCode1",
"note": "Datenbank experte"
},
{
"nickname": "lauri",
"surname": "Laurenz",
"name": "Schindler",
"email": "hello@world.gmx.de",
"contactCode": "ContactCode2",
"note": "voll der pro"
}
];
final _users = [
{
"nickname": "dude2",
"surname": "drei",
"name": "vier",
"email": "hello@hello.gmx.de",
"contactCode": "12345",
"password": "Calendar123",
"mobileNo": ""
}];
final _users = [
{
"nickname": "dude2",
"surname": "drei",
"name": "vier",
"email": "hello@hello.gmx.de",
"contactCode": "12345",
"password": "Calendar123",
"mobileNo": ""
}];
_appointments.forEach((Map<String, dynamic> map) async =>
await database.store.execute(
"INSERT INTO _Appointment (name,time,year,month,day,duration,location) VALUES (@name,@time,@year,@month,@day,@duration,@location)",
substitutionValues: {
"name": map['name'],
"time": map['time'],
"year": map['year'],
"month": map['month'],
"day": map['day'],
"duration": map['duration'],
"location": map['location'],
}));
_appointments.forEach((Map<String, dynamic> map) async =>
await database.store.execute(
"INSERT INTO _Appointment (name,time,year,month,day,duration,location,note) VALUES (@name,@time,@year,@month,@day,@duration,@location,@note)",
substitutionValues: {
"name": map['name'],
"time": map['time'],
"year": map['year'],
"month": map['month'],
"day": map['day'],
"duration": map['duration'],
"location": map['location'],
"note": map['note']
}));
_contacts.forEach((Map<String, String> map) async =>
await database.store.execute(