-
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.
Refactor js services to work with function expression
- Loading branch information
Showing
3 changed files
with
35 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
app.factory('jobSvc', ['$resource', '$q', 'serviceHelperSvc', function ($resource, $q, serviceHelper) { | ||
(function () { | ||
var jobSvc = function($resource, $q, serviceHelper) { | ||
var jobServiceInstance = serviceHelper.Job; | ||
|
||
return { | ||
getTopFiveJobs: function () { | ||
getTopFiveJobs: function() { | ||
return jobServiceInstance.query({ count: 5 }); | ||
}, | ||
getJobs: function () { | ||
getJobs: function() { | ||
return jobServiceInstance.query(); | ||
}, | ||
deleteJob: function (jobId) { | ||
deleteJob: function(jobId) { | ||
return jobServiceInstance.delete({ jobId: jobId }).$promise; | ||
}, | ||
addJob: function (job) { | ||
addJob: function(job) { | ||
return jobServiceInstance.save(job).$promise; | ||
}, | ||
editJob: function (job) { | ||
editJob: function(job) { | ||
return jobServiceInstance.update(job).$promise; | ||
}, | ||
getJob: function (id) { | ||
getJob: function(id) { | ||
return jobServiceInstance.get({ jobId: id }); | ||
}, | ||
createJobEditFormModel: function (jobId) { | ||
createJobEditFormModel: function(jobId) { | ||
var singleJob = $q.all([this.getJob(jobId).$promise]); | ||
singleJob.then(function(data) { | ||
return data; | ||
}); | ||
return singleJob; | ||
} | ||
}; | ||
}]); | ||
|
||
}; | ||
|
||
jobSvc.$inject = ['$resource', '$q', 'serviceHelperSvc']; | ||
app.factory('jobSvc', jobSvc); | ||
}()); |
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 |
---|---|---|
@@ -1,18 +1,23 @@ | ||
app.factory('jobAttachmentSvc', ['$resource', '$q', 'serviceHelperSvc', function ($resource, $q, serviceHelper) { | ||
(function () { | ||
var jobAttachmentSvc = function ($resource, $q, serviceHelper) { | ||
var jobAttachService = serviceHelper.JobAttachment; | ||
|
||
return { | ||
getAttachmentsForAJob: function (jobId) { | ||
getAttachmentsForAJob: function(jobId) { | ||
return jobAttachService.query({ jobId: jobId }); | ||
}, | ||
deleteJobAttachment: function (attachmentId) { | ||
deleteJobAttachment: function(attachmentId) { | ||
return jobAttachService.delete({ attachmentId: attachmentId }).$promise; | ||
}, | ||
addJobAttachment: function (jobAttachment) { | ||
addJobAttachment: function(jobAttachment) { | ||
return jobAttachService.save({ jobAttachmentId: jobAttachment.Id }, jobAttachment).$promise; | ||
}, | ||
getJobAttachment: function (attachmentId) { | ||
getJobAttachment: function(attachmentId) { | ||
return jobAttachService.get({ jobAttachmentId: attachmentId }); | ||
} | ||
}; | ||
}]); | ||
}; | ||
|
||
jobAttachmentSvc.$inject = ['$resource', '$q', 'serviceHelperSvc']; | ||
app.factory('jobAttachmentSvc', ['$resource', '$q', 'serviceHelperSvc'], jobAttachmentSvc); | ||
}()); |
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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
app.factory('jobStatusSvc', ['$resource', 'serviceHelperSvc', function ($resource, serviceHelper) { | ||
(function () { | ||
|
||
var jobStatusSvc = function ($resource, serviceHelper) { | ||
var JobStatus = serviceHelper.JobStatus; | ||
|
||
return { | ||
get: function () { | ||
return JobStatus.query(); | ||
} | ||
}; | ||
}]); | ||
}; | ||
|
||
jobStatusSvc.$inject = ['$resource', 'serviceHelperSvc']; | ||
app.factory('jobStatusSvc', jobStatusSvc); | ||
|
||
}()); |