Giter Club home page Giter Club logo

autocms's Introduction

autoCms for Meteor.js

A simple solution to manage contents. You can easly list your data in a table, update, delete or insert. ```js meteor add guncebektas:autocms ``` Click here to watch what you can do with the package

How to

Routes

```js // cmsCollections FlowRouter.route('/cms/:collection/:function', { action: function() { BlazeLayout.render("main", { content: 'autoCms' }); } }); FlowRouter.route('/cms/:collection/:function/:id', { action: function() { BlazeLayout.render("main", { content: "autoCms" }); } }); ```

Into Body

```js {{> Template.dynamic template=content}} ```

Rules

```js Players = new Mongo.Collection('players'); // Attach schema for autoForm Players.attachSchema(new SimpleSchema({ name: { type: String, label: "Name", max: 100 }, surname: { type: String, label: "Surname", max: 100 }, picture: { type: String, label: 'Profile Picture', autoform: { afFieldInput: { type: 'fileUpload', collection: 'Images', accept: 'image/*', label: 'Choose a file', previewTemplate: 'filePreview', selectFileBtnTemplate: 'fileButtonSelect', removeFileBtnTemplate: 'fileButtonRemove', onBeforeInsert: function(fileObj) { }, onAfterInsert: function(err, fileObj) { } } }, optional: true } })); // Define rules for autoCms Players.autoCms = { wrapper: { type: 'list' }, title: 'All players', showNo: false, columns: { picture: { type: 'image', width: 40 }, name: { }, surname: { } } } ```

Open links

``` localhost:3000/cms/Players/list localhost:3000/cms/Players/insert ```

The result will be like that

Another example which covers more

```js // First of all create Mongo collections Games = new Mongo.Collection('games'); // Attach schema into collection Games.attachSchema(new SimpleSchema({ title:{ type: String, label: "Title", max: 100 }, date: { type: Date, label: "Due Date", optional: true }, gamer1: { type: String, label: "Gamer 1", autoform: { //type: "select2", options: function () { return Players.find().map(function (p) { return {label: p.name+' '+p.surname, value: p._id}; }); } } }, score1: { type: Number, label: "Score 1", defaultValue: 0 }, gamer2: { type: String, label: "Gamer 2", autoform: { //type: "select2", options: function () { return Players.find().map(function (p) { return {label: p.name+' '+p.surname, value: p._id}; }); } } }, score2: { type: String, label: "Score 2", defaultValue: 0 }, // hide createdBy column createdBy: { type: String, autoform: { type: "hidden", label: false }, autoValue: function () { return Meteor.userId() } } })); // Define rules for autoCms Games.autoCms = { wrapper: { type: 'table', class: 'table table-hover' }, title: 'All games', buttons: { extra: { label: ' Extra', class: 'btn btn-xs btn-success', auth: function() { // default true return true; }, href: function(data) { return location.origin+'/link/'+data; } }, edit: { label: ' Edit', class: 'btn btn-xs btn-default', auth: function() { // default true return true; } }, delete: { label: ' Delete', class: 'btn btn-xs btn-danger', auth: function() { // default true return false; } }, showNavButtons: true, // default true navButtonInsert: { label: '', class: 'btn btn-default' }, navButtonList: { label: '', class: 'btn btn-default' }, showActionButtons: true // default true }, showNo: true, // default true columns: { title: { }, gamer1: function(data){ result = Players.findOne(data); return '

'+result.name+' '+result.surname; }, score1: { class: function(data) { switch(true) { case (data < 3): return 'danger' break; case (data == 3): return 'info'; break; case (data > 3): return 'success'; break; default: return undefined; } } }, gamer2: function(data){ result = Players.findOne(data); return '

'+result.name+' '+result.surname; }, score2: { class: function(data) { switch(true) { case (data < 3): return 'danger' break; case (data == 3): return 'info'; break; case (data > 3): return 'success'; break; default: return undefined; } } } } } // Allow database actions in server if (Meteor.isServer) { Games.allow({ insert: function () { return true; }, update: function () { return true; }, remove: function () { return true; } }); } ```

Open links

``` localhost:3000/cms/Games/list localhost:3000/cms/Games/insert ```

The result will be like that if you add bootstrap

autocms's People

Contributors

guncebektas avatar

Watchers

 avatar  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.