mirror of https://github.com/apache/cloudstack.git
UI: detail view
Support dynamically updating context on detail view load, to support cases where certain context items are required by other elements loaded, but may not be present in the browser history.
This commit is contained in:
parent
c112088fc5
commit
711551e34f
|
|
@ -870,6 +870,13 @@
|
|||
var removedTabs = [];
|
||||
var tabFilter = options.tabFilter;
|
||||
var context = options.context ? options.context : {};
|
||||
var updateContext = $detailView.data('view-args').updateContext;
|
||||
|
||||
if (updateContext) {
|
||||
$.extend($detailView.data('view-args').context, updateContext({
|
||||
context: $detailView.data('view-args').context
|
||||
}));
|
||||
}
|
||||
|
||||
if(options.newData &&
|
||||
($detailView.data('view-args').section != null && context[$detailView.data('view-args').section] != null && context[$detailView.data('view-args').section].length > 0)) {
|
||||
|
|
|
|||
|
|
@ -743,4 +743,53 @@
|
|||
};
|
||||
$detailView.find('.action.updateDataTestAsync a').click();
|
||||
});
|
||||
|
||||
test('Update context', function() {
|
||||
var detailView = {
|
||||
context: {
|
||||
listViewItemA: [
|
||||
{ fieldA: 'fieldAContent' }
|
||||
]
|
||||
// listViewItemB [not stored yet]
|
||||
},
|
||||
|
||||
tabFilter: function(args) {
|
||||
start();
|
||||
ok($.isArray(args.context.listViewItemB), 'updateContext called before tabFilter');
|
||||
stop();
|
||||
|
||||
return [];
|
||||
},
|
||||
|
||||
// updateContext is executed every time a data provider is called
|
||||
updateContext: function(args) {
|
||||
start();
|
||||
ok(true, 'updateContext called');
|
||||
equal(args.context.listViewItemA[0].fieldA, 'fieldAContent', 'updateContext: Item A present in context');
|
||||
stop();
|
||||
|
||||
return {
|
||||
listViewItemB: [
|
||||
{ fieldB: 'fieldBContent' }
|
||||
]
|
||||
};
|
||||
},
|
||||
|
||||
tabs: {
|
||||
test: {
|
||||
title: 'test',
|
||||
fields: { fieldA: { label: 'fieldA'}, fieldB: { label: 'fieldB' }},
|
||||
dataProvider: function(args) {
|
||||
start();
|
||||
equal(args.context.listViewItemA[0].fieldA, 'fieldAContent', 'dataProvider: Item A present in context');
|
||||
equal(args.context.listViewItemB[0].fieldB, 'fieldBContent', 'dataProvider: Item B present in context');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var $detailView = $('<div></div>');
|
||||
|
||||
stop();
|
||||
$detailView.detailView(detailView);
|
||||
});
|
||||
}(jQuery));
|
||||
|
|
|
|||
Loading…
Reference in New Issue