mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-16 12:15:31 +00:00
Company create (#610)
* API: refactor checkPermission - Rename to checkRole (actually what it is doing) - Permission check will be incoming * Add checkPermission function for API * Create a new company * Bump release notes * Cleanup * Fix
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_speed_dial/flutter_speed_dial.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
|
||||
import "package:inventree/api.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
@ -35,6 +37,48 @@ class _CompanyListWidgetState extends RefreshableState<CompanyListWidget> {
|
||||
@override
|
||||
String getAppBarTitle() => widget.title;
|
||||
|
||||
Future<void> _addCompany(BuildContext context) async {
|
||||
|
||||
InvenTreeCompany().createForm(
|
||||
context,
|
||||
L10().companyAdd,
|
||||
data: widget.filters,
|
||||
onSuccess: (result) async {
|
||||
Map<String, dynamic> data = result as Map<String, dynamic>;
|
||||
|
||||
if (data.containsKey("pk")) {
|
||||
var company = InvenTreeCompany.fromJson(data);
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CompanyDetailWidget(company)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<SpeedDialChild> actionButtons(BuildContext context) {
|
||||
List<SpeedDialChild> actions = [];
|
||||
|
||||
if (InvenTreeAPI().checkPermission("company", "add")) {
|
||||
actions.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(TablerIcons.circle_plus, color: Colors.green),
|
||||
label: L10().companyAdd,
|
||||
onTap: () {
|
||||
_addCompany(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget getBody(BuildContext context) {
|
||||
return PaginatedCompanyList(widget.title, widget.filters);
|
||||
|
@ -183,7 +183,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> with BaseWidgetPr
|
||||
bool allowed = true;
|
||||
|
||||
if (role.isNotEmpty || permission.isNotEmpty) {
|
||||
allowed = InvenTreeAPI().checkPermission(role, permission);
|
||||
allowed = InvenTreeAPI().checkRole(role, permission);
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
|
Reference in New Issue
Block a user