2015-06-29 22:51:29 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
//Forms service used for communicating with the forms REST endpoints
|
|
|
|
angular.module('forms').factory('Forms', ['$resource',
|
|
|
|
function($resource) {
|
2015-08-19 22:29:01 +00:00
|
|
|
return $resource('/forms/:formId', {
|
2015-06-29 22:51:29 +00:00
|
|
|
formId: '@_id'
|
|
|
|
}, {
|
|
|
|
'query' : {
|
2016-04-29 04:57:04 +00:00
|
|
|
method: 'GET',
|
2016-06-01 01:06:45 +00:00
|
|
|
isArray: true
|
2015-08-19 22:29:01 +00:00
|
|
|
//DAVID: TODO: Do we really need to get visible_form_fields for a Query?
|
|
|
|
// transformResponse: function(data, header) {
|
|
|
|
// var forms = angular.fromJson(data);
|
|
|
|
// angular.forEach(forms, function(form, idx) {
|
|
|
|
// form.visible_form_fields = _.filter(form.form_fields, function(field){
|
|
|
|
// return (field.deletePreserved === false);
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// return forms;
|
|
|
|
// }
|
2015-07-27 18:11:43 +00:00
|
|
|
},
|
|
|
|
'get' : {
|
2016-04-29 04:57:04 +00:00
|
|
|
method: 'GET',
|
2015-07-27 18:11:43 +00:00
|
|
|
transformResponse: function(data, header) {
|
|
|
|
var form = angular.fromJson(data);
|
2016-04-29 04:57:04 +00:00
|
|
|
|
2016-06-01 01:06:45 +00:00
|
|
|
form.visible_form_fields = _.filter(form.form_fields, function(field){
|
2015-08-19 22:29:01 +00:00
|
|
|
return (field.deletePreserved === false);
|
|
|
|
});
|
2015-07-27 18:11:43 +00:00
|
|
|
return form;
|
|
|
|
}
|
2015-06-29 22:51:29 +00:00
|
|
|
},
|
|
|
|
'update': {
|
|
|
|
method: 'PUT'
|
|
|
|
},
|
|
|
|
'save': {
|
|
|
|
method: 'POST'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-04-29 04:57:04 +00:00
|
|
|
]);
|