2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2012 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)
77 elCell.innerHTML = oData.replace(/\:\s*?$/, '');
81 {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}},
82 {key:"label", label:SUGAR.language.get("ModuleBuilder", "LBL_DROPDOWN_ITEM_LABEL"),sortable:true, resizeable:true, formatter:"labelFormatter", width:200},
83 {key:"type", label:SUGAR.language.get("ModuleBuilder", "LBL_DATA_TYPE"),sortable:true,resizeable:true, width:125}
87 var myDataSource = new YAHOO.util.DataSource({$fieldsData});
88 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
90 myDataSource.responseSchema = {fields: ["label","name","type"]};
91 YAHOO.widget.DataTable.Formatter.editFieldFormatter = editFieldFormatter;
92 YAHOO.widget.DataTable.Formatter.labelFormatter = labelFormatter;
94 var fieldsTable = new YAHOO.widget.ScrollingDataTable("field_table", myColumnDefs, myDataSource);
96 fieldsTable.doBeforeSortColumn = function(column, sortDirection)
98 var url = 'index.php?module=ModuleBuilder&action=savetablesort&column=' + column.getKey() + '&direction=' + sortDirection;
99 YUI().use('io', function (Y) {
103 success: function(id, data) {},
104 failure: function(id, data) {}
112 fieldsTable.subscribe("rowMouseoverEvent", fieldsTable.onEventHighlightRow);
113 fieldsTable.subscribe("rowMouseoutEvent", fieldsTable.onEventUnhighlightRow);
114 fieldsTable.subscribe("rowClickEvent", function(args) {
115 var field = this.getRecord(args.target).getData();
116 ModuleBuilder.moduleLoadField(field.name);
119 fieldsTable.render("#field_table");
122 {if !empty($sortPreferences)}
123 pref = {$sortPreferences};
124 sortDirection = (pref.direction == 'ASC') ? YAHOO.widget.DataTable.CLASS_ASC : YAHOO.widget.DataTable.CLASS_DESC;
125 fieldsTable.sortColumn(fieldsTable.getColumn(pref.key), sortDirection);
128 ModuleBuilder.module = '{$module->name}';
129 ModuleBuilder.MBpackage = '{$package->name}';
130 ModuleBuilder.helpRegisterByID('studiofields', 'input');
131 {if $package->name != 'studio'}
132 ModuleBuilder.helpSetup('fieldsEditor','mbDefault');
134 ModuleBuilder.helpSetup('fieldsEditor','default');
141 text-decoration:none;