43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
//Forms service used for communicating with the forms REST endpoints
|
|
angular.module('forms').factory('Forms', ['$resource', 'FORM_URL',
|
|
function($resource, FORM_URL) {
|
|
return $resource(FORM_URL, {
|
|
formId: '@_id'
|
|
}, {
|
|
'query' : {
|
|
method: 'GET',
|
|
isArray: true,
|
|
//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;
|
|
// }
|
|
},
|
|
'get' : {
|
|
method: 'GET',
|
|
transformResponse: function(data, header) {
|
|
var form = angular.fromJson(data);
|
|
//console.log(form);
|
|
form.visible_form_fields = _.filter(form.form_fields, function(field){
|
|
return (field.deletePreserved === false);
|
|
});
|
|
return form;
|
|
}
|
|
},
|
|
'update': {
|
|
method: 'PUT'
|
|
},
|
|
'save': {
|
|
method: 'POST'
|
|
}
|
|
});
|
|
}
|
|
]);
|