mirror of https://github.com/apache/archiva.git
add a mechanism in knockout simpleGrid binding to add callback subscribe on values change
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1233120 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7852bfcf1d
commit
a4d3620a65
|
@ -299,13 +299,16 @@ $(function() {
|
|||
title: "Repository type (default is Maven 2)"
|
||||
}
|
||||
],
|
||||
pageSize: 5
|
||||
pageSize: 5,
|
||||
gridUpdateCallBack: function(){
|
||||
$.log("gridUpdateCallBack");
|
||||
$("#main-content #managed-repositories-table [title]").twipsy();
|
||||
}
|
||||
});
|
||||
ko.applyBindings(managedRepositoriesViewModel,$("#main-content #managed-repositories-table").get(0));
|
||||
$("#main-content #managed-repositories-pills").pills();
|
||||
$("#managed-repositories-view").addClass("active");
|
||||
removeMediumSpinnerImg("#main-content #managed-repositories-content");
|
||||
$("#main-content #managed-repositories-table [title]").twipsy();
|
||||
activateManagedRepositoriesGridTab();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,12 +42,11 @@
|
|||
<div id="managed-repositories-tabs-content" class="pill-content">
|
||||
<div id="managed-repositories-view" class="active">
|
||||
<table class="bordered-table zebra-striped" id="managed-repositories-table"
|
||||
data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko_managed-repositoriesGrid',pageLinksId:'managed-repositoriesPagination'">
|
||||
data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko_managed-repositoriesGrid',pageLinksId:'managed-repositoriesPagination',data:'managedRepositories'">
|
||||
</table>
|
||||
<div id="managed-repositoriesPagination"></div>
|
||||
</div>
|
||||
<div id="managed-repository-edit" data-bind='template: {name:"managed-repository-edit-tmpl"}'>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2743,6 +2743,7 @@ ko.exportSymbol('templateRewriting.applyMemoizedBindingsToNextSibling', ko.templ
|
|||
}
|
||||
|
||||
function executeTemplate(targetNodeOrNodeArray, renderMode, template, bindingContext, options) {
|
||||
|
||||
options = options || {};
|
||||
var templateEngineToUse = (options['templateEngine'] || _templateEngine);
|
||||
ko.templateRewriting.ensureTemplateIsRewritten(template, templateEngineToUse);
|
||||
|
@ -2797,7 +2798,6 @@ ko.exportSymbol('templateRewriting.applyMemoizedBindingsToNextSibling', ko.templ
|
|||
|
||||
// Support selecting template as a function of the data being rendered
|
||||
var templateName = typeof(template) == 'function' ? template(bindingContext['$data']) : template;
|
||||
|
||||
var renderedNodesArray = executeTemplate(targetNodeOrNodeArray, renderMode, templateName, bindingContext, options);
|
||||
if (renderMode == "replaceNode") {
|
||||
targetNodeOrNodeArray = renderedNodesArray;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
ko.simpleGrid = {
|
||||
// Defines a view model class you can use to populate a grid
|
||||
viewModel: function (configuration) {
|
||||
this.data = configuration.data;
|
||||
this.data = ko.observableArray(configuration.data);
|
||||
this.currentPageIndex = ko.observable(0);
|
||||
this.pageSize = configuration.pageSize || 5;
|
||||
this.columns = configuration.columns;
|
||||
|
@ -31,6 +31,8 @@
|
|||
this.i18n=function(key){
|
||||
return $.i18n.prop(key);
|
||||
};
|
||||
this.gridUpdateCallBack = configuration.gridUpdateCallBack;
|
||||
this.pageLinksUpdateCallBack = configuration.pageLinksUpdateCallBack;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -54,11 +56,13 @@
|
|||
|
||||
// Render the main grid
|
||||
var gridContainer = element.appendChild(document.createElement("DIV"));
|
||||
ko.renderTemplate(gridTemplateName, viewModel, { templateEngine: templateEngine }, gridContainer, "replaceNode");
|
||||
ko.renderTemplate(gridTemplateName, viewModel, { templateEngine: templateEngine }, gridContainer, "replaceNode")
|
||||
.subscribe(viewModel.gridUpdateCallBack?viewModel.gridUpdateCallBack:function(){});
|
||||
|
||||
// Render the page links
|
||||
var pageLinksContainer = $("#"+allBindings.pageLinksId).get(0);
|
||||
ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode");
|
||||
ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode")
|
||||
.subscribe(viewModel.pageLinksUpdateCallBack?viewModel.pageLinksUpdateCallBack:function(){});
|
||||
}
|
||||
};
|
||||
})();
|
Loading…
Reference in New Issue