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 ********************************************************************************/
38 {if $view_module != 'KBDocuments'}
39 <input type='button' name='addrelbtn' value='{$mod_strings.LBL_BTN_ADD_RELATIONSHIP}'
40 class='button' onclick='ModuleBuilder.moduleLoadRelationship2("");' style="margin-bottom:5px;">
42 <div id='relGrid'></div>
43 {if $studio}{sugar_translate label='LBL_CUSTOM_RELATIONSHIPS' module='ModuleBuilder'}</h3>{/if}
46 //Workaround for YUI bug 2527707: http://yuilibrary.com/projects/yui2/ticket/913efafad48ce433199f3e72e4847b18, should be removed when YUI 2.8+ is used
47 YAHOO.widget.DataTable.prototype.getColumn = function(column) {
48 var oColumn = this._oColumnSet.getColumn(column);
51 // Validate TD element
52 var elCell = column.nodeName.toLowerCase() != "th" ? this.getTdEl(column) : false;
54 oColumn = this._oColumnSet.getColumn(elCell.cellIndex);
56 // Validate TH element
58 elCell = this.getThEl(column);
61 var allColumns = this._oColumnSet.flat;
62 for(var i=0, len=allColumns.length; i<len; i++) {
63 if(allColumns[i].getThEl().id === elCell.id) {
64 oColumn = allColumns[i];
71 YAHOO.log("Could not get Column for column at " + column, "info", this.toString());
76 var relationships = {ldelim}relationships:{$relationships}{rdelim};
77 var grid = new YAHOO.widget.ScrollingDataTable('relGrid',
79 {ldelim}key:'name', label: SUGAR.language.get('ModuleBuilder','LBL_REL_NAME'), width: 200, sortable: true{rdelim},
80 {ldelim}key:'lhs_module', label: SUGAR.language.get('ModuleBuilder','LBL_LHS_MODULE'), width: 120, sortable: true{rdelim},
81 {ldelim}key:'relationship_type', label: SUGAR.language.get('ModuleBuilder','LBL_REL_TYPE'), width: 120, sortable: true{rdelim},
82 {ldelim}key:'rhs_module', label: SUGAR.language.get('ModuleBuilder','LBL_RHS_MODULE'), width: 120, sortable: true{rdelim}
84 new YAHOO.util.LocalDataSource(relationships, {
86 resultsList : "relationships",
87 fields : [{key : "name"}, {key: "lhs_module"}, {key: "relationship_type"}, {key: "rhs_module"}]
90 {MSG_EMPTY: SUGAR.language.get('ModuleBuilder','LBL_NO_RELS'), height:"auto"}
92 grid.subscribe("rowMouseoverEvent", grid.onEventHighlightRow);
93 grid.subscribe("rowMouseoutEvent", grid.onEventUnhighlightRow);
94 grid.subscribe("rowClickEvent", function(args){
95 var rel = this.getRecord(args.target).getData();
96 var editTab = ModuleBuilder.findTabById("relEditor");
97 if (editTab) ModuleBuilder.tabPanel.removeTab(editTab);
98 var name = rel.name.indexOf("*") > -1 ? rel.name.substring(0, rel.name.length-1) : rel.name;
99 ModuleBuilder.moduleLoadRelationship2(name);
104 ModuleBuilder.module = '{$view_module}';
105 ModuleBuilder.MBpackage = '{$view_package}';
106 ModuleBuilder.helpRegisterByID('relGrid');
107 {if $fromModuleBuilder}
108 ModuleBuilder.helpSetup('relationshipsHelp','default');
110 ModuleBuilder.helpSetup('studioWizard','relationshipsHelp');