Skip to content

Commit

Permalink
cleanup of summary page
Browse files Browse the repository at this point in the history
  • Loading branch information
johnculviner committed Apr 25, 2013
1 parent 275b784 commit 780448c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
3 changes: 0 additions & 3 deletions demo/SurveyApp.Web/App/viewmodels/surveys.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
var self = this;

self.surveySummaries = null; //loaded from ajax as ko.observableArray()
self.loading = ko.observable(true);
self.selectedSurvey = ko.observable(null);

//the router's activator calls this function and waits for the .complete jQuery Promise before
Expand All @@ -19,8 +18,6 @@

if (self.surveySummaries().length > 0)
self.toggleSelected(self.surveySummaries()[0]);

self.loading(false);
});
};

Expand Down
46 changes: 26 additions & 20 deletions demo/SurveyApp.Web/App/views/surveys.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@
@using (var summary = summaries.ForEachKoComment())
{
<tr data-bind="click: $root.toggleSelected, css: { selected: $root.selectedSurvey() == $data }">
<td @summary.DataBind(db => db.Text(x => x.LastName))></td>

@*probably the preferred way*@
<td @summary.DataBind(db => db.Text(x => x.LastName))></td>
<td @summary.DataBind(db => db.Text(x => x.FirstName))></td>
<td @summary.DataBind(db => db.Text(x => x.DateOfBirth))></td>
<td @summary.DataBind(db => db.Text(x => x.Gender))></td>

@*if you like pain*@
@summary.ElementSelfClosing("td", true).DataBind(db => db.Text(x => x.Gender))

<td class="actions">
@*EDIT*@
<a class="btn btn-info"
Expand All @@ -45,7 +50,7 @@
</tr>
}

<tr data-bind="if: !loading() && surveySummaries().length == 0">
<tr data-bind="if: surveySummaries().length == 0">
<td colspan="5" style="text-align: center">
No survey found
</td>
Expand All @@ -56,30 +61,31 @@
<i class="icon-plus"></i>
New Survey
</a>
<div class="spinner" data-bind="visible: loading"></div>
</div>


@*SELECTED SURVEY DETAIL*@
@{
var detail = this.KnockoutHelperForApi<SurveyController>().Endpoint(api => api.Get().Single(), "selectedSurvey", true);
}
<fieldset class="survey-quickview">
<legend><span @detail.DataBind(db => db.Text(x => x.LastName))></span>, <span @detail.DataBind(db => db.Text(x => x.FirstName))></span></legend>
<form class ="form-horizontal">
<div class="control-group">
@detail.LabelFor(x => x.NumberOfTechProducts).Class("control-label")
<div @detail.DataBind(db => db.Text(x => x.NumberOfTechProducts)).Class("uneditable controls")></div>
</div>
<div class="control-group">
@detail.LabelFor(x => x.NumberOfChildren).Class("control-label")
<div @detail.DataBind(db => db.Text(x => x.NumberOfChildren)).Class("uneditable controls")></div>
</div>
<fieldset class="survey-quickview">

<legend>@detail.BoundTextFor(x => x.LastName), @detail.BoundTextFor(x => x.FirstName)</legend>

<form class ="form-horizontal">
<div class="control-group">
@detail.LabelFor(x => x.NumberOfTechProducts).Class("control-label")
<div @detail.DataBind(db => db.Text(x => x.NumberOfTechProducts)).Class("uneditable controls")></div>
</div>
<div class="control-group">
@detail.LabelFor(x => x.NumberOfChildren).Class("control-label")
<div @detail.DataBind(db => db.Text(x => x.NumberOfChildren)).Class("uneditable controls")></div>
</div>

@*Inject a 'shared view' into the DOM specifiying the model and view to compose together*@
<div class="control-group" data-bind="compose: { model: new locationInfo(selectedSurvey().Location), view: 'views/surveys/shared/locationInfo' }">
</div>
</form>
</fieldset>
@*Inject a 'shared view' into the DOM specifiying the model and view to compose together*@
<div class="control-group" data-bind="compose: { model: new locationInfo(selectedSurvey().Location), view: 'views/surveys/shared/locationInfo' }">
</div>
</form>
</fieldset>

</section>

0 comments on commit 780448c

Please sign in to comment.