Mercurial > libervia-backend
changeset 2071:c2fdee1bd908
core (stdui): fixed cancellation of ContactList forms
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 11 Sep 2016 23:17:31 +0200 |
parents | 58f0c96d60e5 |
children | 11fb5f5e2f89 |
files | src/stdui/ui_contact_list.py src/tools/xml_tools.py |
diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/stdui/ui_contact_list.py Sun Sep 11 11:03:25 2016 +0200 +++ b/src/stdui/ui_contact_list.py Sun Sep 11 23:17:31 2016 +0200 @@ -22,7 +22,6 @@ from sat.tools import xml_tools from twisted.words.protocols.jabber import jid from xml.dom.minidom import Element -import re class ContactList(object): @@ -209,9 +208,14 @@ @param profile: %(doc_profile)s @return dict """ + if C.bool(data.get('cancelled', 'false')): + return {} contact = data[xml_tools.formEscape('contact_jid')] - cb = lambda data, profile: self._deleteContact(jid.JID(contact), profile) - delete_id = self.host.registerCallback(cb, with_data=True, one_shot=True) + def delete_cb(data, profile): + if not C.bool(data.get('cancelled', 'false')): + self._deleteContact(jid.JID(contact), profile) + return {} + delete_id = self.host.registerCallback(delete_cb, with_data=True, one_shot=True) form_ui = xml_tools.XMLUI("form", title=D_("Delete contact"), submit_id=delete_id) form_ui.addText(D_("Are you sure you want to remove %s from your contact list?") % contact) return {'xmlui': form_ui.toXml()} @@ -223,6 +227,8 @@ @param profile: %(doc_profile)s @return dict """ + if C.bool(data.get('cancelled', 'false')): + return {} contact_jid_s = data[xml_tools.formEscape('contact_jid')] try: contact_jid = jid.JID(contact_jid_s) @@ -244,6 +250,8 @@ @param profile: %(doc_profile)s @return dict """ + if C.bool(data.get('cancelled', 'false')): + return {} contact_jid = jid.JID(data[xml_tools.formEscape('contact_jid')]) # TODO: replace '\t' by a constant (see tools.xmlui.XMLUI.onFormSubmitted) groups = data[xml_tools.formEscape('groups_list')].split('\t')
--- a/src/tools/xml_tools.py Sun Sep 11 11:03:25 2016 +0200 +++ b/src/tools/xml_tools.py Sun Sep 11 23:17:31 2016 +0200 @@ -913,6 +913,8 @@ - a tuple with a couple of string (value,label) if the label and the value differ @param selected (list[string]): list of the selected values @param styles (iterable[string]): flags to set the behaviour of the list + can be: + - multi: mutliple selection is allowed @param name (string) @param parent """