SHARE
TWEET
Untitled
a guest
Dec 16th, 2014
175
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- angularApp.factory('ChunkFactoryUI', function(ChunksFactory, ImageFactoryUI, PatientIdRequestService) {
- var chunks = {};
- function Chunk(json) {
- this.init(json);
- }
- Chunk.prototype.buildAssociations = function() {
- var imagesObject = [];
- angular.forEach(this.images, function(value, key){
- imagesObject.push(new ImageFactoryUI(value));
- });
- delete this.images;
- this.images = imagesObject;
- }
- Chunk.prototype.init = function(json) {
- angular.extend(this, json);
- this.buildAssociations();
- chunks[self.id] = self;
- }
- Chunk.getById = function(id) {
- return chunks[id];
- }
- Chunk.getAllChunks = function(id) {
- return chunks;
- }
- Chunk.prototype.delete = function() {
- if (confirm("Desea borrar todas las imagenes!!!!!!!!!! OMFGGG?")) {
- var self = this;
- ChunksFactory.delete({id: this.id}, function(){
- self.reload();
- });
- }
- }
- Chunk.prototype.reload = function() {
- var self = this;
- ChunksFactory.get({id:this.id},function(data){
- self.init(data);
- })
- }
- Chunk.prototype.reset = function () {
- var self = this;
- ChunksFactory.reset({id: this.id}, function(){
- self.reload();
- });
- }
- Chunk.prototype.unassign = function() {
- var self = this;
- if (confirm("Este lote ya esta asociado a uno o varios pacientes\nDesea desasignar las imagenes?")) {
- ChunksFactory.unassign({id: this.id}, function(){
- self.reload();
- });
- }
- };
- Chunk.prototype.assignToPatient = function(patient) {
- var self = this;
- if (angular.isUndefined(patient)) {
- PatientIdRequestService.open().then(function(patient) {
- ChunksFactory.assignToPatient({id: self.id, patient: patient}, function(){
- self.reload();
- //$scope.chunks = ChunksFactory.getAll();
- });
- });
- }
- else {
- ChunksFactory.assignToPatient({id: self.id, patient: patient}, function(){
- self.reload();
- //$scope.chunks = ChunksFactory.getAll();
- });
- }
- };
- Chunk.loadAll = function() {
- return ChunksFactory.getAll().$promise
- .then(function(res){
- return res.map(function(result){
- return new Chunk(result)
- })
- });
- }
- return Chunk;
- });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

