Skip to content

Instantly share code, notes, and snippets.

@jeremyjs
Created August 22, 2015 08:40
Show Gist options
  • Select an option

  • Save jeremyjs/6a4c200f7a32e10e5abb to your computer and use it in GitHub Desktop.

Select an option

Save jeremyjs/6a4c200f7a32e10e5abb to your computer and use it in GitHub Desktop.
Iddocs = new Meteor.Collection ('iddocs');
Iddocs.attachBehaviour('softRemovable');
Iddocs.helpers({
update: function (modifier) {
return Meteor.call('updateDoc', this._id, modifier);
},
approve: function () {
return this.update({ status: 'APPROVED' });
},
reject: function (reason) {
return this.update({ status: 'REJECTED', statusReason: reason });
},
isPending: function () {
return this.status === 'PENDING';
},
isApproved: function () {
return this.status === 'APPROVED';
},
isRejected: function () {
return this.status === 'REJECTED';
},
setPending: function () {
return this.update({ status: 'PENDING' });
},
owner: function () {
return Meteor.users.findOne({ _id: this.userId });
},
file: function () {
return Docs.findOne(this.fileId);
},
filetype: function () {
switch(this.mimetype) {
case 'image/jpeg':
case 'image/png':
case 'image/bmp':
case 'image/gif':
case 'image/pjpeg':
case 'image/tiff':
case 'image/x-tiff':
return 'IMAGE';
case 'application/pdf':
case 'application/msword':
case 'application/rtf':
case 'application/x-rtf':
case 'text/richtext':
case 'application/rtf':
return 'DOC';
default:
return 'UNKNOWN';
}
},
isImage: function () {
return this.filetype() === 'IMAGE';
},
isDoc: function() {
return this.filetype() == 'DOC';
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment