,"knockout.simpleGrid","knockout.sortable"],
function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
- RepositoryGroup=function(id,repositories){
+ RepositoryGroup=function(id,repositories,mergedIndexPath){
var self=this;
this.id=ko.observable(id);
this.id.subscribe(function(newValue){self.modified(true)});
+ //private String mergedIndexPath = "/.indexer";
+ this.mergedIndexPath=ko.observable(mergedIndexPath?mergedIndexPath:".indexer");
+ this.mergedIndexPath.subscribe(function(newValue){self.modified(true)});
+
// private List<String> repositories;
this.repositories=ko.observableArray(repositories);
this.repositories.subscribe(function(newValue){self.modified(true)});
repositoryGroupViewModel.renderSortableChoosed(self);
repositoryGroupViewModel.renderSortableAvailables(self);
mainContent.find("#repository-groups-view-tabs-li-edit" ).find("a").html($.i18n.prop("edit"));
+ repositoryGroupValidator();
}
});
}
}
this.saveRepositoryGroup=function(repositoryGroup){
- clearUserMessages();
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- $("#repository-group-save" ).button('loading');
- $.ajax("restServices/archivaServices/repositoryGroupService/updateRepositoryGroup",
- {
- type: "POST",
- contentType: 'application/json',
- data:ko.toJSON(repositoryGroup),
- dataType: 'json',
- success: function(data) {
- $.log("update repositoryGroup id:"+repositoryGroup.id());
- var message=$.i18n.prop('repository.group.updated',repositoryGroup.id());
- displaySuccessMessage(message);
- repositoryGroup.modified(false);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete:function(data){
- $("#repository-group-save" ).button('reset');
- removeMediumSpinnerImg(userMessages);
- }
+ if(valid==false){
+ $.log("saveRepositoryGroup, valid:"+valid);
+ return;
+ }
+ clearUserMessages();
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ var valid = $("#main-content").find("#repository-group-edit-form" ).valid();
+
+
+ $("#repository-group-save" ).button('loading');
+ $.ajax("restServices/archivaServices/repositoryGroupService/updateRepositoryGroup",
+ {
+ type: "POST",
+ contentType: 'application/json',
+ data:ko.toJSON(repositoryGroup),
+ dataType: 'json',
+ success: function(data) {
+ $.log("update repositoryGroup id:"+repositoryGroup.id());
+ var message=$.i18n.prop('repository.group.updated',repositoryGroup.id());
+ displaySuccessMessage(message);
+ repositoryGroup.modified(false);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete:function(data){
+ $("#repository-group-save" ).button('reset');
+ removeMediumSpinnerImg(userMessages);
}
- );
+ }
+ );
}
}
activateRepositoryGroupEditTab=function(){
+ $.log("activateRepositoryGroupEditTab");
var mainContent = $("#main-content");
mainContent.find("#repository-groups-view-tabs-content div[class*='tab-pane']").removeClass("active");
mainContent.find("#repository-groups-edit").addClass("active");
mainContent.find("#repository-groups-view-tabs-li-edit").addClass("active");
+
+
+ }
+
+ repositoryGroupValidator=function(){
+ $.log("validator");
+ var theForm=$("#main-content").find("#repository-group-edit-form");
+ var validator = theForm.validate({
+ rules: {
+ id: {
+ required: true
+ },
+ mergedIndexPath:{
+ required:true
+ }
+ },
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError("#main-content #repository-group-edit-form",validator,errorMap,errorMap);
+ }
+ });
+ return validator;
}
mapRepositoryGroups=function(data){
}
mapRepositoryGroup=function(data){
- return new RepositoryGroup(data.id, mapStringArray(data.repositories));
+ return new RepositoryGroup(data.id, mapStringArray(data.repositories),data.mergedIndexPath);
}
});
<script id="repository-group-edit-tmpl" type="text/html">
<div class="row-fluid">
- {{if update}}
- <div class="dotted span8">
- <blockquote>
- ${repositoryGroup.id}
- <br/>
- <a href="${window.archivaRuntimeInfo.baseUrl}/repository/${repositoryGroup.id()}" target="_blank">
- ${applicationUrl}/repository/${repositoryGroup.id()}
- </a>
- </blockquote>
- </div>
- {{else}}
+
<div class="dotted span8">
<form id="repository-group-edit-form" class="well">
<fieldset id="repository-group-edit-fieldset">
<div class="control-group">
<label class="control-label" for="id">${$.i18n.prop('id')}</label>
-
<div class="controls">
<input type="text" class="input-medium required" id="id" name="id" size="15"
data-bind="value: repositoryGroup.id,css:{'uneditable-input': update},readonly:update"/>
</div>
</div>
+ <div class="control-group">
+ <label class="control-label" for="mergedIndexPath">${$.i18n.prop('repository.group.mergedIndexPath')}</label>
+ <div class="controls">
+ <input type="text" class="input-large required" id="mergedIndexPath" name="mergedIndexPath"
+ data-bind="value: repositoryGroup.mergedIndexPath"/>
+ </div>
+ </div>
+ <div>
+ <a href="${window.archivaRuntimeInfo.baseUrl}/repository/${repositoryGroup.id()}" target="_blank">
+ {{if repositoryGroup.id()}}
+ ${applicationUrl}/repository/${repositoryGroup.id()}
+ {{/if}}
+ </a>
+ </div>
</fieldset>
</form>
</div>
- {{/if}}
+
{{if repositoryGroup.modified()}}
<div class="span3">
<a href="#" class="btn btn-warning" data-loading-text="${$.i18n.prop('common.loading')}"