[DE] Changed format for data in setHistoryData (+ support for old format).

{
  version: '...',
  url: '...',
  key: '...',
  changesUrl: '...',
  previous: {
    url: '...',
    key: '...',
  }
}
This commit is contained in:
Julia Radzhabova 2016-10-31 15:01:45 +03:00
parent 0c251ec008
commit 8b90eb4925

View file

@ -164,14 +164,9 @@ define([
var rev, revisions = historyStore.findRevisions(data.version), var rev, revisions = historyStore.findRevisions(data.version),
urlGetTime = new Date(); urlGetTime = new Date();
var diff = opts.data.changesUrl, var diff = opts.data.changesUrl,
url, docId; url = (!_.isEmpty(diff) && opts.data.previous) ? opts.data.previous.url : opts.data.url,
if (opts.data.current && opts.data.previous) { docId = opts.data.key ? opts.data.key : this.currentDocId,
url = _.isEmpty(diff) ? opts.data.current.url : opts.data.previous.url; docIdPrev = opts.data.previous && opts.data.previous.key ? opts.data.previous.key : this.currentDocIdPrev;
docId = _.isEmpty(diff) ? opts.data.current.key : opts.data.previous.key;
} else {
url = opts.data.url;
docId = _.isEmpty(diff) ? this.currentDocId : this.currentDocIdPrev;
}
if (revisions && revisions.length>0) { if (revisions && revisions.length>0) {
for(var i=0; i<revisions.length; i++) { for(var i=0; i<revisions.length; i++) {
@ -179,16 +174,16 @@ define([
rev.set('url', url, {silent: true}); rev.set('url', url, {silent: true});
rev.set('urlDiff', diff, {silent: true}); rev.set('urlDiff', diff, {silent: true});
rev.set('urlGetTime', urlGetTime, {silent: true}); rev.set('urlGetTime', urlGetTime, {silent: true});
if (opts.data.current && opts.data.previous) { if (opts.data.key) {
rev.set('docId', opts.data.current.key, {silent: true}); rev.set('docId', docId, {silent: true});
rev.set('docIdPrev', opts.data.previous.key, {silent: true}); rev.set('docIdPrev', docIdPrev, {silent: true});
} }
} }
} }
var hist = new Asc.asc_CVersionHistory(); var hist = new Asc.asc_CVersionHistory();
hist.asc_setUrl(url); hist.asc_setUrl(url);
hist.asc_setUrlChanges(diff); hist.asc_setUrlChanges(diff);
hist.asc_setDocId(docId); hist.asc_setDocId(_.isEmpty(diff) ? docId : docIdPrev);
hist.asc_setCurrentChangeId(this.currentChangeId); hist.asc_setCurrentChangeId(this.currentChangeId);
hist.asc_setArrColors(this.currentArrColors); hist.asc_setArrColors(this.currentArrColors);
this.api.asc_showRevision(hist); this.api.asc_showRevision(hist);