เราสามารถเข้าสู่โปแกรม fixed asset management system ได้จาก https://localhost:8443/assetmaint ได้ด้วย เป็นอีกหน้า interface ที่ไม่เหมือนกันจากการลิงค์จาก https://localhost:8443/accounting ที่ต้องกด menu ย่อยไปที่ fixed asset ก็จะเห็นหน้า list ของ fixed asset ที่มีในระบบ
จากการศึกษาค้นคว้า (เหมือนทำมานานแล้ว ^ ^) พบว่า fixed asset management ระบบใหม่ที่ยังคงเป็น special purpose สำหรับ OFBiz นั้น extend มาจากระบบ accounting ซึ่งมีการทำงานของ fixed asset management อยู่แล้วเป็น module ย่อย เนื่องจากว่าในการทำกระบวนการทางด้านบัญชีนั้นต้องมีการจัดการ asset ด้วย
แต่ ก็ยังคงไม่แน่ใจว่า มีอะไรเพิ่มมาจากระบบ asset เดิมหรือไม่ หรือเพียง extend interface ออกมาให้ใช้งานได้ง่ายขึ้น เพราะเท่าที่เห็นก็ใช้พวก service และอะไรต่อมิอะไรจากระบบ accounting ทั้งนั้น จะถามว่า ระบบ asset ฉบับใหม่ที่ทำขึ้น เพื่อช่วยในการคำนวณ depreciation ก็ไม่ใช่อีก เพราะทั้งระบบ asset ใน accounting และระบบ asset ที่ยังเป็น version special purpose ต่างก็ยังไม่มีการช่วยคำนวณ depreciation หรือ amortization ใดๆ ทั้งสิ้น
ตอนนี้เลยสรุปกับตัวเองว่า จะแกะ asset management ในเวอร์ชัน special purpose ตัวใหม่นี้ก่อน แล้วค่อยกลับไปดู asset management ในเวอร์ชั่นที่เป็น sub module ของ accounting เพราะท่าทางฝั่ง accounting จะวุ่นวายกับเรื่องอื่นๆ ด้วยเยอะเกินไป
หลังจากเข้า https://localhost:8443/assetmaint แล้วก็จะเห็นเมนูหลักอยู่ 3 เมนู คือ Equipments, Maintenance และ Warehouse โดยหากเรา find equipments ก็จะได้ equipments ที่โชว์เหมือนๆ กับตอนที่เรานำเข้าจากระบบ accounting แต่สำหรับ Warehouse นี่กำลังสงสัยอยู่ ว่าทำไมโชว์แต่ facility ที่เป็น WebStoreWarehouse ก็ไม่รู้ เพราะจริงๆ มี facility หลายอันที่นำเข้าไปใหม่ หรืออาจจะเป็นหลักการบัญชีที่คิดว่า Warehouse เป็นเฉพาะ WebStoreWarehouse หรือจริงๆ ระบบอาจจะกล่าวถึงเฉพาะ Warehouse ที่ใหญ่ที่สุดครอบตัวอื่นๆ
ก่อนอื่น ก็ต้องเข้าไปดูใน controller.xml ว่า หน้า main เรียกไปไหนกันหนอ? จาก view-mapping จะเห็นได้ว่า
CODE
<view-map name=”main” type=”screen” page=”component://assetmaint/widget/FixedAssetScreens.xml#FindFixedAssets”/>
หน้า main โดนเรียกไปที่ FixedAssetScreens.xml ไปดูที่ screen ชื่อ FindFixedAssets แสดงว่าหน้านี้จะแสดงหน้าค้นหา equipments มาให้เราเลย
CODE
<!–FindFixedAssets in FixedAssetScreens.xml–>
<screen name=”FindFixedAssets”>
<section>
<actions>
<set field=”titleProperty” value=”AccountingFindFixedAsset” />
<set field=”labelTitleProperty” value=”AccountingFindFixedAsset” />
</actions>
<widgets>
<decorator-screen name=”CommonFixedAssetDecorator” location=”${parameters.mainDecoratorLocation}”>
<decorator-section name=”body”>
<container style=”screenlet”>
<container style=”screenlet-header”>
<label style=”boxhead”>${uiLabelMap.AccountingFixedAssets}</label>
</container>
<container style=”screenlet-body”>
<include-form name=”FindFixedAssets” location=”component://assetmaint/widget/forms/FixedAssetForms.xml” />
</container>
</container>
<container style=”button-bar”>
<link target=”EditFixedAsset” text=”${uiLabelMap.AccountingNewFixedAsset}” style=”buttontext” />
</container>
<include-form name=”ListFixedAssets” location=”component://assetmaint/widget/forms/FixedAssetForms.xml” />
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
ใน ส่วนของ <widget></widget> เหมือนเป็นการจัดว่าในหน้านี้มีอะไรบ้าง
decorator-screen คือ เป็นนำ screen มา render เ้ข้ากับหน้า มีประโยชน์กับการ reuse คือจะเปลี่ยนแปลงไปเฉพาะ decorator เล็กๆ นี้เท่านั้นเวลาเกิด action โดยจะเห็นว่า decorator-screen นี้เรียกไปที่ CommonFixedAssetDecorator ซึ่งอยู่ใน folder widget เช่นเดียวกัน แต่เป็นไฟล์ CommonScreens.xml โดยเรียกไปยัง ${parameters.mainDecoratorLocation} ซึ่งตอนนี้กำลังไม่เข้าใจว่ารับ parameter มาจากที่ไหน ไฟล์นี้มีหน้าตาดังต่อไปนี
CODE
<screen name=”CommonFixedAssetDecorator”>
<section>
<actions>
<set field=”headerItem” value=”ListFixedAssets”/>
</actions>
<widgets>
<decorator-screen name=”main-decorator” location=”${parameters.mainDecoratorLocation}”>
<decorator-section name=”body”>
<section>
<!– do check for ACCOUNTING, _VIEW permission –>
<condition>
<if-has-permission permission=”ACCOUNTING” action=”_VIEW”/>
</condition>
<widgets>
<section>
<condition><not><if-empty field-name=”fixedAssetId”/></not></condition>
<widgets>
<include-menu name=”FixedAssetTabBar” location=”component://accounting/widget/Menus.xml”/>
<label style=”head1″ text=”${uiLabelMap.${labelTitleProperty}} ${uiLabelMap.CommonFor}: ${fixedAsset.fixedAssetName} [${uiLabelMap.CommonId}:${fixedAssetId}] ${${extraFunctionName}}”/>
</widgets>
</section>
</widgets>
<fail-widgets>
<label style=”head3″ text=”${uiLabelMap.AcccountingViewPermissionError}”/>
</fail-widgets>
</section>
<decorator-section-include name=”body”/>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
ใน ส่วน action คือการกำหนดใน Screen นี้ว่าจะกำหนดให้อะไร มีค่าเป็นอะไร
CODE
<actions>
<set field=”headerItem” value=”ListFixedAssets”/>
</actions>
อัน นี้ก็คือให้ field headerItem เป็น ListFixedAssets โดยค่า value ตรงนี้น่าจะเป็นชื่อ screen ที่ชื่อ ListFixedAssets ดังนั้นความหมายของ CommonDecorator.xml ยังไม่เข้าใจความหมายของมันครับว่าคืออะไร
โดย จาก CommonDecorator.xml จะเห็นว่ามันจะไปเรียก main-decorator อีกที โดย main-decorator ก็อยู่ในไฟล์ CommonDecorator.xml เหมือนกัน มีหน้าตาเป็นดังนี้ค่ะ
CODE
<screen name=”main-decorator”>
<section>
<actions>
<property-map resource=”AccountingUiLabels” map-name=”uiLabelMap” global=”true”/>
<property-map resource=”PartyUiLabels” map-name=”uiLabelMap” global=”true”/>
<property-map resource=”ProductUiLabels” map-name=”uiLabelMap” global=”true”/>
<property-map resource=”WorkEffortUiLabels” map-name=”uiLabelMap” global=”true”/>
<property-map resource=”CommonUiLabels” map-name=”uiLabelMap” global=”true”/>
<set field=”layoutSettings.companyName” from-field=”uiLabelMap.AccountingCompanyName” global=”true”/>
<set field=”layoutSettings.companySubtitle” from-field=”uiLabelMap.AccountingCompanySubtitle” global=”true”/>
<set field=”layoutSettings.headerImageUrl” value=”/images/ofbiz_logo.jpg” global=”true”/>
<set field=”activeApp” value=”accounting” global=”true”/>
<set field=”appheaderTemplate” value=”component://accounting/webapp/accounting/includes/appheader.ftl” global=”true”/>
</actions>
<widgets>
<include-screen name=”GlobalDecorator” location=”component://common/widget/CommonScreens.xml”/>
</widgets>
</section>
</screen
>
มี Action มากมายใน main-decorator นะครับ
CODE
<property-map resource=”AccountingUiLabels” map-name=”uiLabelMap” global=”true”/>
อัน นี้เข้าใจว่า มันน่าจะไป map ไฟล์ .properties ที่เป็น resource ที่ชื่อว่า AccountingUiLabels โดยเดาว่าชื่อนี้น่าจะถูกตั้งโดย global เป็น resource ที่เรียกจากที่ใดก็ได้ โดยไฟล์นี้จะอยู่ใน config ของ Accounting ดังนั้นจะเห็นว่า main-decorator ตัวนี้ไปเรียก resource มาจาก 5 ที่ คือ Accounting Party Product Workeffort และ common โดย common ไม่ได้เป็น application ใด เป็นส่วนหนึ่งของ framework
CODE
<set field=”layoutSettings.companyName” from-field=”uiLabelMap.AccountingCompanyName” global=”true”/>
field layoutSettings.companyName นี่ยังงง ว่าอะไร แต่ uiLabelMap.AccountingCompanyName เดาว่า ตะกี้เราได้ map resource จาก Accounting เป็น uiLabelMap แล้ว เมื่อไปดูค่า AccountingCompanyName=OFBiz: Accounting Manager แสดงว่ามัน set field ชื่อ layoutSettings.companyName ให้เป็นชื่อ OFBiz: Accounting Manager
CODE
<include-screen name=”GlobalDecorator” location=”component://common/widget/CommonScreens.xml”/>
อัน นี้ก็ include screen GlobalDecorator เข้ามา โดยบอกว่า screen นี้อยู่ที่ component://common/widget/CommonScreens.xml
CODE
<condition>
<if-has-permission permission=”ACCOUNTING” action=”_VIEW”/>
</condition>
อัน นี้เป็นการ เช็ค permission ครับ
CODE
<widgets>
<include-menu name=”FixedAssetTabBar” location=”component://accounting/widget/Menus.xml”/>
<label style=”head1″ text=”${uiLabelMap.${labelTitleProperty}} ${uiLabelMap.CommonFor}: ${fixedAsset.fixedAssetName} [${uiLabelMap.CommonId}:${fixedAssetId}] ${${extraFunctionName}}”/>
</widgets>
โค้ด ด้านบนเป็นโค๊ดที่เพิ่มเมนูบาร์น่ะครับ
CODE
<fail-widgets>
<label style=”head3″ text=”${uiLabelMap.AcccountingViewPermissionError}”/>
</fail-widgets>
อัน นี้คือ ถ้าการเข้า widets นี้มัน fail จากการไม่มี permission ต้องทำอย่างไร
กลับไปที่ FixedAssetScreens ตะกี้นะครับ แสดงว่าส่วน code ตรงนี้
CODE
<actions>
<set field=”titleProperty” value=”AccountingFindFixedAsset” />
<set field=”labelTitleProperty” value=”AccountingFindFixedAsset” />
</actions>
คือ set field ชื่อ titleProperty ให้มีค่าเป็นค่าเดียวกับ AccountingFindFixedAsset ซึ่งตะกี้จะได้รางๆ ไหมคครับว่า value ตรงนี้หาได้จาก folder config ซึ่งตอนนี้เรากำลังทำระบบ Assetmaint ก็เลยไปหา config ใน assetmaint ในไฟล์ AssetMaintUiLabels.properties เดาเอาว่าเป็น resource อันนี้ ก็เจอ AccountingFindFixedAsset = Find Equipments แต่ก็ยังสงสัยอยู่ดีว่า field titleProperty กะ labelTitleProperty มันอยู่ตรงไหน หากันเอานะครับ
เคยมีคนบอกไว้ว่า
container ก็คือ wrapper ที่ไว้จัดกลุ่ม widget
การทำงานภายในของมัน ก็คือเวลามัน render html มันจะ render
<div> block คร่อม widget ที่อยู่ข้างในมัน
ดู ส่วนนี้ของ FindFixedAsset Screen กัน
CODE
<decorator-section name=”body”>
<container style=”screenlet”>
<container style=”screenlet-header”>
<label style=”boxhead”>${uiLabelMap.AccountingFixedAssets}</label>
</container>
<container style=”screenlet-body”>
<include-form name=”FindFixedAssets” location=”component://assetmaint/widget/forms/FixedAssetForms.xml” />
</container>
</container>
เป็น ส่วนที่อยู่ภายใน container ตรงนี้เป็นการกำหนดส่วน body ของหน้า โดย header ของ body นี้มี style เป็น boxhead มีชื่อเป็น ${uiLabelMap.AccountingFixedAssets} = Equipments แว๊บกลับไปดู interface เห็นแล้วค่ะ boxhead คือหัวของ body เป็นสีน้ำเงิน และมีชื่อว่า Equipments จริงๆ
ในส่วน screenlet-body ให้แสดง form ชื่อ FindFixedAssets โดยอยู่ที่ component://assetmaint/widget/forms/FixedAssetForms.xml เราก็ไปหามา หน้าตา code เป็นดังนี้ครับ
CODE
<form name=”FindFixedAssets” type=”single” target=”findFixedAssets” title=”${uiLabelMap.AccountingFindFixedAssets}”>
<field name=”hideSearch”><hidden value=”Y”/></field>
<field name=”fixedAssetId” title=”${uiLabelMap.AccountingFixedAssetId}”><text-find default-option=”contains” ignore-case=”true”/></field>
<field name=”instanceOfProductId” title=”${uiLabelMap.AccountingInstanceOfProductId}”><text-find default-option=”contains” ignore-case=”true”/></field>
<field name=”classEnumId” title=”${uiLabelMap.AccountingFixedAssetClassEnumId}”>
<drop-down allow-empty=”true”>
<entity-options description=”${description}” entity-name=”Enumeration” key-field-name=”enumId”>
<entity-constraint name=”enumTypeId” operator=”equals” value=”FXAST_CLASS”/>
<entity-order-by field-name=”description”/>
</entity-options>
</drop-down>
</field>
<field name=”noConditionFind”><hidden value=”Y”/><!– if this isn’t there then with all fields empty no query will be done –></field>
<field name=”submitButton” title=”${uiLabelMap.CommonFind}”><submit button-type=”button”/></field>
</form>
อย่าง น้อยก็ได้มา 3 fields ที่เห็นคือ fixedAssetId มีชื่อเป็น {uiLabelMap.AccountingFixedAssetId} = Equipment Id และ Manufacturer Product Id และ Equipment Class โดย Equipment Class โดนกำหนดเป็น drop-down เป็น Enumeration ในส่วนนี้ยังไม่เข้าใจค่ะว่าเอาค่ามาจากไหน หาเจอแล้วจะมาบอกนะครับ
+555+
ต่อไปมาดูนี่กัน
CODE
<container style=”button-bar”>
<link target=”EditFixedAsset” text=”${uiLabelMap.AccountingNewFixedAsset}” style=”buttontext” />
</container>
<include-form name=”ListFixedAssets” location=”component://assetmaint/widget/forms/FixedAssetForms.xml” />
อัน นี้เพิ่มปุ่มขึ้นมา ลิงค์ไปที่ screen ชื่อ EditFixedAsset ในไฟล์ FixedAssetForms.xml และ include ด้วย form ของ ListFixedAssets
แต่ ก็ยังคงไม่แน่ใจว่า มีอะไรเพิ่มมาจากระบบ asset เดิมหรือไม่ หรือเพียง extend interface ออกมาให้ใช้งานได้ง่ายขึ้น เพราะเท่าที่เห็นก็ใช้พวก service และอะไรต่อมิอะไรจากระบบ accounting ทั้งนั้น จะถามว่า ระบบ asset ฉบับใหม่ที่ทำขึ้น เพื่อช่วยในการคำนวณ depreciation ก็ไม่ใช่อีก เพราะทั้งระบบ asset ใน accounting และระบบ asset ที่ยังเป็น version special purpose ต่างก็ยังไม่มีการช่วยคำนวณ depreciation หรือ amortization ใดๆ ทั้งสิ้น
ตอนนี้เลยสรุปกับตัวเองว่า จะแกะ asset management ในเวอร์ชัน special purpose ตัวใหม่นี้ก่อน แล้วค่อยกลับไปดู asset management ในเวอร์ชั่นที่เป็น sub module ของ accounting เพราะท่าทางฝั่ง accounting จะวุ่นวายกับเรื่องอื่นๆ ด้วยเยอะเกินไป
หลังจากเข้า https://localhost:8443/assetmaint แล้วก็จะเห็นเมนูหลักอยู่ 3 เมนู คือ Equipments, Maintenance และ Warehouse โดยหากเรา find equipments ก็จะได้ equipments ที่โชว์เหมือนๆ กับตอนที่เรานำเข้าจากระบบ accounting แต่สำหรับ Warehouse นี่กำลังสงสัยอยู่ ว่าทำไมโชว์แต่ facility ที่เป็น WebStoreWarehouse ก็ไม่รู้ เพราะจริงๆ มี facility หลายอันที่นำเข้าไปใหม่ หรืออาจจะเป็นหลักการบัญชีที่คิดว่า Warehouse เป็นเฉพาะ WebStoreWarehouse หรือจริงๆ ระบบอาจจะกล่าวถึงเฉพาะ Warehouse ที่ใหญ่ที่สุดครอบตัวอื่นๆ
ก่อนอื่น ก็ต้องเข้าไปดูใน controller.xml ว่า หน้า main เรียกไปไหนกันหนอ? จาก view-mapping จะเห็นได้ว่า
CODE
<view-map name=”main” type=”screen” page=”component://assetmaint/widget/FixedAssetScreens.xml#FindFixedAssets”/>
หน้า main โดนเรียกไปที่ FixedAssetScreens.xml ไปดูที่ screen ชื่อ FindFixedAssets แสดงว่าหน้านี้จะแสดงหน้าค้นหา equipments มาให้เราเลย
CODE
<!–FindFixedAssets in FixedAssetScreens.xml–>
<screen name=”FindFixedAssets”>
<section>
<actions>
<set field=”titleProperty” value=”AccountingFindFixedAsset” />
<set field=”labelTitleProperty” value=”AccountingFindFixedAsset” />
</actions>
<widgets>
<decorator-screen name=”CommonFixedAssetDecorator” location=”${parameters.mainDecoratorLocation}”>
<decorator-section name=”body”>
<container style=”screenlet”>
<container style=”screenlet-header”>
<label style=”boxhead”>${uiLabelMap.AccountingFixedAssets}</label>
</container>
<container style=”screenlet-body”>
<include-form name=”FindFixedAssets” location=”component://assetmaint/widget/forms/FixedAssetForms.xml” />
</container>
</container>
<container style=”button-bar”>
<link target=”EditFixedAsset” text=”${uiLabelMap.AccountingNewFixedAsset}” style=”buttontext” />
</container>
<include-form name=”ListFixedAssets” location=”component://assetmaint/widget/forms/FixedAssetForms.xml” />
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
ใน ส่วนของ <widget></widget> เหมือนเป็นการจัดว่าในหน้านี้มีอะไรบ้าง
decorator-screen คือ เป็นนำ screen มา render เ้ข้ากับหน้า มีประโยชน์กับการ reuse คือจะเปลี่ยนแปลงไปเฉพาะ decorator เล็กๆ นี้เท่านั้นเวลาเกิด action โดยจะเห็นว่า decorator-screen นี้เรียกไปที่ CommonFixedAssetDecorator ซึ่งอยู่ใน folder widget เช่นเดียวกัน แต่เป็นไฟล์ CommonScreens.xml โดยเรียกไปยัง ${parameters.mainDecoratorLocation} ซึ่งตอนนี้กำลังไม่เข้าใจว่ารับ parameter มาจากที่ไหน ไฟล์นี้มีหน้าตาดังต่อไปนี
CODE
<screen name=”CommonFixedAssetDecorator”>
<section>
<actions>
<set field=”headerItem” value=”ListFixedAssets”/>
</actions>
<widgets>
<decorator-screen name=”main-decorator” location=”${parameters.mainDecoratorLocation}”>
<decorator-section name=”body”>
<section>
<!– do check for ACCOUNTING, _VIEW permission –>
<condition>
<if-has-permission permission=”ACCOUNTING” action=”_VIEW”/>
</condition>
<widgets>
<section>
<condition><not><if-empty field-name=”fixedAssetId”/></not></condition>
<widgets>
<include-menu name=”FixedAssetTabBar” location=”component://accounting/widget/Menus.xml”/>
<label style=”head1″ text=”${uiLabelMap.${labelTitleProperty}} ${uiLabelMap.CommonFor}: ${fixedAsset.fixedAssetName} [${uiLabelMap.CommonId}:${fixedAssetId}] ${${extraFunctionName}}”/>
</widgets>
</section>
</widgets>
<fail-widgets>
<label style=”head3″ text=”${uiLabelMap.AcccountingViewPermissionError}”/>
</fail-widgets>
</section>
<decorator-section-include name=”body”/>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
ใน ส่วน action คือการกำหนดใน Screen นี้ว่าจะกำหนดให้อะไร มีค่าเป็นอะไร
CODE
<actions>
<set field=”headerItem” value=”ListFixedAssets”/>
</actions>
อัน นี้ก็คือให้ field headerItem เป็น ListFixedAssets โดยค่า value ตรงนี้น่าจะเป็นชื่อ screen ที่ชื่อ ListFixedAssets ดังนั้นความหมายของ CommonDecorator.xml ยังไม่เข้าใจความหมายของมันครับว่าคืออะไร
โดย จาก CommonDecorator.xml จะเห็นว่ามันจะไปเรียก main-decorator อีกที โดย main-decorator ก็อยู่ในไฟล์ CommonDecorator.xml เหมือนกัน มีหน้าตาเป็นดังนี้ค่ะ
CODE
<screen name=”main-decorator”>
<section>
<actions>
<property-map resource=”AccountingUiLabels” map-name=”uiLabelMap” global=”true”/>
<property-map resource=”PartyUiLabels” map-name=”uiLabelMap” global=”true”/>
<property-map resource=”ProductUiLabels” map-name=”uiLabelMap” global=”true”/>
<property-map resource=”WorkEffortUiLabels” map-name=”uiLabelMap” global=”true”/>
<property-map resource=”CommonUiLabels” map-name=”uiLabelMap” global=”true”/>
<set field=”layoutSettings.companyName” from-field=”uiLabelMap.AccountingCompanyName” global=”true”/>
<set field=”layoutSettings.companySubtitle” from-field=”uiLabelMap.AccountingCompanySubtitle” global=”true”/>
<set field=”layoutSettings.headerImageUrl” value=”/images/ofbiz_logo.jpg” global=”true”/>
<set field=”activeApp” value=”accounting” global=”true”/>
<set field=”appheaderTemplate” value=”component://accounting/webapp/accounting/includes/appheader.ftl” global=”true”/>
</actions>
<widgets>
<include-screen name=”GlobalDecorator” location=”component://common/widget/CommonScreens.xml”/>
</widgets>
</section>
</screen
>
มี Action มากมายใน main-decorator นะครับ
CODE
<property-map resource=”AccountingUiLabels” map-name=”uiLabelMap” global=”true”/>
อัน นี้เข้าใจว่า มันน่าจะไป map ไฟล์ .properties ที่เป็น resource ที่ชื่อว่า AccountingUiLabels โดยเดาว่าชื่อนี้น่าจะถูกตั้งโดย global เป็น resource ที่เรียกจากที่ใดก็ได้ โดยไฟล์นี้จะอยู่ใน config ของ Accounting ดังนั้นจะเห็นว่า main-decorator ตัวนี้ไปเรียก resource มาจาก 5 ที่ คือ Accounting Party Product Workeffort และ common โดย common ไม่ได้เป็น application ใด เป็นส่วนหนึ่งของ framework
CODE
<set field=”layoutSettings.companyName” from-field=”uiLabelMap.AccountingCompanyName” global=”true”/>
field layoutSettings.companyName นี่ยังงง ว่าอะไร แต่ uiLabelMap.AccountingCompanyName เดาว่า ตะกี้เราได้ map resource จาก Accounting เป็น uiLabelMap แล้ว เมื่อไปดูค่า AccountingCompanyName=OFBiz: Accounting Manager แสดงว่ามัน set field ชื่อ layoutSettings.companyName ให้เป็นชื่อ OFBiz: Accounting Manager
CODE
<include-screen name=”GlobalDecorator” location=”component://common/widget/CommonScreens.xml”/>
อัน นี้ก็ include screen GlobalDecorator เข้ามา โดยบอกว่า screen นี้อยู่ที่ component://common/widget/CommonScreens.xml
CODE
<condition>
<if-has-permission permission=”ACCOUNTING” action=”_VIEW”/>
</condition>
อัน นี้เป็นการ เช็ค permission ครับ
CODE
<widgets>
<include-menu name=”FixedAssetTabBar” location=”component://accounting/widget/Menus.xml”/>
<label style=”head1″ text=”${uiLabelMap.${labelTitleProperty}} ${uiLabelMap.CommonFor}: ${fixedAsset.fixedAssetName} [${uiLabelMap.CommonId}:${fixedAssetId}] ${${extraFunctionName}}”/>
</widgets>
โค้ด ด้านบนเป็นโค๊ดที่เพิ่มเมนูบาร์น่ะครับ
CODE
<fail-widgets>
<label style=”head3″ text=”${uiLabelMap.AcccountingViewPermissionError}”/>
</fail-widgets>
อัน นี้คือ ถ้าการเข้า widets นี้มัน fail จากการไม่มี permission ต้องทำอย่างไร
กลับไปที่ FixedAssetScreens ตะกี้นะครับ แสดงว่าส่วน code ตรงนี้
CODE
<actions>
<set field=”titleProperty” value=”AccountingFindFixedAsset” />
<set field=”labelTitleProperty” value=”AccountingFindFixedAsset” />
</actions>
คือ set field ชื่อ titleProperty ให้มีค่าเป็นค่าเดียวกับ AccountingFindFixedAsset ซึ่งตะกี้จะได้รางๆ ไหมคครับว่า value ตรงนี้หาได้จาก folder config ซึ่งตอนนี้เรากำลังทำระบบ Assetmaint ก็เลยไปหา config ใน assetmaint ในไฟล์ AssetMaintUiLabels.properties เดาเอาว่าเป็น resource อันนี้ ก็เจอ AccountingFindFixedAsset = Find Equipments แต่ก็ยังสงสัยอยู่ดีว่า field titleProperty กะ labelTitleProperty มันอยู่ตรงไหน หากันเอานะครับ
เคยมีคนบอกไว้ว่า
container ก็คือ wrapper ที่ไว้จัดกลุ่ม widget
การทำงานภายในของมัน ก็คือเวลามัน render html มันจะ render
<div> block คร่อม widget ที่อยู่ข้างในมัน
ดู ส่วนนี้ของ FindFixedAsset Screen กัน
CODE
<decorator-section name=”body”>
<container style=”screenlet”>
<container style=”screenlet-header”>
<label style=”boxhead”>${uiLabelMap.AccountingFixedAssets}</label>
</container>
<container style=”screenlet-body”>
<include-form name=”FindFixedAssets” location=”component://assetmaint/widget/forms/FixedAssetForms.xml” />
</container>
</container>
เป็น ส่วนที่อยู่ภายใน container ตรงนี้เป็นการกำหนดส่วน body ของหน้า โดย header ของ body นี้มี style เป็น boxhead มีชื่อเป็น ${uiLabelMap.AccountingFixedAssets} = Equipments แว๊บกลับไปดู interface เห็นแล้วค่ะ boxhead คือหัวของ body เป็นสีน้ำเงิน และมีชื่อว่า Equipments จริงๆ
ในส่วน screenlet-body ให้แสดง form ชื่อ FindFixedAssets โดยอยู่ที่ component://assetmaint/widget/forms/FixedAssetForms.xml เราก็ไปหามา หน้าตา code เป็นดังนี้ครับ
CODE
<form name=”FindFixedAssets” type=”single” target=”findFixedAssets” title=”${uiLabelMap.AccountingFindFixedAssets}”>
<field name=”hideSearch”><hidden value=”Y”/></field>
<field name=”fixedAssetId” title=”${uiLabelMap.AccountingFixedAssetId}”><text-find default-option=”contains” ignore-case=”true”/></field>
<field name=”instanceOfProductId” title=”${uiLabelMap.AccountingInstanceOfProductId}”><text-find default-option=”contains” ignore-case=”true”/></field>
<field name=”classEnumId” title=”${uiLabelMap.AccountingFixedAssetClassEnumId}”>
<drop-down allow-empty=”true”>
<entity-options description=”${description}” entity-name=”Enumeration” key-field-name=”enumId”>
<entity-constraint name=”enumTypeId” operator=”equals” value=”FXAST_CLASS”/>
<entity-order-by field-name=”description”/>
</entity-options>
</drop-down>
</field>
<field name=”noConditionFind”><hidden value=”Y”/><!– if this isn’t there then with all fields empty no query will be done –></field>
<field name=”submitButton” title=”${uiLabelMap.CommonFind}”><submit button-type=”button”/></field>
</form>
อย่าง น้อยก็ได้มา 3 fields ที่เห็นคือ fixedAssetId มีชื่อเป็น {uiLabelMap.AccountingFixedAssetId} = Equipment Id และ Manufacturer Product Id และ Equipment Class โดย Equipment Class โดนกำหนดเป็น drop-down เป็น Enumeration ในส่วนนี้ยังไม่เข้าใจค่ะว่าเอาค่ามาจากไหน หาเจอแล้วจะมาบอกนะครับ
+555+
ต่อไปมาดูนี่กัน
CODE
<container style=”button-bar”>
<link target=”EditFixedAsset” text=”${uiLabelMap.AccountingNewFixedAsset}” style=”buttontext” />
</container>
<include-form name=”ListFixedAssets” location=”component://assetmaint/widget/forms/FixedAssetForms.xml” />
อัน นี้เพิ่มปุ่มขึ้นมา ลิงค์ไปที่ screen ชื่อ EditFixedAsset ในไฟล์ FixedAssetForms.xml และ include ด้วย form ของ ListFixedAssets