Our flexible Kanban board for managing tasks with drag drop


Post by harish22 »

Hi Team,

I want to call the API in the Bryntum TaskBoard (Angular version) on the initial load.

API Endpoint:
🔗 https://4014cb28-75f5-47dd-a319-b2121529886c.mock.pstmn.io/getTasks

API response format: {
"success": true,
"tasks": {
"rows": [
{
"id": 1,
"name": "Book flight",
"description": "Booking flight using APP",
"resourceId": "Dave"
},
{
"id": 2,
"name": "Book hotel",
"description": "Booking Hotel using APP",
"resourceId": "Celia"
},
{
"id": 3,
"name": "Pack bags",
"description": "Need to pack bags for vacation",
"resourceId": "Angelo"
},
{
"id": 4,
"name": "Get visa",
"description": "Immediate Visa Need for us",
"resourceId": "Celia"
},
{
"id": 5,
"name": "Book train",
"description": "Booking Train using APP",
"resourceId": "Angelo"
},
{
"id": 6,
"name": "Book Movie Ticket",
"description": "Booking movie ticket using APP",
"resourceId": ""
},
{
"id": 7,
"name": "Get Passport",
"description": "Apply new passport",
"resourceId": ""
}
]
},
"resources": {
"rows": [
{
"id": 1,
"name": "Angelo"
},
{
"id": 2,
"name": "Celia"
},
{
"id": 3,
"name": "Dave"
}
]
}
}

Requirements:

  1. Fetch tasks and resources from the API when the taskboard loads.
  2. Dynamically add a new column labeled "UnAssigned" at the end of the taskboard.
  3. If a task's resourceId is empty, it should be automatically assigned to the "UnAssigned" column.

app.component.html

<!-- BryntumDemoHeader component is used for Bryntum example styling only and can be removed -->
<bryntum-demo-header></bryntum-demo-header>

<bryntum-task-board-project-model
    #project
    [tasksData] = "projectProps.tasks!"
    [resourcesData] = "projectProps.resourcesData!"
</bryntum-task-board-project-model>
<bryntum-task-board
    #taskboard
    [project] = "project"
    [resourceImagePath] = "taskBoardProps.resourceImagePath!"
    [useDomTransition] = "taskBoardProps.useDomTransition!"
    [autoGenerateColumns] = "taskBoardProps.autoGenerateColumns!"
    [columnField] = "taskBoardProps.columnField!"
</bryntum-task-board>

app.component.ts

import { AfterViewInit, Component, ViewChild, ViewEncapsulation } from '@angular/core';
import { TaskBoard } from '@bryntum/taskboard-thin';
import { BryntumTaskBoardComponent, BryntumTaskBoardProjectModelComponent } from '@bryntum/taskboard-angular-thin';
import { projectProps, taskBoardProps } from './app.config';
import {ApiService} from './app.service'

@Component({
    selector      : 'app-root',
    templateUrl   : './app.component.html',
    styleUrls     : ['./app.component.scss'],
    encapsulation : ViewEncapsulation.None,
    standalone : false
})

export class AppComponent implements AfterViewInit {

taskBoardProps = taskBoardProps;
projectProps = projectProps;

// Bryntum TaskBoard Angular wrapper reference
@ViewChild(BryntumTaskBoardComponent, { static : false }) taskBoardComponent!: BryntumTaskBoardComponent;
@ViewChild(BryntumTaskBoardProjectModelComponent, { static : true }) project!: BryntumTaskBoardProjectModelComponent;

private taskBoard! : TaskBoard;
constructor(private ApiService: ApiService) {}

ngAfterViewInit(): void {
    this.taskBoard = this.taskBoardComponent.instance;
    this.ApiService.fetchTasks().subscribe({
    next: (data) => {
    console.log("res",data); 
    this.projectProps.tasks = data.tasks;
    this.projectProps.resources = data.resources;
  },
  error: (error) => {
    console.log("error", error);
    
  }
});

}
}

app.config.ts

import { type BryntumTaskBoardProps, type BryntumTaskBoardProjectModelProps } from '@bryntum/taskboard-angular-thin';

export const projectProps : BryntumTaskBoardProjectModelProps = {
    // transport : {
    //     load : {
    //         url : 'https://4014cb28-75f5-47dd-a319-b2121529886c.mock.pstmn.io/getTasks',
    //     }
    // },
    //autoLoad : true
};

export const taskBoardProps : BryntumTaskBoardProps = {
    resourceImagePath : 'assets/users/',

// Experimental, transition moving cards using the editor
useDomTransition : true,

autoGenerateColumns : true,

// Field used to pair a task to a column
columnField : 'resourceId'

};

How can this be achieved in Angular? 🚀


Post by alex.l »

Hi!

Fetch tasks and resources from the API when the taskboard loads.

Did you see our Angular demos? https://bryntum.com/products/taskboard/examples/ You can find source code in the zip you downloaded from CustomerZone, check examples/frameworks/angular
Here is guide how to work with remote data
https://bryntum.com/products/taskboard/docs/guide/TaskBoard/data/remotedata
And CrudManager
https://bryntum.com/products/taskboard/docs/guide/TaskBoard/data/crud_manager_project
https://bryntum.com/products/taskboard/docs/guide/TaskBoard/data/crud_manager_in_depth

Dynamically add a new column labeled "UnAssigned" at the end of the taskboard.

See docs https://bryntum.com/products/taskboard/docs/api/Grid/data/ColumnStore
or demo here https://bryntum.com/products/taskboard/examples/auto-columns/
and here https://bryntum.com/products/taskboard/examples/columns-remote/

If a task's resourceId is empty, it should be automatically assigned to the "UnAssigned" column.

To set default value you can use https://bryntum.com/products/taskboard/docs/api/Core/data/field/DataField#config-defaultValue
How to extend TaskModel, see docs of TaskModel https://bryntum.com/products/taskboard/docs/api/TaskBoard/model/TaskModel#customizing-task-fields

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy

We do not write the code in bounds of forum support. If you need help with development, contact us via bryntum.com/services


Post by harish22 »

Thanks for the quick response, Alex.

I've gone through the documentation and tried implementing it, but it's still not working for me. I'm using the Angular version of Bryntum TaskBoard.

Could you provide a runnable code snippet or point out the necessary changes in my existing code?
Objective:

I want to fetch data from a REST API and load it into the Bryntum TaskBoard in Angular.

API End Point: https://4014cb28-75f5-47dd-a319-b2121529886c.mock.pstmn.io/getTasks


Post by ghulam.ghous »

Hey Harish,

Just to be clear on couple of things, you are calling the api end point to load the data and then you want to provide that data to the taskboard component. Is the api endpoint needs to specifically called by you? If not you can just configure it as a loadUrl on the project and set autoload to true and it will load the data. See this demo where we are loading the data from a provided url: https://bryntum.com/products/taskboard/examples/frameworks/angular/undo-redo/dist/undo-redo/

Another example is how you can load inline data, similar to what you are doing in the above snippets. You can load the data by calling api and wait for the request to be fulfilled and then either call the loadInlineData method on the project https://bryntum.com/products/taskboard/docs/api/Scheduler/model/mixin/ProjectModelMixin#function-loadInlineData or you can pass the data through project props as shown here: https://bryntum.com/products/taskboard/examples/frameworks/angular/inline-data/dist/inline-data/

Does this help?


Post Reply