Add VP link to vendors

This commit is contained in:
Hillel Coren 2022-08-05 12:55:06 +03:00
parent 3de53667d0
commit 54f71be4a4
3 changed files with 49 additions and 10 deletions

View File

@ -210,6 +210,8 @@ abstract class VendorEntity extends Object
actions.add(EntityAction.edit);
}
actions.add(EntityAction.vendorPortal);
if (userCompany.canCreate(EntityType.purchaseOrder)) {
actions.add(EntityAction.newPurchaseOrder);
}
@ -502,6 +504,7 @@ abstract class VendorContactEntity extends Object
customValue2: '',
customValue3: '',
customValue4: '',
link: '',
);
}
@ -541,6 +544,10 @@ abstract class VendorContactEntity extends Object
@BuiltValueField(wireName: 'custom_value4')
String get customValue4;
String get link;
String get silentLink => '$link?silent=true';
String get fullName {
return (firstName + ' ' + lastName).trim();
}
@ -606,6 +613,7 @@ abstract class VendorContactEntity extends Object
FormatNumberType get listDisplayAmountType => FormatNumberType.money;
static void _initializeBuilder(VendorContactEntityBuilder builder) => builder
..link = ''
..customValue1 = ''
..customValue2 = ''
..customValue3 = ''

View File

@ -409,6 +409,8 @@ class _$VendorContactEntitySerializer
'custom_value4',
serializers.serialize(object.customValue4,
specifiedType: const FullType(String)),
'link',
serializers.serialize(object.link, specifiedType: const FullType(String)),
'created_at',
serializers.serialize(object.createdAt,
specifiedType: const FullType(int)),
@ -501,6 +503,10 @@ class _$VendorContactEntitySerializer
result.customValue4 = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'link':
result.link = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'isChanged':
result.isChanged = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
@ -1259,6 +1265,8 @@ class _$VendorContactEntity extends VendorContactEntity {
@override
final String customValue4;
@override
final String link;
@override
final bool isChanged;
@override
final int createdAt;
@ -1289,6 +1297,7 @@ class _$VendorContactEntity extends VendorContactEntity {
this.customValue2,
this.customValue3,
this.customValue4,
this.link,
this.isChanged,
this.createdAt,
this.updatedAt,
@ -1316,6 +1325,7 @@ class _$VendorContactEntity extends VendorContactEntity {
customValue3, 'VendorContactEntity', 'customValue3');
BuiltValueNullFieldError.checkNotNull(
customValue4, 'VendorContactEntity', 'customValue4');
BuiltValueNullFieldError.checkNotNull(link, 'VendorContactEntity', 'link');
BuiltValueNullFieldError.checkNotNull(
createdAt, 'VendorContactEntity', 'createdAt');
BuiltValueNullFieldError.checkNotNull(
@ -1347,6 +1357,7 @@ class _$VendorContactEntity extends VendorContactEntity {
customValue2 == other.customValue2 &&
customValue3 == other.customValue3 &&
customValue4 == other.customValue4 &&
link == other.link &&
isChanged == other.isChanged &&
createdAt == other.createdAt &&
updatedAt == other.updatedAt &&
@ -1375,6 +1386,7 @@ class _$VendorContactEntity extends VendorContactEntity {
$jc(
$jc(
$jc(
$jc(
$jc(
$jc(
0,
@ -1382,13 +1394,16 @@ class _$VendorContactEntity extends VendorContactEntity {
.hashCode),
lastName
.hashCode),
email.hashCode),
isPrimary.hashCode),
email
.hashCode),
isPrimary
.hashCode),
phone.hashCode),
customValue1.hashCode),
customValue2.hashCode),
customValue3.hashCode),
customValue4.hashCode),
link.hashCode),
isChanged.hashCode),
createdAt.hashCode),
updatedAt.hashCode),
@ -1411,6 +1426,7 @@ class _$VendorContactEntity extends VendorContactEntity {
..add('customValue2', customValue2)
..add('customValue3', customValue3)
..add('customValue4', customValue4)
..add('link', link)
..add('isChanged', isChanged)
..add('createdAt', createdAt)
..add('updatedAt', updatedAt)
@ -1463,6 +1479,10 @@ class VendorContactEntityBuilder
String get customValue4 => _$this._customValue4;
set customValue4(String customValue4) => _$this._customValue4 = customValue4;
String _link;
String get link => _$this._link;
set link(String link) => _$this._link = link;
bool _isChanged;
bool get isChanged => _$this._isChanged;
set isChanged(bool isChanged) => _$this._isChanged = isChanged;
@ -1513,6 +1533,7 @@ class VendorContactEntityBuilder
_customValue2 = $v.customValue2;
_customValue3 = $v.customValue3;
_customValue4 = $v.customValue4;
_link = $v.link;
_isChanged = $v.isChanged;
_createdAt = $v.createdAt;
_updatedAt = $v.updatedAt;
@ -1559,6 +1580,7 @@ class VendorContactEntityBuilder
customValue3, 'VendorContactEntity', 'customValue3'),
customValue4:
BuiltValueNullFieldError.checkNotNull(customValue4, 'VendorContactEntity', 'customValue4'),
link: BuiltValueNullFieldError.checkNotNull(link, 'VendorContactEntity', 'link'),
isChanged: isChanged,
createdAt: BuiltValueNullFieldError.checkNotNull(createdAt, 'VendorContactEntity', 'createdAt'),
updatedAt: BuiltValueNullFieldError.checkNotNull(updatedAt, 'VendorContactEntity', 'updatedAt'),

View File

@ -17,6 +17,7 @@ import 'package:invoiceninja_flutter/redux/document/document_actions.dart';
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
import 'package:invoiceninja_flutter/utils/completers.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:url_launcher/url_launcher.dart';
class ViewVendorList implements PersistUI {
ViewVendorList({this.force = false});
@ -288,6 +289,14 @@ void handleVendorAction(
case EntityAction.edit:
editEntity(entity: vendor);
break;
case EntityAction.vendorPortal:
final contact = vendor.contacts.firstWhere((contact) {
return (contact.link ?? '').isNotEmpty;
}, orElse: null);
if (contact != null) {
launchUrl(Uri.parse(contact.silentLink));
}
break;
case EntityAction.newPurchaseOrder:
createEntity(
context: context,