[DE] Version history: add "Show/Hide detailed changes" to history panel. Don't reload editor, when press Back to Document (= Close Menu) in the File menu.

This commit is contained in:
Julia Radzhabova 2016-10-05 16:31:49 +03:00
parent 9f3d70bbf0
commit 379d61e759
6 changed files with 76 additions and 9 deletions

View file

@ -57,6 +57,14 @@ define([
findRevisions: function(revision) {
return this.where({revision: revision});
},
hasChanges: function() {
return !!this.findWhere({isRevision: false});
},
hasCollapsed: function() {
return !!this.findWhere({isRevision: true, hasChanges: true, isExpanded: false});
}
});
});

View file

@ -66,6 +66,7 @@ define([
this.panelHistory= this.createView('Common.Views.History', {
storeHistory: this.getApplication().getCollection('Common.Collections.HistoryVersions')
});
this.panelHistory.storeHistory.on('reset', _.bind(this.onResetStore, this));
this.panelHistory.on('render:after', _.bind(this.onAfterRender, this));
Common.Gateway.on('sethistorydata', _.bind(this.onSetHistoryData, this));
},
@ -86,6 +87,13 @@ define([
onAfterRender: function(historyView) {
historyView.viewHistoryList.on('item:click', _.bind(this.onSelectRevision, this));
historyView.btnBackToDocument.on('click', _.bind(this.onClickBackToDocument, this));
historyView.btnExpand.on('click', _.bind(this.onClickExpand, this));
},
onResetStore: function() {
var hasChanges = this.panelHistory.storeHistory.hasChanges();
this.panelHistory.$el.find('#history-expand-changes')[hasChanges ? 'show' : 'hide']();
this.panelHistory.$el.find('#history-list').css('padding-bottom', hasChanges ? '45px' : 0);
},
onDownloadUrl: function(url) {
@ -183,6 +191,20 @@ define([
Common.Gateway.requestHistoryClose();
},
onClickExpand: function () {
var store = this.panelHistory.storeHistory,
needExpand = store.hasCollapsed();
store.where({isRevision: true, hasChanges: true, isExpanded: !needExpand}).forEach(function(item){
item.set('isExpanded', needExpand);
});
store.where({isRevision: false}).forEach(function(item){
item.set('isVisible', needExpand);
});
this.panelHistory.viewHistoryList.scroller.update({minScrollbarLength: 40});
this.panelHistory.btnExpand.cmpEl.text(needExpand ? this.panelHistory.textHideAll : this.panelHistory.textShowAll);
},
notcriticalErrorTitle: 'Warning'
}, Common.Controllers.History || {}));

View file

@ -55,10 +55,13 @@ define([
template: _.template([
'<div id="history-box" class="layout-ct vbox">',
'<div id="history-header" class="">',
'<div id="history-btn-back"><%=scope.textHistoryHeader%></div>',
'<div id="history-btn-back"><%=scope.textCloseHistory%></div>',
'</div>',
'<div id="history-list" class="">',
'</div>',
'<div id="history-expand-changes" class="">',
'<div id="history-btn-expand"><%=scope.textHideAll%></div>',
'</div>',
'</div>'
].join('')),
@ -110,6 +113,7 @@ define([
this.scroller.update({minScrollbarLength: 40});
} else
Common.UI.DataView.prototype.onClickItem.call(this, view, record, e);
me.btnExpand.cmpEl.text(me.storeHistory.hasCollapsed() ? me.textShowAll : me.textHideAll);
};
var changetooltip = function (dataview, view, record) {
@ -132,14 +136,22 @@ define([
enableToggle: false
});
this.btnExpand = new Common.UI.Button({
el: $('#history-btn-expand'),
enableToggle: false
});
this.trigger('render:after', this);
return this;
},
textHistoryHeader: 'Back to Document',
textRestore: 'Restore',
textShow: 'Show Changes',
textHide: 'Hide Changes'
textShow: 'Expand',
textHide: 'Collapse',
textCloseHistory: 'Close History',
textHideAll: 'Hide detailed changes',
textShowAll: 'Show detailed changes'
}, Common.Views.History || {}))
});

View file

@ -26,10 +26,33 @@
}
}
#history-expand-changes {
position: absolute;
height: 45px;
left: 0;
bottom: 0;
right: 0;
overflow: hidden;
border-top: 1px solid @gray-dark;
#history-btn-expand {
height: 27px;
margin-top: 8px;
padding-top: 4px;
padding-left: 20px;
font-size: 13px;
cursor: pointer;
&:hover {
background-color: @secondary;
}
}
}
#history-list {
height: 100%;
overflow: hidden;
padding-top: 45px;
padding: 45px 0;
.item {
display: block;

View file

@ -190,10 +190,6 @@ define([
var close_menu = true;
switch (action) {
case 'back':
if (this.mode.canUseHistory && this.leftMenu.panelHistory.isVisible()) {
// reload editor
Common.Gateway.requestHistoryClose();
}
break;
case 'save': this.api.asc_Save(); break;
case 'save-desktop': this.api.asc_DownloadAs(); break;

View file

@ -143,8 +143,13 @@
"Common.Views.Header.textBack": "Go to Documents",
"Common.Views.Header.txtHeaderDeveloper": "DEVELOPER MODE",
"Common.Views.Header.txtRename": "Rename",
"Common.Views.History.textHistoryHeader": "Back to Document",
"Common.Views.History.textCloseHistory": "Close History",
"del_Common.Views.History.textHistoryHeader": "Back to Document",
"Common.Views.History.textRestore": "Restore",
"Common.Views.History.textShow": "Expand",
"Common.Views.History.textHide": "Collapse",
"Common.Views.History.textHideAll": "Hide detailed changes",
"Common.Views.History.textShowAll": "Show detailed changes",
"Common.Views.ImageFromUrlDialog.cancelButtonText": "Cancel",
"Common.Views.ImageFromUrlDialog.okButtonText": "OK",
"Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:",
@ -868,6 +873,7 @@
"DE.Views.DropcapSettingsAdvanced.tipFontName": "Font Name",
"DE.Views.DropcapSettingsAdvanced.txtNoBorders": "No borders",
"DE.Views.FileMenu.btnBackCaption": "Go to Documents",
"DE.Views.FileMenu.btnCloseMenuCaption": "Close Menu",
"DE.Views.FileMenu.btnCreateNewCaption": "Create New",
"DE.Views.FileMenu.btnDownloadCaption": "Download as...",
"DE.Views.FileMenu.btnHelpCaption": "Help...",