2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2013 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 ********************************************************************************/
43 .yui-dt-col-required .yui-dt-liner, .yui-dt-col-select .yui-dt-liner, .yui-dt-col-copyData .yui-dt-liner,
44 .yui-dt-col-edit .yui-dt-liner, .yui-dt-col-delete .yui-dt-liner
50 {if !empty($warningMessage)}
51 <p class="error">{$warningMessage}</p>
53 <input type='button' name='saveLayout' value='{sugar_translate label="LBL_BTN_SAVE" module="ModuleBuilder"}'
54 class='button' onclick='ModuleBuilder.saveConvertLeadLayout();' style="margin-bottom:5px;">
55 <img class="spacer" src="include/images/blank.gif" style="width:50px;height:5px"/>
56 {html_options name="convertSelectNewModule" id="convertSelectNewModule" options=$availibleModules}
57 <input type='button' name='addModule' value='{sugar_translate label="LBL_CONVERT_ADD_MODULE"}'
58 class='button' onclick='ModuleBuilder.addConvertLeadLayout();' style="margin-bottom:5px;">
61 <div id='relGrid'></div>
62 {if $studio}{sugar_translate label='LBL_CUSTOM_RELATIONSHIPS' module='ModuleBuilder'}</h3>{/if}
66 function getModuleNameFromLabel(label) {
67 var moduleList = SUGAR.language.get('app_list_strings', "moduleList");
68 for ( var i in moduleList) {
69 if (moduleList[i] == label) {
76 var editLayout = function(row)
78 var panel = ModuleBuilder.findTabById('convEditor');
80 panel = new YAHOO.SUGAR.ClosableTab({ {/literal}
81 label: "{sugar_translate label="LBL_CONVERT_EDIT_LAYOUT"}",
86 content: "<img alt='{$mod_strings.LBL_LOADING}' name='loading' src='{sugar_getimagepath file='loading.gif'}' />{sugar_translate label='LBL_LOADING'}"{literal}
87 }, ModuleBuilder.tabPanel);
88 ModuleBuilder.tabPanel.addTab(panel);
90 ModuleBuilder.tabPanel.set("activeTab", panel);
94 action: 'editconvertlayout',
95 view_module: getModuleNameFromLabel(row.module),
99 ModuleBuilder.asyncRequest(params, function(o) {
100 ajaxStatus.hideStatus();
101 var tab = ModuleBuilder.findTabById('convEditor');
102 tab.set("content", o.responseText);
103 SUGAR.util.evalScript(o.responseText);
106 var removeLayout = function(row)
108 if (confirm("Are you sure you wish to remove this layout?")) {
111 action: 'editconvert',
113 targetModule:getModuleNameFromLabel(row.module)
116 ModuleBuilder.asyncRequest(params, function(o) {
117 ajaxStatus.hideStatus();
118 ModuleBuilder.updateContent(o);
123 var formatSelect = function(el, rec, col, data)
125 var row = rec.getData();
126 var selected = false;
127 if (row.select) selected = row.select;
128 var ret = "<input type='checkbox' name='" + rec.getData().module + "-" + col.field + "'";
129 if(typeof(relationships[row.module]) == "undefined")
130 ret += " disabled />";
132 ret += "onclick='ModuleBuilder.convertLayoutGrid.getRecord(this).setData(\"select\", this.checked ? \""
133 + relationships[row.module][0] + "\" : false);'";
135 ret += " checked='true'";
140 var getEditButton = function(el, rec, col, data){
141 var out = {/literal}"<img alt='{$mod_strings.LBL_EDIT_INLINE}' name='edit_inline' src='{sugar_getimagepath file='edit_inline.gif'}' />";{literal}
143 YAHOO.util.Event.addListener(el, "click", function(){editLayout(grid.getRecord(el).getData());});
145 var getRemoveButton = function(el, rec, col, data){
146 if (rec.getData().module =="Contacts")
148 var out = {/literal}"<img alt='{$mod_strings.LBL_EDIT_INLINE}' name='delete_inline' src='{sugar_getimagepath file='delete_inline.gif'}' />";{literal}
150 YAHOO.util.Event.addListener(el, "click", function(){removeLayout(grid.getRecord(el).getData());});
152 var getDisabledCheckbox = function(el, rec, col, data){
153 var out = "<input type='checkbox' name='" + rec.getData().module + "-" + col.field + "'"
154 + "onclick='ModuleBuilder.convertLayoutGrid.getRecord(this).setData(\"" + col.field + "\", this.checked)';";
156 out += " checked='checked'";
157 if (rec.getData().module == "Contacts")
161 // YAHOO.util.Event.addListener(el, "click", function(){editLayout(grid.getRecord(el).getData());});
165 var modules = {ldelim}modules:{$modules}{rdelim};
166 var relationships = {$relationships};
167 YAHOO.SUGAR.DragDropTable.groups = [];
168 var grid = ModuleBuilder.convertLayoutGrid = new YAHOO.SUGAR.DragDropTable('relGrid',
170 {ldelim}key:'module', label: '{sugar_translate label="LBL_CONVERT_MODULE_NAME"}', hidden: true {rdelim},
171 {ldelim}key:'moduleName', label: '{sugar_translate label="LBL_CONVERT_MODULE_NAME"}', width: 200,sortable: true {rdelim},
172 {ldelim}key:'required', label: '{sugar_translate label="LBL_CONVERT_REQUIRED"}', width: 80, sortable: false, formatter:getDisabledCheckbox{rdelim},
173 {ldelim}key:'copyData', label: '{sugar_translate label="LBL_CONVERT_COPY"}', width: 80, sortable: false, formatter:getDisabledCheckbox{rdelim},
174 {ldelim}key:'select', label: '{sugar_translate label="LBL_CONVERT_SELECT"}', width: 80, sortable: false, formatter:formatSelect{rdelim},
175 {ldelim}key:'edit', label: '{sugar_translate label="LBL_CONVERT_EDIT"}', width: 40, sortable: false, formatter:getEditButton{rdelim},
176 {ldelim}key:'delete', label: '{sugar_translate label="LBL_CONVERT_DELETE"}', width: 40, sortable: false, formatter:getRemoveButton{rdelim}
178 new YAHOO.util.LocalDataSource(modules, {
180 resultsList : "modules",
181 fields : [{key : "module"}, {key : "moduleName"},{key: "required"}, {key: "select"}, {key: "copyData"}, {key: "edit"}, {key: "delete"}]
184 {MSG_EMPTY: SUGAR.language.get('ModuleBuilder','LBL_NO_RELS')}
186 grid.subscribe("rowMouseoverEvent", grid.onEventHighlightRow);
187 grid.subscribe("rowMouseoutEvent", grid.onEventUnhighlightRow);
191 new YAHOO.widget.Tooltip("module_tooltip", {ldelim}
192 context: grid.getColumn(0).getThEl(),
193 text: '{sugar_translate label="LBL_MODULE_TIP"}',
196 new YAHOO.widget.Tooltip("required_tooltip", {ldelim}
197 context: grid.getColumn(1).getThEl(),
198 text: '{sugar_translate label="LBL_REQUIRED_TIP"}',
201 new YAHOO.widget.Tooltip("copy_tooltip", {ldelim}
202 context: grid.getColumn(2).getThEl(),
203 text: '{sugar_translate label="LBL_COPY_TIP"}',
206 new YAHOO.widget.Tooltip("selection_tooltip", {ldelim}
207 context: grid.getColumn(3).getThEl(),
208 text: '{sugar_translate label="LBL_SELECTION_TIP"}',
211 new YAHOO.widget.Tooltip("edit_tooltip", {ldelim}
212 context: grid.getColumn(4).getThEl(),
213 text: '{sugar_translate label="LBL_EDIT_TIP"}',
216 new YAHOO.widget.Tooltip("delete_tooltip", {ldelim}
217 context: grid.getColumn(5).getThEl(),
218 text: '{sugar_translate label="LBL_DELETE_TIP"}',
222 ModuleBuilder.saveConvertLeadLayout = function()
224 var rows = ModuleBuilder.convertLayoutGrid.getRecordSet().getRecords();
226 for (var i in rows) {
227 out[i] = rows[i].getData();
228 out[i].module = getModuleNameFromLabel(out[i].module);
232 action: 'editconvert',
234 data:YAHOO.lang.JSON.stringify(out)
237 ModuleBuilder.asyncRequest(params, function(o) {
238 ajaxStatus.hideStatus();
239 ModuleBuilder.updateContent(o);
242 ModuleBuilder.addConvertLeadLayout = function()
244 var rows = ModuleBuilder.convertLayoutGrid.getRecordSet().getRecords();
245 var Dom = YAHOO.util.Dom;
246 ModuleBuilder.convertLayoutGrid.addRow({
247 module:Dom.get("convertSelectNewModule").value,
252 ModuleBuilder.saveConvertLeadLayout();
255 ModuleBuilder.module = '{$view_module}';
256 ModuleBuilder.MBpackage = '{$view_package}';
257 ModuleBuilder.helpSetup('studioWizard','convertLeadHelp');