fix: changed owner managment
This commit is contained in:
parent
f89efc3c52
commit
d2cbb43bcb
1 changed files with 25 additions and 29 deletions
|
|
@ -22,6 +22,7 @@ class _OwnerPopupState extends State<OwnerPopup> {
|
||||||
String? firstName;
|
String? firstName;
|
||||||
String? lastName;
|
String? lastName;
|
||||||
String? contact;
|
String? contact;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|
@ -68,18 +69,8 @@ class _OwnerPopupState extends State<OwnerPopup> {
|
||||||
onSelected: (Owner? owner) {
|
onSelected: (Owner? owner) {
|
||||||
widget.viewModel.currentOwner = owner;
|
widget.viewModel.currentOwner = owner;
|
||||||
},
|
},
|
||||||
|
enableSearch: true,
|
||||||
),
|
),
|
||||||
SizedBox(height: 20),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
showNewOwner = !showNewOwner;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
(showNewOwner) ? "Annuler" : "Ajouter un propriétaire",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(!showNewOwner)
|
(!showNewOwner)
|
||||||
? SizedBox()
|
? SizedBox()
|
||||||
: Form(
|
: Form(
|
||||||
|
|
@ -139,23 +130,6 @@ class _OwnerPopupState extends State<OwnerPopup> {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
_formKey.currentState!.save();
|
|
||||||
await widget.viewModel.addOwner(
|
|
||||||
firstName!,
|
|
||||||
lastName!,
|
|
||||||
contact!,
|
|
||||||
);
|
|
||||||
setState(() {
|
|
||||||
showNewOwner = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text("Créer"),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -166,7 +140,29 @@ class _OwnerPopupState extends State<OwnerPopup> {
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
widget.onPressAccept(context);
|
setState(() {
|
||||||
|
showNewOwner = !showNewOwner;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text((showNewOwner) ? "Annuler" : "Ajouter un propriétaire"),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
if (showNewOwner) {
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
_formKey.currentState!.save();
|
||||||
|
await widget.viewModel.addOwner(
|
||||||
|
firstName!,
|
||||||
|
lastName!,
|
||||||
|
contact!,
|
||||||
|
);
|
||||||
|
setState(() {
|
||||||
|
showNewOwner = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
widget.onPressAccept(context);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Text("Valider"),
|
child: Text("Valider"),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Reference in a new issue