Skip to content

Commit

Permalink
Merge pull request #108 from CoderNate/#29photos
Browse files Browse the repository at this point in the history
#29 Photos and #5 Child Info Menu
  • Loading branch information
rockfordlhotka committed Mar 26, 2016
2 parents b8e9740 + 28331c8 commit 556d440
Show file tree
Hide file tree
Showing 18 changed files with 499 additions and 67 deletions.
3 changes: 2 additions & 1 deletion src/MCM.KidsIdApp/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ionic": "driftyco/ionic-bower#1.2.4"
},
"dependencies": {
"ionic-datepicker": "~0.9.0"
"ionic-datepicker": "~0.9.0",
"blob-util": "1.2.1"
}
}
1 change: 1 addition & 0 deletions src/MCM.KidsIdApp/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/ionic-datepicker/dist/ionic-datepicker.bundle.min.js"></script>
<script src="lib/blob-util/dist/blob-util.min.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
Expand Down
12 changes: 12 additions & 0 deletions src/MCM.KidsIdApp/www/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ app.config(function ($stateProvider, $urlRouterProvider) {
controller: 'childProfileListController'
})

.state('childProfileItem', {
url: '/childprofileitem/:childId',
templateUrl: 'templates/childprofileitem.html',
controller: 'childProfileItemController'
})

.state('settings', {
url: '/settings',
templateUrl: 'templates/settingspage.html',
Expand All @@ -115,6 +121,12 @@ app.config(function ($stateProvider, $urlRouterProvider) {
controller: 'basicDetailsController'
})

.state('photos', {
url: '/photos/:childId',
templateUrl: 'templates/photos.html',
controller: 'photosController'
})

// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/login');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module MCM {
private _state: angular.ui.IStateService;
private _ionicPopup: ionic.popup.IonicPopupService;
private _childDataService: MCM.ChildDataService;
private _childId: string

public static $inject = ['$scope', '$state', '$stateParams', '$ionicPopup', 'childDataService'];

Expand Down Expand Up @@ -42,9 +41,9 @@ module MCM {
public NavigateToPreviousView() {
let hasChangesPromise = this._childDataService.get(this.child)
.then(chld => this.checkChildHasChanges(this.child, chld));

hasChangesPromise.then(hasChanges => {
let go = () => this._state.go("childProfileList");
let go = () => this._state.go("childProfileItem", { childId: this.child.id });
if (hasChanges) {
this._ionicPopup.confirm({
title: 'Confirm Leave Page',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,50 @@
/// <reference path="../models/models.ts" />
/// <reference path="IControllerNavigation.ts" />

class ChildProfileItemController implements IControllerNavigation {
private _state;
private _scope;
private _navigationLinks: Array<NavigationLink>;

constructor($scope, $state) {
this._state = $state;
this._scope = $scope;

this._navigationLinks =
[
new NavigationLink("addPhoto", "Add Photo", "ion-ios-person-outline", "ion-chevron-right"),
new NavigationLink("childBasics", "Child Basics", "ion-android-person", "ion-chevron-right"),
new NavigationLink("measurements", "Measurements", "ion-android-calendar", "ion-chevron-right"),
new NavigationLink("physicalDetails", "Physical Details", "ion-ios-eye", "ion-chevron-right"),
new NavigationLink("doctorInfo", "Doctor Info", "ion-network", "ion-chevron-right"),
new NavigationLink("dentalInfo", "Dental Info", "ion-android-happy", "ion-chevron-right"),
new NavigationLink("medicalAlertInfo", "Medical Alert Info", "ion-medkit", "ion-chevron-right"),
new NavigationLink("distinguishingFeatures", "Distinguishing Features", "ion-ios-body", "ion-chevron-right"),
new NavigationLink("idChecklist", "I.D. Checklist", "ion-checkmark", "ion-chevron-right")
];
}

public static $inject = ["$scope", "$state"]

public NavigateToHomeScreen() {
this.NavigateTo('landing');
}

public NavigateToPreviousView() {
this.NavigateTo('childProfileList');
}

public NavigationLinks() {
return this._navigationLinks;
}

public NavigateTo(pStateName: string) {
this._state.go(pStateName);
module MCM {
export class ChildProfileItemController implements IControllerNavigation {
private _state;
private _scope;
private _childId: string;
private _navLinks: Array<NavigationLink>;

constructor($scope, $state, $stateParams: any) {
this._state = $state;
this._scope = $scope;
this._childId = $stateParams.childId;

this._navLinks =
[
new NavigationLink("basicDetails", "Child Basics", "ion-android-person", "ion-chevron-right"),
new NavigationLink("photos", "Photos", "ion-ios-person-outline", "ion-chevron-right"),
new NavigationLink("measurements", "Measurements", "ion-android-calendar", "ion-chevron-right"),
new NavigationLink("physicalDetails", "Physical Details", "ion-ios-eye", "ion-chevron-right"),
new NavigationLink("doctorInfo", "Doctor Info", "ion-network", "ion-chevron-right"),
new NavigationLink("dentalInfo", "Dental Info", "ion-android-happy", "ion-chevron-right"),
new NavigationLink("medicalAlertInfo", "Medical Alert Info", "ion-medkit", "ion-chevron-right"),
new NavigationLink("distinguishingFeatures", "Distinguishing Features", "ion-ios-body", "ion-chevron-right"),
new NavigationLink("idChecklist", "I.D. Checklist", "ion-checkmark", "ion-chevron-right")
];
}

public static $inject = ["$scope", "$state", "$stateParams"]

public NavigateToHomeScreen() {
this.NavigateTo('landing');
}

public NavigateToPreviousView() {
this.NavigateTo('childProfileList');
}

public NavigationLinks() {
return this._navLinks;
}

public NavigateTo(pStateName: string) {
this._state.go(pStateName, { childId: this._childId });
}
}
}

angular.module('mcmapp').controller('childProfileItemController', ChildProfileItemController);
angular.module('mcmapp').controller('childProfileItemController', MCM.ChildProfileItemController);
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class ChildProfileListController implements IControllerNavigation {
}

public editChild(child: Child) {
//This should be changed to bring you to the child profile item page instead of going to basicDetails
this.editChildById(child.id);
this._state.go("childProfileItem", { childId: child.id });
}

private reloadChildList(): angular.IPromise<void> {
Expand Down
77 changes: 77 additions & 0 deletions src/MCM.KidsIdApp/www/scripts/controllers/PhotosController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/// <reference path="../Definitions/angular.d.ts" />
/// <reference path="../Services/UserService.ts" />
/// <reference path="../Services/DocumentService.ts" />
/// <reference path="../Definitions/angular-ui-router.d.ts" />


module MCM {


export class PhotosController {

private $scope: any
private $state: angular.ui.IStateService
private $ionicPopup: ionic.popup.IonicPopupService
private $q: angular.IQService
private _childDataService: MCM.ChildDataService
private _childId: string

public static $inject = ['$scope', '$state', '$stateParams', '$ionicPopup', '$q', 'childDataService',
'documentService'];

constructor($scope: any, $state: angular.ui.IStateService, $stateParams: any,
$ionicPopup: ionic.popup.IonicPopupService, $q: angular.IQService,
childDataService: MCM.ChildDataService,
private documentService: MCM.DocumentService) {
this.$scope = $scope;

this.$state = $state;
this.$ionicPopup = $ionicPopup;
this.$q = $q;
let childId = $stateParams.childId;
this._childId = childId;
this._childDataService = childDataService;

this.documentInfos = null;
this.getStoredDocumentInfos().then(docInfos => this.documentInfos = docInfos);
}

public documentInfos: Array<DocumentInfo>;


private getStoredDocumentInfos(): angular.IPromise<Array<DocumentInfo>> {
return this.documentService.getDocumentInfos(this._childId);
}

public processSelectedFiles = (files: Array<File>) => {
angular.forEach(files, (file, i) => {
this.$ionicPopup.prompt({
title: 'File Description',
template: 'Enter file description',
inputPlaceholder: 'Your description'
}).then(res => {
this.documentService.saveDocument(this._childId, file, res).then(() => {
this.getStoredDocumentInfos().then(docInfos => this.documentInfos = docInfos);
});
});

});
};

public removeDocument(docInfo: DocumentInfo) {
this.documentService.removeDocument(this._childId, docInfo).then(() => {
this.getStoredDocumentInfos().then(docInfos => {
this.documentInfos = docInfos
});
}, err => console.log("Error removing doc: " + err));
}

public NavigateToPreviousView() {
this.$state.go('childProfileItem', { childId: this._childId });
}

}

}

angular.module('mcmapp').controller('photosController', MCM.PhotosController);
40 changes: 40 additions & 0 deletions src/MCM.KidsIdApp/www/scripts/directives/FileSelectDir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module MCM {

export class FileSelectDir implements ng.IDirective {
public restrict = 'A';
public scope = { fileSelect: "=" };

constructor() {
}

link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ctrl: any) => {
const fileEl = angular.element("<input type='file' />");
element.after(fileEl);
//Apparently can't use display:none or visibility:hidden for security reasons in Android
//so just position the ugly file input element off screen like this post suggests:
//http://stackoverflow.com/a/7302101
fileEl.css({ "position": "absolute", "top": "-100px" });


element.on("click", () => {
const event = document.createEvent("HTMLEvents");
event.initEvent("click", true, true);
//event.eventName = "click";
fileEl[0].dispatchEvent(event);
});
fileEl.bind("change", changeEvent => {
const files = (changeEvent.target as any).files;
const fileSelectHandler: (files: Array<File>) => void = (scope as any).fileSelect;
fileSelectHandler(files);
});
}

static factory(): ng.IDirectiveFactory {
const directive = () => new FileSelectDir();
directive.$inject = [];
return directive;
}
}
}

angular.module('mcmapp').directive('fileSelect', MCM.FileSelectDir.factory());
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module MCM{

},
templateUrl: 'templates/static-content.html',
controller:MCM.StaticContentCtrl
//controller:MCM.StaticContentCtrl
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/MCM.KidsIdApp/www/scripts/models/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ interface Child extends Person {
friends?: Array<Person>
medicalNotes?: MedicalNotes
checklist?: PreparationChecklist
documentMetadatas: Array<DocumentMetadata>
}

interface CareProvider extends Person {
Expand All @@ -143,6 +144,13 @@ interface FamilyMember extends Person{
}


interface DocumentMetadata {
description: string;
fileName: string;
thumbnailFileName: string;
}


// TOP LEVEL STRUCTURES

interface UserApplicationProfile{
Expand Down
6 changes: 3 additions & 3 deletions src/MCM.KidsIdApp/www/scripts/services/ChildDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module MCM{
.then(appData => appData.Family.children);
}

public getById(id: number): angular.IPromise<Child> {
public getById(id: string): angular.IPromise<Child> {
return this.findChild(id);
}

Expand Down Expand Up @@ -105,11 +105,11 @@ module MCM{
return uuid;
}

private hasChild(childId): angular.IPromise<boolean> {
private hasChild(childId: string): angular.IPromise<boolean> {
return this.getAllChildren()
.then(children => children.some((child: Child) => child.id === childId ));
}
private findChild(childId): angular.IPromise<Child> {
private findChild(childId: string): angular.IPromise<Child> {
return this.getAllChildren()
.then(children => children.filter((child:Child) => (child.id === childId))[0] || null);
}
Expand Down
Loading

0 comments on commit 556d440

Please sign in to comment.