...
Thai |
---|
ในบทช่วยสอนนี้เราจะทำตามคำแนะนำ guideline of developing a plugin เพื่อพัฒนาปลั๊กอินเมนู Userview UI เมนู Gantt Chart โปรดอ้างอิงถึง How to develop a Bean Shell Hash Variable สำหรับขั้นตอนรายละเอียดเพิ่มเติม |
1. What is the problem?
Thai |
---|
อะไรคือปัญหา? |
I want to display collected form data in a gantt chart view. I can choose to use Jasper Reports Userview Menu to achieve it but It does not look nice and lack of interactive control. Then, I found this Jquery Gantt Chart library developed by Tait Brown under MIT license which look nicer and work better than viewing a gantt chart using Jasper Report. I want to use it to display my collected form data.
Thai |
---|
ฉันต้องการแสดงข้อมูลแบบฟอร์มที่เก็บรวบรวมในมุมมองแผนภูมิแกนต์ ฉันสามารถเลือกที่จะใช้ Jasper Reports Userview Menu เพื่อให้บรรลุ แต่ไม่ได้ดูดีและขาดการควบคุมแบบอินเตอร์แอคทีฟ จากนั้นฉันได้พบห้องสมุด Jquery Gantt Chart ที่พัฒนาโดย Tait Brown ภายใต้ใบอนุญาต MIT ซึ่งดูดีกว่าและทำงานได้ดีกว่าการดูแผนภูมิ gantt โดยใช้ Jasper Report ฉันต้องการใช้มันเพื่อแสดงข้อมูลในแบบฟอร์มที่รวบรวมไว้ของฉัน |
2. What is your idea to solve the problem?
Thai |
---|
ความคิดของคุณในการแก้ปัญหาคืออะไร? |
We can develop a Userview Menu Plugin to use the Jquery Gantt Chart library to display the collected form data.
Thai |
---|
เราสามารถพัฒนา Userview Menu Plugin เพื่อใช้ไลบรารี Jquery Gantt Chart เพื่อแสดงข้อมูลแบบฟอร์มที่รวบรวมได้ |
3. What is the input needed for your plugin?
Thai |
---|
การป้อนข้อมูลที่จำเป็นสำหรับปลั๊กอินของคุณคืออะไร? |
To develop a Gantt Chart Userview Menu plugin, we can consider to provide the following as input.
...
Data Binder : We can reuse datalist binder to retrieve data
Thai Data Binder: เราสามารถนำ Data Binder Binder กลับมาใช้เพื่อดึงข้อมูล
Data Mapping : Map the retrieve data from datalist binder to the data format of the library
Thai การแมปข้อมูล: แม็พข้อมูลที่ดึงจากตัวยึดข้อมูลไปยังรูปแบบข้อมูลของไลบรารี
Formatting options : Options to format and customise the gantt chart.
Thai ตัวเลือกการจัดรูปแบบ: ตัวเลือกในการจัดรูปแบบและปรับแต่งแผนภูมิแกนต์
4. What is the output and expected outcome of your plugin?
Thai |
---|
ผลลัพธ์และผลลัพธ์ที่คาดหวังของปลั๊กอินของคุณคืออะไร? |
By referring to the library demo, we can quickly come out a static HTML page like the picture below. As this is a Joget plugin tutorial, we will not go into the detail on coding the static HTML page. You can refer to static.zip. We will expect our userview page can display our collected data as the static HTML page.
Thai |
---|
ด้วยการอ้างอิงถึง library demo เราสามารถออกหน้า HTML แบบคงที่ได้อย่างรวดเร็วเช่นภาพด้านล่าง เนื่องจากนี่คือการสอนปลั๊กอิน Joget เราจะไม่เข้าไปดูรายละเอียดเกี่ยวกับการเขียนโค้ดหน้า HTML แบบคงที่ คุณสามารถอ้างถึง static.zip เราคาดว่าหน้า userview ของเราสามารถแสดงข้อมูลที่รวบรวมได้เป็นหน้า HTML คงที่ |
5. Is there any resources/API that can be reuse?
Thai |
---|
มีทรัพยากร / API ที่สามารถนำกลับมาใช้ใหม่ได้หรือไม่? |
If you are not familiar with FreeMaker syntax, you should have a look on their document before proceed.
Thai |
---|
หากคุณไม่คุ้นเคยกับไวยากรณ์ของ FreeMaker คุณควรตรวจสอบเอกสารของพวกเขาก่อนดำเนินการต่อ |
6. Prepare your development environment
Thai |
---|
เตรียมสภาพแวดล้อมการพัฒนาของคุณ |
We need to always have our Joget Workflow Source Code ready and builded by following this guideline.
The following of this tutorial is prepared with a Macbook Pro and Joget Source Code version 5.0.0. Please refer to Guideline for developing Developing a pluginPlugin for other platform command.
...
Thai |
---|
เราจำเป็นต้องให้ซอร์สโค้ด Joget Workflow ของเราพร้อมและสร้างโดยปฏิบัติตาม this guideline บทช่วยสอนต่อไปนี้จัดทำขึ้นด้วย Macbook Pro และ Joget Source Code เวอร์ชั่น 5.0.0 โปรดอ้างอิง Guideline for developing Developing a pluginPlugin สำหรับคำสั่งแพลตฟอร์มอื่น ๆ ให้กล่าวว่าไดเรกทอรีโฟลเดอร์ของเราดังต่อไปนี้ |
...
Thai |
---|
เราควรได้รับข้อความ "BUILD SUCCESS" ที่ปรากฏในเครื่องของเราและโฟลเดอร์ "gantt_chart_menu" ที่สร้างขึ้นในโฟลเดอร์ "ปลั๊กอิน" เปิดโครงการ maven ด้วย IDE ที่คุณชื่นชอบ ฉันจะใช้ NetBeans |
7. Just code it!
Thai |
---|
เพียงแค่รหัส! |
a. Extending the abstract class of a plugin type
Thai |
---|
การขยายคลาสนามธรรมของประเภทปลั๊กอิน |
Create a "GanttChartMenu" class under "org.joget.tutorial" package. Then, extend the class with org.joget.apps.userview.model.UserviewMenu abstract class. Please refer to Userview Menu Plugin.
Thai |
---|
สร้างคลาส "GanttChartMenu" ใต้แพ็คเกจ "org.joget.tutorial" จากนั้นขยายคลาสด้วย org.joget.apps.userview.model.UserviewMenu คลาสนามธรรม โปรดดูที่ Userview Menu Plugin |
b. Implement all the abstract methods
Thai |
---|
ใช้วิธีนามธรรมทั้งหมด |
As usual, we have to implement all the abstract methods. We will using AppPluginUtil.getMessage method to support i18n and using constant variable MESSAGE_PATH for message resource bundle directory.
...
Now, for testing purpose, we can skip to c. Manage the dependency libraries of your plugin, d. Make your plugin internationalization (i18n) ready, e. Register your plugin to Felix Framework and f. Build it and testing then continue the below after testing it. You will get something similar to below in your userview.
Thai |
---|
ตอนนี้เพื่อการทดสอบเราสามารถข้ามไปที่ c. Manage the dependency libraries of your plugin, d. Make your plugin internationalization (i18n) ready, e. Register your plugin to Felix Framework และ f. Build it and testing จากนั้นทำต่อไปด้านล่างหลังจากทดสอบ คุณจะได้รับสิ่งที่คล้ายกับด้านล่างในมุมมองของเรา |
...
Code Block |
---|
<link href="${request.contextPath}/plugin/org.joget.tutorial.GanttChartMenu/lib/jquery.gantt/css/style.css" rel="stylesheet" type="text/css" /> <script src="${request.contextPath}/plugin/org.joget.tutorial.GanttChartMenu/lib/jquery.gantt/js/jquery.fn.gantt.min.js"></script> <div class="gantt_chart_menu_body"> <#if element.properties.title?? ><h3>${element.properties.title!}</h3></#if> ${element.properties.customHeader!} <div class="gantt"></div> <script> $(function() { "use strict"; $(".gantt").gantt({ source: ${data!}, months: [@@userview.ganttChart.months.label@@], dow: [@@userview.ganttChart.dow.label@@], itemsPerPage: ${element.properties.itemsPerPage!}, navigate: "${element.properties.navigate!}", scale: "${element.properties.scale!}", maxScale: "${element.properties.maxScale!}", minScale: "${element.properties.minScale!}", waitText: "@@userview.ganttChart.waitText@@", onItemClick: function (data) { ${element.properties.onItemClick!} }, onAddClick: function(datetime, rowId) { ${element.properties.onAddClick!} }, onRender: function() { ${element.properties.onRender!} }, useCookie: <#if element.properties.useCookie! == 'true'>true<#else>false</#if>, scrollToToday: <#if element.properties.scrollToToday! == 'true'>true<#else>false</#if> }); }); </script> ${element.properties.customFooter!} </div> |
c. Manage the dependency libraries of your plugin
Thai |
---|
จัดการไลบรารีการพึ่งพาของปลั๊กอินของคุณ |
Our plugin is using some libraries, we have to add all of them to our POM file.
...
Code Block | ||
---|---|---|
| ||
<!-- Change plugin specific dependencies here --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20080701</version> </dependency> <dependency> <groupId>displaytag</groupId> <artifactId>displaytag</artifactId> <version>1.2</version> <exclusions> <exclusion> <artifactId>slf4j-api</artifactId> <groupId>org.slf4j</groupId> </exclusion> <exclusion> <artifactId>jcl104-over-slf4j</artifactId> <groupId>org.slf4j</groupId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> </exclusions> </dependency> <!-- End change plugin specific dependencies here --> |
d. Make your plugin internationalization (i18n) ready
Thai |
---|
เตรียมปลั๊กอินสากลให้พร้อม (i18n) |
We are using i18n message key in getLabel and getDescription method. We also used i18n message key in our properties options definition as well. So, we will need to create a message resource bundle properties file for our plugin.
...
Code Block |
---|
org.joget.tutorial.GanttChartMenu.pluginLabel=Gantt Chart Menu org.joget.tutorial.GanttChartMenu.pluginDesc=Display data in a Gantt Chart view userview.ganttchart.config=Configure Gantt Chart Menu userview.ganttchart.customId=Custom ID userview.ganttchart.invalidId=Only alpha-numeric and underscore characters allowed userview.ganttchart.label=Label userview.ganttchart.title=Page Title userview.ganttchart.binder=Data Binder userview.ganttchart.mapping=Column to Data Mappings userview.ganttchart.mapping.category=Category (column ID) userview.ganttchart.mapping.task=Task (column ID) userview.ganttchart.mapping.activity=Activity (column ID) userview.ganttchart.mapping.fromDate=Activity From Date (column ID) userview.ganttchart.mapping.toDate=Activity To Date (column ID) userview.ganttchart.mapping.dateFormat=Date format for Activity From/To Date userview.ganttchart.mapping.taskId=Task Id (column ID) userview.ganttchart.mapping.cssClass=Status (column ID, use as CSS class for styling) userview.ganttchart.advanced=Advanced userview.ganttchart.itemsPerPage=Item pre page userview.ganttchart.navigate=Navigator userview.ganttchart.navigate.buttons=Buttons userview.ganttchart.navigate.scroll=Scroll userview.ganttchart.scale=Default Scale userview.ganttchart.scale.hours=Hours userview.ganttchart.scale.days=Days userview.ganttchart.scale.weeks=Weeks userview.ganttchart.scale.months=Months userview.ganttchart.maxScale=Maximum Scale userview.ganttchart.minScale=Minimum Scale userview.ganttchart.useCookie=Use cookie for storing chart states userview.ganttchart.scrollToToday=Auto scroll to today after rendered userview.ganttchart.onItemClick=On Item Clicked Event (Javascript) userview.ganttchart.onAddClick=On Empty Space Clicked Event (Javascript) userview.ganttchart.onRender=On Rendered Event (Javascript) userview.ganttchart.customHeader=Custom Header (HTML) userview.ganttchart.customFooter=Custom Footer (HTML) userview.ganttChart.months.label="January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" userview.ganttChart.dow.label="S", "M", "T", "W", "T", "F", "S" userview.ganttChart.waitText=Loading... |
e. Register your plugin to Felix Framework
Thai |
---|
ลงทะเบียนปลั๊กอินของคุณไปที่ Felix Framework |
We will have to register our plugin class in Activator class (Auto generated in the same class package) to tell Felix Framework that this is a plugin.
...
Code Block | ||
---|---|---|
| ||
public void start(BundleContext context) { registrationList = new ArrayList<ServiceRegistration>(); //Register plugin here registrationList.add(context.registerService(GanttChartMenu.class.getName(), new GanttChartMenu(), null)); } |
f. Build it and testing
Thai |
---|
สร้างและทดสอบ |
Let build our plugin. Once the building process is done, we will found a "gantt_chart_menu-5.0.0.jar" file is created under "gantt_chart_menu/target" directory.
...
Thai |
---|
จากนั้นให้อัปโหลด jar ปลั๊กอินไปที่ Manage Plugins หลังจากอัปโหลดไฟล์ jar ตรวจสอบอีกครั้งว่าปลั๊กอินถูกอัปโหลดและเปิดใช้งานอย่างถูกต้อง |
Open a userview, you will see the new plugin is added under "Marketplace". Drag it to one of your Userview UI Category.
Thai |
---|
เปิด userview คุณจะเห็นปลั๊กอินใหม่ถูกเพิ่มภายใต้ "Marketplace" ลากไปยังหมวดหมู่ Userview UI ของคุณ |
Edit the properties of the Gantt Chart Menu.
Thai |
---|
แก้ไขคุณสมบัติของเมนูแผนภูมิแกนต์ |
I selected "Form Data Binder" as "Data Binder" for testing. Fill all the mappings to corresponding Field Id/Column Id.
Thai |
---|
ฉันเลือก "Form Data Binder" เป็น "Data Binder" สำหรับการทดสอบ กรอกข้อมูลการแมปทั้งหมดให้สอดคล้องกับฟิลด์รหัส / หมายเลขคอลัมน์ |
Configure binder.
Thai |
---|
กำหนดค่า binder |
Advanced setting to configure the gantt chart.
Thai |
---|
การตั้งค่าขั้นสูงเพื่อกำหนดค่าแผนภูมิแกนต์ |
Writing some css styling in "Custom Footer (HTML)" option to give different colors for different status.
...
The end result.
Thai |
---|
ผลลัพธ์ที่ได้ |
8. Take a step further, share it or sell it
Thai |
---|
ก้าวไปอีกขั้นแบ่งปันหรือขายมัน |
You can download the source code from gantt_chart_menu.zip.
...