improve automatic conversation from taglist, by setting multiple=true, allowFreeEntries=true and enableEditMode=true

fix Admin > Mail account by using et2-select-email instead of taglist, as et2-select-multiple does NOT yet support allowFreeEntries and enableEditMode
This commit is contained in:
ralf 2022-06-22 16:28:09 +02:00
parent 9a1f8e591f
commit 2db52d939b
2 changed files with 18 additions and 5 deletions

View File

@ -256,12 +256,12 @@
</row>
<row>
<description for="mailAlternateAddress" value="Alternate email address"/>
<taglist id="mailAlternateAddress" autocomplete_url=""/>
<taglist-email id="mailAlternateAddress" autocomplete_url=""/>
<description/>
</row>
<row disabled="@no_forward_available">
<description for="mailForwardingAddress" value="Forward email's to"/>
<taglist id="mailForwardingAddress" autocomplete_url=""/>
<taglist-email id="mailForwardingAddress" autocomplete_url=""/>
<vbox>
<checkbox label="Forward only" id="deliveryMode" selected_value="forwardOnly" onchange="if (widget.getValue()) et2_dialog.alert('Forward only disables IMAP mailbox / storing of mails and just forwards them to given address.','Forward only');"/>
<checkbox label="Allow users to change forwards" id="acc_user_forward"/>
@ -373,8 +373,8 @@
<button label="Apply" id="button[apply]" />
<button statustext="Use wizard to detect or verify configuration" label="Wizard" id="button[wizard]" image="magicwand" background_image="1"/>
<button label="Cancel" id="button[cancel]" onclick="window.close();"/>
<button align="right" label="Delete" id="button[delete]" onclick="et2_dialog.confirm(widget,'Delete this account','Delete')"/>
<button align="right" label="Delete identity" id="button[delete_identity]" onclick="et2_dialog.confirm(widget,'Delete identity','Delete')" image="delete" background_image="1"/>
<button align="right" label="Delete" id="button[delete]" onclick="et2_dialog.confirm(widget,'Delete this account','Delete')" hideOnReadonly="true"/>
<button align="right" label="Delete identity" id="button[delete_identity]" onclick="et2_dialog.confirm(widget,'Delete identity','Delete')" hideOnReadonly="true" image="delete" background_image="1"/>
</hbox>
</template>
</overlay>

View File

@ -183,11 +183,24 @@ function send_template()
preg_match_all('/(^|\s)([a-z0-9_-]+)="([^"]*)"/i', $matches[3], $attrs, PREG_PATTERN_ORDER);
$attrs = array_combine($attrs[2], $attrs[3]);
if (isset($attrs['tags']))
// set multiple for old tags attribute or taglist without maxSelection="1"
if (isset($attrs['tags']) || $matches['1'] === 'taglist' && (empty($attrs['maxSelection']) || $attrs['maxSelection'] > 1))
{
$attrs['multiple'] = 'true';
unset($attrs['tags']);
}
// taglist had allowFreeEntries and enableEditMode with a default of true, while et2-select has it with a default of false
if ($matches['1'] === 'taglist')
{
if (!isset($attrs['allowFreeEntries']))
{
$attrs['allowFreeEntries'] = 'true';
}
if (!isset($attrs['enableEditMode']))
{
$attrs['enableEditMode'] = 'true';
}
}
// no multiple="toggle" or expand_multiple_rows="N" currently, thought Shoelace's select multiple="true" is relative close
// until we find something better, just switch to multiple="true"
if (isset($attrs['multiple']) && $attrs['multiple'] === 'toggle' || !empty($attrs['expand_multiple_rows']))