Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WEBUI: Fix the apply functionality (maintain dirty)
  • Loading branch information
perexg committed Jan 8, 2016
1 parent 6a92dac commit 5a06449
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/webui/static/app/extensions.js
Expand Up @@ -1832,9 +1832,6 @@ Ext.ux.Window = Ext.extend(Ext.Window, {

});

// create namespace
Ext.ns('Ext.ux');

Ext.layout.Column2Layout = Ext.extend(Ext.layout.ColumnLayout, {

getLayoutTargetSize : function() {
Expand Down
23 changes: 19 additions & 4 deletions src/webui/static/app/idnode.js
Expand Up @@ -1105,15 +1105,22 @@ tvheadend.idnode_editor = function(_uilevel, item, conf)
iconCls: 'apply',
handler: function() {
if (panel.getForm().isDirty()) {
var node = panel.getForm().getFieldValues();
var form = panel.getForm();
var node = form.getFieldValues();
node.uuid = conf.uuids ? conf.uuids : item.uuid;
tvheadend.Ajax({
url: conf.saveURL || 'api/idnode/save',
params: {
node: Ext.encode(node)
},
success: function(d) {
panel.getForm().reset();
Ext.MessageBox.alert(_('Apply'), _('Changes were applied!'));
form.trackResetOnLoad = true;
form.setValues(node);
},
failure: function(response) {
Ext.MessageBox.alert(_('Apply'), _('Cannot apply') + ': ' + response.responseText + '!');
form.reset();
}
});
}
Expand Down Expand Up @@ -1417,12 +1424,20 @@ tvheadend.idnode_create = function(conf, onlyDefault, cloneValues)
params['uuid'] = puuid;
if (pclass)
params['class'] = pclass;
params['conf'] = Ext.encode(panel.getForm().getFieldValues());
var form = panel.getForm();
var values = form.getFieldValues();
params['conf'] = Ext.encode(values);
tvheadend.Ajax({
url: conf.create.url || conf.url + '/create',
params: params,
success: function(d) {
panel.getForm().reset();
Ext.MessageBox.confirm(_('Apply'), _('Changes were applied!'));
form.trackResetOnLoad = true;
form.setValues(node);
},
failure: function(response) {
Ext.MessageBox.confirm(_('Apply'), _('Cannot apply') + ': ' + response.responseText + '!');
form.reset();
}
});
}
Expand Down

0 comments on commit 5a06449

Please sign in to comment.