From e5e9308d240c9901afded4dee8e9439fc4107b18 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 4 Mar 2020 12:43:32 +0200 Subject: [PATCH] Hide credit.due_date --- lib/data/models/design_model.dart | 26 ++++++++++++++++++++++++++ stubs/data/models/stub_model | 22 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/lib/data/models/design_model.dart b/lib/data/models/design_model.dart index 31a3be49b..9d0c72df3 100644 --- a/lib/data/models/design_model.dart +++ b/lib/data/models/design_model.dart @@ -66,6 +66,32 @@ abstract class DesignEntity extends Object String get displayName => name; + @override + List getActions( + {UserCompanyEntity userCompany, + ClientEntity client, + bool includeEdit = false, + bool multiselect = false}) { + final actions = []; + + if (!isDeleted) { + if (!multiselect && includeEdit && userCompany.canEditEntity(this)) { + actions.add(EntityAction.edit); + } + } + + if (userCompany.canCreate(EntityType.design) && !multiselect) { + actions.add(EntityAction.clone); + } + + if (actions.isNotEmpty) { + actions.add(null); + } + + return actions..addAll(super.getActions(userCompany: userCompany)); + } + + int compareTo(DesignEntity design, String sortField, bool sortAscending) { int response = 0; DesignEntity designA = sortAscending ? this : design; diff --git a/stubs/data/models/stub_model b/stubs/data/models/stub_model index 22fb19fab..8a49aa71c 100644 --- a/stubs/data/models/stub_model +++ b/stubs/data/models/stub_model @@ -58,6 +58,28 @@ abstract class StubEntity extends Object with BaseEntity implements Built getActions( + {UserCompanyEntity userCompany, + ClientEntity client, + bool includeEdit = false, + bool multiselect = false}) { + final actions = []; + + if (!isDeleted) { + if (!multiselect && includeEdit && userCompany.canEditEntity(this)) { + actions.add(EntityAction.edit); + } + } + + if (actions.isNotEmpty) { + actions.add(null); + } + + return actions..addAll(super.getActions(userCompany: userCompany)); + } + int compareTo(StubEntity stub, String sortField, bool sortAscending) { int response = 0; StubEntity stubA = sortAscending ? this : stub;