Giter Club home page Giter Club logo

meteor-cfs-autoform's Introduction

cfs-autoform

WORK IN PROGRESS

A smart package for Meteor that provides a file UI component for use within an autoform. The UI component supports clicking to select files or dropping them. Once the full form is valid, the files are uploaded using CollectionFS. The form document is inserted only if the uploads are all successful. If the form document fails to insert on the server, the uploaded files are removed.

Installation

Work in progress. For now, not on Atmosphere. Put this in the packages section of your smart.json:

"cfs-autoform": {
  "git": "https://github.com/aldeed/meteor-cfs-autoform",
  "branch": "master"
}

And then run mrt add cfs-autoform

Prerequisites

Add collection2, autoform, and collectionFS packages to your app. Also add any other CFS packages you need, particularly a storage adapter package.

Example

Assumption: autopublish, insecure, and cfs-gridfs packages are in use

common.js

Docs = new Meteor.Collection("docs");
Docs.attachSchema(new SimpleSchema({
  name: {
    type: String
  },
  fileId: {
    type: String,
    label: "File"
  }
}));

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

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

html:

<template name="insertForm">
  {{#autoForm id="insertForm" type="insert" collection="Docs"}}
  {{> afQuickField name="name"}}
  {{> cfsFileField name="fileId" collection="files"}}
  <button type="submit">Submit</button>
  {{/autoForm}}
</template>

Notes

  • Only insert forms (type="insert") are supported
  • The collection attribute for cfsFileField must be the same as the first argument you passed to the FS.Collection constructor.
  • Files are uploaded only after you click submit and the form is valid.
  • If file upload fails, the form document is not inserted.
  • If one file fails to upload, any other files from that form that did upload are deleted.
  • If the form document insert fails on the server, the associated files are automatically deleted as part of the latency compensation rollback.

TODO

  • Insert FS.File itself when using cfs-ejson-file package.
  • Display customizable progress bar template in place of each field while uploading.
  • Better template/component structure so that it does not have to be a quickField.

Support via Gittip

meteor-cfs-autoform's People

Contributors

aldeed avatar teonimesic avatar

Watchers

James Cloos avatar Georges Baladi avatar

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.