-
Notifications
You must be signed in to change notification settings - Fork 44
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 #108 from CoderNate/#29photos
- Loading branch information
Showing
18 changed files
with
499 additions
and
67 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
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
77 changes: 77 additions & 0 deletions
77
src/MCM.KidsIdApp/www/scripts/controllers/PhotosController.ts
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,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); |
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,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()); |
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
Oops, something went wrong.