fixing update

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1392957 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-10-02 15:13:53 +00:00
parent 0113a7a12e
commit 4f2f7f1351
2 changed files with 30 additions and 9 deletions

View File

@ -55,11 +55,12 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
});
}
addProxyConnectorRule=function(proxyConnectorRule){
$("#proxy-connector-rule-add-btn" ).button("loading");
$.log("addProxyConnectorRule");
self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/proxyConnectorRule");
self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/proxyConnectorRule",true);
}
this.saveProxyConnectorRule=function(proxyConnectorRule,url){
this.saveProxyConnectorRule=function(proxyConnectorRule,url,add,completeFnCallback){
$.log("saveProxyConnectorRule:"+url);
$("#user-messages" ).html(mediumSpinnerImg());
$.ajax(url,
@ -70,10 +71,12 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
dataType: 'json',
success: function(data) {
$.log("save proxyConnectorRule pattern:"+proxyConnectorRule.pattern());
var message=$.i18n.prop(self.update?'proxy-connector-rule.updated':'proxy-connector-rule.added',proxyConnectorRule.pattern());
var message=$.i18n.prop(add?'proxy-connector-rule.added':'proxy-connector-rule.updated',proxyConnectorRule.pattern());
displaySuccessMessage(message);
proxyConnectorRule.modified(false);
self.proxyConnectorRules.push(proxyConnectorRule);
if(add){
self.proxyConnectorRules.push(proxyConnectorRule);
}
activateProxyConnectorRulesGridTab();
},
error: function(data) {
@ -82,6 +85,9 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
},
complete:function(data){
removeMediumSpinnerImg("#user-messages");
if(completeFnCallback){
completeFnCallback();
}
}
}
);
@ -89,13 +95,19 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
updateProxyConnectorRule=function(proxyConnectorRule){
$.log("updateProxyConnectorRule");
self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/updateProxyConnectorRule");
$("#main-content" ).find("#proxy-connectors-rules-edit-div").find("#proxy-connector-rule-update-btn").button("loading");
self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/updateProxyConnectorRule",
false,
function(){
$("#proxy-connector-rule-update-btn" ).button("reset");
}
);
}
removeProxyConnectorRule=function(proxyConnectorRule){
//FIXME modal dialog to confirm
//$("#proxy-connector-rule-delete-btn" ).button("loading");
$("#user-messages" ).html(mediumSpinnerImg());
$.ajax("restServices/archivaServices/proxyConnectorRuleService/deleteProxyConnectorRule",
{
@ -113,6 +125,7 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
},
complete:function(data){
removeMediumSpinnerImg("#user-messages");
//$("#proxy-connector-rule-delete-btn" ).button("reset");
}
}
);

View File

@ -1303,7 +1303,7 @@
</a>
</td>
<td>
<a href="#" data-bind="click: function(){ removeProxyConnectorRule(row) }">
<a href="#" data-bind="click: function(){ removeProxyConnectorRule(row) }" data-loading-text="${$.i18n.prop('common.loading')}">
<span class="btn btn-danger">
<i class="icon-trash icon-white"/>
</span>
@ -1311,7 +1311,8 @@
</td>
<td>
{{if row.modified()}}
<a href="#" class="btn btn-warning" data-bind="click: function(){ updateProxyConnectorRule(row) }">${$.i18n.prop('save')}</a>
<a href="#" id="proxy-connector-rule-update-btn" class="btn btn-warning" data-loading-text="${$.i18n.prop('common.loading')}"
data-bind="click: function(){ updateProxyConnectorRule(row) }">${$.i18n.prop('save')}</a>
{{/if}}
</td>
</tr>
@ -1357,8 +1358,15 @@
{{/if}}
{{if proxyConnectorRule.modified()}}
<div class="span3">
<a href="#" class="btn btn-warning" data-bind="click: function(){addProxyConnectorRule(proxyConnectorRule)}">${$.i18n.prop('save')}</a>
{{if update}}
<a href="#" class="btn btn-warning" data-loading-text="${$.i18n.prop('common.loading')}"
id="proxy-connector-rule-update-btn" data-bind="click: function(){updateProxyConnectorRule(proxyConnectorRule)}">${$.i18n.prop('update')}</a>
{{else}}
<a href="#" class="btn btn-warning" data-loading-text="${$.i18n.prop('common.loading')}"
id="proxy-connector-rule-add-btn" data-bind="click: function(){addProxyConnectorRule(proxyConnectorRule)}">${$.i18n.prop('add')}</a>
{{/if}}
</div>
<br/>
{{/if}}
</div>