Beispiel #1
0
        initialize: function() {
            this.modelsParamsLoader = this.loadModelsParams();

            this.sourceList = new SyncList(null, { url: routes.buildUrl('TASKS_DATA') });
            this.runningList = new SyncList(null, { url: routes.buildUrl('TASKS_DATA', 'executing') });
            this.listenTo(this.sourceList, {
                'edit:cron': this.openCronPopup,
                'edit:parameters': this.openParametersPopup,
                'edit:errors': this.openErrorsPopup,
                'expire': this.fetchRunningTasks,
                'sync:delete': this.onSyncDelete
            });
        },
 onRecordsSelectorSelected: function(id){
     var recode = new RecodeModel({
         fromRecordIDs: this.fromRecordsSelected,
         toRecordId: id
     }, { url: routes.buildUrl('RECODES_DATA', this.currentRRS.id) }),
         self = this;
     recode.save().done(function(resp){
         if (id) {
             self.recodes.set(resp, {remove: false});
         } else {
             var idsToRemove = _.pluck(resp, 'fromRecordId');
             self.recodes.remove(idsToRemove);
         }
         self.recodes.trigger('reset');
         self.trigger('recodes:unselect');
     });
 }
 onSubmit: function(){
     var attrs = this.getFieldsValues();
     if (this.model.set(attrs, {validate: true})) {
         this.ui.btnSave.attr('disabled', true);
         var self = this,
             xhr = this.ui.form.ajaxSubmit({
                 url: routes.buildUrl('DICTIONARIES_UPLOAD', this.model.id)
             }).data('jqxhr');
         if (xhr) {
             xhr.done(function(resp, status, xhr){
                 self.ui.btnSave.attr('disabled', false);
                 try {
                     var response = JSON.parse(resp);
                 } catch(ex) {
                     response =  {
                         globalErrors: [resp]
                     }
                 }
                 if (response && (response.globalErrors || response.fieldErrors)) {
                     self.putErrors(response);
                 } else {
                     self.onClose();
                     self.model.set(response);
                     self.model.trigger('sync', self.model);
                 }
             })
             .fail(function(xhr){
                 var error;
                 try {
                     error = JSON.parse(xhr.responseText) || {};
                 } catch (ex) {
                     error = {
                         globalErrors: [xhr.statusText]
                     }
                 }
                 self.putErrors(error);
             });
         }
     }
 },
 onRRSNavigate: function(model){
     var url = routes.buildUrl('RECODES', model.id);
     this.trigger('navigate', url);
 },
 onAsideDone: function(){
     var fromDictionaryId = this.currentRRS.get('fromDictionary').id;
     var url = routes.buildUrl('RECORDS', fromDictionaryId);
     this.trigger('navigate', url);
 },