Use angular-ui-bootstrap for Operation modal.
This commit is contained in:
parent
3537470cff
commit
9acaa4033e
@ -58,7 +58,7 @@ var operationModule = angular.module('accountant.operations', [
|
|||||||
* Controller for the operations.
|
* Controller for the operations.
|
||||||
*/
|
*/
|
||||||
.controller('OperationController', function($rootScope, $scope, $routeParams,
|
.controller('OperationController', function($rootScope, $scope, $routeParams,
|
||||||
$ngBootbox, Notification, Operation) {
|
$ngBootbox, $uibModal, Notification, Operation, $log) {
|
||||||
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
@ -167,6 +167,23 @@ var operationModule = angular.module('accountant.operations', [
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm.modify = function(operation, $index) {
|
||||||
|
$uibModal.open({
|
||||||
|
component: 'operationModalComponent',
|
||||||
|
resolve: {
|
||||||
|
operation: function() {
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).result.then(function(operation) {
|
||||||
|
// FIXME Alexis Lahouze 2017-06-15 Save Operation and reload data to
|
||||||
|
// update balances.
|
||||||
|
$log.info('modal validated', operation);
|
||||||
|
}, function() {
|
||||||
|
$log.info('modal-component dismissed at: ' + new Date());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reload operations on rangeSelectedEvent.
|
* Reload operations on rangeSelectedEvent.
|
||||||
*/
|
*/
|
||||||
@ -181,56 +198,41 @@ var operationModule = angular.module('accountant.operations', [
|
|||||||
vm.load(moment().date(1).year(2000), moment());
|
vm.load(moment().date(1).year(2000), moment());
|
||||||
})
|
})
|
||||||
|
|
||||||
.directive('operationFormDialog', function($log, $ngBootbox) {
|
.component('operationModalComponent', {
|
||||||
return {
|
|
||||||
restrict: 'A',
|
|
||||||
scope: {
|
|
||||||
operation: '=ngModel'
|
|
||||||
},
|
|
||||||
link: function(scope, element) {
|
|
||||||
var title = 'Operation';
|
|
||||||
|
|
||||||
if (scope.operation && scope.operation.id) {
|
|
||||||
title = title + ' #' + scope.operation.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
scope.form = {};
|
|
||||||
|
|
||||||
element.on('click', function() {
|
|
||||||
scope.data = {};
|
|
||||||
angular.copy(scope.operation, scope.data);
|
|
||||||
|
|
||||||
// Open dialog with form.
|
|
||||||
$ngBootbox.customDialog({
|
|
||||||
scope: scope,
|
|
||||||
title: title,
|
|
||||||
templateUrl: operationFormTmpl,
|
templateUrl: operationFormTmpl,
|
||||||
onEscape: true,
|
bindings: {
|
||||||
buttons: {
|
resolve: '<',
|
||||||
save: {
|
close: '&',
|
||||||
label: 'Save',
|
dismiss: '&'
|
||||||
className: 'btn-success',
|
|
||||||
callback: function() {
|
|
||||||
// Validate form
|
|
||||||
$log.log(scope.form);
|
|
||||||
|
|
||||||
// Save operation
|
|
||||||
$log.log(scope.operation);
|
|
||||||
|
|
||||||
// TODO Alexis Lahouze 2016-05-24 Save operation, handle return.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
cancel: {
|
controller: function() {
|
||||||
label: 'Cancel',
|
var vm = this;
|
||||||
className: 'btn-default',
|
|
||||||
callback: true
|
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 "Operation #" + vm.operation.id;
|
||||||
|
} else {
|
||||||
|
return "Operation";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = operationModule;
|
module.exports = operationModule;
|
||||||
|
@ -16,12 +16,18 @@
|
|||||||
-->
|
-->
|
||||||
<!-- 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; -->
|
<!-- kate: space-indent on; indent-width 2; mixedindent off; -->
|
||||||
<form class="form-horizontal" role="form" name="form">
|
<div class="modal-header">
|
||||||
|
<h3 class="modal-title" id="modal-title">{{ $ctrl.title() }}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-body" id="modal-body">
|
||||||
|
<form class="form-horizontal simple-form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label" for="operation-date">Date</label>
|
<label class="col-sm-4 control-label" for="operation-date">Date</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input class="form-control" id="operation-date" name="operation_date" ng-model="data.operation_date"
|
<input class="form-control" id="operation-date" name="operation_date"
|
||||||
type="text" bs-datepicker data-date-format="yyyy-MM-dd"
|
type="text" ng-model="$ctrl.operation.operation_date"
|
||||||
|
bs-datepicker data-date-format="yyyy-MM-dd"
|
||||||
placeholder="Operation date">
|
placeholder="Operation date">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -30,8 +36,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="data.label"
|
ng-model="$ctrl.operation.label" type="text" placeholder="Label">
|
||||||
type="text" placeholder="Label">
|
|
||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -40,8 +45,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="data.value"
|
ng-model="$ctrl.operation.value" type="number" placeholder="Value">
|
||||||
type="number" placeholder="Value">
|
|
||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -50,9 +54,18 @@
|
|||||||
<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="data.category"
|
ng-model="$ctrl.operation.category" type="text" placeholder="Category">
|
||||||
type="text" placeholder="Category">
|
|
||||||
</input>
|
</input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-primary" type="button" ng-click="$ctrl.ok()">
|
||||||
|
OK
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-default" type="button" ng-click="$ctrl.cancel()">
|
||||||
|
Annuler
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
<!-- Edit operation, for non-canceled operation. -->
|
<!-- Edit operation, for non-canceled operation. -->
|
||||||
<button type="button" class="btn btn-default"
|
<button type="button" class="btn btn-default"
|
||||||
ng-if="!operation.canceled"
|
ng-if="!operation.canceled"
|
||||||
operation-form-dialog ng-model="operation" title="edit">
|
ng-click="operationsCtrl.modify(operation, $index)" title="edit">
|
||||||
<span class="fa fa-pencil-square-o"></span>
|
<span class="fa fa-pencil-square-o"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user