Bug 1769506 - Reinstate the vCard editor in Account Manager. r=aleca
Differential Revision: https://phabricator.services.mozilla.com/D146416 --HG-- extra : rebase_source : b4abea542a4dc3eeb02a44ffda3bbca74e0aa1a0
This commit is contained in:
Родитель
6ecf0db6bf
Коммит
4ece5f5845
|
@ -42,10 +42,14 @@ class VCardEdit extends HTMLElement {
|
||||||
|
|
||||||
set vCardString(value) {
|
set vCardString(value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.vCardProperties = VCardProperties.fromVCard(value);
|
try {
|
||||||
} else {
|
this.vCardProperties = VCardProperties.fromVCard(value);
|
||||||
this.vCardProperties = new VCardProperties();
|
return;
|
||||||
|
} catch (ex) {
|
||||||
|
Cu.reportError(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.vCardProperties = new VCardProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
get vCardProperties() {
|
get vCardProperties() {
|
||||||
|
|
|
@ -521,6 +521,7 @@ body:not(.is-editing) #detailsPane :is(.edit, .noValue) {
|
||||||
#detailsFooter,
|
#detailsFooter,
|
||||||
vcard-edit {
|
vcard-edit {
|
||||||
padding-inline: 20px;
|
padding-inline: 20px;
|
||||||
|
/* Two <vcard-edit> columns. */
|
||||||
max-width: 54em;
|
max-width: 54em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,3 +271,8 @@ body {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#editVCardDialog {
|
||||||
|
/* Two <vcard-edit> columns. */
|
||||||
|
width: 54em;
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: repeat(auto-fill, minmax(26.5em, 1fr));
|
||||||
|
grid-template-rows: masonry;
|
||||||
|
gap: 1em;
|
||||||
margin-block: 15px;
|
margin-block: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +14,6 @@ fieldset {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: none;
|
border: none;
|
||||||
margin-block-end: 21px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
legend {
|
legend {
|
||||||
|
@ -34,8 +35,7 @@ th[hidden] {
|
||||||
}
|
}
|
||||||
|
|
||||||
#addr-book-edit-n {
|
#addr-book-edit-n {
|
||||||
grid-column: 1 / 3;
|
grid-column: 1 / -1;
|
||||||
grid-row: 1 / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.addr-book-edit-fieldset-button:not([hidden]) {
|
.addr-book-edit-fieldset-button:not([hidden]) {
|
||||||
|
|
|
@ -150,15 +150,18 @@
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
<dialog xmlns="http://www.w3.org/1999/xhtml" id="editVCardDialog">
|
<dialog xmlns="http://www.w3.org/1999/xhtml" id="editVCardDialog">
|
||||||
<!-- TODO add vCard editing UI -->
|
<form autocomplete="off">
|
||||||
<menu class="dialog-menu-container">
|
#include ../../../../mail/components/addrbook/content/vcard-edit/vCardTemplates.inc.xhtml
|
||||||
<button class="cancel"
|
<vcard-edit class="edit"/>
|
||||||
data-l10n-id="edit-vcard-dialog-cancel-button"
|
<menu class="dialog-menu-container">
|
||||||
data-l10n-attrs="accesskey"></button>
|
<button type="reset" class="cancel"
|
||||||
<button class="accept primary"
|
data-l10n-id="edit-vcard-dialog-cancel-button"
|
||||||
data-l10n-id="edit-vcard-dialog-accept-button"
|
data-l10n-attrs="accesskey"></button>
|
||||||
data-l10n-attrs="accesskey"></button>
|
<button type="submit" class="accept primary"
|
||||||
</menu>
|
data-l10n-id="edit-vcard-dialog-accept-button"
|
||||||
|
data-l10n-attrs="accesskey"></button>
|
||||||
|
</menu>
|
||||||
|
</form>
|
||||||
</dialog>
|
</dialog>
|
||||||
</html:body>
|
</html:body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -73,7 +73,7 @@ function initIdentityValues(identity) {
|
||||||
document.getElementById("identity.attachVCard").checked =
|
document.getElementById("identity.attachVCard").checked =
|
||||||
identity.attachVCard;
|
identity.attachVCard;
|
||||||
document.getElementById("identity.escapedVCard").value =
|
document.getElementById("identity.escapedVCard").value =
|
||||||
identity.escapedVCard;
|
identity.escapedVCard || "";
|
||||||
|
|
||||||
document.getElementById("identity.catchAll").checked = identity.catchAll;
|
document.getElementById("identity.catchAll").checked = identity.catchAll;
|
||||||
document.getElementById("identity.catchAllHint").value =
|
document.getElementById("identity.catchAllHint").value =
|
||||||
|
@ -464,34 +464,61 @@ function setupSignatureItems() {
|
||||||
function editVCard() {
|
function editVCard() {
|
||||||
// Read vCard hidden value from UI.
|
// Read vCard hidden value from UI.
|
||||||
let escapedVCard = document.getElementById("identity.escapedVCard");
|
let escapedVCard = document.getElementById("identity.escapedVCard");
|
||||||
|
|
||||||
let dialog = top.document.getElementById("editVCardDialog");
|
let dialog = top.document.getElementById("editVCardDialog");
|
||||||
// TODO connect vCard editing UI
|
let form = dialog.querySelector("form");
|
||||||
// dialog.querySelector("vcard-edit").vCardString = decodeURIComponent(
|
let vCardEdit = dialog.querySelector("vcard-edit");
|
||||||
// escapedVCard.value
|
|
||||||
// );
|
|
||||||
|
|
||||||
dialog.querySelector(".accept").addEventListener("click", () => {
|
vCardEdit.vCardString = decodeURIComponent(escapedVCard.value);
|
||||||
// escapedVCard.value = encodeURIComponent(
|
|
||||||
// dialog.querySelector("vcard-edit").vCardString
|
|
||||||
// );
|
|
||||||
// Trigger a change event so for the am-main view the event listener
|
|
||||||
// set up in AccountManager.js onLoad() can make sure to save the change.
|
|
||||||
escapedVCard.dispatchEvent(new CustomEvent("change"));
|
|
||||||
|
|
||||||
top.gSubDialog._topDialog?._overlay.setAttribute("topmost", "true");
|
top.addEventListener("keydown", editVCardKeyDown, { capture: true });
|
||||||
dialog.close();
|
form.addEventListener("submit", editVCardSubmit);
|
||||||
});
|
form.addEventListener("reset", editVCardReset);
|
||||||
|
|
||||||
dialog.querySelector(".cancel").addEventListener("click", () => {
|
|
||||||
top.gSubDialog._topDialog?._overlay.setAttribute("topmost", "true");
|
|
||||||
dialog.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
top.gSubDialog._topDialog?._overlay.removeAttribute("topmost");
|
top.gSubDialog._topDialog?._overlay.removeAttribute("topmost");
|
||||||
dialog.showModal();
|
dialog.showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function editVCardKeyDown(event) {
|
||||||
|
let dialog = top.document.getElementById("editVCardDialog");
|
||||||
|
if (event.keyCode == KeyboardEvent.DOM_VK_ESCAPE && dialog.open) {
|
||||||
|
// This is a bit of a hack to prevent other dialogs (particularly
|
||||||
|
// SubDialogs) from closing when the vCard dialog is open.
|
||||||
|
event.preventDefault();
|
||||||
|
editVCardReset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function editVCardSubmit(event) {
|
||||||
|
let escapedVCard = document.getElementById("identity.escapedVCard");
|
||||||
|
let dialog = top.document.getElementById("editVCardDialog");
|
||||||
|
let form = dialog.querySelector("form");
|
||||||
|
let vCardEdit = dialog.querySelector("vcard-edit");
|
||||||
|
|
||||||
|
vCardEdit.saveVCard();
|
||||||
|
escapedVCard.value = encodeURIComponent(vCardEdit.vCardString);
|
||||||
|
// Trigger a change event so for the am-main view the event listener
|
||||||
|
// set up in AccountManager.js onLoad() can make sure to save the change.
|
||||||
|
escapedVCard.dispatchEvent(new CustomEvent("change"));
|
||||||
|
|
||||||
|
top.gSubDialog._topDialog?._overlay.setAttribute("topmost", "true");
|
||||||
|
dialog.close();
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
form.removeEventListener("submit", editVCardSubmit);
|
||||||
|
form.removeEventListener("reset", editVCardReset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function editVCardReset() {
|
||||||
|
let dialog = top.document.getElementById("editVCardDialog");
|
||||||
|
let form = dialog.querySelector("form");
|
||||||
|
|
||||||
|
top.gSubDialog._topDialog?._overlay.setAttribute("topmost", "true");
|
||||||
|
dialog.close();
|
||||||
|
|
||||||
|
form.removeEventListener("submit", editVCardSubmit);
|
||||||
|
form.removeEventListener("reset", editVCardReset);
|
||||||
|
}
|
||||||
|
|
||||||
function getAccountForFolderPickerState() {
|
function getAccountForFolderPickerState() {
|
||||||
return gAccount;
|
return gAccount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ messenger.jar:
|
||||||
content/messenger/addressbook/abMailListDialog.js (addrbook/content/abMailListDialog.js)
|
content/messenger/addressbook/abMailListDialog.js (addrbook/content/abMailListDialog.js)
|
||||||
content/messenger/addressbook/abView.js (addrbook/content/abView.js)
|
content/messenger/addressbook/abView.js (addrbook/content/abView.js)
|
||||||
content/messenger/addressbook/map-list.js (addrbook/content/map-list.js)
|
content/messenger/addressbook/map-list.js (addrbook/content/map-list.js)
|
||||||
content/messenger/AccountManager.xhtml (base/prefs/content/AccountManager.xhtml)
|
* content/messenger/AccountManager.xhtml (base/prefs/content/AccountManager.xhtml)
|
||||||
content/messenger/AccountManager.js (base/prefs/content/AccountManager.js)
|
content/messenger/AccountManager.js (base/prefs/content/AccountManager.js)
|
||||||
content/messenger/am-main.xhtml (base/prefs/content/am-main.xhtml)
|
content/messenger/am-main.xhtml (base/prefs/content/am-main.xhtml)
|
||||||
content/messenger/am-main.js (base/prefs/content/am-main.js)
|
content/messenger/am-main.js (base/prefs/content/am-main.js)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче