forked from HospitalRun/hospitalrun-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from eHealthAfrica/fix-new-route
URL Navigation Fix
- Loading branch information
Showing
12 changed files
with
124 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import Ember from 'ember'; | ||
|
||
const { get, isEmpty, Mixin } = Ember; | ||
|
||
export default Mixin.create({ | ||
queryParams: { | ||
forPatientId: { | ||
refreshModel: false | ||
}, | ||
forVisitId: { | ||
refreshModel: false | ||
} | ||
}, | ||
|
||
model(params) { | ||
let idParam = get(this, 'idParam'); | ||
let modelPromise = this._super(params); | ||
if (params[idParam] === 'new') { | ||
if (!isEmpty(params.forPatientId)) { | ||
return this._setPatientOnModel(modelPromise, params.forPatientId); | ||
} else if (!isEmpty(params.forVisitId)) { | ||
return this._setVisitOnModel(modelPromise, params.forVisitId); | ||
} else { | ||
return this._createNewRecord(params); | ||
} | ||
} else { | ||
return modelPromise; | ||
} | ||
}, | ||
|
||
/** | ||
* Resolves the model promise and then sets the patient information on the model. | ||
*/ | ||
_setPatientOnModel(modelPromise, patientId) { | ||
let store = get(this, 'store'); | ||
return modelPromise.then((model) => { | ||
return store.find('patient', patientId).then((patient) => { | ||
model.set('patient', patient); | ||
model.set('returnToPatient', patientId); | ||
model.set('selectPatient', false); | ||
return model; | ||
}); | ||
}); | ||
}, | ||
|
||
/** | ||
* Resolves the model promise and then sets the visit information on the model. | ||
*/ | ||
_setVisitOnModel(modelPromise, visitId) { | ||
let store = get(this, 'store'); | ||
return modelPromise.then((model) => { | ||
return store.find('visit', visitId).then((visit) => { | ||
model.set('visit', visit); | ||
model.set('returnToVisit', visitId); | ||
model.set('selectPatient', false); | ||
model.set('patient', visit.get('patient')); | ||
return model; | ||
}); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters