From b9c040d72340aac1f017f291e40388232e5bcd77 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Wed, 31 Jul 2019 18:35:23 +0300 Subject: [PATCH] Initiated Tree Component --- public/demo/data/treenodes.json | 54 ++++ public/demo/data/treetablenodes.json | 353 +++++++++++++++++++++++++++ src/AppMenu.vue | 1 + src/components/tree/Tree.vue | 194 +++++++++++++++ src/components/tree/TreeNode.vue | 62 +++++ src/main.js | 6 +- src/router.js | 5 + src/service/NodeService.js | 15 ++ src/views/tree/TreeDemo.vue | 38 +++ src/views/tree/TreeDoc.vue | 150 ++++++++++++ 10 files changed, 876 insertions(+), 2 deletions(-) create mode 100644 public/demo/data/treenodes.json create mode 100644 public/demo/data/treetablenodes.json create mode 100644 src/components/tree/Tree.vue create mode 100644 src/components/tree/TreeNode.vue create mode 100644 src/service/NodeService.js create mode 100644 src/views/tree/TreeDemo.vue create mode 100644 src/views/tree/TreeDoc.vue diff --git a/public/demo/data/treenodes.json b/public/demo/data/treenodes.json new file mode 100644 index 000000000..1648fefd8 --- /dev/null +++ b/public/demo/data/treenodes.json @@ -0,0 +1,54 @@ +{ + "root": [ + { + "key": "0", + "label": "Documents", + "data": "Documents Folder", + "icon": "pi pi-fw pi-inbox", + "children": [{ + "key": "0-0", + "label": "Work", + "data": "Work Folder", + "icon": "pi pi-fw pi-cog", + "children": [{ "key": "0-0-0", "label": "Expenses.doc", "icon": "pi pi-fw pi-file", "data": "Expenses Document" }, { "key": "0-0-1", "label": "Resume.doc", "icon": "pi pi-fw pi-file", "data": "Resume Document" }] + }, + { + "key": "0-1", + "label": "Home", + "data": "Home Folder", + "icon": "pi pi-fw pi-home", + "children": [{ "key": "0-1-0", "label": "Invoices.txt", "icon": "pi pi-fw pi-file", "data": "Invoices for this month" }] + }] + }, + { + "key": "1", + "label": "Events", + "data": "Events Folder", + "icon": "pi pi-fw pi-calendar", + "children": [ + { "key": "1-0", "label": "Meeting", "icon": "pi pi-fw pi-calendar-plus", "data": "Meeting" }, + { "key": "1-1", "label": "Product Launch", "icon": "pi pi-fw pi-calendar-plus", "data": "Product Launch" }, + { "key": "1-2", "label": "Report Review", "icon": "pi pi-fw pi-calendar-plus", "data": "Report Review" }] + }, + { + "key": "2", + "label": "Movies", + "data": "Movies Folder", + "icon": "pi pi-fw pi-star", + "children": [{ + "key": "2-0", + "icon": "pi pi-fw pi-star", + "label": "Al Pacino", + "data": "Pacino Movies", + "children": [{ "key": "2-0-0", "label": "Scarface", "icon": "pi pi-fw pi-video", "data": "Scarface Movie" }, { "key": "2-0-1", "label": "Serpico", "icon": "pi pi-fw pi-video", "data": "Serpico Movie" }] + }, + { + "key": "2-1", + "label": "Robert De Niro", + "icon": "pi pi-fw pi-star", + "data": "De Niro Movies", + "children": [{ "key": "2-1-0", "label": "Goodfellas", "icon": "pi pi-fw pi-video", "data": "Goodfellas Movie" }, { "key": "2-1-1", "label": "Untouchables", "icon": "pi pi-fw pi-video", "data": "Untouchables Movie" }] + }] + } + ] +} diff --git a/public/demo/data/treetablenodes.json b/public/demo/data/treetablenodes.json new file mode 100644 index 000000000..be13bfa5b --- /dev/null +++ b/public/demo/data/treetablenodes.json @@ -0,0 +1,353 @@ +{ + "root": + [ + { + "key": "0", + "data":{ + "name":"Applications", + "size":"100kb", + "type":"Folder" + }, + "children":[ + { + "key": "0-0", + "data":{ + "name":"React", + "size":"25kb", + "type":"Folder" + }, + "children":[ + { + "key": "0-0-0", + "data":{ + "name":"react.app", + "size":"10kb", + "type":"Application" + } + }, + { + "key": "0-0-1", + "data":{ + "name":"native.app", + "size":"10kb", + "type":"Application" + } + }, + { + "key": "0-0-2", + "data":{ + "name":"mobile.app", + "size":"5kb", + "type":"Application" + } + } + ] + }, + { + "key": "0-1", + "data":{ + "name":"editor.app", + "size":"25kb", + "type":"Application" + } + }, + { + "key": "0-2", + "data":{ + "name":"settings.app", + "size":"50kb", + "type":"Application" + } + } + ] + }, + { + "key": "1", + "data":{ + "name":"Cloud", + "size":"20kb", + "type":"Folder" + }, + "children":[ + { + "key": "1-0", + "data":{ + "name":"backup-1.zip", + "size":"10kb", + "type":"Zip" + } + }, + { + "key": "1-1", + "data":{ + "name":"backup-2.zip", + "size":"10kb", + "type":"Zip" + } + } + ] + }, + { + "key": "2", + "data": { + "name":"Desktop", + "size":"150kb", + "type":"Folder" + }, + "children":[ + { + "key": "2-0", + "data":{ + "name":"note-meeting.txt", + "size":"50kb", + "type":"Text" + } + }, + { + "key": "2-1", + "data":{ + "name":"note-todo.txt", + "size":"100kb", + "type":"Text" + } + } + ] + }, + { + "key": "3", + "data":{ + "name":"Documents", + "size":"75kb", + "type":"Folder" + }, + "children":[ + { + "key": "3-0", + "data":{ + "name":"Work", + "size":"55kb", + "type":"Folder" + }, + "children":[ + { + "key": "3-0-0", + "data":{ + "name":"Expenses.doc", + "size":"30kb", + "type":"Document" + } + }, + { + "key": "3-0-1", + "data":{ + "name":"Resume.doc", + "size":"25kb", + "type":"Resume" + } + } + ] + }, + { + "key": "3-1", + "data":{ + "name":"Home", + "size":"20kb", + "type":"Folder" + }, + "children":[ + { + "key": "3-1-0", + "data":{ + "name":"Invoices", + "size":"20kb", + "type":"Text" + } + } + ] + } + ] + }, + { + "key": "4", + "data": { + "name":"Downloads", + "size":"25kb", + "type":"Folder" + }, + "children":[ + { + "key": "4-0", + "data": { + "name":"Spanish", + "size":"10kb", + "type":"Folder" + }, + "children":[ + { + "key": "4-0-0", + "data":{ + "name":"tutorial-a1.txt", + "size":"5kb", + "type":"Text" + } + }, + { + "key": "4-0-1", + "data":{ + "name":"tutorial-a2.txt", + "size":"5kb", + "type":"Text" + } + } + ] + }, + { + "key": "4-1", + "data":{ + "name":"Travel", + "size":"15kb", + "type":"Text" + }, + "children":[ + { + "key": "4-1-0", + "data":{ + "name":"Hotel.pdf", + "size":"10kb", + "type":"PDF" + } + }, + { + "key": "4-1-1", + "data":{ + "name":"Flight.pdf", + "size":"5kb", + "type":"PDF" + } + } + ] + } + ] + }, + { + "key": "5", + "data": { + "name":"Main", + "size":"50kb", + "type":"Folder" + }, + "children":[ + { + "key": "5-0", + "data":{ + "name":"bin", + "size":"50kb", + "type":"Link" + } + }, + { + "key": "5-1", + "data":{ + "name":"etc", + "size":"100kb", + "type":"Link" + } + }, + { + "key": "5-2", + "data":{ + "name":"var", + "size":"100kb", + "type":"Link" + } + } + ] + }, + { + "key": "6", + "data":{ + "name":"Other", + "size":"5kb", + "type":"Folder" + }, + "children":[ + { + "key": "6-0", + "data":{ + "name":"todo.txt", + "size":"3kb", + "type":"Text" + } + }, + { + "key": "6-1", + "data":{ + "name":"logo.png", + "size":"2kb", + "type":"Picture" + } + } + ] + }, + { + "key": "7", + "data":{ + "name":"Pictures", + "size":"150kb", + "type":"Folder" + }, + "children":[ + { + "key": "7-0", + "data":{ + "name":"barcelona.jpg", + "size":"90kb", + "type":"Picture" + } + }, + { + "key": "7-1", + "data":{ + "name":"primeng.png", + "size":"30kb", + "type":"Picture" + } + }, + { + "key": "7-2", + "data":{ + "name":"prime.jpg", + "size":"30kb", + "type":"Picture" + } + } + ] + }, + { + "key": "8", + "data":{ + "name":"Videos", + "size":"1500kb", + "type":"Folder" + }, + "children":[ + { + "key": "8-0", + "data":{ + "name":"primefaces.mkv", + "size":"1000kb", + "type":"Video" + } + }, + { + "key": "8-1", + "data":{ + "name":"intro.avi", + "size":"500kb", + "type":"Video" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/AppMenu.vue b/src/AppMenu.vue index bec339394..4b72e633e 100644 --- a/src/AppMenu.vue +++ b/src/AppMenu.vue @@ -62,6 +62,7 @@ ● Org Chart ● Paginator ● PickList + ● Tree diff --git a/src/components/tree/Tree.vue b/src/components/tree/Tree.vue new file mode 100644 index 000000000..263d2f088 --- /dev/null +++ b/src/components/tree/Tree.vue @@ -0,0 +1,194 @@ + + + + + \ No newline at end of file diff --git a/src/components/tree/TreeNode.vue b/src/components/tree/TreeNode.vue new file mode 100644 index 000000000..cdaee12ab --- /dev/null +++ b/src/components/tree/TreeNode.vue @@ -0,0 +1,62 @@ + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 7930727f6..e558784cf 100644 --- a/src/main.js +++ b/src/main.js @@ -44,12 +44,13 @@ import Slider from './components/slider/Slider'; import Sidebar from './components/sidebar/Sidebar'; import SplitButton from './components/splitbutton/SplitButton'; import Spinner from './components/spinner/Spinner'; +import TabView from './components/tabview/TabView'; +import TabPanel from './components/tabpanel/TabPanel'; import Textarea from './components/textarea/Textarea'; +import Tree from './components/tree/Tree'; import Toast from './components/toast/Toast'; import ToastService from './components/toast/ToastService'; import Toolbar from './components/toolbar/Toolbar'; -import TabView from './components/tabview/TabView'; -import TabPanel from './components/tabpanel/TabPanel'; import ToggleButton from './components/togglebutton/ToggleButton'; import TriStateCheckbox from './components/tristatecheckbox/TriStateCheckbox'; import ValidationMessage from './components/validationmessage/ValidationMessage'; @@ -117,6 +118,7 @@ Vue.component('Textarea', Textarea); Vue.component('Toast', Toast); Vue.component('Toolbar', Toolbar); Vue.component('ToggleButton', ToggleButton); +Vue.component('Tree', Tree); Vue.component('TriStateCheckbox', TriStateCheckbox); Vue.component('ValidationMessage', ValidationMessage); diff --git a/src/router.js b/src/router.js index 7c5d6d3d2..fa8680d94 100644 --- a/src/router.js +++ b/src/router.js @@ -355,6 +355,11 @@ export default new Router({ path: '/toolbar', name: 'toolbar', component: () => import('./views/toolbar/ToolbarDemo.vue') + }, + { + path: '/tree', + name: 'tree', + component: () => import('./views/tree/TreeDemo.vue') }, { path: '/tristatecheckbox', diff --git a/src/service/NodeService.js b/src/service/NodeService.js new file mode 100644 index 000000000..091b0482f --- /dev/null +++ b/src/service/NodeService.js @@ -0,0 +1,15 @@ +import axios from 'axios'; + +export default class NodeService { + + getTreeTableNodes() { + return axios.get('demo/data/treetablenodes.json') + .then(res => res.data.root); + } + + getTreeNodes() { + return axios.get('demo/data/treenodes.json') + .then(res => res.data.root); + } + +} \ No newline at end of file diff --git a/src/views/tree/TreeDemo.vue b/src/views/tree/TreeDemo.vue new file mode 100644 index 000000000..f86bc62e2 --- /dev/null +++ b/src/views/tree/TreeDemo.vue @@ -0,0 +1,38 @@ + + \ No newline at end of file diff --git a/src/views/tree/TreeDoc.vue b/src/views/tree/TreeDoc.vue new file mode 100644 index 000000000..97b1811c7 --- /dev/null +++ b/src/views/tree/TreeDoc.vue @@ -0,0 +1,150 @@ + \ No newline at end of file