Giter Club home page Giter Club logo

meteor-cfs-autoform's People

Contributors

aldeed avatar comerc avatar dpankros avatar erasaur avatar fcmatteo avatar neobii avatar robertlowe avatar teonimesic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

meteor-cfs-autoform's Issues

How do you add a before insert hook on this?

I have omitted fields on a quickform instance and will provide on a beforeInsert hook but it seem it does not work? normally i would just do:

insert: function(doc) {
doc.hidden_var = 'some_value';
};

any idea about this?

Error on the exemple code

mySchema = new SimpleSchema({
name: {
type: String
},
fileId: {
type: String,
autoform: {
afFieldInput: {
type: "cfs-file",
collection: "files"
}
}
}
}));
Docs.attachSchema(mySchema);

error ::
}));
^
SyntaxError: Unexpected token )

CfsAutoForm.Hooks.beforeInsert() is called, but after my Meteor.call() to save the form

I am using the method form type with CFS AutoForm. When I submit my form, the before hook is called, where I call CfsAutoForm.Hooks.beforeInsert(), but the lines that actually set the saved fileIds to the doc are not called until after my Meteor.call() executes and saves the doc. As a result, all my file uploads store the files, but the file ids are not properly set on the doc. I am providing my code below:

Form hooks:

Template.assignments.onRendered(function() {
    AutoForm.hooks({
        insertAssignmentsForm: {
            before: {
                method: function(doc) {
                    CfsAutoForm.Hooks.beforeInsert.call(this, doc);

                    doc = Assignments.simpleSchema().clean(doc);
                    return doc;
                }
            },
            after: {
                method: function(err, result) {
                    console.log('err: ', err);
                    console.log('result', result);
                    if (err) {
                        console.log('An error occured: ', err);
                    } else {
                        method: CfsAutoForm.Hooks.afterInsert.call(this, err, result);

                        FlowRouter.go('/assignments/' + result.assignmentId);
                    }
                }
            },
            onError: function(formType, error) {
                console.log('error: ', error);
            }
        }
    });
});

Form setup:

{{#autoForm collection="Assignments" id="insertAssignmentsForm" type="method" meteormethod="createNewAssignment"}}

Versions:

[email protected]
[email protected]
alanning:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
[email protected]
anti:[email protected]
arillo:[email protected]
[email protected]
[email protected]_1
[email protected]
babrahams:[email protected]
babrahams:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
cfs:[email protected]
[email protected]
chuangbo:[email protected]
codechimp:[email protected]
[email protected]
constellation:[email protected]
constellation:[email protected]
constellation:[email protected]
constellation:[email protected]
cosmos:[email protected]
dburles:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
flyandi:[email protected]
[email protected]
[email protected]
gwendall:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
ian:[email protected]
[email protected]
[email protected]
juliancwirko:[email protected]
kadira:[email protected]
kadira:[email protected]
lai:[email protected]
[email protected]
[email protected]_3
[email protected]
[email protected]
[email protected]
manuel:[email protected]
[email protected]
[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
meteorhacks:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
momentjs:[email protected]
[email protected]
[email protected]
[email protected]
mrt:[email protected]
natestrauser:[email protected]
[email protected]_2
[email protected]_1
[email protected]
[email protected]
[email protected]
practicalmeteor:[email protected]_1
practicalmeteor:[email protected]_2
[email protected]
raix:[email protected]
raix:[email protected]
rajit:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
sanjo:[email protected]
sanjo:[email protected]_1
sanjo:[email protected]
[email protected]
[email protected]
[email protected]
simple:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]_2
[email protected]
[email protected]
[email protected]
tsega:[email protected]_1
twbs:[email protected]
[email protected]
[email protected]
[email protected]
velocity:[email protected]_1
velocity:[email protected]
velocity:[email protected]
velocity:[email protected]
velocity:[email protected]_7
velocity:[email protected]
velocity:[email protected]_1
[email protected]
[email protected]
xolvio:[email protected]
zimme:[email protected]

Why is the before not finishing prior to the Meteor.call() call runs?

File schema with an owner

I want to limit the people who are able to view / download a file based on their ownership of the file. Thus I'm trying to create a schema with an autovalue. Check out the Receipts collection below.

@Records = new Mongo.Collection "records"

@Receipts = new FS.Collection "receipts", 
  stores: [new FS.Store.GridFS("receiptStore")]

@Receipts.allow
  download: (userId, doc) -> userId is doc.ownerId
  fetch: ['ownerId']

@Receipts.attachSchema new SimpleSchema
  ownerId:
    type: String,
    label: "Author"
    autoValue: -> Meteor.userId()

@Records.attachSchema new SimpleSchema
  ownerId:
    type: String,
    label: "Author"
    autoValue: -> Meteor.userId()
  createdAt:
    type: Date
    autoValue: -> new Date
  amount:
    type: Number
    label: "Amount"
    min: 0
  memo:
    type: String
    label: "Memo"
    optional: true
  receiptId:
    type: String
    optional: true
    autoform:
      afFieldInput:
        type: "cfs-file"
        collection: "receipts"

I'm ending up with this error:

TypeError: Object #<EventEmitter> has no method 'attachSchema'

apparently Receipts is an EventEmitter.

Anyways, is there an easy way of implementing this functionality?

Multiple file upload

This project looks good so far. Does it currently support multiple file upload? I saw that it handles it on the front-end but I have been having trouble getting it to store an array of file Ids. I could be doing something wrong. Autoform and the related projects are new to me as well.

File Validation

I have created an filter on a FSCollection and used context based validation to achieve an error message based on a wrong file type. Is there an way to publish an error message from the onInvalid function, and would It be possible to add an example to the project README?

Files = new FS.Collection("files", { stores: [new FS.Store.GridFS("filesStore")] });

var myFilter = {
maxSize: 2000000, // in bytes
allow: {
contentTypes: ['image/*'], //allow only images in this FS.Collection
extensions: ['png']
},
onInvalid: function (message) {
SimpleSchema.messages({fileError: "File Error!"});
Context1.addInvalidKeys([{name: "fileId", type: "fileError"}]);
}
};

Files.filters(myFilter);

Validation bug

Not compatible with latest Meteor, Autoform and SimpleSchema.
BeforeUpdate hook returns doc.$set instead of doc. That results in further validation errors and SimpleSchema exception
When the modifier option is true, all validation object keys must be operators. Did you forget$set?

How to retrieve a stored file?

This works very well for me but (as a meteor noob) I can't seem to figure out how to retrieve the file (using cfg-gridfs) and display it in the frontpage loop of my items from the DB.

I keep getting: "Uncaught TypeError: Cannot read property 'insert' of undefined"

I am using cfs-filesystem with the autoform and I have set it up using both the documentation in the collectionFS and meteor-cfs-autoform but I am getting the error above when i try to submit a form creating a record for my school collections. I am not sure what I am missing or where the error is getting generated

common.js:


// File methods
Images = new FS.Collection("images", {
  stores: [new FS.Store.FileSystem("images", {path: "~/img/uploads"})]
});

Images.allow({
  download: function () {
    return true;
  },
  fetch: null
});

school_collection.js:


chools = new Mongo.Collection("Schools");


//Defining the schema
Schools.attachSchema(schoolSchema = new SimpleSchema({
  name: {
    type:String,
    label: "Name",
    max:200
  },
  primary_color: {
    type:String,
    label: "Color",
    optional: true
  },
  sub_domain: {
    type:String,
    label: "Sub Domain",
    max:50
  },
  user_id:{
    type: String,
    autoform: {
      type: "hidden",
      label: false
    },
    autoValue: function(){
      if (this.isInsert) {
            return Meteor.userId();
        } else if (this.isUpsert) {
            return {$setOnInsert: Meteor.userId()};
        } else {
            this.unset();
        }
      },
    denyUpdate:true
  },
  image: {
    type: String,
    label: "Logo",
    autoform: {
      afFieldInput: {
        type: "cfs-file",
        collection: "files"
      }
    }
  }
}));

school_create.html



  
School Create
{{#autoForm collection="Schools" id="school_create" type="insert"}} Add a School
{{> afQuickField name='name'}}
{{> afQuickField name='sub_domain'}}
{{> afQuickField name="image"}}
Add a School {{/autoForm}}

Update to autoform 5.0.0?

Any chance on updating it to autoform 5?
If you can just update the api.use section I can test it and confirm everything is working.

Thanks!

Issue with file upload on android cordova

I have file_id field in my schema which displays an upload box perfectly on web browsers and mobile browsers but the android app doesn't allow for file upload. Nothing happens when the box is clicked.

I am using quickForm

Is there something I'm doing wrong? Is this a known bug? Do you require any further info.

Use with Quickform

The readme mentions using file inputs with Autoform like so:

{{> cfsFileField name="fileId" collection="files"}}

But what about using them with Quickform? Is there a schema property you can specify so that Autoform knows to use cfsFileField when rendering the form?

Customize the ui "field" for multiple files

Is there a way to customize the UI component of this? The single text box is rather unintuitive, and doesn't work when the file names extend past the end of the field. Also, there is no way to remove a file once you added it to the list, at least not that I can tell.

I am thinking it would be nice to have the files in something like a Bootstrap list group.

Progress bar support

@dpankros @yogiben, I had a thought regarding progress. What if it's just a generic ability to pass in a progress template, which we then include with a this.percent context?

{{> afFieldInput name="myFile" type="cfs-file" progressTemplate=pt}}

<template name="myProgress">
  {{this.percent}}% done
</template>
Template.registerHelper("pt", function () {
  return Template.myProgress;
});

That way I have ultimate flexibility to render whatever I want as the progress bar. We could also have a default one.

validate as image

Is there a way to validate it as an image? both server and client side?

How to restrict file type?

Hi there,

Suppose that I want to restrict the file types that the user can upload, such as only "jpg and gif and png files", is there a way to do that?

support for uploading multiple files in an array

Hi,
I'm running into some trouble trying to upload multiple files, and I'm pretty much stuck. And help would be greatly appreciated.

My schema looks like this:

  images: {
    type: [String]
    min: 1
  }

And in my form:

+autoForm collection="Works" doc=this type="insert" id="upsertWorkForm"
<!-- other fields -->
+afQuickField name='images' type='cfs-files' collection='images'

When I submit, I get the following error in the browser console:

 Exception in setTimeout callback: TypeError: Cannot read property 'split' of undefined
    at Object.Util.deepFind (http://localhost:3000/packages/cfs_autoform.js?ca0ee21422d608dd4c429aa4c230839a532b1cd9:289:16)
    at cb (http://localhost:3000/packages/cfs_autoform.js?ca0ee21422d608dd4c429aa4c230839a532b1cd9:168:28)
    at http://localhost:3000/packages/cfs_autoform.js?ca0ee21422d608dd4c429aa4c230839a532b1cd9:220:13
    at http://localhost:3000/packages/raix_eventemitter.js?2698ca3a2e678f77962ebe839ad04615958a4c26:122:16
    at Array.forEach (native)
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:11)
    at _runCallbacks (http://localhost:3000/packages/raix_eventemitter.js?2698ca3a2e678f77962ebe839ad04615958a4c26:118:7)
    at EventEmitter.emit (http://localhost:3000/packages/raix_eventemitter.js?2698ca3a2e678f77962ebe839ad04615958a4c26:150:12)
    at oneChunkQueueEnded [as onEnded] (http://localhost:3000/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:510:19)
    at PowerQueue.next (http://localhost:3000/packages/cfs_power-queue.js?255f444fbb9de891f6e803923430c0dc1fa40e4f:478:14)

Thanks for reading!

Insert only?

The readme mentions this package works with insert forms.

So how would you deal with someone wanting to change a file they previously uploaded? A typical use case would be someone uploading an avatar to their profile.

Nested file upload fields

Hi,

Trying to debug a error when having a file filed inside a document that is nested more than one level.

I'm thinking that it has to do the the . notation which should really be templates[0][preview], but I am not sure, if you need me to run some more tests on my side, I am willing to assist!

My Schema is as follows,

fieldSchema = new SimpleSchema({
  name: {
    type: String,
    label: "Name",
    max: 200
  },

  style: {
    type: String,
    label: "Style",
    max: 200
  },
  width: {
    type: String,
    label: "Width",
    max: 200
  },
  height: {
    type: String,
    label: "Height",
    max: 200
  }
});

templateSchema = new SimpleSchema({
  name: {
    type: String,
    label: "Name",
    max: 200
  },
  preview: {
    type: String,
    autoform: {
      type: "cfs-file",
      collection: 'images' 
    }
  },
  window: {
    type: String,
    autoform: {
      type: "cfs-file",
      collection: 'image' 
    }
  },
  fields: {
    type: [fieldSchema],
    minCount: 1
  }
});


Products = new Mongo.Collection('products');

productSchema = new SimpleSchema({
  name: {
    type: String,
    label: "Name",
    max: 200
  },

  description: {
    type: String,
    label: "Description",
    max: 1000
  },

  templates: {
    type: [templateSchema],
    minCount: 1
  }
});

Products.attachSchema(productSchema);

And I am using quickform like this

+quickForm(collection="Products" id="insertProductForm" type="insert")  

I have a Image schema that looks like this

Images = new FS.Collection("images", {             
  stores: [new FS.Store.GridFS("imagesStore")]     
});                                                

And then we have the stack trace

I20141201-20:55:54.803(2)? Exception while invoking method '/products/insert' Error: key templates.0.preview must not contain '.'
I20141201-20:55:54.805(2)?     at Object.Future.wait (/Users/user/.meteor/packages/meteor-tool/.1.0.35.wql4jh++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:323:16)
I20141201-20:55:54.806(2)?     at null.<anonymous> (packages/meteor/helpers.js:118)
I20141201-20:55:54.806(2)?     at MongoConnection.(anonymous function) [as insert] (packages/mongo/mongo_driver.js:607)
I20141201-20:55:54.806(2)?     at Mongo.Collection._validatedInsert (packages/mongo/collection.js:950)
I20141201-20:55:54.806(2)?     at m.(anonymous function) (packages/mongo/collection.js:849)
I20141201-20:55:54.806(2)?     at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1599)
I20141201-20:55:54.806(2)?     at packages/ddp/livedata_server.js:648
I20141201-20:55:54.807(2)?     at _.extend.withValue (packages/meteor/dynamics_nodejs.js:56)
I20141201-20:55:54.807(2)?     at packages/ddp/livedata_server.js:647
I20141201-20:55:54.807(2)?     at _.extend.withValue (packages/meteor/dynamics_nodejs.js:56)
I20141201-20:55:54.807(2)?     - - - - -
I20141201-20:55:54.807(2)?     at Error (<anonymous>)
I20141201-20:55:54.807(2)?     at Function.checkKey (/Users/user/.meteor/packages/mongo/.1.0.8.sperx0++os+web.browser+web.cordova/npm/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:1450:13)
I20141201-20:55:54.807(2)?     at serializeObject (/Users/user/.meteor/packages/mongo/.1.0.8.sperx0++os+web.browser+web.cordova/npm/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:356:14)
I20141201-20:55:54.808(2)?     at Function.serializeWithBufferAndIndex (/Users/user/.meteor/packages/mongo/.1.0.8.sperx0++os+web.browser+web.cordova/npm/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:332:10)
I20141201-20:55:54.808(2)?     at BSON.serializeWithBufferAndIndex (/Users/user/.meteor/packages/mongo/.1.0.8.sperx0++os+web.browser+web.cordova/npm/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:1532:15)
I20141201-20:55:54.808(2)?     at InsertCommand.toBinary (/Users/user/.meteor/packages/mongo/.1.0.8.sperx0++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/commands/insert_command.js:146:37)
I20141201-20:55:54.808(2)?     at Connection.write (/Users/user/.meteor/packages/mongo/.1.0.8.sperx0++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/connection.js:234:42)
I20141201-20:55:54.808(2)?     at __executeInsertCommand (/Users/user/.meteor/packages/mongo/.1.0.8.sperx0++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/db.js:1894:14)
I20141201-20:55:54.808(2)?     at Db._executeInsertCommand (/Users/user/.meteor/packages/mongo/.1.0.8.sperx0++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/db.js:1967:5)
I20141201-20:55:54.808(2)?     at insertAll (/Users/user/.meteor/packages/mongo/.1.0.8.sperx0++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/collection/core.js:233:13)
I20141201-20:55:54.809(2)?     at Collection.insert (/Users/user/.meteor/packages/mongo/.1.0.8.sperx0++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/collection/core.js:35:3)

Error installing meteor-cfs-autoform

Hi,

I tried installing this package as per the docs and this is what happened. Looks like its looking for collectionFS instead of collectionfs. I did try changing the package to look for collectionfs but that didn't work.

Done installing smart packages

/usr/local/lib/node_modules/meteorite/lib/meteor.js:145
          throw error;
                ^
Error: Command failed: => Errors while scanning packages:

While reading package from `/home/me/game2/packages/cfs-autoform`:
package.js:7:7: Package names can only contain lowercase ASCII alphanumerics, dash, dot, or colon, not "F".

While reading package from `/home/me/game2/packages/collectionFS`:
error: Package names can only contain lowercase ASCII alphanumerics, dash, dot, or colon, not "F".

at ChildProcess.exithandler (child_process.js:637:15)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)

Now when I start Meteor I get this:

While reading package from `/home/me/game2/packages/collectionFS`:
error: Package names can only contain lowercase ASCII alphanumerics, dash, dot, or colon, not "F".

Any idea how I can sort this?

Thanks again :)

Update for deeply nested cfs-file's broken

The experimental update image functionality seems to work, but only if the property is defined at the document root. Nested properties raise errors.

Example:

AutoForm declaration:

{{ #autoForm collection='MyCollection' doc=myDoc id='myForm' type='update' }}
    {{ >afQuickField name="deeply.nested.imageId" type="cfs-file" collection='images' }}
    <button type="submit" class="btn btn-primary">Update</button>
{{ /autoForm }}

It seems to be an issue with the deepDelete function called in cfs-autoforms-hooks.js:

Call Stack:

Uncaught TypeError: Cannot read property 'nested' of undefined
Util.deepDo @ cfs-autoform-util.js:26
Util.deepDelete @ cfs-autoform-util.js:5
(anonymous function) @ cfs-autoform-hooks.js:183
jQuery.extend.each @ jquery.js:384
jQuery.fn.jQuery.each @ jquery.js:136
Hooks.beforeUpdate @ cfs-autoform-hooks.js:165
runHook @ autoform-events.js:241
runBeforeHooks @ autoform-events.js:250
AutoForm.addFormType.onSubmit @ update.js:17
autoFormSubmitHandler @ autoform-events.js:326

Incompatiple when adding cfs:autoform

Any fixes available instead of running meteor --allow-incompatible-update ?
`Errors prevented startup:

While selecting package versions:
error: Potentially incompatible change required to top-level dependency: aldeed:autoform 5.8.1, was 6.2.0.
Constraints on package "aldeed:autoform":

AutoForm.find undefined after update to AutoForm 5.0

I updated my project to AutoForm 5.0 and I'm using this package to upload files but i'm having this problem for the three field that are included in my form:

Exception from Tracker afterFlush function: undefined is not a function
TypeError: undefined is not a function
    at Template.cfsFileField_bootstrap3.rendered.Template.cfsFilesField_bootstrap3.rendered 

I debug the problem and I track it until this code in cfs-autoform.js

  Template["cfsFilesField_bootstrap3"].rendered = function () {
    var d = AutoForm.find(); <-------

I checked the version and it's the latest 2.1.1, is there a way to get this working or should i wait to update my package until this is fixed??

Thanks in advance...

Exception in delivering result of invoking 'myServerMethod': Error: [[object Object]]

Not a valid enum value

Two solid days of troubleshooting and I still can't get Meteor to upload some text files.
"The provided value 'undefined' is not a valid enum value of type XMLHttpRequestResponseType" error in cfs_upload-http.js. Judging from peoples comments online, this is just broken right now.

Filetype validation blocks entire form avoiding save

Hi, i'm having problems in the validation of filetypes, not sure if is my configuration or an issue with autoform.

I have this collections:

Problems = new Meteor.Collection('problems');

ProblemsSchema = new SimpleSchema({
  title: {
      type: String,
      label: 'Nombre'
  },
  author: {
      type: String,
      label: 'Autor',
      defaultValue: 'Anónimo'
  },
  descriptionFile: {
    type: String,
    label: 'Descripcion del Problema'
  }
//More fields here...
});

Problems.attachSchema(ProblemsSchema);

ProblemDescriptionFiles = new FS.Collection('problemDescriptionFiles', {
    stores: [
      new FS.Store.FileSystem("problemDescriptions", {
        path: "~/uploads"
      })
    ],
    filter: {
      allow: {
        contentTypes: ['application/pdf'],
        extensions: ['pdf']
      },
      onInvalid: function(message) {
        if (Meteor.isClient) {
          var problemDescription = $('#problemDescription'),
            parent = problemDescription.parent(),
            span = parent.children('.help-block');
          parent.addClass('has-error');
          span.text('El archivo subido debe ser en formato PDF.');
        } else {
          console.log(message);
        }
      }
    }
  }
);

And my template follows:

<template name="problemSubmit">
  <div class="panel panel-default">
    <div class="panel-heading">
      <h3>Nuevo Problema</h3>
    </div>
    <div class="panel-body">
      {{#autoForm collection="Problems" id="insertProblemForm" type="insert"}} {{> afQuickField name='title'}} {{> afQuickField name='author'}} {{> afQuickField name='descriptionFile' id='problemDescription' type='cfs-file' collection='problemDescriptionFiles' placeholder='Ingrese la descripcion en formato pdf'}}

      <h2>Restricciones</h2>
      <div class="col-md-6 col-sm-6">
        <div class="form-group{{#if afFieldIsInvalid name='timeConstraint'}} has-error{{/if}}">
          <div class="input-group">
            {{> afFieldInput name='timeConstraint'}}
            <span class="input-group-addon">Milisegundos</span>
          </div>
          {{#if afFieldIsInvalid name='timeConstraint'}}
          <span class="help-block">{{afFieldMessage name='timeConstraint'}}</span> {{/if}}
        </div>
      </div>

      <div class="col-md-6 col-sm-6">
        <div class="form-group{{#if afFieldIsInvalid name='memoryConstraint'}} has-error{{/if}}">
          <div class="input-group">
            {{> afFieldInput name='memoryConstraint'}}
            <span class="input-group-addon">Bytes</span>
          </div>
          {{#if afFieldIsInvalid name='memoryConstraint'}}
          <span class="help-block">{{afFieldMessage name='memoryConstraint'}}</span> {{/if}}
        </div>
      </div>
      <!--{{> afQuickField name='solutionSizeConstraint'}}-->

      <h2>Pruebas</h2> {{> afQuickField name='inputTest' type='cfs-file' collection='problemFiles' placeholder='Ingrese el archivo con casos de entrada'}} {{> afQuickField name='outputTest' type='cfs-file' collection='problemFiles' placeholder='Ingrese el archivo con las salidas esperadas'}}
      <button type="submit" class="btn btn-default">Crear</button>
      {{/autoForm}}
    </div>
  </div>
</template>

Since I added the validation for the descriptionFile (PDF) is throwing an exception when the file is not a PDF. But only is reproducible when i fill all the fields correctly and i put in the descriptionFile field a non PDF file. So this exception is thrown and the save button keeps disabled no matter what change i do in the form.

debug.js:41 Exception in setTimeout callback: Error: Cannot remove a file that is not associated with a collection
    at FS.File.remove (http://localhost:3000/packages/cfs_file.js?f44220407bc5afa9d512bd07e33dcd3dde0839b9:371:14)
    at http://localhost:3000/packages/cfs_autoform.js?ca0ee21422d608dd4c429aa4c230839a532b1cd9:331:9
    at Array.forEach (native)
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:11)
    at HTMLInputElement.<anonymous> (http://localhost:3000/packages/cfs_autoform.js?ca0ee21422d608dd4c429aa4c230839a532b1cd9:330:7)
    at Function.jQuery.extend.each (http://localhost:3000/packages/jquery.js?dd8bac56f8fd3666d433d2285ae01e52597cc51a:417:23)
    at jQuery.fn.jQuery.each (http://localhost:3000/packages/jquery.js?dd8bac56f8fd3666d433d2285ae01e52597cc51a:169:17)
    at Object.CfsAutoForm.deleteUploadedFiles (http://localhost:3000/packages/cfs_autoform.js?ca0ee21422d608dd4c429aa4c230839a532b1cd9:328:31)
    at cb (http://localhost:3000/packages/cfs_autoform.js?ca0ee21422d608dd4c429aa4c230839a532b1cd9:180:23)
    at http://localhost:3000/packages/cfs_autoform.js?ca0ee21422d608dd4c429aa4c230839a532b1cd9:220:13

File selector says it is empty everytime. I am stomped!

When I choose (by browsing) or drag an image to my image uploader and submit my form I get a message "Logo is required". Logo is the image upload field and it is required, but no matter which way i try to load an image to upload it does not recognize it (even though the name of the image shows in the field as normal once it is "seeminly" chosen). This all was working two days ago and suddenly stopped working. I have done everything, from re-write the code, re-install each component and try different browsers. The only thing I know that has changed is that i upgraded from meteor 1.0.5 to 1.1.2. I am not sure if the upgrade was the problem but everything stopped working.

I am using autoform 5.1.2
cfs-autoform 2.20
cfs-ui 0.1.3
cfs-filesystem 0.1.2

Meteor 1.1.2

Multiple file upload

Hello,

I had to amend to following code (in a local package clone of cfs:autoform) in order to allow me to upload multiple files. ;-

if (arrayFields[key]) {
var temp = CfsAutoForm.Util.deepFind(doc,key)
temp[key].push(fileObj._id);
} else {
//doc[key] = fileObj._id;
CfsAutoForm.Util.deepSet(doc,key,fileObj._id

in the cfs-autoform-hooks.js file beginning line 68. Otherwise I was getting an error of "undefined function" as "deepFind" was returning an object with both the "name" property and the "fileId" property.

Basing on your example on your site, I have changed the "Docs" Schema property "fileId" to [String] and changed the attribute "cfs-files", otherwise the form validation did not work.

Now multiple uploads (ie. one Name (In Docs) and mulitple files/images attached to it) all works splendidly ! I have no problem retrieving images.... I convert the "FileId" object which is held in MongoDb as "[hfiufhrifuhirhf,hkhkfhsdkfhm,hfshkshfksh]" to ["hfiufhrifuhirhf","hkhkfhsdkfhm","hfshkshfks"] in order to use it in this code

temp = ["hfiufhrifuhirhf","hkhkfhsdkfhm","hfshkshfks"]
Files.find({_id: {$in: temp}})

which returns just those images which pertain to the selected name.

Apologies in advance if I have made the changes in a daft way, but I am not a professional programmer, just a 61 year old hobbyist !.

Grateful if you could steer me on better solution.

Rgds

Howard

Before hooks not work

Hi, Im using before hook to store userId to my 'post' collection, after Im using cfs-autoform to store fileId to my 'post' collection this hooks not working anymore. How can I fix its?

AutoForm.hooks({
  insertResForm: { // Insert form
    before: {
      insert: function(doc) {
        if(Meteor.userId()){
          doc.userId = Meteor.userId();
        }
        return doc;
      }
    }
});

No way to make a file field mandatory

Currently it is not possible to make a file field mandatory because it has "dummyId" value and passes the form validation.

Handling formToDoc, docToForm, formToModifier hooks of AutoForm could help invalidating the form if the field is not optional.

this.template is undefined when before hook is a function

I am using cfs-autoform to create an attachments upload feature. I need to be able to "clean" my schema prior to submit via Meteor.call, but when I try to run CfsAutoForm.Hooks.beforeInsert(doc) I get the following error in the browser:

Uncaught TypeError: Cannot read property '$' of undefined
    Hooks.beforeInsert @ cfs-autoform-hooks.js:11
    AutoForm.hooks.insertAssignmentsForm.before.method @ assignments.js?8a262c80b842e07fc32509b0d2ce45b425685c40:6
    runHook @ autoform-events.js:241runBeforeHooks @ autoform-events.js:250
    AutoForm.addFormType.onSubmit @ method.js:15
    autoFormSubmitHandler @ autoform-events.js:326
    (anonymous function) @ template.js:463
    Template._withTemplateInstanceFunc @ template.js:437
    (anonymous function) @ template.js:462
    (anonymous function) @ view.js:869
    Blaze._withCurrentView @ view.js:523
    (anonymous function) @ view.js:868
    (anonymous function) @ events.js:47
    jQuery.event.dispatch @ jquery.js:4665
    jQuery.event.add.elemData.handle @ jquery.js:4333

When I placed a breakpoint on line 11 of cfs-autoform-hooks.js, the this has a template field but it's set to undefined. My Autoform hooks look like:

Template.assignments.onRendered(function() {
    AutoForm.hooks({
        insertAssignmentsForm: {
            before: {
                method: function(doc) {
                    CfsAutoForm.Hooks.beforeInsert(doc);

                    console.log('Cleaning doc: ', doc);
                    Assignments.simpleSchema().clean(doc);
                    console.log('doc: ', doc);

                    return doc;
                }
            },
            after: {
                method: function(err, result) {
                    if (err) {
                        console.log('An error occured: ', err);
                    } else {
                        console.log('Insert was successful: ', result);
                        method: CfsAutoForm.Hooks.afterInsert(err, result);
                    }
                }
            }
        }
    });
});

cfs-files (the multi version) does not work

There are 2 issue with cfs-files (the "multi" version)...

  1. When file or files are selected, submit fails with "must be a string" error
  2. When changing files, the previous one or ones are not cleared

how to display images of a array?

Images = new FS.Collection("images",{
  stores: [new FS.Store.FileSystem("images")],
  filter:{
    allow:{
      contentTypes: ['image/*']
    }
  }
});
Images.allow({
  insert: function(userId,doc){
    return true;
  },
  update:function(userId,doc){
    return true;
  },
  download: function(userId){
    return true;
  }
});
Posts = new Meteor.Collection('posts');

Posts.allow({
  insert:function(userId,doc){
    return true;
  },
  update:function(userId,doc){
    return true;
  }
});
PostSchema = new SimpleSchema({
  title:{
    type: String,
    autoform:{
      label:false,
      type:"textarea",
      placeholder:"Comparte con la comunidad"
    }
  },
  pictures:{
    type:[String],
    optional: true,
    label: " "
  },
  'pictures.$':{
    autoform:{
      type:"fileUpload",
      collection: 'images',
      selectFileBtnTemplate: 'mySelectFileBtn',
      previewTemplate: 'myFilePreview',
      uploadProgressTemplate: 'myUploadProgressTemplate'
    }
  },
  author:{
    type:String,
    label: "Author",
    autoValue: function(){
      return this.userId
    },
    autoform:{
      type:"hidden"
    }
  },
  createdAt:{
    type: Date,
    label: "created At",
    autoValue:function(){
      return new Date()
    },
    autoform:{
      type:"hidden"
    }
  }
});
Posts.attachSchema(PostSchema);
<template name="Posts">
  {{> NewPost}}
  <div class="col-lg-6 col-lg-offset-3">
    {{#each posts}}
      {{> Post}}
    {{/each}}
  </div>
</template>
<template name="Post">
  <div class="card">
    <div class="card-header">
      Bryan zamora
    </div>
    <div class="card-block">
      <p class="card-text">{{title}}</p>
      {{#each FS.GetFile "images" pictures}}
        <img src="{{this.name}}" alt="" class="card-img-bottom">
      {{/each}}
    </div>
  </div>
</template>


Meteor.publish("postAndImage",function(){
  return[
    Posts.find({author:this.userId}),
    Images.find({})
  ]
})

file upload not working in IOS simulator

My file upload works perfect, but when I run my app in IOS simulator (meteor run ios) the input form field for the file is not clickable.
{{> afQuickField name="fileId" type="cfs-file" collection="files"}}

what is the solution? I was expecting that I could choose a file from library or camera (iphone behaviour)

How to subscribe cfs-files

I defined in Ads schema

images: {
    type: [String],
    optional: true,
    label: "Pictures",
    autoform: {
      afFieldInput: {
        type: "cfs-files",
        collection: "images"
      }
    }
  },

At server publish

new Meteor.Pagination(Ads,{
	transform_options: function (filters, options) {
        const fields = { "images":1,"adlocation":1,"title":1,"slug":1 }
        options.fields = _.extend(fields, options.fields);
        return options;
    }
});

at client side subscription

this.pagination = new Meteor.Pagination(Ads, {
  	sort: {
    				_id: -1
        	},
		perPage: 1,
		filters:conditions,
		fields:{"images":1,"adlocation":1,"title":1,"slug":1}
  });

How to subscribe images based on Ads pagination.

Regards,
Jagan

First Impressions and possible issue with loading files

Don't know if Im doing something wrong, but it seems it didn't copy the client files correctly? I've added the project github to smart.json, i see its files under ./packages/cfs-autoform, but it doens't loads them? Says the template cfsFileField is not found for example. Copying the files manually from packages/cfs-autoform to the root directory works thought.

Anyway, i really like how the insert form is working! 2 questions:
1 - When removing a document that has a file, do I need to also remember to delete its corresponding file, or will collection2 automatically delete it (call remove on the corresponding File) automatically in the future?
2 - Do you intend to add support for dragging files to the file input?

I'm testing with cfs-filesystem and so far so good! Awesome work!

Support server methods

This is along the same line as #7 but with a slightly different twist. I'm inserting only one element of an array thats contained in a sub-schema. I.e.

docSchema = new SimpleSchema([
    {
        name: {
            type:String,
            label:"Name"
        }, 
        fileId: { 
            type: String, 
            autoform: { 
                afFieldInput: { 
                    type: "cfs-file", 
                    collection: "files" 
                } 
            } 
        }
    }
]);

correspondenceSchema = new SimpleSchema([{
    //a bunch of simple properties here
    documents: {
        type: [docSchema],
        label: "Documents"
    }
};

mainSchema = new SimpleSchema([{
    //more simple properties here

    correspondence: {
        type: [correspondenceSchema],
        label: "Correspondence"
    }
}]);

mainCollection = new Mongo.Collection("main");
mainCollection.attachSchema(mainSchema);

Just for reference, think of the main collection as a project, for example. The correspondence can track discussions about the project and those correspondence items can contain one or more documents. The app allows the ability to add one new correspondence but it is inserted in a server method called addCorrespondence. e.g.

{{#autoForm schema=correspondenceSchema id="correspondenceForm" type="method" meteormethod="addCorrespondence"}}...

I was thinking, I know CFS:autoform only handles inserts but that's all I'm doing. Of course, after debugging and looking through your code, it struck me the autoform has to be an insert form. facepalm

On the server side I just see "dummyId" as the fileId because none of your autoform insert hooks are running. edit realized you were trying to address this with function afAddHook(formId). /edit It seems like they should have run, but for some reason they are not.

Thoughts? BTW, I do realize you intend this as more of a POC.

edited to remove inaccurate information

field doesn't appear

I'm trying to use it with autoform but the fields doesn't appear. Just the label.

CTIcons = new FS.Collection('ctypeicons',{
  stores: [ new FS.Store.GridFS('ctiStore')]
});
CTypes = new Meteor.Collection('ctypes');
CTypes.attachSchema(new SimpleSchema({
  ...
  icon: {
    type: String,
    label:'Icon',
    autoform: {
      afFieldInput: {
        type: "cfs-file",
        collection: "ctypeicons"
      }
    }
  }
}));

...
AutoForm.setDefaultTemplateForType('quickForm', 'plain');

in the template I have

<template name="cTypeEdit">
    ...
    {{> quickForm collection="CTypes" doc=this }}
    ...
  </div>
</template>

The result is this:
schermata da 2015-03-06 11 53 39

Am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.