Skip to content
This repository has been archived by the owner on Aug 8, 2018. It is now read-only.

Latest commit

 

History

History
133 lines (109 loc) · 2.71 KB

README.md

File metadata and controls

133 lines (109 loc) · 2.71 KB

vazco/Universe Files Blaze UI

 

-- Abandonware. This package is deprecated! --

 

Using as standalone

for file:

<template name="myFile">
     {{> universeUploadButton name='file' value=doc.avatar class='img-circle'}}
 </template>
Template.myFile.events({
    fileUploaded (e, tmpl, result) {
        console.log('uploaded', result);
    },
    fileError (e, tmpl, error) {
         console.error('uploaded', error);
    }
});

for image:

<template name="myImage">
     {{> universeUploadButton name='image' isImage=true value=doc.avatar class='img-circle'}}
 </template>
  • parameter isImage=true will activate making sizes for uploaded image (default: small, medium, large)
Template.myImage.events({
    fileUploaded (e, tmpl, result) {
        console.log('uploaded', result);
    },
    fileError (e, tmpl, error) {
         console.error('uploaded', error);
    }
});

for avatar:

<template name="myAvatar">
     {{> universeAvatar name='avatar' value=doc.avatar class='img-circle'}}
 </template>
Template.myAvatar.events({
    fileUploaded (e, tmpl, result) {
        console.log('uploaded', result);
    },
    fileError (e, tmpl, error) {
         console.error('uploaded', error);
    }
});

Using with AutoForms

for file:

import {getFileSchemaField} from 'meteor/universe:files-blaze-ui';
// adding to schema:
const mySchema = new SimpleSchema(Object.assign({
        title: {
            type: String
        }
    },
    getFileSchemaField({
        name: 'file',
        isImage: false
    })
));
<template name="myTemplate">
    {{#autoForm schema=getSchema id="myForm"}}
        {{> afQuickField name='title'}}
        {{> afQuickField name='file' class='img-circle' label=false}}
        <button type="submit">Submit</button>
    {{/autoForm}}
</template>

for avatar

import {getFileSchemaField} from 'meteor/universe:files-blaze-ui';
// adding to schema:
const mySchema = new SimpleSchema(Object.assign({
        title: {
            type: String
        }
    },
    getAvatarSchemaField({
        name: 'logo'
    })
));
<template name="myTemplate">
    {{#autoForm schema=getMySchema id="myLogo"}}
        {{> afQuickField name='title'}}
        {{> afQuickField name='logo'  label=false}}
        <button type="submit">Submit</button>
    {{/autoForm}}
</template>

License

Like every package maintained by Vazco, Universe Files Blaze UI is MIT licensed.