Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

update for deeply nested properties #41

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion cfs-autoform-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Hooks = {
CfsAutoForm.Util.deepFind(doc.$set,key).push(fileObj._id);
} else {
//doc[key] = fileObj._id;
CfsAutoForm.Util.deepSet(doc.$set,key,fileObj._id);
CfsAutoForm.Util.set(doc.$set,key,fileObj._id);
}
}

Expand Down
8 changes: 5 additions & 3 deletions cfs-autoform-util.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Util = {
//delete prop from obj
//prop can be something like "obj.3.badprop
//CHANGE: nested properties with dot are still strings, no need to dive into
deepDelete: function(obj, prop){
return CfsAutoForm.Util.deepDo(obj, prop, function(obj, prop){
delete obj[prop];
});
delete obj[prop];
},
set: function(obj, prop, value) {
obj[prop] = value;
},
deepSet: function(obj, prop, value){
return CfsAutoForm.Util.deepDo(obj, prop, function(obj, prop){
Expand Down
1 change: 0 additions & 1 deletion cfs-autoform.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ CfsAutoForm.deleteUploadedFiles = function(template) {
});
};


if (Meteor.isClient) {
// Adds a custom "cfs-file" input type that AutoForm will recognize
AutoForm.addInputType("cfs-file", {
Expand Down
3 changes: 3 additions & 0 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
Package.describe({
name: "cfs:autoform",
version: "2.2.1",

summary: "Upload files as part of autoform submission",
git: "https://github.com/aldeed/meteor-cfs-autoform.git"
});



Package.onUse(function(api) {
api.use('[email protected]', 'client');
api.use('[email protected]', 'client');
Expand Down