Skip to content

Latest commit

 

History

History
105 lines (81 loc) · 2.17 KB

Start-From-Scratch.md

File metadata and controls

105 lines (81 loc) · 2.17 KB

Starting from scratch

Install Node.JS

https://nodejs.org/en/download/

Install sailsJS

npm install sails -g

We recommend using an "Empty" project, but you can use "Webapp", too

Create new app called projectmanage

sails new projectmanage

Install forestay

npm install sails generate forestay

Generate a new models with CRUD

sails generate forestay user
sails generate forestay usergroup
sails generate forestay project

Your models are located at api/models and can be modified with Forestay features.

Run your app

node app.js

Navigate to localhost:1337/user/ or /project/ etc

Navigate around. You'll quickly realize that there's nothing there.

Add attributes to models

Add to api/models/User.js
attributes: {
  name: {
      type: "string",
      required: true
    },
  email: {
    type: "string",
    required: true
  },
}

These attributes will now appear when you add new users when you go to /user/create

Additional models for Proejcts and User Groups

Add to api/models/Project.js
attributes: {
  name: {
      type: "string",
      description: "The project name",
      required: true
    },
}
Add to api/models/Usergroup.js
attributes: {
  name: {
      type: "string",
      description: "The project name",
      required: true
    },
}

Let's add a one-to-many relationship between users and usergroups inside the attributes section of api/models/Usergroup.js

userGroups: {
  model:"Usergroup",
    meta: {
      forestay: {
        populateBy: "name",  // This is the attribute value that it uses to populate your UI
        filterable: true,    // you will now be able to filter users by usergroups
        label: "User Group", // This is what label will be shown to the user
        description: "The user group this user is assigned to", // This will display as a help description on create/update
      }
    }
},

Now navigate to /userGroup/ and create a couple user groups like "Admin" or "Project Manager"

You can now associate users to usergroups by creating new users.