4 /*********************************************************************************
5 * SugarCRM Community Edition is a customer relationship management program developed by
6 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Affero General Public License version 3 as published by the
10 * Free Software Foundation with the addition of the following permission added
11 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
20 * You should have received a copy of the GNU Affero General Public License along with
21 * this program; if not, see http://www.gnu.org/licenses or write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
28 * The interactive user interfaces in modified source and object code versions
29 * of this program must display Appropriate Legal Notices, as required under
30 * Section 5 of the GNU Affero General Public License version 3.
32 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33 * these Appropriate Legal Notices must retain the display of the "Powered by
34 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35 * technical reasons, the Appropriate Legal Notices must display the words
36 * "Powered by SugarCRM".
37 ********************************************************************************/
47 <style type='text/css'>
49 border-width:1px;border-color:#999999;border-style:solid;padding:0px 1px 0px 1px;margin:2px;cursor:move;
54 border-width:0;cursor:move;
59 <table width="100%" border="0" cellspacing="0" cellpadding="0">
62 <h2 style='margin-bottom:10px;'>{$title}</h2>
63 <p>{$MOD.LBL_RENAME_TAB_WELCOME}</p><br/>
64 <table cellspacing="2">
67 <input type="button" value="{$MOD.LBL_BTN_UNDO}" onclick="jstransaction.undo()" name="{$MOD.LBL_BTN_UNDO}" />
70 <input type="button" value="{$MOD.LBL_BTN_REDO}" onclick="jstransaction.redo()" name="{$MOD.LBL_BTN_REDO}" />
73 <input type="button" value="{$MOD.LBL_BTN_SAVE}"
74 onclick='{literal}if(check_form("editdropdown")){document.editdropdown.submit();}{/literal}'
75 name="{$MOD.LBL_BTN_SAVE}" />
79 <table width="100%" border="0" cellspacing="0" cellpadding="0" class='edit view'>
81 <span class='error'>{$error}</span>
84 {if empty($newDropDown)}
85 <form method='post' action='index.php' name='dropdownsform'>
86 <input type='hidden' name='action' value='wizard'>
87 <input type='hidden' name='wizard' value='EditDropDownWizard'>
88 <input type='hidden' name='option' value='EditDropdown'>
89 <input type='hidden' name='module' value='Studio'>
90 <input type='hidden' name='dropdown_name' value='{$dropdown_name}'>
92 {html_options name='dropdown_lang' options=$dropdown_languages selected=$dropdown_lang onchange="document.dropdownsform.submit();"}
98 {if !empty($dropdown) || !empty($newDropDown)}
99 <form method='post' action='index.php' name='editdropdown'>
100 <input type='hidden' name='action' value='wizard'>
101 <input type='hidden' name='wizard' value='EditDropDownWizard'>
102 <input type='hidden' name='option' value='SaveDropDown'>
103 <input type='hidden' name='module' value='Studio'>
104 <input type='hidden' name='dropdown_lang' value='{$dropdown_lang}'>
105 {if empty($newDropDown)}
106 <input type='hidden' name='dropdown_name' value='moduleList'>
109 {$MOD.LBL_DROPDOWN_NAME}
110 </td><td>{$MOD.COLUMN_TITLE_NAME}<input type='text' name='dropdown_name' value='{$dropdown_name}'>
112 {$MOD.LBL_DROPDOWN_LANGUAGE}</td><td>{html_options name='dropdown_lang' options=$dropdown_languages selected=$dropdown_lang}
115 <table name='tabDropdown' id='tabDropdown'>
116 <tr><td>{$MOD.LBL_DD_DATABASEVALUE}<hr></td><td>{$MOD.LBL_DD_DISPALYVALUE}<hr></td></tr>
117 {counter start=0 name="rowCounter" print=false assign="rowCounter"}
118 {foreach from=$dropdown item="value" key="key"}
121 <span id='slot{$rowCounter}' class='slot' style='cursor: move'>
122 <span id='slot{$rowCounter}_key'>{$key}</span>
125 <span id='slot{$rowCounter}b' >
126 {if empty($disable_remove)}
127 <span onclick='deleteDropDownValue({$rowCounter}, document.getElementById("delete_{$rowCounter}"), true);'>
131 <span onclick='prepChangeDropDownValue({$rowCounter}, document.getElementById("slot{$rowCounter}_value"));'>{$editImage}</span>
133 <span id ='slot{$rowCounter}_value' onclick='prepChangeDropDownValue({$rowCounter}, this);'>{$value.lang}</span>
134 <span id='slot{$rowCounter}_textspan' style='display:none'>
135 <input id='slot{$rowCounter}_text' value='' type='text' onchange='setDropDownValue({$rowCounter}, this.value, true)' >
138 <input name='slot_{$rowCounter}' id='slot_{$rowCounter}' value='{$rowCounter}' type = 'hidden'>
139 <input name='value_{$rowCounter}' id='value_{$rowCounter}' value='{$value.lang}' type = 'hidden'>
140 <input type='hidden' name='key_{$rowCounter}' id='key_{$rowCounter}' value='{$key|default:"BLANK"}'>
141 <input type='hidden' id='delete_{$rowCounter}' name='delete_{$rowCounter}' value='0'>
145 {counter name="rowCounter"}
148 {if empty($disable_add)}
149 <tr><td><input type='text' name='addKey' id='addKey' value=''></td><td><input type='text' name='addValue' id='addValue' value=''><input type='button' onclick='addDropDown();' value='+' class='button'></td>
154 <script type="text/javascript" src="{sugar_getjspath file='modules/Studio/JSTransaction.js'}" ></script>
156 var jstransaction = new JSTransaction();
160 <script src = "include/javascript/yui/build/dragdrop/dragdrop.js" ></script>
161 <script type="text/javascript" src="modules/Studio/studiodd.js" ></script>
162 <script type="text/javascript" src="modules/Studio/studio.js" ></script>
165 var lastRowCount = -1;
166 var undoDeleteDropDown = function(transaction){
167 deleteDropDownValue(transaction['row'], document.getElementById(transaction['id']), false);
169 jstransaction.register('deleteDropDown', undoDeleteDropDown, undoDeleteDropDown);
170 function deleteDropDownValue(rowCount, field, record){
172 jstransaction.record('deleteDropDown',{'row':rowCount, 'id': field.id });
174 //We are deleting if the value is 0
175 if(field.value == '0'){
177 document.getElementById('slot' + rowCount + '_key').style.textDecoration = 'line-through';
178 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'line-through';
181 document.getElementById('slot' + rowCount + '_key').style.textDecoration = 'none';
182 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'none';
187 function prepChangeDropDownValue(rowCount, field){
189 var tempLastField = lastField;
190 if(lastRowCount != -1){
191 setDropDownValue(lastRowCount, lastField.innerHTML, true);
193 if(tempLastField == field)return;
195 lastRowCount = rowCount;
197 field.style.display="none";
199 var textspan = document.getElementById('slot' + rowCount + '_textspan');
200 var text = document.getElementById("slot" + rowCount + "_text");
201 text.value=field.innerHTML;
202 textspan.style.display='inline'
205 var undoDropDownChange = function(transaction){
206 setDropDownValue(transaction['row'], transaction['old'], false);
208 var redoDropDownChange = function(transaction){
209 setDropDownValue(transaction['row'], transaction['new'], false);
211 jstransaction.register('changeDropDownValue', undoDropDownChange, redoDropDownChange);
212 function setDropDownValue(rowCount, val, record){
214 var key = document.getElementById('slot' + rowCount + '_key').innerHTML;
219 jstransaction.record('changeDropDownValue', {'row':rowCount, 'new':val, 'old':document.getElementById('value_'+ rowCount).value});
221 document.getElementById('value_' + rowCount).value = YAHOO.lang.escapeHTML(val);
222 var text = document.getElementById('slot' + rowCount + '_text');
223 var textspan = document.getElementById('slot' + rowCount + '_textspan');
224 var span = document.getElementById('slot' + rowCount + '_value');
225 span.innerHTML = YAHOO.lang.escapeHTML(val);
226 textspan.style.display = 'none';
228 span.style.display = 'inline';
234 function addDropDown(){
235 var addKey = document.getElementById('addKey');
236 var keyValue = addKey.value;
237 if(trim(keyValue) == ''){
241 //Check for the single quote value
242 //Comment out this if block in case you don't want validation
243 //or add other rules as needed (e.g. isDBName() from sugar_3.js)
244 if(/[\']/.test(keyValue)) {
245 alert("{/literal}{$MOD.ERROR_INVALID_KEY_VALUE}{literal}");
249 var addValue = document.getElementById('addValue')
250 for(var i = 0; i < slotCount ; i++){
251 if(typeof(document.getElementById('key_' + i)) != 'undefined'){
252 if(document.getElementById('key_' + i).value == keyValue){
253 alert('key already exists');
258 var table = document.getElementById('tabDropdown');
259 var row = table.insertRow(table.rows.length - 1);
260 var cell = row.insertCell(0);
261 var cell2 = row.insertCell(1);
263 var span1 = document.createElement('span');
264 span1.id = 'slot' + slotCount;
265 span1.className = 'slot';
266 var keyspan = document.createElement('span');
267 keyspan.id = 'slot' + slotCount + '_key'
268 keyspan.innerHTML = YAHOO.lang.escapeHTML(addKey.value);
269 span1.appendChild(keyspan);
270 var span2 = document.createElement('span');
271 span2.id = 'slot' + slotCount + 'b';
272 var delimage = document.createElement('span');
273 delimage.innerHTML = '{/literal}{$deleteImage}{literal} ';
274 delimage.slotCount = slotCount
275 delimage.recordKey = keyValue;
276 delimage.onclick = function(){
278 deleteDropDownValue(this.slotCount, document.getElementById( 'delete_' + this.slotCount), true);
280 var span2image = document.createElement('span');
281 span2image.innerHTML = '{/literal}{$editImage}{literal} ';
282 span2image.slotCount = slotCount
283 span2image.onclick = function(){
284 prepChangeDropDownValue(this.slotCount, document.getElementById('slot' + this.slotCount + '_value'));
286 var span2inner = document.createElement('span');
287 span2inner.innerHTML = addValue.value;
288 span2inner.id = 'slot' + slotCount + '_value';
289 span2inner.slotCount = slotCount
290 span2inner.onclick = function(){
291 prepChangeDropDownValue(this.slotCount, this);
293 var text2span = document.createElement('span');
294 text2span.id = 'slot' + slotCount + '_textspan'
295 text2span.style.display = 'none';
297 var text2 = document.createElement('input');
299 text2.id = 'slot' + slotCount + '_text'
301 text2.slotCount = slotCount;
302 text2.onchange = function(){
303 setDropDownValue(this.slotCount, this.value, true);
306 var text3 = document.createElement('input');
307 text3.type = 'hidden';
308 text3.id = 'value_' + slotCount;
309 text3.name = 'value_' + slotCount;
310 text3.value = addValue.value;
312 var text4 = document.createElement('input');
313 text4.type = 'hidden';
314 text4.id = 'key_' + slotCount;
315 text4.name = 'key_' + slotCount;
316 text4.value = keyValue;
318 var text5 = document.createElement('input');
319 text5.type = 'hidden';
320 text5.id = 'delete_' + slotCount ;
321 text5.name = 'delete_' + slotCount ;
324 var text6 = document.createElement('input');
325 text6.type = 'hidden';
326 text6.id = 'slot_' + slotCount;
327 text6.name = 'slot_' + slotCount;
328 text6.value = slotCount;
330 cell.appendChild(span1);
331 span2.appendChild(delimage);
332 span2.appendChild(span2image);
333 span2.appendChild(span2inner);
334 cell2.appendChild(span2);
335 text2span.appendChild(text2);
336 span2.appendChild(text2span);
337 cell2.appendChild(text3);
338 cell2.appendChild(text4);
339 cell2.appendChild(text5);
340 cell2.appendChild(text6);
343 yahooSlots["slot" + slotCount] = new ygDDSlot("slot" + slotCount, "studio");
346 var slotCount = {/literal}{$rowCounter}{literal};
349 function dragDropInit(){
350 YAHOO.util.DDM.mode = YAHOO.util.DDM.POINT;
352 for(mj = 0; mj <= slotCount; mj++){
353 yahooSlots["slot" + mj] = new ygDDSlot("slot" + mj, "studio");
357 YAHOO.util.Event.addListener(window, "load", dragDropInit);
364 <div id='logDiv' style='display:none'>
368 <input type='hidden' name='use_push' value='{$use_push}'>
373 {if !empty($newDropDown)}
375 <script type="text/javascript">
376 addToValidate('editdropdown', 'dropdown_name', 'DBName', true, '{/literal}{$MOD.LBL_DROPDOWN_NAME}{literal} [a-zA-Z_0-9]' );