]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ModuleBuilder/tpls/MBModule/fields.tpl
Release 6.4.0
[Github/sugarcrm.git] / modules / ModuleBuilder / tpls / MBModule / fields.tpl
1 {*
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5  * 
6  * This program is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  * 
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
16  * details.
17  * 
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  * 
23  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25  * 
26  * The interactive user interfaces in modified source and object code versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  * 
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the "Powered by
32  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33  * technical reasons, the Appropriate Legal Notices must display the words
34  * "Powered by SugarCRM".
35  ********************************************************************************/
36
37 *}
38
39
40 <div id='studiofields'>
41 <input type='button' name='addfieldbtn' value='{$mod_strings.LBL_BTN_ADDFIELD}' class='button' onclick='ModuleBuilder.moduleLoadField("");'>&nbsp;
42 {if $editLabelsMb=='1'}
43 <input type='button' name='addfieldbtn' value='{$mod_strings.LBL_BTN_EDLABELS}' class='button' onclick='ModuleBuilder.moduleLoadLabels("mb");'>
44 {else}
45 <input type='button' name='addfieldbtn' value='{$mod_strings.LBL_BTN_EDLABELS}' class='button' onclick='ModuleBuilder.moduleLoadLabels("studio");'>
46 {/if}
47 </div>
48
49 <br>
50
51 <div id="field_table"></div>
52 {if $studio}{sugar_translate label='LBL_CUSTOM_FIELDS' module='ModuleBuilder'}</h3>{/if}
53
54 <script type="text/javascript">
55
56 var customFieldsData = {$customFieldsData};
57
58 {literal}
59 //create sortName function to apply custom sorting for the name column which contains HTML
60 var sortName = function(a, b, desc)
61 {
62     var comp = YAHOO.util.Sort.compare;
63     var aString = a.getData('name').replace(/<[^>]*>/g, "");
64     var bString = b.getData('name').replace(/<[^>]*>/g, "");
65     return comp(aString, bString, desc);
66 };
67
68 var editFieldFormatter = function(elCell, oRecord, oColumn, oData)
69 {
70   var label = customFieldsData[oData] ? '* ' + oData : oData;
71   elCell.innerHTML = "<a class='mbLBLL' href='javascript:void(0)' id='" + oData + "' onclick='ModuleBuilder.moduleLoadField(\"" + oData + "\");'>" + label + "</a>";
72 };
73
74 var labelFormatter = function(elCell, oRecord, oColumn, oData)
75 {
76    elCell.innerHTML = oData.replace(/\:\s*?$/, '');
77 };
78
79 var myColumnDefs = [
80     {key:"name", label:SUGAR.language.get("ModuleBuilder", "LBL_NAME"),sortable:true, resizeable:true, formatter:"editFieldFormatter", width:150, sortOptions:{sortFunction:sortName, defaultDir:YAHOO.widget.DataTable.CLASS_ASC}},
81     {key:"label", label:SUGAR.language.get("ModuleBuilder", "LBL_DROPDOWN_ITEM_LABEL"),sortable:true, resizeable:true, formatter:"labelFormatter", width:200},
82     {key:"type", label:SUGAR.language.get("ModuleBuilder", "LBL_DATA_TYPE"),sortable:true,resizeable:true, width:125}
83 ];
84 {/literal}
85
86 var myDataSource = new YAHOO.util.DataSource({$fieldsData});
87 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
88 {literal}
89 myDataSource.responseSchema = {fields: ["label","name","type"]};
90 YAHOO.widget.DataTable.Formatter.editFieldFormatter = editFieldFormatter;
91 YAHOO.widget.DataTable.Formatter.labelFormatter = labelFormatter;
92
93 var fieldsTable = new YAHOO.widget.ScrollingDataTable("field_table", myColumnDefs, myDataSource);
94
95 fieldsTable.doBeforeSortColumn = function(column, sortDirection)
96 {
97     var url = 'index.php?module=ModuleBuilder&action=savetablesort&column=' + column.getKey() + '&direction=' + sortDirection;
98     YUI().use('io', function (Y) {
99         Y.io(url, {
100             method: 'POST',
101             on: {
102                 success: function(id, data) {},
103                 failure: function(id, data) {}
104             }
105         });
106     });
107     return true;
108 };
109
110
111 fieldsTable.subscribe("rowMouseoverEvent", fieldsTable.onEventHighlightRow);
112 fieldsTable.subscribe("rowMouseoutEvent", fieldsTable.onEventUnhighlightRow);
113 fieldsTable.subscribe("rowClickEvent", function(args) {
114     var field = this.getRecord(args.target).getData();
115     ModuleBuilder.moduleLoadField(field.name);
116 });
117
118 fieldsTable.render("#field_table");
119 {/literal}
120
121 {if !empty($sortPreferences)}
122 pref = {$sortPreferences};
123 sortDirection = (pref.direction == 'ASC') ? YAHOO.widget.DataTable.CLASS_ASC : YAHOO.widget.DataTable.CLASS_DESC;
124 fieldsTable.sortColumn(fieldsTable.getColumn(pref.key), sortDirection);
125 {/if}
126
127 ModuleBuilder.module = '{$module->name}';
128 ModuleBuilder.MBpackage = '{$package->name}';
129 ModuleBuilder.helpRegisterByID('studiofields', 'input');
130 {if $package->name != 'studio'}
131 ModuleBuilder.helpSetup('fieldsEditor','mbDefault');
132 {else}
133 ModuleBuilder.helpSetup('fieldsEditor','default');
134 {/if}
135 </script>
136
137 <style>
138 {literal}
139 a.mbLBLL {
140         text-decoration:none;
141         font-weight:normal;
142         color:black;
143 }
144
145 #field_table {
146     text-align:left;
147 }
148 {/literal}
149 </style>