Skip to content

Commit

Permalink
[INTERNAL] mvc.ControllerExtension: add support for the new "overrides"
Browse files Browse the repository at this point in the history
Tests are adapted to the new name, but a copy of the main tests still
checks the old property "override".

Change-Id: I559c2f6aa79f8ef022052effc60d504f10127fa5
  • Loading branch information
akudev committed Feb 16, 2023
1 parent afa5f0b commit 167251e
Show file tree
Hide file tree
Showing 16 changed files with 838 additions and 20 deletions.
7 changes: 4 additions & 3 deletions src/sap.ui.core/src/sap/ui/core/mvc/ControllerMetadata.js
Expand Up @@ -37,10 +37,11 @@ sap.ui.define([
ControllerMetadata.prototype.constructor = ControllerMetadata;

ControllerMetadata.prototype.applySettings = function(oClassInfo) {
// property 'override' needs to be handled separately and must not be attached to the prototype
if (oClassInfo.override) {
this._override = oClassInfo.override;
// property 'overrides' needs to be handled separately and must not be attached to the prototype
if (oClassInfo.overrides || oClassInfo.override) { // also consider the deprecated 'override' property
this._override = oClassInfo.overrides || oClassInfo.override; // ...but only when the new property is not set
delete oClassInfo.override;
delete oClassInfo.overrides;
}

Metadata.prototype.applySettings.call(this, oClassInfo);
Expand Down
Expand Up @@ -37,7 +37,7 @@ sap.ui.define([
oMyOwnButtonFromExtension.setText(sText);
},

override: {
overrides: {
//Override controller method; this is the second extension, so this override will win
getToolbarTitle: function(){
return "OtherExtension Table Operations:";
Expand Down
Expand Up @@ -13,7 +13,7 @@ sap.ui.define(['sap/ui/core/mvc/ControllerExtension'],
customerAction: function() {
customSub2ControllerCalled();
},
override: {
overrides: {
onInit: function() {
aLifeCycleCalls.push("Sub2ControllerExtension Controller onInit()");
},
Expand Down
Expand Up @@ -12,7 +12,7 @@ sap.ui.define(['sap/ui/core/mvc/ControllerExtension'],
}
},

override: {
overrides: {
onInit: function() {
oLifecycleSpy("Sub6AnotherControllerExtension Controller onInit()");
},
Expand Down
Expand Up @@ -12,7 +12,7 @@ sap.ui.define(['sap/ui/core/mvc/ControllerExtension'],
}
},

override: {
overrides: {
onInit: function() {
oLifecycleSpy("Sub6ControllerExtension Controller onInit()");
},
Expand Down
Expand Up @@ -11,7 +11,7 @@ sap.ui.define(['sap/ui/core/mvc/ControllerExtension'],
}
},

override: {
overrides: {
onInit: function() {
oLifecycleSpy("Sub6InstanceSpecificControllerExtension Controller onInit()");
},
Expand Down
Expand Up @@ -12,7 +12,7 @@ sap.ui.define(['sap/ui/core/mvc/ControllerExtension'],
}
},

override: {
overrides: {

onInit: function() {
aLifeCycleCalls.push("Sub2SubControllerExtension Controller onInit()");
Expand Down
Expand Up @@ -13,7 +13,7 @@ sap.ui.define(['sap/ui/core/mvc/ControllerExtension'],
customerAction: function() {
customSub2ControllerCalled();
},
override: {
overrides: {
onInit: function() {
aLifeCycleCalls.push("Sub2ControllerExtension Controller onInit()");
},
Expand Down
Expand Up @@ -12,7 +12,7 @@ sap.ui.define(['sap/ui/core/mvc/ControllerExtension'],
}
},

override: {
overrides: {

onInit: function() {
aLifeCycleCalls.push("Sub2SubControllerExtension Controller onInit()");
Expand Down
Expand Up @@ -163,7 +163,7 @@ sap.ui.define([
myAfter: function() {
this.base.overrideCalledAfter = true;
},
override: {
overrides: {
callbackMethod: function() {
return "callbackOfControllerExt1";
}
Expand Down Expand Up @@ -286,7 +286,7 @@ sap.ui.define([
},
myAfter: function() {
},
override: {
overrides: {
extHookLegacy: function() {
return "extHookLegacy App implementation";
},
Expand Down Expand Up @@ -360,7 +360,7 @@ sap.ui.define([
},
myAfter: function() {
},
override: {
overrides: {
extension: {
"example.ProviderExt1": {
publicMethodToOverride: function() {
Expand Down

0 comments on commit 167251e

Please sign in to comment.