]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Studio/DropDowns/EditView.tpl
Release 6.2.3
[Github/sugarcrm.git] / modules / Studio / DropDowns / EditView.tpl
1 {*
2
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38
39
40
41 *}
42
43
44 {literal}
45 <br>    
46 <style type='text/css'>
47 .slot {
48         border-width:1px;border-color:#999999;border-style:solid;padding:0px 1px 0px 1px;margin:2px;cursor:move;
49
50 }
51
52 .slotB {
53         border-width:0;cursor:move;
54
55 }
56 </style>
57 {/literal}
58 <table width="100%" border="0" cellspacing="0" cellpadding="0">
59         <tr>
60                 <td>
61 <h2 style='margin-bottom:10px;'>{$title}</h2>
62 <p>{$MOD.LBL_RENAME_TAB_WELCOME}</p><br/>
63 <table cellspacing="2">
64 <tr>
65 <td valign="center">
66     <input type="button" value="{$MOD.LBL_BTN_UNDO}" onclick="jstransaction.undo()" name="{$MOD.LBL_BTN_UNDO}" />
67 </td>
68 <td valign="center">
69     <input type="button" value="{$MOD.LBL_BTN_REDO}" onclick="jstransaction.redo()" name="{$MOD.LBL_BTN_REDO}" />
70 </td>
71 <td valign="center">
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}" />
75 </td>
76 </tr>
77 </table>
78 <table width="100%" border="0" cellspacing="0" cellpadding="0" class='edit view'>
79 <tr><td>
80 <span class='error'>{$error}</span>
81 <table >
82 <tr><td colspan='2'>
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}'>
90
91 {html_options name='dropdown_lang' options=$dropdown_languages selected=$dropdown_lang onchange="document.dropdownsform.submit();"}
92 </form>
93 {/if}
94 </td></tr>
95 </table>
96 </td></tr><tr><td>
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'>
106 {else}
107 <table><tr><td>
108 {$MOD.LBL_DROPDOWN_NAME}
109 </td><td>{$MOD.COLUMN_TITLE_NAME}<input type='text' name='dropdown_name' value='{$dropdown_name}'>
110 </td></tr><tr><td>
111 {$MOD.LBL_DROPDOWN_LANGUAGE}</td><td>{html_options name='dropdown_lang' options=$dropdown_languages selected=$dropdown_lang}
112 </td></tr></table>
113 {/if}
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"}
118
119 <tr><td>
120 <span id='slot{$rowCounter}' class='slot' style='cursor: move'>
121     <span id='slot{$rowCounter}_key'>{$key}</span>
122 </span>
123 </td><td>
124 <span id='slot{$rowCounter}b' >
125 {if empty($disable_remove)}
126     <span onclick='deleteDropDownValue({$rowCounter}, document.getElementById("delete_{$rowCounter}"), true);'>
127         {$deleteImage}
128     </span>
129 {/if}
130     <span onclick='prepChangeDropDownValue({$rowCounter}, document.getElementById("slot{$rowCounter}_value"));'>{$editImage}</span>
131         &nbsp;
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)' >
135         {$value.user_lang}
136     </span>
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'>
141  </span>
142
143     </td></tr>
144 {counter name="rowCounter"}
145 {/foreach}
146
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>
149 {/if}
150 </table>
151 </table>
152
153 {literal}
154 <script type="text/javascript" src="modules/Studio/JSTransaction.js" ></script>
155                         <script>
156                         var jstransaction = new JSTransaction();
157                         </script>
158 <script src = "include/javascript/yui/build/dragdrop/dragdrop.js" ></script>
159                                         
160                         <script type="text/javascript" src="modules/Studio/studiodd.js" ></script>      
161                         <script type="text/javascript" src="modules/Studio/studio.js" ></script>        
162                         <script>
163                         var lastField = '';
164                         var lastRowCount = -1;
165                         var undoDeleteDropDown = function(transaction){
166                             deleteDropDownValue(transaction['row'], document.getElementById(transaction['id']), false);
167                         }
168                         jstransaction.register('deleteDropDown', undoDeleteDropDown, undoDeleteDropDown);
169                         function deleteDropDownValue(rowCount, field, record){
170                             if(record){
171                                 jstransaction.record('deleteDropDown',{'row':rowCount, 'id': field.id });
172                             }
173                             //We are deleting if the value is 0
174                             if(field.value == '0'){
175                                 field.value = '1';
176                                 document.getElementById('slot' + rowCount + '_key').style.textDecoration = 'line-through';
177                                 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'line-through';
178                             }else{
179                                 field.value = '0';
180                                 document.getElementById('slot' + rowCount + '_key').style.textDecoration = 'none';
181                                 document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'none';
182                             }
183                             
184                            
185                         }
186                         function prepChangeDropDownValue(rowCount, field){
187                           
188                             var tempLastField = lastField;
189                              if(lastRowCount != -1){
190                                 setDropDownValue(lastRowCount, lastField.innerHTML, true);
191                             }
192                              if(tempLastField == field)return;
193                             lastField = field;
194                             lastRowCount = rowCount;
195                             
196                             field.style.display="none";
197                             
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'
202                             text.focus();
203                         }
204                         var undoDropDownChange = function(transaction){
205                             setDropDownValue(transaction['row'], transaction['old'], false);
206                         }
207                         var redoDropDownChange = function(transaction){
208                             setDropDownValue(transaction['row'], transaction['new'], false);
209                         }
210                         jstransaction.register('changeDropDownValue', undoDropDownChange, redoDropDownChange);
211                         function setDropDownValue(rowCount, val, record){
212                           
213                             var key = document.getElementById('slot' + rowCount + '_key').innerHTML;
214                             if(key == ''){
215                                 key = 'BLANK';
216                             }
217                             if(record){
218                                 jstransaction.record('changeDropDownValue', {'row':rowCount, 'new':val, 'old':document.getElementById('value_'+ rowCount).value});
219                             }
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';
226                             text.value = '';
227                             span.style.display = 'inline';
228                             lastField = '';
229                             lastRowCount = -1;
230                             
231                         }
232
233                         function addDropDown(){
234                       var addKey =  document.getElementById('addKey');
235                       var keyValue = addKey.value;
236                       if(trim(keyValue) == ''){
237                           keyValue = 'BLANK';
238                       }
239                       
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}");
245                          return false;
246                       }
247                       
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');
253                                   return;
254                               }
255                           }
256                       }
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);
261
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}&nbsp;';
273                           delimage.slotCount = slotCount
274                           delimage.recordKey = keyValue;
275                           delimage.onclick = function(){
276                           
277                               deleteDropDownValue(this.slotCount, document.getElementById( 'delete_' + this.slotCount), true);
278                           };
279                           var span2image = document.createElement('span');
280                           span2image.innerHTML = '{/literal}{$editImage}{literal}&nbsp;';
281                           span2image.slotCount = slotCount
282                           span2image.onclick = function(){
283                               prepChangeDropDownValue(this.slotCount, document.getElementById('slot' + this.slotCount + '_value'));
284                           };
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);
291                           };
292                           var text2span = document.createElement('span');
293                           text2span.id = 'slot' + slotCount + '_textspan'
294                           text2span.style.display = 'none';
295
296                           var text2 = document.createElement('input');
297                           text2.type = 'text';
298                           text2.id = 'slot' + slotCount + '_text'
299                           
300                           text2.slotCount = slotCount;
301                           text2.onchange = function(){
302                               setDropDownValue(this.slotCount, this.value, true);
303                           }
304                           
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;
310                           
311                           var text4 = document.createElement('input');
312                           text4.type = 'hidden';
313                           text4.id = 'key_' + slotCount;
314                           text4.name = 'key_' + slotCount;
315                           text4.value = keyValue;
316               
317               var text5 = document.createElement('input');
318                           text5.type = 'hidden';
319                           text5.id = 'delete_' + slotCount  ;
320                           text5.name = 'delete_' + slotCount  ;
321                           text5.value = '0';
322                           
323                           var text6 = document.createElement('input');
324                           text6.type = 'hidden';
325                           text6.id = 'slot_' + slotCount;
326                           text6.name = 'slot_' + slotCount;
327                           text6.value = slotCount;
328                           
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);
340                           addKey.value = '';
341                           addValue.value = '';
342                           yahooSlots["slot" + slotCount] = new ygDDSlot("slot" + slotCount, "studio");
343                           slotCount++;
344                         }
345                         var slotCount = {/literal}{$rowCounter}{literal};
346                         var yahooSlots = [];
347                         
348                         function dragDropInit(){
349                                 YAHOO.util.DDM.mode = YAHOO.util.DDM.POINT;
350                                         
351                                 for(mj = 0; mj <= slotCount; mj++){
352                                         yahooSlots["slot" + mj] = new ygDDSlot("slot" + mj, "studio");
353                                 }
354                                           // initPointMode();
355                         }
356                         YAHOO.util.Event.addListener(window, "load", dragDropInit);
357                         
358                         
359 </script>       
360 {/literal}
361
362
363 <div id='logDiv' style='display:none'> 
364 </div>
365
366 {/if}
367 <input type='hidden' name='use_push' value='{$use_push}'>
368 </form>
369 </td></tr>
370 </table>
371
372 {if !empty($newDropDown)}
373 {literal}
374 <script type="text/javascript">
375 addToValidate('editdropdown', 'dropdown_name', 'DBName', true, '{/literal}{$MOD.LBL_DROPDOWN_NAME}{literal} [a-zA-Z_0-9]' );
376 </script>
377 {/literal}
378 {/if}