mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
* Mail: allow placeholders in compose instead of email-addresses to be able to create mail templates
This commit is contained in:
parent
3f04be2d03
commit
649645ab0f
@ -8,9 +8,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {Et2Select} from "./Et2Select";
|
import {Et2Select} from "./Et2Select";
|
||||||
import {css, html, nothing} from "@lion/core";
|
import {css, html, nothing, PropertyValues} from "@lion/core";
|
||||||
import {IsEmail} from "../Validators/IsEmail";
|
import {IsEmail} from "../Validators/IsEmail";
|
||||||
import interact from "@interactjs/interact";
|
import interact from "@interactjs/interact";
|
||||||
|
import {Validator} from "@lion/form-core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select email address(es)
|
* Select email address(es)
|
||||||
@ -55,6 +56,11 @@ export class Et2SelectEmail extends Et2Select
|
|||||||
*/
|
*/
|
||||||
allowDragAndDrop: {type: Boolean},
|
allowDragAndDrop: {type: Boolean},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow placeholders like {{email}}, beside real email-addresses
|
||||||
|
*/
|
||||||
|
allowPlaceholder: {type: Boolean},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include mailing lists: returns them with their integer list_id
|
* Include mailing lists: returns them with their integer list_id
|
||||||
*/
|
*/
|
||||||
@ -73,12 +79,25 @@ export class Et2SelectEmail extends Et2Select
|
|||||||
this.search = true;
|
this.search = true;
|
||||||
this.searchUrl = "EGroupware\\Api\\Etemplate\\Widget\\Taglist::ajax_email";
|
this.searchUrl = "EGroupware\\Api\\Etemplate\\Widget\\Taglist::ajax_email";
|
||||||
this.allowFreeEntries = true;
|
this.allowFreeEntries = true;
|
||||||
|
this.allowPlaceholder = false;
|
||||||
this.editModeEnabled = true;
|
this.editModeEnabled = true;
|
||||||
this.allowDragAndDrop = false;
|
this.allowDragAndDrop = false;
|
||||||
this.includeLists = false;
|
this.includeLists = false;
|
||||||
this.multiple = false;
|
this.multiple = false;
|
||||||
this.fullEmail = false;
|
this.fullEmail = false;
|
||||||
this.defaultValidators.push(new IsEmail());
|
this.defaultValidators.push(new IsEmail(this.allowPlaceholder));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param {import('@lion/core').PropertyValues } changedProperties */
|
||||||
|
willUpdate(changedProperties : PropertyValues)
|
||||||
|
{
|
||||||
|
super.willUpdate(changedProperties);
|
||||||
|
|
||||||
|
if(changedProperties.has('allowPlaceholder'))
|
||||||
|
{
|
||||||
|
this.defaultValidators = (<Array<Validator>>this.defaultValidators).filter(v => !(v instanceof IsEmail));
|
||||||
|
this.defaultValidators.push(new IsEmail(this.allowPlaceholder));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback()
|
connectedCallback()
|
||||||
|
@ -27,9 +27,23 @@ export class IsEmail extends Pattern
|
|||||||
*/
|
*/
|
||||||
static EMAIL_PREG : RegExp = /^(([^\042',<][^,<]+|\042[^\042]+\042|\'[^\']+\'|"(?:[^"\\]|\\.)*")\s?<)?[^\x00-\x20()\xe2\x80\x8b<>@,;:\042\[\]\x80-\xff]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,}>?$/i;
|
static EMAIL_PREG : RegExp = /^(([^\042',<][^,<]+|\042[^\042]+\042|\'[^\']+\'|"(?:[^"\\]|\\.)*")\s?<)?[^\x00-\x20()\xe2\x80\x8b<>@,;:\042\[\]\x80-\xff]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,}>?$/i;
|
||||||
|
|
||||||
constructor()
|
/**
|
||||||
|
* Allow everything containing at least one placeholder e.g.:
|
||||||
|
* - "{{email}}"
|
||||||
|
* - "{{n_fn}} <{{email}}"
|
||||||
|
* - "{{#<custom-field-name>}}"
|
||||||
|
* - we do NOT check if the placeholder is implemented by addressbook or a valid custom-field name!
|
||||||
|
* - "test" or "{test}}" are NOT valid
|
||||||
|
*/
|
||||||
|
static EMAIL_PLACEHOLDER_PREG = new RegExp('^(.*{{#?[a-z0-9_]+}}.*|'+IsEmail.EMAIL_PREG.source.substr(1, IsEmail.EMAIL_PREG.source.length-2)+')$', 'i');
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param _allowPlaceholders true: allow valid email-addresses OR something with placeholder(s)
|
||||||
|
*/
|
||||||
|
constructor(_allowPlaceholders: boolean)
|
||||||
{
|
{
|
||||||
super(IsEmail.EMAIL_PREG);
|
super(_allowPlaceholders ? IsEmail.EMAIL_PLACEHOLDER_PREG : IsEmail.EMAIL_PREG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,8 @@
|
|||||||
</row>
|
</row>
|
||||||
<row class="mailComposeHeaders mailComposeJQueryReplyto">
|
<row class="mailComposeHeaders mailComposeJQueryReplyto">
|
||||||
<et2-description value="Reply to"></et2-description>
|
<et2-description value="Reply to"></et2-description>
|
||||||
<et2-select-email id="replyto" width="100%" onclick="app.mail.address_click" multiple="true" searchUrl="EGroupware\Api\Etemplate\Widget\Taglist::ajax_email"></et2-select-email>
|
<et2-select-email id="replyto" width="100%" onclick="app.mail.address_click" multiple="true"
|
||||||
|
searchUrl="EGroupware\Api\Etemplate\Widget\Taglist::ajax_email" allowPlaceholder="true"></et2-select-email>
|
||||||
<et2-description></et2-description>
|
<et2-description></et2-description>
|
||||||
</row>
|
</row>
|
||||||
<row class="mailComposeHeaders mailComposeJQueryFolder">
|
<row class="mailComposeHeaders mailComposeJQueryFolder">
|
||||||
@ -56,7 +57,9 @@
|
|||||||
</row>
|
</row>
|
||||||
<row class="mailComposeHeaders" >
|
<row class="mailComposeHeaders" >
|
||||||
<et2-description value="To"></et2-description>
|
<et2-description value="To"></et2-description>
|
||||||
<et2-select-email id="to" allowDragAndDrop="true" width="100%" onclick="app.mail.address_click" multiple="true" onchange="app.mail.recipients_onchange" autofocus="true" searchUrl="EGroupware\Api\Etemplate\Widget\Taglist::ajax_email" placeholder="select or insert email address" includeLists="true"></et2-select-email>
|
<et2-select-email id="to" allowDragAndDrop="true" width="100%" onclick="app.mail.address_click" multiple="true"
|
||||||
|
onchange="app.mail.recipients_onchange" autofocus="true" searchUrl="EGroupware\Api\Etemplate\Widget\Taglist::ajax_email"
|
||||||
|
placeholder="select or insert email address" includeLists="true" allowPlaceholder="true"></et2-select-email>
|
||||||
<et2-hbox>
|
<et2-hbox>
|
||||||
<et2-description id="cc_expander" value="Cc" class="et2_button_text" onclick="app.mail.compose_fieldExpander"></et2-description>
|
<et2-description id="cc_expander" value="Cc" class="et2_button_text" onclick="app.mail.compose_fieldExpander"></et2-description>
|
||||||
<et2-description id="bcc_expander" value="Bcc" class="et2_button_text" onclick="app.mail.compose_fieldExpander"></et2-description>
|
<et2-description id="bcc_expander" value="Bcc" class="et2_button_text" onclick="app.mail.compose_fieldExpander"></et2-description>
|
||||||
@ -64,12 +67,16 @@
|
|||||||
</row>
|
</row>
|
||||||
<row class="mailComposeHeaders mailComposeJQueryCc">
|
<row class="mailComposeHeaders mailComposeJQueryCc">
|
||||||
<et2-description value="Cc"></et2-description>
|
<et2-description value="Cc"></et2-description>
|
||||||
<et2-select-email id="cc" width="100%" allowDragAndDrop="true" onclick="app.mail.address_click" multiple="true" onchange="app.mail.recipients_onchange" searchUrl="EGroupware\Api\Etemplate\Widget\Taglist::ajax_email" placeholder="select or insert email address" includeLists="true"></et2-select-email>
|
<et2-select-email id="cc" width="100%" allowDragAndDrop="true" onclick="app.mail.address_click" multiple="true"
|
||||||
|
onchange="app.mail.recipients_onchange" searchUrl="EGroupware\Api\Etemplate\Widget\Taglist::ajax_email"
|
||||||
|
placeholder="select or insert email address" includeLists="true" allowPlaceholder="true"></et2-select-email>
|
||||||
<et2-description></et2-description>
|
<et2-description></et2-description>
|
||||||
</row>
|
</row>
|
||||||
<row class="mailComposeHeaders mailComposeJQueryBcc">
|
<row class="mailComposeHeaders mailComposeJQueryBcc">
|
||||||
<et2-description value="Bcc"></et2-description>
|
<et2-description value="Bcc"></et2-description>
|
||||||
<et2-select-email id="bcc" width="100%" allowDragAndDrop="true" onclick="app.mail.address_click" multiple="true" onchange="app.mail.recipients_onchange" searchUrl="EGroupware\Api\Etemplate\Widget\Taglist::ajax_email" placeholder="select or insert email address" includeLists="true"></et2-select-email>
|
<et2-select-email id="bcc" width="100%" allowDragAndDrop="true" onclick="app.mail.address_click" multiple="true"
|
||||||
|
onchange="app.mail.recipients_onchange" searchUrl="EGroupware\Api\Etemplate\Widget\Taglist::ajax_email"
|
||||||
|
placeholder="select or insert email address" includeLists="true" allowPlaceholder="true"></et2-select-email>
|
||||||
<et2-description></et2-description>
|
<et2-description></et2-description>
|
||||||
</row>
|
</row>
|
||||||
<row class="mailComposeHeaders">
|
<row class="mailComposeHeaders">
|
||||||
|
Loading…
Reference in New Issue
Block a user