Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #55 from NGO-DB/49_pn-readonly
Browse files Browse the repository at this point in the history
make project number readonly after the child is created
  • Loading branch information
sleidig committed Dec 20, 2015
2 parents c946120 + 32495c5 commit 5ae43b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/scripts/controllers/child-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ angular.module('hdbApp')
}

child.update();
$scope.new = false;

$scope.savedMsg = true;
$timeout(function () {
Expand Down
4 changes: 4 additions & 0 deletions app/scripts/services/child.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ angular.module('hdbApp')

/* Public Methods */
update: function () {
if(this._id != prefix + this.pn) {
throw "Child data inconsistent: 'pn' ("+this.pn+") does not match '_id' ("+this._id+").";
}

var data = angular.copy(this);
appDB.put(data);

Expand Down
7 changes: 5 additions & 2 deletions app/views/child-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ <h1 class="page-header section-child"><i class="fa fa-child fa-fw"></i> {{ child
<div class="col-lg-2">
<div class="form-group">
<label>Age</label>
<input class="form-control" value="{{ child.age() }}" disabled>
<input class="form-control" value="{{ child.age() }}"
tooltip="Age is automatically calculated based on the date of birth." readonly>
</div>
</div>
</div>
Expand All @@ -77,7 +78,9 @@ <h1 class="page-header section-child"><i class="fa fa-child fa-fw"></i> {{ child
<div class="form-group">
<label>Project Number</label>
<input type="number" class="form-control" ng-model="child.pn"
value="{{child.pn |number:0}}">
value="{{child.pn |number:0}}" ng-readonly="!new"
tooltip="Uniquely identifies the child and cannot be changed once the record is created."
required>
</div>

<div class="form-group">
Expand Down

0 comments on commit 5ae43b2

Please sign in to comment.