3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
46 <style type='text/css'>
48 border-width:1px;border-color:#999999;border-style:solid;padding:0px 1px 0px 1px;margin:2px;cursor:move;
53 border-width:0;cursor:move;
58 <table width="100%" border="0" cellspacing="0" cellpadding="0">
61 <h2 style='margin-bottom:10px;'>{$title}</h2>
62 <p>{$MOD.LBL_RENAME_TAB_WELCOME}</p><br/>
63 <table cellspacing="2">
66 <input type="button" value="{$MOD.LBL_BTN_UNDO}" onclick="jstransaction.undo()" name="{$MOD.LBL_BTN_UNDO}" />
69 <input type="button" value="{$MOD.LBL_BTN_REDO}" onclick="jstransaction.redo()" name="{$MOD.LBL_BTN_REDO}" />
72 <input type="button" value="{$MOD.LBL_BTN_SAVE}"
73 onclick='{literal}if(check_form("editdropdown")){document.editdropdown.submit();}{/literal}'
74 name="{$MOD.LBL_BTN_SAVE}" />
78 <table width="100%" border="0" cellspacing="0" cellpadding="0" class='edit view'>
80 <span class='error'>{$error}</span>
83 {if empty($newDropDown)}
84 <form method='post' action='index.php' name='dropdownsform'>
85 <input type='hidden' name='action' value='wizard'>
86 <input type='hidden' name='wizard' value='EditDropDownWizard'>
87 <input type='hidden' name='option' value='EditDropdown'>
88 <input type='hidden' name='module' value='Studio'>
89 <input type='hidden' name='dropdown_name' value='{$dropdown_name}'>
91 {html_options name='dropdown_lang' options=$dropdown_languages selected=$dropdown_lang onchange="document.dropdownsform.submit();"}
97 {if !empty($dropdown) || !empty($newDropDown)}
98 <form method='post' action='index.php' name='editdropdown'>
99 <input type='hidden' name='action' value='wizard'>
100 <input type='hidden' name='wizard' value='EditDropDownWizard'>
101 <input type='hidden' name='option' value='SaveDropDown'>
102 <input type='hidden' name='module' value='Studio'>
103 <input type='hidden' name='dropdown_lang' value='{$dropdown_lang}'>
104 {if empty($newDropDown)}
105 <input type='hidden' name='dropdown_name' value='moduleList'>
108 {$MOD.LBL_DROPDOWN_NAME}
109 </td><td>{$MOD.COLUMN_TITLE_NAME}<input type='text' name='dropdown_name' value='{$dropdown_name}'>
111 {$MOD.LBL_DROPDOWN_LANGUAGE}</td><td>{html_options name='dropdown_lang' options=$dropdown_languages selected=$dropdown_lang}
114 <table name='tabDropdown' id='tabDropdown'>
115 <tr><td>{$MOD.LBL_DD_DATABASEVALUE}<hr></td><td>{$MOD.LBL_DD_DISPALYVALUE}<hr></td></tr>
116 {counter start=0 name="rowCounter" print=false assign="rowCounter"}
117 {foreach from=$dropdown item="value" key="key"}
120 <span id='slot{$rowCounter}' class='slot' style='cursor: move'>
121 <span id='slot{$rowCounter}_key'>{$key}</span>
124 <span id='slot{$rowCounter}b' >
125 {if empty($disable_remove)}
126 <span onclick='deleteDropDownValue({$rowCounter}, document.getElementById("delete_{$rowCounter}"), true);'>
130 <span onclick='prepChangeDropDownValue({$rowCounter}, document.getElementById("slot{$rowCounter}_value"));'>{$editImage}</span>
132 <span id ='slot{$rowCounter}_value' onclick='prepChangeDropDownValue({$rowCounter}, this);'>{$value.lang}</span>
133 <span id='slot{$rowCounter}_textspan' style='display:none'>
134 <input id='slot{$rowCounter}_text' value='' type='text' onchange='setDropDownValue({$rowCounter}, this.value, true)' >
137 <input name='slot_{$rowCounter}' id='slot_{$rowCounter}' value='{$rowCounter}' type = 'hidden'>
138 <input name='value_{$rowCounter}' id='value_{$rowCounter}' value='{$value.lang}' type = 'hidden'>
139 <input type='hidden' name='key_{$rowCounter}' id='key_{$rowCounter}' value='{$key|default:"BLANK"}'>
140 <input type='hidden' id='delete_{$rowCounter}' name='delete_{$rowCounter}' value='0'>
144 {counter name="rowCounter"}
147 {if empty($disable_add)}
148 <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="modules/Studio/JSTransaction.js" ></script>
156 var jstransaction = new JSTransaction();
158 <script src = "include/javascript/yui/build/dragdrop/dragdrop.js" ></script>
160 <script type="text/javascript" src="modules/Studio/studiodd.js" ></script>
161 <script type="text/javascript" src="modules/Studio/studio.js" ></script>
164 var lastRowCount = -1;
165 var undoDeleteDropDown = function(transaction){
166 deleteDropDownValue(transaction['row'], document.getElementById(transaction['id']), false);
168 jstransaction.register('deleteDropDown', undoDeleteDropDown, undoDeleteDropDown);
169 function deleteDropDownValue(rowCount, field, record){
171 jstransaction.record('deleteDropDown',{'row':rowCount, 'id': field.id });
173 //We are deleting if the value is 0
174 if(field.value == '0'){
176 document.getElementById('slot' + rowCount + '_key').style.textDecoration = 'line-through';
177 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'line-through';
180 document.getElementById('slot' + rowCount + '_key').style.textDecoration = 'none';
181 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'none';
186 function prepChangeDropDownValue(rowCount, field){
188 var tempLastField = lastField;
189 if(lastRowCount != -1){
190 setDropDownValue(lastRowCount, lastField.innerHTML, true);
192 if(tempLastField == field)return;
194 lastRowCount = rowCount;
196 field.style.display="none";
198 var textspan = document.getElementById('slot' + rowCount + '_textspan');
199 var text = document.getElementById("slot" + rowCount + "_text");
200 text.value=field.innerHTML;
201 textspan.style.display='inline'
204 var undoDropDownChange = function(transaction){
205 setDropDownValue(transaction['row'], transaction['old'], false);
207 var redoDropDownChange = function(transaction){
208 setDropDownValue(transaction['row'], transaction['new'], false);
210 jstransaction.register('changeDropDownValue', undoDropDownChange, redoDropDownChange);
211 function setDropDownValue(rowCount, val, record){
213 var key = document.getElementById('slot' + rowCount + '_key').innerHTML;
218 jstransaction.record('changeDropDownValue', {'row':rowCount, 'new':val, 'old':document.getElementById('value_'+ rowCount).value});
220 document.getElementById('value_' + rowCount).value = YAHOO.lang.escapeHTML(val);
221 var text = document.getElementById('slot' + rowCount + '_text');
222 var textspan = document.getElementById('slot' + rowCount + '_textspan');
223 var span = document.getElementById('slot' + rowCount + '_value');
224 span.innerHTML = YAHOO.lang.escapeHTML(val);
225 textspan.style.display = 'none';
227 span.style.display = 'inline';
233 function addDropDown(){
234 var addKey = document.getElementById('addKey');
235 var keyValue = addKey.value;
236 if(trim(keyValue) == ''){
240 //Check for the single quote value
241 //Comment out this if block in case you don't want validation
242 //or add other rules as needed (e.g. isDBName() from sugar_3.js)
243 if(/[\']/.test(keyValue)) {
244 alert("{/literal}{$MOD.ERROR_INVALID_KEY_VALUE}{literal}");
248 var addValue = document.getElementById('addValue')
249 for(var i = 0; i < slotCount ; i++){
250 if(typeof(document.getElementById('key_' + i)) != 'undefined'){
251 if(document.getElementById('key_' + i).value == keyValue){
252 alert('key already exists');
257 var table = document.getElementById('tabDropdown');
258 var row = table.insertRow(table.rows.length - 1);
259 var cell = row.insertCell(0);
260 var cell2 = row.insertCell(1);
262 var span1 = document.createElement('span');
263 span1.id = 'slot' + slotCount;
264 span1.className = 'slot';
265 var keyspan = document.createElement('span');
266 keyspan.id = 'slot' + slotCount + '_key'
267 keyspan.innerHTML = YAHOO.lang.escapeHTML(addKey.value);
268 span1.appendChild(keyspan);
269 var span2 = document.createElement('span');
270 span2.id = 'slot' + slotCount + 'b';
271 var delimage = document.createElement('span');
272 delimage.innerHTML = '{/literal}{$deleteImage}{literal} ';
273 delimage.slotCount = slotCount
274 delimage.recordKey = keyValue;
275 delimage.onclick = function(){
277 deleteDropDownValue(this.slotCount, document.getElementById( 'delete_' + this.slotCount), true);
279 var span2image = document.createElement('span');
280 span2image.innerHTML = '{/literal}{$editImage}{literal} ';
281 span2image.slotCount = slotCount
282 span2image.onclick = function(){
283 prepChangeDropDownValue(this.slotCount, document.getElementById('slot' + this.slotCount + '_value'));
285 var span2inner = document.createElement('span');
286 span2inner.innerHTML = addValue.value;
287 span2inner.id = 'slot' + slotCount + '_value';
288 span2inner.slotCount = slotCount
289 span2inner.onclick = function(){
290 prepChangeDropDownValue(this.slotCount, this);
292 var text2span = document.createElement('span');
293 text2span.id = 'slot' + slotCount + '_textspan'
294 text2span.style.display = 'none';
296 var text2 = document.createElement('input');
298 text2.id = 'slot' + slotCount + '_text'
300 text2.slotCount = slotCount;
301 text2.onchange = function(){
302 setDropDownValue(this.slotCount, this.value, true);
305 var text3 = document.createElement('input');
306 text3.type = 'hidden';
307 text3.id = 'value_' + slotCount;
308 text3.name = 'value_' + slotCount;
309 text3.value = addValue.value;
311 var text4 = document.createElement('input');
312 text4.type = 'hidden';
313 text4.id = 'key_' + slotCount;
314 text4.name = 'key_' + slotCount;
315 text4.value = keyValue;
317 var text5 = document.createElement('input');
318 text5.type = 'hidden';
319 text5.id = 'delete_' + slotCount ;
320 text5.name = 'delete_' + slotCount ;
323 var text6 = document.createElement('input');
324 text6.type = 'hidden';
325 text6.id = 'slot_' + slotCount;
326 text6.name = 'slot_' + slotCount;
327 text6.value = slotCount;
329 cell.appendChild(span1);
330 span2.appendChild(delimage);
331 span2.appendChild(span2image);
332 span2.appendChild(span2inner);
333 cell2.appendChild(span2);
334 text2span.appendChild(text2);
335 span2.appendChild(text2span);
336 cell2.appendChild(text3);
337 cell2.appendChild(text4);
338 cell2.appendChild(text5);
339 cell2.appendChild(text6);
342 yahooSlots["slot" + slotCount] = new ygDDSlot("slot" + slotCount, "studio");
345 var slotCount = {/literal}{$rowCounter}{literal};
348 function dragDropInit(){
349 YAHOO.util.DDM.mode = YAHOO.util.DDM.POINT;
351 for(mj = 0; mj <= slotCount; mj++){
352 yahooSlots["slot" + mj] = new ygDDSlot("slot" + mj, "studio");
356 YAHOO.util.Event.addListener(window, "load", dragDropInit);
363 <div id='logDiv' style='display:none'>
367 <input type='hidden' name='use_push' value='{$use_push}'>
372 {if !empty($newDropDown)}
374 <script type="text/javascript">
375 addToValidate('editdropdown', 'dropdown_name', 'DBName', true, '{/literal}{$MOD.LBL_DROPDOWN_NAME}{literal} [a-zA-Z_0-9]' );