Over a million developers have joined DZone.

Build a Kanban TaskManager App in 10 Minutes

Use AllcountJS to utilize the power of Node.js to create a Kanban task management app.

· Agile Zone

Reduce testing time & get feedback faster through automation. Read the Benefits of Parallel Testing, brought to you in partnership with Sauce Labs.

Task management is one of the most important features for businesses. While there are many solutions for this problem, there's no silver bullet yet because each business field has its own specifics. Development of an application to meet specific requirements in this circumstance isn’t rare. AllcountJS allows you to build custom task management applications from scratch pretty quickly.

If you're unfamiliar with AllcountJS, check out this Getting Started guide first. While AllcountJS allows you to use all the power of Node.js, in this article we will work only with App Config code. In order to run demo code you should do npm install allcountjs-cli then allcountjs init or simply run code from our demo page here and you’ll get something like:

Image title

Model

Let’s start with model declaration. Probably the most important thing in task management is to have a task object (obviously) and some status flow. Let’s define our model in main.js:

A.app({
  appName: "Task manager",
  onlyAuthenticated: true,
  menuItems: [
    {
      name: "Planning",
      entityTypeId: "Task"
    }, {
      name: "Statuses",
      entityTypeId: "Status"
    }
  ],
  entities: function(Fields) {
    return {
      Task: {
        fields: {
          summary: Fields.textarea("Summary").required(),
          dueDate: Fields.date("Due Date").required(),
          status: Fields.fixedReference("Status", "Status")
        }
      },
      Status: {
        fields: {
          name: Fields.text("Name").required(),
          order: Fields.integer("Order").required()
        },
        referenceName: "name"
      }
    }
  }
});

This App Config produces a working application that has two entities: Task and Status. The task object has a summary and due date fields along with the status reference. The status entity has a name field used as a reference name while showing a combo box and an order field that will be used later to define the order of statuses. As you can see required fields are marked with .required(). It means entity couldn’t be created or saved until these fields are filled. Also you could note onlyAuthenticated flag which designates app couldn’t be accessed without authentication.

Order of Statuses

We could define our status priorities just by adding sorting: [['order', 1]], to the Statusentity type:

A.app({
  appName: "Task manager",
  onlyAuthenticated: true,
  menuItems: [
    {
      name: "Planning",
      entityTypeId: "Task"
    }, {
      name: "Statuses",
      entityTypeId: "Status"
    }
  ],
  entities: function(Fields) {
    return {
      Task: {
        fields: {
          summary: Fields.textarea("Summary").required(),
          dueDate: Fields.date("Due Date").required(),
          status: Fields.fixedReference("Status", "Status")
        }
      },
      Status: {
        fields: {
          name: Fields.text("Name").required(),
          order: Fields.integer("Order").required()
        },
        sorting: [['order', 1]],
        referenceName: "name"
      }
    }
  }
});

This declaration instructs AllcountJS to sort Status entity by order field in ascending order.

Board View

One of the most powerful AllcountJS features is the Views concept. View is an Entity too but as a storage it uses another entity. So there is an opportunity to create many multiple behaviors and visualizations for same data source. Let’s create a board view for our Task entity by adding following property

views: {
  TaskBoard: {
    customView: "board"
  }
}

And create new menu item to open the board:

{
  name: "Board",
  entityTypeId: "TaskBoard",
  icon: "bars"
}

Also we should create custom view board we reference (board.jade)

extends project/card-board
block panelBody
  .panel-body
    h4 {{item.summary}}
    p {{item.dueDate | date}}

AllcountJS uses jade template language by default. Code in board.jade defines template for custom view of our board. It defines panelBody block that describes how the card will look like. We should get following result for main.js

A.app({
  appName: "Task manager",
  onlyAuthenticated: true,
  menuItems: [
    {
      name: "Planning",
      entityTypeId: "Task"
    }, {
      name: "Board",
      entityTypeId: "TaskBoard",
      icon: "bars"
    }, {
      name: "Statuses",
      entityTypeId: "Status"
    }
  ],
  entities: function(Fields) {
    return {
      Task: {
        fields: {
          summary: Fields.textarea("Summary").required(),
          dueDate: Fields.date("Due Date").required(),
          status: Fields.fixedReference("Status", "Status")
        },
        views: {
          TaskBoard: {
            customView: "board"
          }
        }
      },
      Status: {
        fields: {
          name: Fields.text("Name").required(),
          order: Fields.integer("Order").required()
        },
        sorting: [['order', 1]],
        referenceName: "name"
      }
    }
  }
});

If you run this code sample you’ll see Kanban board with status where you can move cards between statuses. Order of statuses is defined by order field because of sorting.

Polishing

To polish things you probably want to add icons for menu items and the app. You could do it by simply referring to Font Awesome icons. Let’s add appIcon and icons for menu and we’ll get final version for the app.

A.app({
  appName: "Task manager",
  appIcon: "book",
  onlyAuthenticated: true,
  menuItems: [
    {
      name: "Planning",
      entityTypeId: "Task",
      icon: "tasks"
    }, {
      name: "Board",
      entityTypeId: "TaskBoard",
      icon: "bars"
    }, {
      name: "Statuses",
      entityTypeId: "Status",
      icon: "sort"
    }
  ],
  entities: function(Fields) {
    return {
      Task: {
        fields: {
          summary: Fields.textarea("Summary").required(),
          dueDate: Fields.date("Due Date").required(),
          status: Fields.fixedReference("Status", "Status")
        },
        views: {
          TaskBoard: {
            customView: "board"
          }
        }
      },
      Status: {
        fields: {
          name: Fields.text("Name").required(),
          order: Fields.integer("Order").required()
        },
        sorting: [['order', 1]],
        referenceName: "name"
      }
    }
  }
});

Try running this in our Demo Gallery.

The Agile Zone is brought to you in partnership with Sauce Labs. Discover how to optimize your DevOps workflows with our cloud-based automated testing infrastructure.

Topics:
node.js ,javascript ,crud api ,kanban ,agile

Published at DZone with permission of Maxim Sorokin. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}