Use angular strap modal instead of angular-ui-bootstrap one.
This commit is contained in:
parent
8194978bcc
commit
30549dd6d8
@ -48,7 +48,7 @@ module.exports = angular.module('accountant.scheduler', [
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
||||||
.controller('SchedulerController', function($rootScope, $routeParams, Notification, ScheduledOperation, $log, $uibModal, $q) {
|
.controller('SchedulerController', function($rootScope, $routeParams, Notification, ScheduledOperation, $log, $modal) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
// Operation store.
|
// Operation store.
|
||||||
@ -92,8 +92,30 @@ module.exports = angular.module('accountant.scheduler', [
|
|||||||
Notification.error(
|
Notification.error(
|
||||||
'Error while saving scheduled operation: ' + result.message
|
'Error while saving scheduled operation: ' + result.message
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return $q.reject(result);
|
/*
|
||||||
|
* Delete an operation and return a promise.
|
||||||
|
*/
|
||||||
|
vm.confirmDelete = function(operation) {
|
||||||
|
var title = "Delete operation #" + operation.id;
|
||||||
|
|
||||||
|
$modal({
|
||||||
|
templateUrl: scheduleDeleteTmpl,
|
||||||
|
controller: function($scope, title, operation, $delete) {
|
||||||
|
$scope.title = title;
|
||||||
|
$scope.operation = operation;
|
||||||
|
$scope.$delete = function() {
|
||||||
|
$scope.$hide();
|
||||||
|
$delete($scope.operation);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
locals: {
|
||||||
|
title: title,
|
||||||
|
operation: operation,
|
||||||
|
$delete: vm.delete
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -103,30 +125,17 @@ module.exports = angular.module('accountant.scheduler', [
|
|||||||
vm.delete = function(operation) {
|
vm.delete = function(operation) {
|
||||||
var id = operation.id;
|
var id = operation.id;
|
||||||
|
|
||||||
$uibModal.open({
|
|
||||||
component: 'scheduleDeleteModalComponent',
|
|
||||||
resolve: {
|
|
||||||
operation: function() {
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).result.then(function(operation) {
|
|
||||||
return operation.$delete().then(function() {
|
return operation.$delete().then(function() {
|
||||||
Notification.success('Operation #' + id + ' deleted.');
|
Notification.success('Scheduled operation #' + id + ' deleted.');
|
||||||
|
|
||||||
vm.operations = vm.load();
|
vm.operations = vm.load();
|
||||||
|
|
||||||
return operation;
|
return operation;
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
Notification.error(
|
Notification.error(
|
||||||
'An error occurred while trying to delete operation #' +
|
'An error occurred while trying to delete scheduled operation #' +
|
||||||
id + ':<br />' + result
|
id + ':<br />' + result
|
||||||
);
|
);
|
||||||
|
|
||||||
return $q.reject(result);
|
|
||||||
});
|
|
||||||
}, function() {
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,17 +144,28 @@ module.exports = angular.module('accountant.scheduler', [
|
|||||||
* @returns a promise.
|
* @returns a promise.
|
||||||
*/
|
*/
|
||||||
vm.modify = function(operation) {
|
vm.modify = function(operation) {
|
||||||
return $uibModal.open({
|
// FIXME Alexis Lahouze 2017-06-15 i18n
|
||||||
component: 'scheduleModifyModalComponent',
|
var title = "Operation";
|
||||||
resolve: {
|
|
||||||
operation: function() {
|
if (operation.id) {
|
||||||
return operation;
|
title = title + " #" + operation.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$modal({
|
||||||
|
templateUrl: scheduleFormTmpl,
|
||||||
|
controller: function($scope, title, operation, $save) {
|
||||||
|
$scope.title = title;
|
||||||
|
$scope.operation = operation;
|
||||||
|
$scope.$save = function() {
|
||||||
|
$scope.$hide();
|
||||||
|
$save($scope.operation);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
locals: {
|
||||||
|
title: title,
|
||||||
|
operation: operation,
|
||||||
|
$save: vm.save
|
||||||
}
|
}
|
||||||
}).result.then(function(operation) {
|
|
||||||
return vm.save(operation);
|
|
||||||
}, function() {
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,78 +173,4 @@ module.exports = angular.module('accountant.scheduler', [
|
|||||||
vm.operations = vm.load();
|
vm.operations = vm.load();
|
||||||
})
|
})
|
||||||
|
|
||||||
.component('scheduleModifyModalComponent', {
|
|
||||||
templateUrl: scheduleFormTmpl,
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
.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";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
.name;
|
.name;
|
||||||
|
@ -1,16 +1,25 @@
|
|||||||
|
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
|
||||||
|
<div class="modal top am-fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h3 class="modal-title" id="modal-title">{{ $ctrl.title() }}</h3>
|
<h3 class="modal-title" id="modal-title">{{ title }}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-body" id="modal-body">
|
<div class="modal-body" id="modal-body">
|
||||||
<p>Voulez-vous supprimer l'opération #{{ $ctrl.operation.id }} ayant pour libellé :<br/>{{ $ctrl.operation.label }}
|
<p>Voulez-vous supprimer l'opération #{{ operation.id }} ayant pour libellé :<br/>{{ operation.label }}
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn btn-danger" type="button" ng-click="$ctrl.ok()">
|
<button class="btn btn-danger" type="button" ng-click="$delete()">
|
||||||
Supprimer
|
Supprimer
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-default" type="button" ng-click="$ctrl.cancel()">
|
|
||||||
|
<button class="btn btn-default" type="button" ng-click="$hide()">
|
||||||
Annuler
|
Annuler
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@ -1,23 +1,9 @@
|
|||||||
<!--
|
|
||||||
This file is part of Accountant.
|
|
||||||
|
|
||||||
Accountant is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Accountant is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
|
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
|
||||||
<!-- kate: space-indent on; indent-width 2; mixedindent off; -->
|
<div class="modal top am-fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h3 class="modal-title" id="modal-title">{{ $ctrl.title() }}</h3>
|
<h3 class="modal-title" id="modal-title">{{ title }}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-body" id="modal-body">
|
<div class="modal-body" id="modal-body">
|
||||||
@ -26,7 +12,7 @@
|
|||||||
<label class="col-sm-4 control-label" for="start-date">Date de début</label>
|
<label class="col-sm-4 control-label" for="start-date">Date de début</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input class="form-control" id="start-date" name="start_date"
|
<input class="form-control" id="start-date" name="start_date"
|
||||||
type="text" ng-model="$ctrl.operation.start_date"
|
type="text" ng-model="operation.start_date"
|
||||||
bs-datepicker data-date-format="yyyy-MM-dd" data-timezone="UTC"
|
bs-datepicker data-date-format="yyyy-MM-dd" data-timezone="UTC"
|
||||||
placeholder="Scheduled operation start date">
|
placeholder="Scheduled operation start date">
|
||||||
</div>
|
</div>
|
||||||
@ -36,7 +22,7 @@
|
|||||||
<label class="col-sm-4 control-label" for="stop-date">Date de fin</label>
|
<label class="col-sm-4 control-label" for="stop-date">Date de fin</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input class="form-control" id="stop-date" name="stop_date"
|
<input class="form-control" id="stop-date" name="stop_date"
|
||||||
type="text" ng-model="$ctrl.operation.stop_date"
|
type="text" ng-model="operation.stop_date"
|
||||||
bs-datepicker data-date-format="yyyy-MM-dd" data-timezone="UTC"
|
bs-datepicker data-date-format="yyyy-MM-dd" data-timezone="UTC"
|
||||||
placeholder="Scheduled operation stop date">
|
placeholder="Scheduled operation stop date">
|
||||||
</div>
|
</div>
|
||||||
@ -46,7 +32,7 @@
|
|||||||
<label class="col-sm-4 control-label" for="day">Jour</label>
|
<label class="col-sm-4 control-label" for="day">Jour</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input class="form-control" id="day" name="day"
|
<input class="form-control" id="day" name="day"
|
||||||
ng-model="$ctrl.operation.day" type="number" placeholder="Day">
|
ng-model="operation.day" type="number" placeholder="Day">
|
||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -55,7 +41,7 @@
|
|||||||
<label class="col-sm-4 control-label" for="frequency">Fréquence</label>
|
<label class="col-sm-4 control-label" for="frequency">Fréquence</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input class="form-control" id="frequency" name="frequency"
|
<input class="form-control" id="frequency" name="frequency"
|
||||||
ng-model="$ctrl.operation.frequency" type="number" placeholder="Frequency">
|
ng-model="operation.frequency" type="number" placeholder="Frequency">
|
||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -64,7 +50,7 @@
|
|||||||
<label class="col-sm-4 control-label" for="label">Label</label>
|
<label class="col-sm-4 control-label" for="label">Label</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input class="form-control" id="label" name="label"
|
<input class="form-control" id="label" name="label"
|
||||||
ng-model="$ctrl.operation.label" type="text" placeholder="Label">
|
ng-model="operation.label" type="text" placeholder="Label">
|
||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -73,7 +59,7 @@
|
|||||||
<label class="col-sm-4 control-label" for="value">Montant</label>
|
<label class="col-sm-4 control-label" for="value">Montant</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input class="form-control" id="value" name="value"
|
<input class="form-control" id="value" name="value"
|
||||||
ng-model="$ctrl.operation.value" type="number" placeholder="Value">
|
ng-model="operation.value" type="number" placeholder="Value">
|
||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -82,7 +68,7 @@
|
|||||||
<label class="col-sm-4 control-label" for="category">Catégorie</label>
|
<label class="col-sm-4 control-label" for="category">Catégorie</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input class="form-control" id="category" name="category"
|
<input class="form-control" id="category" name="category"
|
||||||
ng-model="$ctrl.operation.category" type="text" placeholder="Category">
|
ng-model="operation.category" type="text" placeholder="Category">
|
||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -90,10 +76,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn btn-primary" type="button" ng-click="$ctrl.ok()">
|
<button class="btn btn-primary" type="button" ng-click="$save()">
|
||||||
OK
|
OK
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-default" type="button" ng-click="$ctrl.cancel()">
|
|
||||||
|
<button class="btn btn-default" type="button" ng-click="$hide()">
|
||||||
Annuler
|
Annuler
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
<!-- Remove operation. -->
|
<!-- Remove operation. -->
|
||||||
<button type="button" class="btn btn-default"
|
<button type="button" class="btn btn-default"
|
||||||
ng-if="operation.id"
|
ng-if="operation.id"
|
||||||
ng-click="schedulerCtrl.delete(operation)"
|
ng-click="schedulerCtrl.confirmDelete(operation)"
|
||||||
title="remove">
|
title="remove">
|
||||||
<span class="fa fa-trash"></span>
|
<span class="fa fa-trash"></span>
|
||||||
</button>
|
</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user