Skip to content

Commit

Permalink
Merge pull request #164 from jspam/09-migration-date
Browse files Browse the repository at this point in the history
transcriptmigration: Allow entering dates in YYYY and YYYY-MM format
  • Loading branch information
TehMillhouse committed Oct 6, 2015
2 parents 910b06e + 622d8ed commit f67ac43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions js/vm/transcriptmigration.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@ export default class TranscriptMigration {
ko.getObservable(this, 'date').subscribe(this.getSimilar.bind(this));
}

getFullDate() {
if (this.date.length == 4)
return this.date + '-01-01';
if (this.date.length == 7)
return this.date + '-01';
return this.date;
}

getSimilar() {
let job = {
department: 'mathematics',
student_name: "",
date: this.date,
date: this.getFullDate(),
document_type: this.doctype,
lectures: this.selectedLectures,
examinants: this.selectedExaminants,
Expand Down Expand Up @@ -69,7 +77,7 @@ export default class TranscriptMigration {
this.errorlabel = "Bitte gib eine Pdf-Datei zum Hochladen an.";
return;
}
if (new Date() < Date.parse(this.date)) {
if (new Date() < Date.parse(this.getFullDate())) {
this.status = 'error';
// ERROR: HACKING TOO MUCH TIME
this.errorlabel = "Bitte verletze nicht die Kausalität.";
Expand All @@ -81,7 +89,7 @@ export default class TranscriptMigration {
fd.append('json', JSON.stringify({
lectures: this.selectedLectures,
examinants: this.selectedExaminants,
date: this.date,
date: this.getFullDate(),
document_type: this.doctype,
student_name: '(Migration)',
department: 'mathematics',
Expand Down
2 changes: 1 addition & 1 deletion views/transcriptmigration.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h3 class="heading">Neues Protokoll</h3>
<div class="form-group">
<label class="control-label col-md-3">Datum<span style="color: red;">*</span>&nbsp;</label>
<div class="col-md-8">
<input class="form-control" id="transcript-migration-date" type="text" placeholder="YYYY-MM-TT" required="required" data-bind="value: date, hasfocus: dateFieldHasFocus">
<input class="form-control" id="transcript-migration-date" type="text" placeholder="YYYY[-MM[-TT]]" required="required" data-bind="value: date, hasfocus: dateFieldHasFocus">
</div>
</div>
<div class="form-group">
Expand Down

0 comments on commit f67ac43

Please sign in to comment.