Client portal settings

This commit is contained in:
Hillel Coren 2020-11-30 14:06:18 +02:00
parent aca92999b9
commit 6b11e8a2bc
3 changed files with 146 additions and 24 deletions

View File

@ -1950,6 +1950,22 @@ abstract class SettingsEntity
@BuiltValueField(wireName: 'use_credits_payment') @BuiltValueField(wireName: 'use_credits_payment')
String get useCreditsPayment; String get useCreditsPayment;
@nullable
@BuiltValueField(wireName: 'portal_custom_head')
String get clientPortalCustomHeader;
@nullable
@BuiltValueField(wireName: 'portal_custom_css')
String get clientPortalCustomCss;
@nullable
@BuiltValueField(wireName: 'portal_custom_footer')
String get clientPortalCustomFooter;
@nullable
@BuiltValueField(wireName: 'portal_custom_js')
String get clientPortalCustomJs;
// TODO remove this field // TODO remove this field
@nullable @nullable
@BuiltValueField(wireName: 'custom_payment_terms') @BuiltValueField(wireName: 'custom_payment_terms')

File diff suppressed because one or more lines are too long

View File

@ -46,6 +46,8 @@ class _ClientPortalState extends State<ClientPortal>
final _portalDomainController = TextEditingController(); final _portalDomainController = TextEditingController();
final _customCssController = TextEditingController(); final _customCssController = TextEditingController();
final _customJavaScriptController = TextEditingController(); final _customJavaScriptController = TextEditingController();
final _customHeaderController = TextEditingController();
final _customFooterController = TextEditingController();
final _customMessageDashboard = TextEditingController(); final _customMessageDashboard = TextEditingController();
final _customMessageUnpaidInvoice = TextEditingController(); final _customMessageUnpaidInvoice = TextEditingController();
@ -63,7 +65,7 @@ class _ClientPortalState extends State<ClientPortal>
final settingsUIState = widget.viewModel.state.settingsUIState; final settingsUIState = widget.viewModel.state.settingsUIState;
_controller = TabController( _controller = TabController(
vsync: this, length: 3, initialIndex: settingsUIState.tabIndex); vsync: this, length: 4, initialIndex: settingsUIState.tabIndex);
_controller.addListener(_onTabChanged); _controller.addListener(_onTabChanged);
} }
@ -96,6 +98,8 @@ class _ClientPortalState extends State<ClientPortal>
_customMessageUnapprovedQuote, _customMessageUnapprovedQuote,
_termsController, _termsController,
_privacyController, _privacyController,
_customHeaderController,
_customFooterController,
]; ];
_controllers _controllers
@ -111,6 +115,10 @@ class _ClientPortalState extends State<ClientPortal>
_customMessageUnapprovedQuote.text = settings.customMessageUnapprovedQuote; _customMessageUnapprovedQuote.text = settings.customMessageUnapprovedQuote;
_privacyController.text = settings.clientPortalPrivacy; _privacyController.text = settings.clientPortalPrivacy;
_termsController.text = settings.clientPortalTerms; _termsController.text = settings.clientPortalTerms;
_customHeaderController.text = settings.clientPortalCustomHeader;
_customFooterController.text = settings.clientPortalCustomFooter;
_customCssController.text = settings.clientPortalCustomCss;
_customJavaScriptController.text = settings.clientPortalCustomJs;
_controllers _controllers
.forEach((dynamic controller) => controller.addListener(_onChanged)); .forEach((dynamic controller) => controller.addListener(_onChanged));
@ -135,7 +143,11 @@ class _ClientPortalState extends State<ClientPortal>
..customMessageUnapprovedQuote = ..customMessageUnapprovedQuote =
_customMessageUnapprovedQuote.text.trim() _customMessageUnapprovedQuote.text.trim()
..clientPortalTerms = _termsController.text.trim() ..clientPortalTerms = _termsController.text.trim()
..clientPortalPrivacy = _privacyController.text.trim()); ..clientPortalPrivacy = _privacyController.text.trim()
..clientPortalCustomJs = _customJavaScriptController.text.trim()
..clientPortalCustomCss = _customCssController.text.trim()
..clientPortalCustomHeader = _customHeaderController.text.trim()
..clientPortalCustomFooter = _customFooterController.text.trim());
if (settings != widget.viewModel.settings) { if (settings != widget.viewModel.settings) {
widget.viewModel.onSettingsChanged(settings); widget.viewModel.onSettingsChanged(settings);
} }
@ -181,11 +193,9 @@ class _ClientPortalState extends State<ClientPortal>
Tab( Tab(
text: localization.messages, text: localization.messages,
), ),
/*
Tab( Tab(
text: localization.customize, text: localization.customize,
), ),
*/
], ],
), ),
body: AppTabForm( body: AppTabForm(
@ -416,27 +426,35 @@ class _ClientPortalState extends State<ClientPortal>
), ),
], ],
), ),
/*
ListView( ListView(
children: <Widget>[ children: <Widget>[
FormCard( FormCard(
children: <Widget>[ children: <Widget>[
DecoratedFormField(
label: localization.header,
controller: _customHeaderController,
maxLines: 6,
),
DecoratedFormField(
label: localization.footer,
controller: _customFooterController,
maxLines: 6,
),
DecoratedFormField( DecoratedFormField(
label: localization.customCss, label: localization.customCss,
controller: _customCssController, controller: _customCssController,
maxLines: 8, maxLines: 6,
), ),
if (isSelfHosted(context)) if (isSelfHosted(context))
DecoratedFormField( DecoratedFormField(
label: localization.customJavascript, label: localization.customJavascript,
controller: _customJavaScriptController, controller: _customJavaScriptController,
maxLines: 8, maxLines: 6,
), ),
], ],
) )
], ],
), ),
*/
], ],
), ),
); );