Projects
This commit is contained in:
parent
c8da195422
commit
988c0e4f04
|
|
@ -155,12 +155,25 @@ abstract class ProjectEntity extends Object
|
||||||
actions.add(EntityAction.edit);
|
actions.add(EntityAction.edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userCompany.canCreate(EntityType.task) && isActive) {
|
if (isActive && client?.isActive == true) {
|
||||||
actions.add(EntityAction.newTask);
|
if (userCompany.canCreate(EntityType.invoice)) {
|
||||||
}
|
actions.add(EntityAction.newInvoice);
|
||||||
|
}
|
||||||
if (userCompany.canCreate(EntityType.invoice) && isActive) {
|
if (userCompany.canCreate(EntityType.recurringInvoice)) {
|
||||||
actions.add(EntityAction.newInvoice);
|
actions.add(EntityAction.newRecurringInvoice);
|
||||||
|
}
|
||||||
|
if (userCompany.canCreate(EntityType.quote)) {
|
||||||
|
actions.add(EntityAction.newQuote);
|
||||||
|
}
|
||||||
|
if (userCompany.canCreate(EntityType.credit)) {
|
||||||
|
actions.add(EntityAction.newCredit);
|
||||||
|
}
|
||||||
|
if (userCompany.canCreate(EntityType.task)) {
|
||||||
|
actions.add(EntityAction.newTask);
|
||||||
|
}
|
||||||
|
if (userCompany.canCreate(EntityType.expense)) {
|
||||||
|
actions.add(EntityAction.newInvoice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -544,6 +544,10 @@ void createEntityByType(
|
||||||
final state = store.state;
|
final state = store.state;
|
||||||
final navigator = Navigator.of(context);
|
final navigator = Navigator.of(context);
|
||||||
|
|
||||||
|
if (!state.userCompany.canCreate(entityType)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
checkForChanges(
|
checkForChanges(
|
||||||
store: store,
|
store: store,
|
||||||
context: context,
|
context: context,
|
||||||
|
|
@ -712,9 +716,14 @@ void createEntity({
|
||||||
Completer cancelCompleter,
|
Completer cancelCompleter,
|
||||||
}) {
|
}) {
|
||||||
final store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
final uiState = store.state.uiState;
|
final state = store.state;
|
||||||
|
final uiState = state.uiState;
|
||||||
final navigator = Navigator.of(context);
|
final navigator = Navigator.of(context);
|
||||||
|
|
||||||
|
if (!state.userCompany.canCreate(entity.entityType)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
checkForChanges(
|
checkForChanges(
|
||||||
store: store,
|
store: store,
|
||||||
context: context,
|
context: context,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/project/project_selectors.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
|
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
|
@ -266,6 +265,7 @@ void handleProjectAction(
|
||||||
final state = store.state;
|
final state = store.state;
|
||||||
final project = projects.first as ProjectEntity;
|
final project = projects.first as ProjectEntity;
|
||||||
final projectIds = projects.map((project) => project.id).toList();
|
final projectIds = projects.map((project) => project.id).toList();
|
||||||
|
final client = state.clientState.get(project.clientId);
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case EntityAction.edit:
|
case EntityAction.edit:
|
||||||
|
|
@ -279,6 +279,12 @@ void handleProjectAction(
|
||||||
..clientId = project.clientId));
|
..clientId = project.clientId));
|
||||||
break;
|
break;
|
||||||
case EntityAction.newInvoice:
|
case EntityAction.newInvoice:
|
||||||
|
createEntity(
|
||||||
|
context: context,
|
||||||
|
entity: InvoiceEntity(state: state, client: client).rebuild((b) => b
|
||||||
|
..projectId = project.id
|
||||||
|
..clientId = project.clientId));
|
||||||
|
/*
|
||||||
final items =
|
final items =
|
||||||
convertProjectToInvoiceItem(project: project, context: context);
|
convertProjectToInvoiceItem(project: project, context: context);
|
||||||
createEntity(
|
createEntity(
|
||||||
|
|
@ -287,6 +293,38 @@ void handleProjectAction(
|
||||||
..hasTasks = true
|
..hasTasks = true
|
||||||
..clientId = project.clientId
|
..clientId = project.clientId
|
||||||
..lineItems.addAll(items)));
|
..lineItems.addAll(items)));
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
case EntityAction.newQuote:
|
||||||
|
createEntity(
|
||||||
|
context: context,
|
||||||
|
entity: InvoiceEntity(state: state, client: client).rebuild((b) => b
|
||||||
|
..projectId = project.id
|
||||||
|
..clientId = project.clientId
|
||||||
|
..entityType = EntityType.quote));
|
||||||
|
break;
|
||||||
|
case EntityAction.newCredit:
|
||||||
|
createEntity(
|
||||||
|
context: context,
|
||||||
|
entity: InvoiceEntity(state: state, client: client).rebuild((b) => b
|
||||||
|
..projectId = project.id
|
||||||
|
..clientId = project.clientId
|
||||||
|
..entityType = EntityType.credit));
|
||||||
|
break;
|
||||||
|
case EntityAction.newRecurringInvoice:
|
||||||
|
createEntity(
|
||||||
|
context: context,
|
||||||
|
entity: InvoiceEntity(state: state, client: client).rebuild((b) => b
|
||||||
|
..projectId = project.id
|
||||||
|
..clientId = project.clientId
|
||||||
|
..entityType = EntityType.recurringInvoice));
|
||||||
|
break;
|
||||||
|
case EntityAction.newExpense:
|
||||||
|
createEntity(
|
||||||
|
context: context,
|
||||||
|
entity: ExpenseEntity(state: state).rebuild((b) => b
|
||||||
|
..projectId = project.id
|
||||||
|
..clientId = project.clientId));
|
||||||
break;
|
break;
|
||||||
case EntityAction.clone:
|
case EntityAction.clone:
|
||||||
createEntity(context: context, entity: project.clone);
|
createEntity(context: context, entity: project.clone);
|
||||||
|
|
|
||||||
|
|
@ -75,20 +75,13 @@ class ProjectViewVM {
|
||||||
onRefreshed: (context) => _handleRefresh(context),
|
onRefreshed: (context) => _handleRefresh(context),
|
||||||
onEntityPressed: (BuildContext context, EntityType entityType,
|
onEntityPressed: (BuildContext context, EntityType entityType,
|
||||||
{bool longPress = false}) {
|
{bool longPress = false}) {
|
||||||
if (!longPress || !project.isActive || !client.isActive) {
|
if (longPress && project.isActive && client.isActive) {
|
||||||
|
handleProjectAction(
|
||||||
|
context, [project], EntityAction.newEntityType(entityType));
|
||||||
|
} else {
|
||||||
viewEntitiesByType(
|
viewEntitiesByType(
|
||||||
context: context, entityType: entityType, filterEntity: project);
|
context: context, entityType: entityType, filterEntity: project);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (entityType) {
|
|
||||||
case EntityType.task:
|
|
||||||
createEntity(
|
|
||||||
context: context,
|
|
||||||
entity: TaskEntity(state: state).rebuild((b) => b
|
|
||||||
..projectId = project.id
|
|
||||||
..clientId = project.clientId));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onAddTaskPressed: (context) {
|
onAddTaskPressed: (context) {
|
||||||
createEntity(
|
createEntity(
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ IconData getEntityActionIcon(EntityAction entityAction) {
|
||||||
case EntityAction.newPayment:
|
case EntityAction.newPayment:
|
||||||
case EntityAction.newQuote:
|
case EntityAction.newQuote:
|
||||||
case EntityAction.newCredit:
|
case EntityAction.newCredit:
|
||||||
|
case EntityAction.newRecurringInvoice:
|
||||||
return Icons.add_circle_outline;
|
return Icons.add_circle_outline;
|
||||||
case EntityAction.resume:
|
case EntityAction.resume:
|
||||||
case EntityAction.start:
|
case EntityAction.start:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue