|
|
@@ -54,9 +54,46 @@ export class LayoutTreeCrawler {
|
|
54
|
54
|
const clazz = this.store.getOriginalComponentClassForName(node.data.name) || {};
|
|
55
|
55
|
const staticOptions = _.cloneDeep(clazz.options) || {};
|
|
56
|
56
|
const passedOptions = node.data.options || {};
|
|
|
57
|
+ this._mergeButtonsStyles(passedOptions, staticOptions);
|
|
57
|
58
|
node.data.options = _.merge({}, staticOptions, passedOptions);
|
|
58
|
59
|
}
|
|
59
|
60
|
|
|
|
61
|
+ _mergeButtonsStyles(passedOptions, staticOptions) {
|
|
|
62
|
+ if (passedOptions.topBar) {
|
|
|
63
|
+ const leftButtons = passedOptions.topBar.leftButtons;
|
|
|
64
|
+ if (leftButtons) {
|
|
|
65
|
+ const leftButtonsStyle = this._extractButtonsStyle(leftButtons);
|
|
|
66
|
+ this._applyButtonsStyle(staticOptions.topBar.leftButtons, leftButtonsStyle);
|
|
|
67
|
+ this._applyButtonsStyle(passedOptions.topBar.leftButtons, leftButtonsStyle);
|
|
|
68
|
+ }
|
|
|
69
|
+
|
|
|
70
|
+ const rightButtons = passedOptions.topBar.rightButtons;
|
|
|
71
|
+ if (rightButtons) {
|
|
|
72
|
+ const rightButtonsStyle = this._extractButtonsStyle(rightButtons);
|
|
|
73
|
+ this._applyButtonsStyle(staticOptions.topBar.rightButtons, rightButtonsStyle);
|
|
|
74
|
+ this._applyButtonsStyle(passedOptions.topBar.rightButtons, rightButtonsStyle);
|
|
|
75
|
+ }
|
|
|
76
|
+ }
|
|
|
77
|
+ }
|
|
|
78
|
+
|
|
|
79
|
+ _extractButtonsStyle(buttons) {
|
|
|
80
|
+ return buttons.find((button) => {
|
|
|
81
|
+ if (button.id === undefined) {
|
|
|
82
|
+ const index = buttons.indexOf(button);
|
|
|
83
|
+ buttons.splice(index, 1);
|
|
|
84
|
+ return button;
|
|
|
85
|
+ } else {
|
|
|
86
|
+ return undefined;
|
|
|
87
|
+ }
|
|
|
88
|
+ });
|
|
|
89
|
+ }
|
|
|
90
|
+
|
|
|
91
|
+ _applyButtonsStyle(buttons, style) {
|
|
|
92
|
+ buttons.forEach((button) => {
|
|
|
93
|
+ _.merge(button, style);
|
|
|
94
|
+ });
|
|
|
95
|
+ }
|
|
|
96
|
+
|
|
60
|
97
|
_assertKnownLayoutType(type) {
|
|
61
|
98
|
if (!LayoutType[type]) {
|
|
62
|
99
|
throw new Error(`Unknown layout type ${type}`);
|