Search:
Template:MindTouch > ToBeDeveloped > Task/To Do Lists > Template:TaskList3Form

Template:TaskList3Form

    Table of contents
    No headers
    // + INCLUDES
    dekiapi();
    jquery.ui('smoothness');
    
    // + VARS
    var def_date = args.default_date;
    if (!Date.IsValid(def_date))
      {
       if (!Date.IsValid(Date.now))
         let def_date = Date.Format(Date.changetimezone(Date.now, user.timezone), "dd/MM/yyyy");
        else
         let def_date = Date.Format('01/08/2009', 'dd/MM/yyyy');
     }
    
    var tfi = args.task_form_id;
    var on_reload_function_name = args.on_reload_func_name;
    var parent_args = json.parse(args.parent_args);
    var new_args = parent_args;
    let new_args ..= { ajax_action: 'reload_tasklist3' };
    
    <script type="text/javascript">"
        var "..tfi.."height_form = 0;
        var "..tfi.."onEndFunction ;
        Deki.$(document).ready(function(){
    
        jQuery(function($){
    	$.datepicker.regional['es'] = {clearText: 'Limpiar', clearStatus: '',
    		closeText: 'Cerrar', closeStatus: 'Cerrar sin notificar',
    		prevText: '<Ant', prevStatus: 'Ver el mes anterior',
    		nextText: 'Sig>', nextStatus: 'Ver el mes siguiente',
    		currentText: 'Actual', currentStatus: 'Ver el mes actual',
    		monthNames: ['Enero','Febrero','Marzo','Abril','Maio','Junio',
    		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
    		monthNamesShort: ['Ene','Feb','Mar','Abr','Mai','Jun',
    		'Jul','Ago','Sep','Oct','Nov','Dic'],
    		monthStatus: 'Ver otro mes', yearStatus: 'Ver otro año',
    		weekHeader: 'Sm', weekStatus: '',
    		dayNames: ['Domingo','Lunes','Martes','Miercoles','Jueves','Viernes','Sabado'],
    		dayNamesShort: ['Dom','Lun','Mar','Mir','Jue','Vie','Sab'],
    		dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sa'],
    		dayStatus: 'Utilizar DD como el primer dia de la semana', dateStatus: 'Escojer el DD, MM d',
    		dateFormat: 'dd/mm/yy', firstDay: 1, 
    		initStatus: 'Escojer la fecha', isRTL: false};
    	$.datepicker.setDefaults($.datepicker.regional['us']);
    
            $('#"..tfi.."').show();
            "..tfi.."height_form = $('#"..tfi.."').height();
            $('#"..tfi.."').hide();
    }); 
    
        });
    
    "</script>
    
    var fTaskId = tfi.."TaskId";
    var fTaskPage = tfi.."TaskPage";
    var fTaskManager = tfi.."TaskManager";
    var fTaskUsername = tfi.."TaskUsername";
    var fTaskTitle = tfi.."TaskTitle";
    var fTaskStartDate = tfi.."TaskStartDate";
    var fTaskEndDate = tfi.."TaskEndDate";
    var fTaskPriority = tfi.."TaskPriority";
    var fTaskProgress = tfi.."TaskProgress";
    var fTaskStatus = tfi.."TaskStatus";
    var bTaskDelete = tfi.."TaskDelete";
    var bTaskCancel = tfi.."TaskCancel";
    var bTaskAdd = tfi.."TaskAdd";
       
        <span id=(tfi.."_dummy_container")>
         <div id=(tfi) ctor=("
               when(@message.name == 'edit_view') $this.show(); 
               when(@message.name == 'default_view') if (true) {
                  $('#"..tfi.."_dummy_row').remove();
                  $this.hide(); 
                }
              ") style="display: none; position: absolute;">/* width: 70%">*/
         <form id=(tfi..'_form_input')>
          <input id=(fTaskId) type="hidden" value="" />
          <input id=(fTaskPage) type="hidden" value="" />
    
         <table class="submitform" cellspacing="0" cellpadding="5" border="1">
            <colgroup>
                <col width="20%" />
                <col />
            </colgroup>
          <tr>
            <td class='label'>" Task Manager/s: "</td>
            <td><input id=(fTaskManager) type="text" value=(user.name) def_value=(user.name)/>" To assign more than one person, add names separated by a comma."</td>
          </tr>
          <tr>
            <td class='label'>" Assignee/s: ";</td>
            <td><input id=(fTaskUsername) type="text" value=(user.name) def_value=(user.name) />" To assign more than one person, add names separated by a comma"</td>
          </tr>
          <tr>
            <td class='label'>" Task Name: ";</td>
            <td><input id=(fTaskTitle) type="text" value='' def_value='' style="width: 90%"/></td>
          </tr>
          <tr>
            <td class='label'>" Start Date: ";</td>
            <td><input id=(fTaskStartDate) type="text" value=(def_date) def_value=(def_date) ctor="$this.datepicker();" /></td>
          </tr>
          <tr>
            <td class='label'>" Due Date: ";</td>
            <td><input id=(fTaskEndDate) type="text" value=(def_date) def_value=(def_date) ctor="$this.datepicker();" /></td>
          </tr>
          <tr>
            <td class='label'>" Priority: ";</td>
            <td><select id=(fTaskPriority) def_value="1">
                       <option value="1">1</option>
                       <option value="2">2</option>
                       <option value="3">3</option>
                       <option value="4">4</option>
                       <option value="5">5</option>
                    </select></td>
          </tr>
          <tr>
            <td class='label'>" Progress: ";</td> 
            <td><select id=(fTaskProgress) def_value="0%">
                       <option value="0%">"0%"</option>
                       <option value="10%">"10%"</option>
                       <option value="20%">"20%"</option>
                       <option value="30%">"30%"</option>
                       <option value="40%">"40%"</option>
                       <option value="50%">"50%"</option>
                       <option value="60%">"60%"</option>
                       <option value="70%">"70%"</option>
                       <option value="80%">"80%"</option>
                       <option value="90%">"90%"</option>
                       <option value="100%">"100%"</option>
                    </select></td>
          </tr>
          <tr>
            <td class='label'>" Task Status: ";</td> 
            <td><select id=(fTaskStatus) def_value="O">
                       <option value="O">"Open"</option>
                       <option value="OH">"On Hold"</option>
                       <option value="C">"Complete"</option>
                    </select></td>
          </tr>
          <tr>
            <td colspan="2" class='label'><div class="task-submit">
            <input id=(bTaskDelete) type="button" style="display: none;" value="Delete" />
            <input id=(bTaskCancel) type="button" value="Cancel" />
            <input id=(bTaskAdd) type="submit" value="Add Task" ctor=("
                when($this.click) if(true) {
                    @taskupdate({ index: #"..fTaskId..".val(), page: #"..fTaskPage..".val(), entry: { manager: #"..fTaskManager..".val(), username: #"..fTaskUsername..".val(), title: #"..fTaskTitle..".val(), startdate: #"..fTaskStartDate..".val(), enddate: #"..fTaskEndDate..".val(), priority: #"..fTaskPriority..".val(), progress: #"..fTaskProgress..".val(), status: #"..fTaskStatus..".val(), Author: {{user.name}} }});
                    @taskreset();
                    @message({ name: 'default_view' });
                    "..tfi.."OnEndFunction();
                    return false;
                }
                when(#"..bTaskDelete..".click) if(true) {
                    @taskupdate({ index: #"..fTaskId..".val(), page: #"..fTaskPage..".val(), entry: { manager: #"..fTaskManager..".val(), username: #"..fTaskUsername..".val(), title: #"..fTaskTitle..".val(), startdate: #"..fTaskStartDate..".val(), enddate: #"..fTaskEndDate..".val(), priority: #"..fTaskPriority..".val(), progress: #"..fTaskProgress..".val(), status: 'D', Author: {{user.name}} }});
                    @taskreset();
                    @message({ name: 'default_view' });
                    "..tfi.."OnEndFunction();
                    @taskreset();
                }
                when(#"..bTaskCancel..".click) if(true) {
                    @message({ name: 'default_view' });
                    "..tfi.."OnEndFunction();
                    @taskreset();
                }
                when(@taskreset) if(true) {
                    #"..fTaskId..".val('');
                    #"..fTaskPage..".val('');
                    #"..fTaskManager..".val(Deki.$('#"..fTaskManager.."').attr('def_value'));
                    #"..fTaskUsername..".val(Deki.$('#"..fTaskUsername.."').attr('def_value'));
                    #"..fTaskTitle..".val(Deki.$('#"..fTaskTitle.."').attr('def_value'));
                    #"..fTaskStartDate..".val(Deki.$('#"..fTaskStartDate.."').attr('def_value'));
                    #"..fTaskEndDate..".val(Deki.$('#"..fTaskEndDate.."').attr('def_value'));
                    #"..fTaskPriority..".val(Deki.$('#"..fTaskPriority.."').attr('def_value'));
                    #"..fTaskProgress..".val(Deki.$('#"..fTaskProgress.."').attr('def_value'));
                    #"..fTaskStatus..".val(Deki.$('#"..fTaskStatus.."').attr('def_value'));
                    #"..bTaskAdd..".val('Add Task');
                    #"..bTaskDelete..".hide();
                    #"..bTaskAdd..".blur();
                }
                when(@taskedit) if(true) {
    
                    if (@taskedit.row_index.indexOf('add_row')!=-1) {
                        $('#'+@taskedit.row_index).after('<tr id="..tfi.."_dummy_row><td colspan=9><div style=\"height: '+"..tfi.."height_form+'px;\"></div></td></tr>');
                        $('#"..tfi.."').css('top',$('#"..tfi.."_dummy_row').position().top); 
                        $('#"..tfi.."').css('left',$('#"..tfi.."_dummy_row').position().left+20); 
                        window.scrollTo($('#"..tfi.."_dummy_row').position().left,$('#"..tfi.."_dummy_row').position().top-30);
                        @taskreset();
                        #"..fTaskPage..".val(@taskedit.page);
                        @message({ name: 'edit_view' }); 
                       }
                     else {
                      MindTouch.Deki.ReadPageProperty(@taskedit.page, 'urn:custom.mindtouch.com#tasks', function(result) {
                        var data = YAHOO.lang.JSON.parse(result.value || '[]');
                        #"..fTaskId..".val(@taskedit.index);
                        #"..fTaskPage..".val(@taskedit.page);
                        #"..fTaskManager..".val(data[@taskedit.index].manager);
                        #"..fTaskUsername..".val(data[@taskedit.index].username);
                        #"..fTaskTitle..".val(data[@taskedit.index].title);
                        #"..fTaskStartDate..".val(data[@taskedit.index].startdate);
                        #"..fTaskEndDate..".val(data[@taskedit.index].enddate);
                        #"..fTaskPriority..".val(data[@taskedit.index].priority);
                        #"..fTaskProgress..".val(data[@taskedit.index].progress);
                        #"..fTaskStatus..".val(data[@taskedit.index].status);
                        #"..bTaskAdd..".val('Update');
                        #"..bTaskDelete..".show();
                        $('#'+@taskedit.row_index).after('<tr id="..tfi.."_dummy_row><td colspan=9><div style=\"height: '+"..tfi.."height_form+'px;\"></div></td></tr>');
                        $('#"..tfi.."').css('top',$('#"..tfi.."_dummy_row').position().top); 
                        $('#"..tfi.."').css('left',$('#"..tfi.."_dummy_row').position().left+20);                    
                        window.scrollTo($('#"..tfi.."_dummy_row').position().left,$('#"..tfi.."_dummy_row').position().top-30);  
                        @message({ name: 'edit_view' }); 
                        }, function(result) {
                        alert('There has been a task reading error  (status: ' + result.status + ' - ' + result.text + ')');
                       });
                      }
                }
                when(@taskupdate) if(true) {
                    MindTouch.Deki.ReadPageProperty(@taskupdate.page, 'urn:custom.mindtouch.com#tasks', function(result) {
                        // var data = eval('(' + (result.value || '[]') + ')');
                        var data = YAHOO.lang.JSON.parse((result.value || '[]'));
                        if(@taskupdate.index !== '') {
                            if(@taskupdate.entry === null) {
                                data.splice(@taskupdate.index, 1);
                            } else {
                                Deki.$.extend(data[@taskupdate.index], @taskupdate.entry);
                            }
                        } else {
                            data.push(@taskupdate.entry);
                        }
                        if(result.etag) {
                            MindTouch.Deki.UpdatePageProperty(result.href, YAHOO.lang.JSON.stringify(data), result.etag, function() {
                                MindTouch.Deki.Reload(#"..tfi.."tasklist, "..json.emit(new_args)..", function() { "..on_reload_function_name.."(); });
                            }, function(result) {
                                alert('There has been a task reading error (status: ' + result.status + ' - ' + result.text + ')');
                            });
                        } else {
                            MindTouch.Deki.CreatePageProperty(@taskupdate.page, 'urn:custom.mindtouch.com#tasks', YAHOO.lang.JSON.stringify(data), function() {
                                MindTouch.Deki.Reload(#"..tfi.."tasklist, "..json.emit(new_args)..", function() { "..on_reload_function_name.."(); });
                         }, function(result) {
                                alert(' (status: ' + result.status + ' - ' + result.text + ')');
                            });
                        }
                    }, function(result) {
                        alert('There has been a task reading error (status: ' + result.status + ' - ' + result.text + ')');
                    });
                }
            ") />
            </div>
            </td>
          </tr>
         </table>
         </form>
        </div>
        </span>
    
    // global script code
    <script type="text/jem">"
      function "..tfi.."EditTask(params,on_end_function) {
          "..tfi.."OnEndFunction = on_end_function;
          @taskedit(params);
          #"..fTaskTitle..".select();
          return false;    
       }
    "</script>
    

    Files (0)

     

    Comments (0)

    You must login to post a comment.