[DE] Debug expand/collapse for table of contents.

This commit is contained in:
Julia Radzhabova 2018-01-23 13:21:27 +03:00
parent ca1bc79bb8
commit 7c70133e2a
3 changed files with 23 additions and 6 deletions

View file

@ -52,6 +52,7 @@ define([
name: '', name: '',
isNotHeader: false, isNotHeader: false,
hasSubItems: false, hasSubItems: false,
hasParent: false,
isEmptyItem: false, isEmptyItem: false,
isExpanded: true, isExpanded: true,
isVisible: true, isVisible: true,
@ -113,8 +114,10 @@ define([
collapseAll: function() { collapseAll: function() {
for (var i=0; i<this.length; i++) { for (var i=0; i<this.length; i++) {
var item = this.at(i); var item = this.at(i);
item.set('isExpanded', false); if (!item.get('isNotHeader')) {
i = this.collapseSubItems(item); item.set('isExpanded', false);
i = this.collapseSubItems(item);
}
} }
}, },
@ -140,9 +143,10 @@ define([
for (var j=0; j<this.length; j++) { for (var j=0; j<this.length; j++) {
var item = this.at(j); var item = this.at(j);
if (item.get('level')<=expandLevel) { if (item.get('level')<=expandLevel || !item.get('hasParent')) {
item.set('isVisible', true); item.set('isVisible', true);
j = _expand_sub_items(j, item.get('level')); if (!item.get('isNotHeader'))
j = _expand_sub_items(j, item.get('level'));
} }
} }
} }

View file

@ -104,20 +104,29 @@ define([
var count = this._navigationObject.get_ElementsCount(), var count = this._navigationObject.get_ElementsCount(),
prev_level = -1, prev_level = -1,
header_level = -1,
first_header = !this._navigationObject.isFirstItemNotHeader(),
arr = []; arr = [];
for (var i=0; i<count; i++) { for (var i=0; i<count; i++) {
var level = this._navigationObject.get_Level(i); var level = this._navigationObject.get_Level(i),
hasParent = true;
if (level>prev_level && i>0) if (level>prev_level && i>0)
arr[i-1].set('hasSubItems', true); arr[i-1].set('hasSubItems', true);
if (header_level<0 || level<=header_level) {
if (i>0 || first_header)
header_level = level;
hasParent = false;
}
arr.push(new Common.UI.TreeViewModel({ arr.push(new Common.UI.TreeViewModel({
name : this._navigationObject.get_Text(i), name : this._navigationObject.get_Text(i),
level: level, level: level,
index: i, index: i,
hasParent: hasParent,
isEmptyItem: this._navigationObject.isEmptyItem(i) isEmptyItem: this._navigationObject.isEmptyItem(i)
})); }));
prev_level = level; prev_level = level;
} }
if (count>0 && this._navigationObject.isFirstItemNotHeader()) { if (count>0 && !first_header) {
arr[0].set('hasSubItems', false); arr[0].set('hasSubItems', false);
arr[0].set('isNotHeader', true); arr[0].set('isNotHeader', true);
arr[0].set('name', this.txtBeginning); arr[0].set('name', this.txtBeginning);
@ -176,6 +185,9 @@ define([
top: showPoint[1] top: showPoint[1]
}); });
menu.show(); menu.show();
_.delay(function() {
menu.cmpEl.focus();
}, 10);
} }
}, },

View file

@ -119,6 +119,7 @@ define([
caption : this.txtExpandToLevel, caption : this.txtExpandToLevel,
menu: new Common.UI.Menu({ menu: new Common.UI.Menu({
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
style: 'min-width: 60px;',
items: [{ caption : '1', value: 1 }, { caption : '2', value: 2 }, { caption : '3', value: 3 }, items: [{ caption : '1', value: 1 }, { caption : '2', value: 2 }, { caption : '3', value: 3 },
{ caption : '4', value: 4 }, { caption : '5', value: 5 }, { caption : '6', value: 6 }, { caption : '4', value: 4 }, { caption : '5', value: 5 }, { caption : '6', value: 6 },
{ caption : '7', value: 7 }, { caption : '8', value: 8 }, { caption : '9', value: 9 } { caption : '7', value: 7 }, { caption : '8', value: 8 }, { caption : '9', value: 9 }