Skip to content

Commit 7ccdd41

Browse files
authored
Merge pull request #1 from vinoth-Kumar-S/master
Angular Scheduler drag and drop video
2 parents e5ba4bd + 93d5d03 commit 7ccdd41

16 files changed

+510
-2
lines changed

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1-
# how-to-drag-and-drop-events-from-an-external-source-into-the-angular-scheduler
2-
A quick-start Angular project that shows how to drag and drop events from an external source into the Angular Scheduler component. This project contains code to drag an item from the TreeView component to the Scheduler and updateit as an event using the nodeDragstop event of the TreeView.
1+
# How to Drag and Drop Events from an External Source into the Angular Scheduler
2+
3+
A quick-start Angular project that shows how to drag and drop events from an external source into the Angular Scheduler component. This project contains code to drag an item from the TreeView component to the Scheduler and update it as an event using the nodeDragstop event of the TreeView.
4+
5+
Check out this online demo for external drag and drop in the Syncfusion Angular Scheduler component:
6+
https://ej2.syncfusion.com/angular/demos/#/material/schedule/external-drag-drop
7+
8+
Refer to the following documentation to get started with the Syncfusion Angular Scheduler component:
9+
https://ej2.syncfusion.com/angular/documentation/schedule/getting-started
10+
11+
Refer to the following documentation to get started with the Syncfusion Angular Treeview component:
12+
https://ej2.syncfusion.com/angular/documentation/treeview/getting-started
13+
14+
Refer to the following documentation about drag and drop in the Syncfusion Angular Treeview component:
15+
https://ej2.syncfusion.com/angular/documentation/treeview/drag-and-drop
16+
17+
Watch the following video to get started with the Angular Scheduler component:
18+
https://www.youtube.com/watch?v=WnBjPXPGmnw
19+
20+
## Project prerequisites
21+
22+
Make sure that you have the latest versions of NodeJS and Visual Studio Code in your machine before starting to work on this project.
23+
24+
### How to run this application?
25+
26+
To run this application, you need to clone the `how-to-drag-and-drop-events-from-an-external-source-into-the-angular-scheduler` repository and then open it in Visual Studio Code. Now, simply install all the necessary react packages into your current project using the `npm install` command and run your project using the `ng serve` command.

angular.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"myangularproject": {
7+
"projectType": "application",
8+
"schematics": {},
9+
"root": "",
10+
"sourceRoot": "src",
11+
"prefix": "app",
12+
"architect": {
13+
"build": {
14+
"builder": "@angular-devkit/build-angular:browser",
15+
"options": {
16+
"outputPath": "dist/myangularproject",
17+
"index": "src/index.html",
18+
"main": "src/main.ts",
19+
"polyfills": [
20+
"zone.js"
21+
],
22+
"tsConfig": "tsconfig.app.json",
23+
"assets": [
24+
"src/favicon.ico",
25+
"src/assets"
26+
],
27+
"styles": [
28+
"src/styles.css",
29+
"./node_modules/@syncfusion/ej2-material-theme/styles/material.css"
30+
],
31+
"scripts": []
32+
},
33+
"configurations": {
34+
"production": {
35+
"budgets": [
36+
{
37+
"type": "initial",
38+
"maximumWarning": "500kb",
39+
"maximumError": "1mb"
40+
},
41+
{
42+
"type": "anyComponentStyle",
43+
"maximumWarning": "2kb",
44+
"maximumError": "4kb"
45+
}
46+
],
47+
"outputHashing": "all"
48+
},
49+
"development": {
50+
"buildOptimizer": false,
51+
"optimization": false,
52+
"vendorChunk": true,
53+
"extractLicenses": false,
54+
"sourceMap": true,
55+
"namedChunks": true
56+
}
57+
},
58+
"defaultConfiguration": "production"
59+
},
60+
"serve": {
61+
"builder": "@angular-devkit/build-angular:dev-server",
62+
"configurations": {
63+
"production": {
64+
"browserTarget": "myangularproject:build:production"
65+
},
66+
"development": {
67+
"browserTarget": "myangularproject:build:development"
68+
}
69+
},
70+
"defaultConfiguration": "development"
71+
},
72+
"extract-i18n": {
73+
"builder": "@angular-devkit/build-angular:extract-i18n",
74+
"options": {
75+
"browserTarget": "myangularproject:build"
76+
}
77+
},
78+
"test": {
79+
"builder": "@angular-devkit/build-angular:karma",
80+
"options": {
81+
"polyfills": [
82+
"zone.js",
83+
"zone.js/testing"
84+
],
85+
"tsConfig": "tsconfig.spec.json",
86+
"assets": [
87+
"src/favicon.ico",
88+
"src/assets"
89+
],
90+
"styles": [
91+
"src/styles.css",
92+
"./node_modules/@syncfusion/ej2-material-theme/styles/material.css"
93+
],
94+
"scripts": []
95+
}
96+
}
97+
}
98+
}
99+
}
100+
}

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "myangularproject",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"start": "ng serve",
7+
"build": "ng build",
8+
"watch": "ng build --watch --configuration development",
9+
"test": "ng test"
10+
},
11+
"private": true,
12+
"dependencies": {
13+
"@angular/animations": "^16.2.0",
14+
"@angular/common": "^16.2.0",
15+
"@angular/compiler": "^16.2.0",
16+
"@angular/core": "^16.2.0",
17+
"@angular/forms": "^16.2.0",
18+
"@angular/platform-browser": "^16.2.0",
19+
"@angular/platform-browser-dynamic": "^16.2.0",
20+
"@angular/router": "^16.2.0",
21+
"@syncfusion/ej2-angular-buttons": "^23.1.36",
22+
"@syncfusion/ej2-angular-inputs": "^23.1.40",
23+
"@syncfusion/ej2-angular-navigations": "^23.1.36",
24+
"@syncfusion/ej2-angular-schedule": "^23.1.36",
25+
"@syncfusion/ej2-material-theme": "~23.1.36",
26+
"rxjs": "~7.8.0",
27+
"tslib": "^2.3.0",
28+
"zone.js": "~0.13.0"
29+
},
30+
"devDependencies": {
31+
"@angular-devkit/build-angular": "^16.2.1",
32+
"@angular/cli": "~16.2.1",
33+
"@angular/compiler-cli": "^16.2.0",
34+
"@types/jasmine": "~4.3.0",
35+
"jasmine-core": "~4.6.0",
36+
"karma": "~6.4.0",
37+
"karma-chrome-launcher": "~3.2.0",
38+
"karma-coverage": "~2.2.0",
39+
"karma-jasmine": "~5.1.0",
40+
"karma-jasmine-html-reporter": "~2.1.0",
41+
"typescript": "~5.1.3"
42+
}
43+
}

src/app/app.component.css

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
.drag-sample-wrapper{
2+
display: flex;
3+
}
4+
5+
.treeview-external-drag #waitlist {
6+
height: 50%;
7+
font-weight: bold;
8+
font-family: "Segoe UI";
9+
font-size: 12px;
10+
padding: 5px 0 0 10px;
11+
overflow: hidden;
12+
text-overflow: ellipsis;
13+
}
14+
15+
.treeview-external-drag #waitcategory {
16+
height: 50%;
17+
font-family: "Segoe UI";
18+
font-size: 10px;
19+
opacity: 0.6;
20+
padding-left: 10px;
21+
padding-top: 5px;
22+
overflow: hidden;
23+
text-overflow: ellipsis;
24+
}
25+
26+
.treeview-external-drag .e-list-text {
27+
border: 0.5px solid #E1E7EC;
28+
height: 50px;
29+
line-height: 15px;
30+
padding: 0 5px;
31+
width: 220px;
32+
}
33+
34+
.treeview-external-drag .e-list-parent {
35+
height: 100%;
36+
padding: 0 2px;
37+
}
38+
39+
.treeview-external-drag .e-list-item {
40+
padding: 0 0 5px 0;
41+
}
42+
43+
.treeview-external-drag .e-fullrow,
44+
.e-bigger .treeview-external-drag .e-fullrow {
45+
height: 55px;
46+
}
47+
48+
.treeview-external-drag .e-list-item.e-hover>.e-fullrow,
49+
.treeview-external-drag .e-list-item.e-active>.e-fullrow,
50+
.treeview-external-drag .e-list-item.e-active.e-hover>.e-fullrow {
51+
background-color: transparent;
52+
border-color: transparent;
53+
box-shadow: none !important;
54+
}
55+
56+
.treeview-external-drag .e-text-content {
57+
padding: 0;
58+
background-color: inherit;
59+
}
60+
61+
.e-drag-item.e-treeview.treeview-external-drag {
62+
padding: 0 !important;
63+
}
64+
65+
.e-quick-popup-wrapper .e-event-popup .e-popup-header .e-subject-wrap,
66+
.e-drag-item.treeview-external-drag .e-icon-expandable {
67+
display: none;
68+
}

src/app/app.component.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div class="drag-sample-wrapper">
2+
<ejs-schedule #schedule width='85%' height='650px'
3+
[eventSettings]="eventSettings">
4+
<e-views>
5+
<e-view option='Week'></e-view>
6+
</e-views>
7+
</ejs-schedule>
8+
9+
<ejs-treeview #treeview [fields]='field'
10+
[allowDragAndDrop]="true"
11+
dragArea=".drag-sample-wrapper"
12+
(nodeDragStop)="onDragStop($event)"
13+
cssClass='treeview-external-drag'>
14+
<ng-template #nodeTemplate let-data>
15+
<div>
16+
<div id="waitlist">{{data.Name}}</div>
17+
<div id="waitcategory">{{data.DepartmentName}} - {{data.Description}}</div>
18+
</div>
19+
</ng-template>
20+
</ejs-treeview>
21+
</div>

src/app/app.component.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { TestBed } from '@angular/core/testing';
2+
import { AppComponent } from './app.component';
3+
4+
describe('AppComponent', () => {
5+
beforeEach(() => TestBed.configureTestingModule({
6+
declarations: [AppComponent]
7+
}));
8+
9+
it('should create the app', () => {
10+
const fixture = TestBed.createComponent(AppComponent);
11+
const app = fixture.componentInstance;
12+
expect(app).toBeTruthy();
13+
});
14+
15+
it(`should have as title 'myangularproject'`, () => {
16+
const fixture = TestBed.createComponent(AppComponent);
17+
const app = fixture.componentInstance;
18+
expect(app.title).toEqual('myangularproject');
19+
});
20+
21+
it('should render title', () => {
22+
const fixture = TestBed.createComponent(AppComponent);
23+
fixture.detectChanges();
24+
const compiled = fixture.nativeElement as HTMLElement;
25+
expect(compiled.querySelector('.content span')?.textContent).toContain('myangularproject app is running!');
26+
});
27+
});

src/app/app.component.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Component, ViewChild } from '@angular/core';
2+
import { CellClickEventArgs, EventSettingsModel, ScheduleComponent } from '@syncfusion/ej2-angular-schedule';
3+
import { hospitalData, waitingList } from './data';
4+
import { DragAndDropEventArgs, TreeViewComponent } from '@syncfusion/ej2-angular-navigations';
5+
import { closest} from '@syncfusion/ej2-base';
6+
@Component({
7+
selector: 'app-root',
8+
templateUrl: './app.component.html',
9+
styleUrls: ['./app.component.css']
10+
})
11+
export class AppComponent {
12+
title = 'myangularproject';
13+
@ViewChild('treeview') treeviewObj !: TreeViewComponent;
14+
@ViewChild('schedule') schedulerObj !: ScheduleComponent;
15+
public eventSettings: EventSettingsModel = {
16+
dataSource: hospitalData,
17+
};
18+
19+
public field: Record<string, any> = { dataSource: waitingList, id: 'Id', text: 'Name' }
20+
21+
public onDragStop(args: DragAndDropEventArgs){
22+
let scheduleElem: Element = closest(args.target, '.e-content-wrap') as Element;
23+
if(scheduleElem && args.target.classList.contains('e-work-cells')){
24+
let treeViewData: Record<string, any>[] = this.treeviewObj.fields.dataSource as Record<string, any>[];
25+
let filteredData: Record<string, any>[] = treeViewData.filter(
26+
(item: any) => item.Id === parseInt(args.draggedNodeData['id'] as string, 10)
27+
);
28+
let cellData: CellClickEventArgs = this.schedulerObj.getCellDetails(args.target);
29+
let eventData: Record<string, any> = {
30+
Id: this.schedulerObj.getEventMaxID(),
31+
Subject: filteredData[0]['Name'],
32+
Description: filteredData[0]['Description'],
33+
StartTime: cellData.startTime,
34+
EndTime: cellData.endTime,
35+
IsAllDay: cellData.isAllDay
36+
}
37+
this.schedulerObj.openEditor(eventData, 'Add', true);
38+
let updatedList: Record<string, any>[] = treeViewData.filter(
39+
(item: any) => item.Id !== parseInt(args.draggedNodeData['id'] as string, 10)
40+
);
41+
this.treeviewObj.fields.dataSource = updatedList;
42+
}
43+
}
44+
}

src/app/app.module.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { NgModule } from '@angular/core';
2+
import { BrowserModule } from '@angular/platform-browser';
3+
4+
import { AppComponent } from './app.component';
5+
import { ScheduleModule, RecurrenceEditorModule, DayService, WeekService, WorkWeekService, MonthService, AgendaService, MonthAgendaService, TimelineViewsService, TimelineMonthService } from '@syncfusion/ej2-angular-schedule';
6+
7+
import { TreeViewModule } from '@syncfusion/ej2-angular-navigations';
8+
9+
@NgModule({
10+
declarations: [
11+
AppComponent
12+
],
13+
imports: [
14+
BrowserModule,
15+
ScheduleModule, RecurrenceEditorModule, TreeViewModule
16+
],
17+
providers: [DayService, WeekService, WorkWeekService, MonthService, AgendaService, MonthAgendaService, TimelineViewsService, TimelineMonthService],
18+
bootstrap: [AppComponent]
19+
})
20+
export class AppModule { }

0 commit comments

Comments
 (0)