Fix indent.
This commit is contained in:
@ -35,197 +35,196 @@ var schedulerModule = angular.module('accountant.scheduler', [
|
||||
ngStrap
|
||||
])
|
||||
|
||||
.config(function($resourceProvider) {
|
||||
// Keep trailing slashes to avoid redirect by flask..
|
||||
$resourceProvider.defaults.stripTrailingSlashes = false;
|
||||
})
|
||||
.config(function($resourceProvider) {
|
||||
// Keep trailing slashes to avoid redirect by flask..
|
||||
$resourceProvider.defaults.stripTrailingSlashes = false;
|
||||
})
|
||||
|
||||
.factory('ScheduledOperation', function($resource) {
|
||||
return $resource(
|
||||
'/api/scheduled_operation/:id', {
|
||||
id: '@id'
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
.controller('SchedulerController', function($rootScope, $routeParams, Notification, ScheduledOperation, $log, $uibModal, $q) {
|
||||
var vm = this;
|
||||
|
||||
// Operation store.
|
||||
vm.operations = [];
|
||||
|
||||
/*
|
||||
* Add a new operation at the beginning of th array.
|
||||
*/
|
||||
vm.add = function() {
|
||||
var operation = new ScheduledOperation({
|
||||
// eslint-disable-next-line camelcase
|
||||
account_id: $routeParams.accountId
|
||||
});
|
||||
|
||||
return vm.modify(operation);
|
||||
};
|
||||
|
||||
/*
|
||||
* Load operations.
|
||||
*/
|
||||
vm.load = function() {
|
||||
return ScheduledOperation.query({
|
||||
// eslint-disable-next-line camelcase
|
||||
account_id: $routeParams.accountId
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Save operation.
|
||||
*/
|
||||
vm.save = function(operation) {
|
||||
return operation.$save().then(function(operation) {
|
||||
Notification.success('Scheduled operation #' + operation.id + ' saved.');
|
||||
|
||||
vm.operations = vm.load();
|
||||
|
||||
return operation;
|
||||
}, function(result){
|
||||
$log.error('Error while saving scheduled operation', operation, result);
|
||||
|
||||
Notification.error(
|
||||
'Error while saving scheduled operation: ' + result.message
|
||||
);
|
||||
|
||||
return $q.reject(result);
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Delete operation.
|
||||
*/
|
||||
vm.delete = function(operation) {
|
||||
var id = operation.id;
|
||||
|
||||
$uibModal.open({
|
||||
component: 'scheduleDeleteModalComponent',
|
||||
resolve: {
|
||||
operation: function() {
|
||||
return operation;
|
||||
}
|
||||
.factory('ScheduledOperation', function($resource) {
|
||||
return $resource(
|
||||
'/api/scheduled_operation/:id', {
|
||||
id: '@id'
|
||||
}
|
||||
}).result.then(function(operation) {
|
||||
return operation.$delete().then(function() {
|
||||
Notification.success('Operation #' + id + ' deleted.');
|
||||
);
|
||||
})
|
||||
|
||||
.controller('SchedulerController', function($rootScope, $routeParams, Notification, ScheduledOperation, $log, $uibModal, $q) {
|
||||
var vm = this;
|
||||
|
||||
// Operation store.
|
||||
vm.operations = [];
|
||||
|
||||
/*
|
||||
* Add a new operation at the beginning of th array.
|
||||
*/
|
||||
vm.add = function() {
|
||||
var operation = new ScheduledOperation({
|
||||
// eslint-disable-next-line camelcase
|
||||
account_id: $routeParams.accountId
|
||||
});
|
||||
|
||||
return vm.modify(operation);
|
||||
};
|
||||
|
||||
/*
|
||||
* Load operations.
|
||||
*/
|
||||
vm.load = function() {
|
||||
return ScheduledOperation.query({
|
||||
// eslint-disable-next-line camelcase
|
||||
account_id: $routeParams.accountId
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Save operation.
|
||||
*/
|
||||
vm.save = function(operation) {
|
||||
return operation.$save().then(function(operation) {
|
||||
Notification.success('Scheduled operation #' + operation.id + ' saved.');
|
||||
|
||||
vm.operations = vm.load();
|
||||
|
||||
return operation;
|
||||
}, function(result) {
|
||||
}, function(result){
|
||||
$log.error('Error while saving scheduled operation', operation, result);
|
||||
|
||||
Notification.error(
|
||||
'An error occurred while trying to delete operation #' +
|
||||
id + ':<br />' + result
|
||||
'Error while saving scheduled operation: ' + result.message
|
||||
);
|
||||
|
||||
return $q.reject(result);
|
||||
});
|
||||
}, function() {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* Open the popup to modify the operation, save it on confirm.
|
||||
* @returns a promise.
|
||||
*/
|
||||
vm.modify = function(operation) {
|
||||
return $uibModal.open({
|
||||
component: 'scheduleModifyModalComponent',
|
||||
resolve: {
|
||||
operation: function() {
|
||||
return operation;
|
||||
/*
|
||||
* Delete operation.
|
||||
*/
|
||||
vm.delete = function(operation) {
|
||||
var id = operation.id;
|
||||
|
||||
$uibModal.open({
|
||||
component: 'scheduleDeleteModalComponent',
|
||||
resolve: {
|
||||
operation: function() {
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}).result.then(function(operation) {
|
||||
return vm.save(operation);
|
||||
}, function() {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
}).result.then(function(operation) {
|
||||
return operation.$delete().then(function() {
|
||||
Notification.success('Operation #' + id + ' deleted.');
|
||||
|
||||
// Load operations on controller initialization.
|
||||
vm.operations = vm.load();
|
||||
})
|
||||
vm.operations = vm.load();
|
||||
|
||||
.component('scheduleModifyModalComponent', {
|
||||
templateUrl: scheduleFormTmpl,
|
||||
bindings: {
|
||||
resolve: '<',
|
||||
close: '&',
|
||||
dismiss: '&'
|
||||
},
|
||||
controller: function() {
|
||||
var vm = this;
|
||||
return operation;
|
||||
}, function(result) {
|
||||
Notification.error(
|
||||
'An error occurred while trying to delete operation #' +
|
||||
id + ':<br />' + result
|
||||
);
|
||||
|
||||
vm.$onInit = function() {
|
||||
vm.operation = vm.resolve.operation;
|
||||
};
|
||||
|
||||
vm.ok = function() {
|
||||
vm.close({
|
||||
$value: vm.operation
|
||||
return $q.reject(result);
|
||||
});
|
||||
}, function() {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
vm.cancel = function() {
|
||||
vm.dismiss({
|
||||
$value: 'cancel'
|
||||
/*
|
||||
* Open the popup to modify the operation, save it on confirm.
|
||||
* @returns a promise.
|
||||
*/
|
||||
vm.modify = function(operation) {
|
||||
return $uibModal.open({
|
||||
component: 'scheduleModifyModalComponent',
|
||||
resolve: {
|
||||
operation: function() {
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
}).result.then(function(operation) {
|
||||
return vm.save(operation);
|
||||
}, function() {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
vm.title = function() {
|
||||
// FIXME Alexis Lahouze 2017-06-15 i18n
|
||||
if (vm.operation.id) {
|
||||
return "Scheduled operation #" + vm.operation.id;
|
||||
} else {
|
||||
return "Scheduled operation";
|
||||
}
|
||||
};
|
||||
}
|
||||
})
|
||||
// Load operations on controller initialization.
|
||||
vm.operations = vm.load();
|
||||
})
|
||||
|
||||
.component('scheduleModifyModalComponent', {
|
||||
templateUrl: scheduleFormTmpl,
|
||||
bindings: {
|
||||
resolve: '<',
|
||||
close: '&',
|
||||
dismiss: '&'
|
||||
},
|
||||
controller: function() {
|
||||
var vm = this;
|
||||
|
||||
.component('scheduleDeleteModalComponent', {
|
||||
templateUrl: scheduleDeleteTmpl,
|
||||
bindings: {
|
||||
resolve: '<',
|
||||
close: '&',
|
||||
dismiss: '&'
|
||||
},
|
||||
controller: function() {
|
||||
var vm = this;
|
||||
vm.$onInit = function() {
|
||||
vm.operation = vm.resolve.operation;
|
||||
};
|
||||
|
||||
vm.$onInit = function() {
|
||||
vm.operation = vm.resolve.operation;
|
||||
};
|
||||
vm.ok = function() {
|
||||
vm.close({
|
||||
$value: vm.operation
|
||||
});
|
||||
};
|
||||
|
||||
vm.ok = function() {
|
||||
vm.close({
|
||||
$value: vm.operation
|
||||
});
|
||||
};
|
||||
vm.cancel = function() {
|
||||
vm.dismiss({
|
||||
$value: 'cancel'
|
||||
});
|
||||
};
|
||||
|
||||
vm.cancel = function() {
|
||||
vm.dismiss({
|
||||
$value: 'cancel'
|
||||
});
|
||||
};
|
||||
vm.title = function() {
|
||||
// FIXME Alexis Lahouze 2017-06-15 i18n
|
||||
if (vm.operation.id) {
|
||||
return "Scheduled operation #" + vm.operation.id;
|
||||
} else {
|
||||
return "Scheduled operation";
|
||||
}
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
vm.title = function() {
|
||||
// FIXME Alexis Lahouze 2017-06-15 i18n
|
||||
if (vm.operation.id) {
|
||||
return "Scheduled operation #" + vm.operation.id;
|
||||
} else {
|
||||
return "Scheduled operation";
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
.component('scheduleDeleteModalComponent', {
|
||||
templateUrl: scheduleDeleteTmpl,
|
||||
bindings: {
|
||||
resolve: '<',
|
||||
close: '&',
|
||||
dismiss: '&'
|
||||
},
|
||||
controller: function() {
|
||||
var vm = this;
|
||||
|
||||
vm.$onInit = function() {
|
||||
vm.operation = vm.resolve.operation;
|
||||
};
|
||||
|
||||
vm.ok = function() {
|
||||
vm.close({
|
||||
$value: vm.operation
|
||||
});
|
||||
};
|
||||
|
||||
vm.cancel = function() {
|
||||
vm.dismiss({
|
||||
$value: 'cancel'
|
||||
});
|
||||
};
|
||||
|
||||
vm.title = function() {
|
||||
// FIXME Alexis Lahouze 2017-06-15 i18n
|
||||
if (vm.operation.id) {
|
||||
return "Scheduled operation #" + vm.operation.id;
|
||||
} else {
|
||||
return "Scheduled operation";
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = schedulerModule;
|
||||
|
Reference in New Issue
Block a user