From 4180ea8ca297de5541e91a342faeeb0158fe3f7c Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Sat, 13 Nov 2010 15:27:49 +0100 Subject: [PATCH] display status messages when saved successfully and hide the texture forms for murmur 1.2.2 --- pyweb/djextdirect/formprovider.py | 17 +++ pyweb/mumble/templates/mumble/mumble.html | 144 +++++++++++++++------- 2 files changed, 115 insertions(+), 46 deletions(-) diff --git a/pyweb/djextdirect/formprovider.py b/pyweb/djextdirect/formprovider.py index 8d036a1..a85dbd6 100644 --- a/pyweb/djextdirect/formprovider.py +++ b/pyweb/djextdirect/formprovider.py @@ -50,6 +50,18 @@ Ext.ux.%(clsname)s = function( config ){ if( typeof config.pk != "undefined" ){ this.load(); } + + this.form.addEvents({ + 'submitSuccess': true, + 'submitFailure': true + }); + + if( typeof config.listeners != "undefined" ){ + if( typeof config.listeners.submitSuccess != "undefined" ) + this.form.on("submitSuccess", config.listeners.submitSuccess); + if( typeof config.listeners.submitFailure != "undefined" ) + this.form.on("submitFailure", config.listeners.submitFailure); + } } Ext.extend( Ext.ux.%(clsname)s, Ext.form.FormPanel, { @@ -64,6 +76,10 @@ Ext.extend( Ext.ux.%(clsname)s, Ext.form.FormPanel, { typeof action.result.errors['__all__'] != 'undefined' ){ Ext.Msg.alert( "Error", action.result.errors['__all__'] ); } + form.fireEvent("submitFailure", form, action); + }, + success: function( form, action ){ + form.fireEvent("submitSuccess", form, action); } }); }, @@ -267,6 +283,7 @@ class FormProvider(Provider): """buttons: [{ text: "Submit", handler: this.submit, + id: '"""+clsname+"""_submit', scope: this }]""" '}', diff --git a/pyweb/mumble/templates/mumble/mumble.html b/pyweb/mumble/templates/mumble/mumble.html index eaabf62..9aa33b1 100644 --- a/pyweb/mumble/templates/mumble/mumble.html +++ b/pyweb/mumble/templates/mumble/mumble.html @@ -119,68 +119,120 @@ xtype: "{{ RegForm|lower }}", pk: {% if MumbleAccount %}{{ MumbleAccount.id }}{% else %}-1{% endif %}, labelWidth: 150, - baseParams: {serverid: {{MumbleServer.id}} } + baseParams: {serverid: {{MumbleServer.id}} }, + {% if not MumbleAccount %} + listeners: { + submitSuccess: function( form, action ){ + window.location.reload(); + } + } + {% else %} + listeners: { + submitSuccess: function( form, action ){ + form.savetip = new Ext.ToolTip({ + id: 'content-anchor-tip', + target: '{{ RegForm }}_submit', + anchor: 'right', + html: gettext("Saved successfully."), + width: 150, + autoHide: true, + listeners: { + hide: function( ttip ){ + form.savetip.destroy(); + form.savetip = null; + } + } + }); + form.savetip.show(); + } + } + {% endif %} }, {% if IsAdmin %} { title: gettext("Administration"), pk: {{ MumbleServer.id }}, labelWidth: 150, - xtype: 'mumbleform' + xtype: 'mumbleform', + listeners: { + submitSuccess: function( form, action ){ + form.savetip = new Ext.ToolTip({ + id: 'content-anchor-tip', + target: 'MumbleForm_submit', + anchor: 'right', + html: gettext("Saved successfully."), + width: 150, + autoHide: true, + listeners: { + hide: function( ttip ){ + form.savetip.destroy(); + form.savetip = null; + } + } + }); + form.savetip.show(); + } + } }, {% endif %} {% if MumbleAccount %} { title: gettext("User texture"), - layout: "border", - items: [{ - region: "north", - layout: "hbox", - height: 200, + {% if MumbleServer|mmversion_eq:"1.2.2" %} + html: gettext( + 'Sorry, due to a bug in Murmur 1.2.2, displaying and setting the Texture is disabled.' + ) + {% else %} + layout: "border", items: [{ - flex: 1, - height: 200, - title: gettext("Texture"), - html: String.format('Avatar', - "{% url mumble.views.showTexture MumbleServer.id MumbleAccount.id %}") - }, { - flex: 1, + region: "north", + layout: "hbox", height: 200, - title: gettext("Gravatar"), - html: String.format('grAvatar', "{{ MumbleAccount.gravatar }}") - }] - }, { - region: "center", - xtype: "form", - labelWidth: 150, - fileUpload: true, - url: "{% url mumble.views.update_avatar MumbleAccount.id %}", - items: [{ - name: "usegravatar", - fieldLabel: gettext("Use Gravatar"), - xtype: "checkbox" + items: [{ + flex: 1, + height: 200, + title: gettext("Texture"), + html: String.format('Avatar', + "{% url mumble.views.showTexture MumbleServer.id MumbleAccount.id %}") + }, { + flex: 1, + height: 200, + title: gettext("Gravatar"), + html: String.format('grAvatar', "{{ MumbleAccount.gravatar }}") + }] }, { - name: "texturefile", - fieldLabel: gettext("Upload Avatar"), - xtype: "textfield", - inputType: "file" - }], - buttons: [{ - text: gettext('Submit'), - handler: function(){ - this.ownerCt.ownerCt.getForm().submit({ - success: function(form, action){ - var now = new Date(); - var img = Ext.fly("img_avatar"); - img.dom.src = String.format("{0}?_dc={1}", - "{% url mumble.views.showTexture MumbleServer.id MumbleAccount.id %}", - now.getTime() - ); - } - }); + region: "center", + xtype: "form", + labelWidth: 150, + fileUpload: true, + url: "{% url mumble.views.update_avatar MumbleAccount.id %}", + items: [{ + name: "usegravatar", + fieldLabel: gettext("Use Gravatar"), + xtype: "checkbox" + }, { + name: "texturefile", + fieldLabel: gettext("Upload Avatar"), + xtype: "textfield", + inputType: "file" + }], + buttons: [{ + text: gettext('Submit'), + handler: function(){ + this.ownerCt.ownerCt.getForm().submit({ + success: function(form, action){ + var now = new Date(); + var img = Ext.fly("img_avatar"); + img.dom.src = String.format("{0}?_dc={1}", + "{% url mumble.views.showTexture MumbleServer.id MumbleAccount.id %}", + now.getTime() + ); + } + }); } + }] }] - }] + {% endif %} }, {% endif %} {% if IsAdmin %}