Skip to content

Commit

Permalink
#6 - support change of origin
Browse files Browse the repository at this point in the history
  • Loading branch information
blueghostuk committed Apr 18, 2013
1 parent eb6c66c commit 25996d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions TrainDelayed/Scripts/viewmodels.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function TrainViewModel(json, from, callingAt) {
self.tocName = json.AtocCode ? json.AtocCode.Name : "";

self.from = json.Origin.Description.toLowerCase();
self.newFrom = json.ChangeOfOrigin !== null ? json.ChangeOfOrigin.NewOrigin.Description.toLowerCase() : null;
self.to = json.Destination.Description.toLowerCase();

self.fromStation = from.toLowerCase();
Expand All @@ -36,6 +37,8 @@ function TrainViewModel(json, from, callingAt) {

self.cancelled = json.Cancellation !== null;

self.changeOfOrigin = json.ChangeOfOrigin !== null;

self.title = json.Cancellation ? "Cancelled " + json.Cancellation.Type +
(json.Cancellation.CancelledAt ? " at " + json.Cancellation.CancelledAt.Description : "") : "";
}
13 changes: 11 additions & 2 deletions TrainDelayed/search-results.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</tr>
</thead>
<tbody data-bind="foreach: $data">
<tr data-bind="css: { error: cancelled }, attr: { Title: title }">
<tr data-bind="css: { info: changeOfOrigin, error: cancelled }, attr: { Title: title }">
@{
if (string.IsNullOrEmpty(@ConfigurationManager.AppSettings["trainLink"]))
{
Expand All @@ -89,7 +89,16 @@
}
}
<td data-bind="text: tocCode, attr: { title : tocName }"></td>
<td data-bind="text: from" class="stationName"></td>
<td>
<!-- ko if: changeOfOrigin -->
<span data-bind="text: from" class="stationName" style="text-decoration: line-through;"></span>
<br />
Starts from <span data-bind="text: newFrom" class="stationName"></span>
<!-- /ko -->
<!-- ko if: !changeOfOrigin -->
<span data-bind="text: from" class="stationName"></span>
<!-- /ko -->
</td>
<td data-bind="text: to" class="stationName"></td>
<td data-bind="text: fromStation" class="stationName"></td>
<td data-bind="text: expectedDeparture"></td>
Expand Down

0 comments on commit 25996d1

Please sign in to comment.