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