[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/layouts/vlayout/modules/Settings/CronTasks/resources/ -> List.js (source)

   1  /*+***********************************************************************************
   2   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   3   * ("License"); You may not use this file except in compliance with the License
   4   * The Original Code is:  vtiger CRM Open Source
   5   * The Initial Developer of the Original Code is vtiger.
   6   * Portions created by vtiger are Copyright (C) vtiger.
   7   * All Rights Reserved.
   8   *************************************************************************************/
   9  
  10  Settings_Vtiger_List_Js("Settings_CronTasks_List_Js",{
  11      triggerEditEvent : function(editUrl) {
  12          AppConnector.request(editUrl).then(function(data) {
  13              app.showModalWindow(data);
  14              jQuery('#cronJobSaveAjax').validationEngine(app.validationEngineOptions);
  15              var listViewInstance = Settings_CronTasks_List_Js.getInstance();
  16              listViewInstance.registerSaveEvent();
  17          });
  18      }
  19  },{
  20  
  21  
  22      getListViewRecords : function() {
  23          var thisInstance = this;
  24          var params = {
  25              module : app.getModuleName(),
  26              parent : app.getParentModuleName(),
  27              view : 'List'
  28          }
  29          var progressIndicatorElement = jQuery.progressIndicator({
  30              'position' : 'html',
  31              'blockInfo' : {
  32                  'enabled' : true
  33              }
  34          });
  35          AppConnector.request(params).then(function(data){
  36              jQuery('#listViewContents').html(data);
  37              thisInstance.registerSortableEvent();
  38              progressIndicatorElement.progressIndicator({
  39                  mode : 'hide'
  40              });
  41          })
  42      },
  43      
  44      
  45      registerSaveEvent : function() {
  46          var thisInstance = this;
  47          jQuery('#cronJobSaveAjax').on('submit',function(e){
  48              var form = jQuery(e.currentTarget);
  49              var validationResult = form.validationEngine('validate');
  50              if(validationResult == true) {
  51                  var timeFormat = jQuery('#time_format').val();
  52                  var frequencyElement = jQuery('#frequencyValue')
  53                  if(timeFormat == 'hours'){
  54                      var frequencyValue = frequencyElement.val()*60*60;
  55                  } else {
  56                      frequencyValue = frequencyElement.val()*60;
  57                  }
  58                  var message = app.vtranslate('JS_VALUE_SHOULD_NOT_BE_LESS_THAN');
  59                  var minimumFrequency = jQuery('#minimumFrequency').val();
  60                  var minutes = app.vtranslate('JS_MINUTES');
  61                  if(frequencyValue < minimumFrequency){
  62                      frequencyElement.validationEngine('showPrompt', message+' '+(minimumFrequency/60)+' '+minutes , 'error');
  63                      e.preventDefault();
  64                      return;
  65                  }else{
  66                      jQuery('#frequency').val(frequencyValue);
  67                  }
  68                  var params = form.serializeFormData();
  69                  AppConnector.request(params).then(function(data){
  70                      if(typeof data.result != 'undefined' && data.result[0] == true){
  71                          app.hideModalWindow();
  72                          thisInstance.getListViewRecords();
  73                      }
  74                  });            
  75              }
  76              e.preventDefault();
  77          });
  78      },
  79      
  80      registerSortableEvent : function() {
  81          var thisInstance = this;
  82          var sequenceList = {};
  83          var tbody = jQuery( "tbody",jQuery('.listViewEntriesTable'));
  84          tbody.sortable({
  85              'helper' : function(e,ui){
  86                  //while dragging helper elements td element will take width as contents width
  87                  //so we are explicity saying that it has to be same width so that element will not
  88                  //look like distrubed
  89                  ui.children().each(function(index,element){
  90                      element = jQuery(element);
  91                      element.width(element.width());
  92                  })
  93                  return ui;
  94              },
  95              'containment' : tbody,
  96              'revert' : true,
  97              update: function(e, ui ) {
  98                  jQuery('tbody tr').each(function(i){
  99                      sequenceList[++i] = jQuery(this).data('id');
 100                  });
 101                  var params = {
 102                      sequencesList : JSON.stringify(sequenceList),
 103                      module : app.getModuleName(),
 104                      parent : app.getParentModuleName(),
 105                      action : 'UpdateSequence'
 106                  }
 107                  AppConnector.request(params).then(function(data) {
 108                      thisInstance.getListViewRecords();
 109                  });
 110              }
 111          });
 112      },
 113  
 114      registerEvents : function() {
 115          this.registerSortableEvent();
 116          //this.triggerDisplayTypeEvent();
 117      }
 118  });


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1