2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
40 <div id='studiofields'>
41 <input type='button' name='addfieldbtn' value='{$mod_strings.LBL_BTN_ADDFIELD}' class='button' onclick='ModuleBuilder.moduleLoadField("");'>
42 {if $editLabelsMb=='1'}
43 <input type='button' name='addfieldbtn' value='{$mod_strings.LBL_BTN_EDLABELS}' class='button' onclick='ModuleBuilder.moduleLoadLabels("mb");'>
45 <input type='button' name='addfieldbtn' value='{$mod_strings.LBL_BTN_EDLABELS}' class='button' onclick='ModuleBuilder.moduleLoadLabels("studio");'>
51 <div id="field_table"></div>
52 {if $studio}{sugar_translate label='LBL_CUSTOM_FIELDS' module='ModuleBuilder'}</h3>{/if}
54 <script type="text/javascript">
56 var customFieldsData = {$customFieldsData};
59 //create sortName function to apply custom sorting for the name column which contains HTML
60 var sortName = function(a, b, desc)
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);
68 var editFieldFormatter = function(elCell, oRecord, oColumn, oData)
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>";
74 var labelFormatter = function(elCell, oRecord, oColumn, oData)
76 elCell.innerHTML = oData.replace(/\:\s*?$/, '');
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}
86 var myDataSource = new YAHOO.util.DataSource({$fieldsData});
87 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
89 myDataSource.responseSchema = {fields: ["label","name","type"]};
90 YAHOO.widget.DataTable.Formatter.editFieldFormatter = editFieldFormatter;
91 YAHOO.widget.DataTable.Formatter.labelFormatter = labelFormatter;
93 var fieldsTable = new YAHOO.widget.ScrollingDataTable("field_table", myColumnDefs, myDataSource);
95 fieldsTable.doBeforeSortColumn = function(column, sortDirection)
97 var url = 'index.php?module=ModuleBuilder&action=savetablesort&column=' + column.getKey() + '&direction=' + sortDirection;
98 YUI().use('io', function (Y) {
102 success: function(id, data) {},
103 failure: function(id, data) {}
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);
118 fieldsTable.render("#field_table");
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);
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');
133 ModuleBuilder.helpSetup('fieldsEditor','default');
140 text-decoration:none;