[SSE] Custom sort: move/copy levels
This commit is contained in:
parent
8be314b4f4
commit
bf226e3cc9
|
@ -94,8 +94,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template',
|
||||||
'</div>'
|
'</div>'
|
||||||
].join(''))
|
].join(''))
|
||||||
});
|
});
|
||||||
// this.rangeList.on('item:select', _.bind(this.onSelectLevel, this))
|
this.sortList.on('item:select', _.bind(this.onSelectLevel, this))
|
||||||
// .on('item:keydown', _.bind(this.onKeyDown, this));
|
.on('item:keydown', _.bind(this.onKeyDown, this));
|
||||||
|
|
||||||
this.btnAdd = new Common.UI.Button({
|
this.btnAdd = new Common.UI.Button({
|
||||||
el: $('#sort-dialog-btn-add')
|
el: $('#sort-dialog-btn-add')
|
||||||
|
@ -110,7 +110,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template',
|
||||||
this.btnCopy = new Common.UI.Button({
|
this.btnCopy = new Common.UI.Button({
|
||||||
el: $('#sort-dialog-btn-copy')
|
el: $('#sort-dialog-btn-copy')
|
||||||
});
|
});
|
||||||
// this.btnCopy.on('click', _.bind(this.onCopyLevel, this, false));
|
this.btnCopy.on('click', _.bind(this.onCopyLevel, this, false));
|
||||||
|
|
||||||
this.btnOptions = new Common.UI.Button({
|
this.btnOptions = new Common.UI.Button({
|
||||||
el: $('#sort-dialog-btn-options')
|
el: $('#sort-dialog-btn-options')
|
||||||
|
@ -123,7 +123,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template',
|
||||||
hint: this.textUp
|
hint: this.textUp
|
||||||
});
|
});
|
||||||
this.btnUp.render($('#sort-dialog-btn-up')) ;
|
this.btnUp.render($('#sort-dialog-btn-up')) ;
|
||||||
// this.btnUp.on('click', _.bind(this.onUpClick, this));
|
this.btnUp.on('click', _.bind(this.onMoveClick, this, true));
|
||||||
|
|
||||||
this.btnDown = new Common.UI.Button({
|
this.btnDown = new Common.UI.Button({
|
||||||
cls: 'btn-toolbar',
|
cls: 'btn-toolbar',
|
||||||
|
@ -131,7 +131,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template',
|
||||||
hint: this.textDown
|
hint: this.textDown
|
||||||
});
|
});
|
||||||
this.btnDown.render($('#sort-dialog-btn-down')) ;
|
this.btnDown.render($('#sort-dialog-btn-down')) ;
|
||||||
// this.btnDown.on('click', _.bind(this.onDownClick, this));
|
this.btnDown.on('click', _.bind(this.onMoveClick, this, false));
|
||||||
|
|
||||||
this.lblColumn = $('#sort-dialog-label-column');
|
this.lblColumn = $('#sort-dialog-label-column');
|
||||||
|
|
||||||
|
@ -195,6 +195,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template',
|
||||||
this.sortList.store.reset(arr);
|
this.sortList.store.reset(arr);
|
||||||
(this.sortList.store.length>0) && this.sortList.selectByIndex(0);
|
(this.sortList.store.length>0) && this.sortList.selectByIndex(0);
|
||||||
}
|
}
|
||||||
|
this.updateButtons();
|
||||||
},
|
},
|
||||||
|
|
||||||
addControls: function(listView, itemView, item) {
|
addControls: function(listView, itemView, item) {
|
||||||
|
@ -291,6 +292,24 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template',
|
||||||
this.sortList.selectRecord(rec);
|
this.sortList.selectRecord(rec);
|
||||||
this.sortList.scrollToRecord(rec);
|
this.sortList.scrollToRecord(rec);
|
||||||
}
|
}
|
||||||
|
this.updateButtons();
|
||||||
|
},
|
||||||
|
|
||||||
|
onCopyLevel: function() {
|
||||||
|
var store = this.sortList.store,
|
||||||
|
rec = this.sortList.getSelectedRec();
|
||||||
|
rec = store.add({
|
||||||
|
levelIndex: this.cmbsColumn.length,
|
||||||
|
columnIndex: rec ? rec.get('columnIndex') : '',
|
||||||
|
sort: rec ? rec.get('sort') : Asc.c_oAscSortOptions.ByValue,
|
||||||
|
order: rec ? rec.get('order') : Asc.c_oAscSortOptions.Ascending,
|
||||||
|
color: rec ? rec.get('color') : null
|
||||||
|
}, {at: rec ? store.indexOf(rec)+1 : store.length});
|
||||||
|
if (rec) {
|
||||||
|
this.sortList.selectRecord(rec);
|
||||||
|
this.sortList.scrollToRecord(rec);
|
||||||
|
}
|
||||||
|
this.updateButtons();
|
||||||
},
|
},
|
||||||
|
|
||||||
onDeleteLevel: function() {
|
onDeleteLevel: function() {
|
||||||
|
@ -305,7 +324,26 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template',
|
||||||
index = store.indexOf(rec);
|
index = store.indexOf(rec);
|
||||||
store.remove(rec);
|
store.remove(rec);
|
||||||
(store.length>0) && this.sortList.selectByIndex(index<store.length ? index : store.length-1);
|
(store.length>0) && this.sortList.selectByIndex(index<store.length ? index : store.length-1);
|
||||||
|
this.sortList.scrollToRecord(this.sortList.getSelectedRec());
|
||||||
}
|
}
|
||||||
|
this.updateButtons();
|
||||||
|
},
|
||||||
|
|
||||||
|
onMoveClick: function(up) {
|
||||||
|
var store = this.sortList.store,
|
||||||
|
length = store.length,
|
||||||
|
rec = this.sortList.getSelectedRec();
|
||||||
|
if (rec) {
|
||||||
|
var index = store.indexOf(rec);
|
||||||
|
store.add(store.remove(rec), {at: up ? Math.max(0, index-1) : Math.min(length-1, index+1)});
|
||||||
|
this.sortList.selectRecord(rec);
|
||||||
|
this.sortList.scrollToRecord(rec);
|
||||||
|
}
|
||||||
|
this.updateMoveButtons();
|
||||||
|
},
|
||||||
|
|
||||||
|
onSelectLevel: function(lisvView, itemView, record) {
|
||||||
|
this.updateMoveButtons();
|
||||||
},
|
},
|
||||||
|
|
||||||
getSettings: function() {
|
getSettings: function() {
|
||||||
|
@ -323,7 +361,22 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template',
|
||||||
|
|
||||||
onKeyDown: function (lisvView, record, e) {
|
onKeyDown: function (lisvView, record, e) {
|
||||||
if (e.keyCode==Common.UI.Keys.DELETE && !this.btnDelete.isDisabled())
|
if (e.keyCode==Common.UI.Keys.DELETE && !this.btnDelete.isDisabled())
|
||||||
this.onDeletelevel();
|
this.onDeleteLevel();
|
||||||
|
},
|
||||||
|
|
||||||
|
updateButtons: function() {
|
||||||
|
this.btnAdd.setDisabled(this.sortList.store.length>63);
|
||||||
|
this.btnCopy.setDisabled(this.sortList.store.length<1);
|
||||||
|
this.btnDelete.setDisabled(this.sortList.store.length<1);
|
||||||
|
this.updateMoveButtons();
|
||||||
|
this.sortList.scroller && this.sortList.scroller.update();
|
||||||
|
},
|
||||||
|
|
||||||
|
updateMoveButtons: function() {
|
||||||
|
var rec = this.sortList.getSelectedRec(),
|
||||||
|
index = rec ? this.sortList.store.indexOf(rec) : -1;
|
||||||
|
this.btnUp.setDisabled(index<1);
|
||||||
|
this.btnDown.setDisabled(index<0 || index==this.sortList.store.length-1);
|
||||||
},
|
},
|
||||||
|
|
||||||
txtTitle: 'Sort',
|
txtTitle: 'Sort',
|
||||||
|
|
Loading…
Reference in a new issue