Browse Source

display status messages when saved successfully and hide the texture forms for murmur 1.2.2

Natenom/support-murmur-13-1446181288462
Michael Ziegler 14 years ago
parent
commit
4180ea8ca2
  1. 17
      pyweb/djextdirect/formprovider.py
  2. 144
      pyweb/mumble/templates/mumble/mumble.html

17
pyweb/djextdirect/formprovider.py

@ -50,6 +50,18 @@ Ext.ux.%(clsname)s = function( config ){
if( typeof config.pk != "undefined" ){ if( typeof config.pk != "undefined" ){
this.load(); 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, { 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' ){ typeof action.result.errors['__all__'] != 'undefined' ){
Ext.Msg.alert( "Error", action.result.errors['__all__'] ); 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: [{ """buttons: [{
text: "Submit", text: "Submit",
handler: this.submit, handler: this.submit,
id: '"""+clsname+"""_submit',
scope: this scope: this
}]""" }]"""
'}', '}',

144
pyweb/mumble/templates/mumble/mumble.html

@ -119,68 +119,120 @@
xtype: "{{ RegForm|lower }}", xtype: "{{ RegForm|lower }}",
pk: {% if MumbleAccount %}{{ MumbleAccount.id }}{% else %}-1{% endif %}, pk: {% if MumbleAccount %}{{ MumbleAccount.id }}{% else %}-1{% endif %},
labelWidth: 150, 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 %} {% if IsAdmin %}
{ {
title: gettext("Administration"), title: gettext("Administration"),
pk: {{ MumbleServer.id }}, pk: {{ MumbleServer.id }},
labelWidth: 150, 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 %} {% endif %}
{% if MumbleAccount %} {% if MumbleAccount %}
{ {
title: gettext("User texture"), 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: [{ items: [{
flex: 1,
height: 200,
title: gettext("Texture"),
html: String.format('<img src="{0}" alt="Avatar" id="img_avatar" />',
"{% url mumble.views.showTexture MumbleServer.id MumbleAccount.id %}")
}, {
flex: 1,
region: "north",
layout: "hbox",
height: 200, height: 200,
title: gettext("Gravatar"),
html: String.format('<img src="{0}" alt="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('<img src="{0}" alt="Avatar" id="img_avatar" />',
"{% url mumble.views.showTexture MumbleServer.id MumbleAccount.id %}")
}, {
flex: 1,
height: 200,
title: gettext("Gravatar"),
html: String.format('<img src="{0}" alt="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 %} {% endif %}
{% if IsAdmin %} {% if IsAdmin %}

Loading…
Cancel
Save