Skip to content

Commit b147c36

Browse files
author
Oleg Kozhukharenko
committed
Merge pull request 'Merge branch release/v9.0.0 into develop' (#337) from release/v9.0.0 into develop
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/desktop-apps/pulls/337
2 parents e96ee50 + ba5ce5a commit b147c36

File tree

10 files changed

+517
-58
lines changed

10 files changed

+517
-58
lines changed

common/loginpage/src/about-dialog.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ window.AboutDialog = function(params) {
33

44
!params && (params = {});
55

6-
let $el, $dialogTitle, $dialogBody;
6+
let $el, $dialogTitle, $dialogBody, pendingBody;
77
const events = {close: params.onclose};
88

99
const _template = `
@@ -21,21 +21,28 @@ window.AboutDialog = function(params) {
2121
};
2222

2323
function close(opts) {
24-
$el.remove();
24+
$el.get(0).close();
2525
if (events.close) {
2626
events.close(opts);
2727
}
2828
}
2929

30-
function setBody(data) {
31-
$dialogBody.html(data);
32-
}
3330

3431
return {
3532
setBody: function(data) {
36-
$dialogBody.html(data);
33+
if ($dialogBody) {
34+
$dialogBody.html(data);
35+
} else {
36+
pendingBody = data;
37+
}
3738
},
3839
show: function () {
40+
if ($el && $el.length) {
41+
const dlg = $el.get(0);
42+
if (!dlg.open) dlg.showModal();
43+
return;
44+
}
45+
3946
$el = $('#placeholder').append(_template).find('.dlg-about');
4047
$el.width(576);
4148

@@ -44,6 +51,10 @@ window.AboutDialog = function(params) {
4451
$dialogTitle.find('.tool.close').bind('click', onCloseClick);
4552

4653
$dialogBody = $el.find('.body');
54+
if (pendingBody) {
55+
$dialogBody.html(pendingBody);
56+
pendingBody = null;
57+
}
4758

4859
$el.get(0).showModal();
4960
$el.addClass('scaled');

common/loginpage/src/css/styles.less

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ button {
7171
}
7272

7373
#placeholder, input, button {
74-
font-family: 'Noto Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
74+
font-family: Arial, Helvetica, "Helvetica Neue", sans-serif;
7575
}
7676

7777
.rtl-font {
@@ -675,8 +675,8 @@ li.menu-item {
675675
}
676676

677677
.recent-panel-container {
678-
display: grid;
679-
grid-auto-rows: max-content;
678+
display: flex;
679+
flex-direction: column;
680680
gap: 40px;
681681
position: relative;
682682
height: 100%;
@@ -789,6 +789,7 @@ li.menu-item {
789789
#area-document-creation-grid {
790790
padding: 12px 16px 0; // 16px inner + outer 32px
791791
overflow-x: auto;
792+
min-height: 184px;
792793

793794
@media(max-width: 1280px) {
794795
padding-right: 48px;
@@ -818,6 +819,14 @@ li.menu-item {
818819
}
819820
}
820821

822+
#box-container {
823+
display: flex;
824+
flex-direction: column;
825+
gap: 40px;
826+
flex: 1;
827+
overflow-y: auto;
828+
}
829+
821830
#box-recent, #box-recovery {
822831
display: none;
823832
flex-direction: column;

common/loginpage/src/model.js

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,28 +96,71 @@ function Collection(attributes) {
9696
this.events.changed = new ModelEvent(this);
9797
this.events.erased = new ModelEvent(this);
9898
this.events.inserted = new ModelEvent(this);
99+
this.events.reset = new ModelEvent(this);
99100
this.events.click = new ModelEvent(this);
100101
this.events.contextmenu = new ModelEvent(this);
101102
};
102103

103-
Collection.prototype.add = function(item) {
104-
item.events.changed.attach(this.on_item_changed);
104+
Collection.prototype.add = function(item, suppressevent) {
105+
const _add_model = (m, se) => {
106+
m.events.changed.attach(this.on_item_changed);
105107

106-
this.items.push(item);
107-
this.events.inserted.notify(item);
108+
this.items.push(m);
108109

109-
$('#' + item.uid).off('click contextmenu');
110-
$('#' + item.uid).on('click', item, this.on_item_click);
111-
$('#' + item.uid).on('contextmenu', item, this.on_item_ctxmenu);
110+
// if ( !(suppressevent === true) )
111+
// this.events.inserted.notify(m);
112+
113+
// $('#' + m.uid).off('click contextmenu')
114+
// .on('click', m, this.on_item_click)
115+
// .on('contextmenu', m, this.on_item_ctxmenu);
116+
}
117+
118+
if ( item instanceof Array ) {
119+
const items = item;
120+
items.forEach(i => {
121+
_add_model(i, true);
122+
});
123+
124+
// if ( !(suppressevent === true) )
125+
this.events.inserted.notify(items);
126+
127+
items.forEach(i => {
128+
$('#' + i.uid).off('click contextmenu')
129+
.on('click', i, this.on_item_click)
130+
.on('contextmenu', i, this.on_item_ctxmenu);
131+
});
132+
} else {
133+
_add_model(item)
134+
135+
// if ( !(suppressevent === true) )
136+
this.events.inserted.notify(item);
137+
138+
$('#' + item.uid).off('click contextmenu')
139+
.on('click', item, this.on_item_click)
140+
.on('contextmenu', item, this.on_item_ctxmenu);
141+
}
112142
};
113143

144+
Collection.prototype.set = function(items) {
145+
if ( items instanceof Array ) {
146+
this.empty(true);
147+
148+
items.forEach(i => {
149+
this.add(i, true);
150+
});
151+
152+
// this.items = items;
153+
this.events.reset.notify(items);
154+
}
155+
}
156+
114157
Collection.prototype.find = function(key, val) {
115158
return this.items.find(function(elem, i, arr){
116159
return elem[key] == val;
117160
});
118161
};
119162

120-
Collection.prototype.empty = function() {
163+
Collection.prototype.empty = function(suppressevent) {
121164
this.items.forEach(function(model, i, a) {
122165
$('#'+model.uid).off();
123166
});
@@ -126,7 +169,8 @@ Collection.prototype.empty = function() {
126169

127170
if (!!this.list) this.view.find(this.list).empty();
128171

129-
this.events.erased.notify();
172+
if ( !(suppressevent === true) )
173+
this.events.erased.notify();
130174
};
131175

132176
Collection.prototype.size = function() {

common/loginpage/src/panelabout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
this.view.$menuitem && this.view.$menuitem.removeClass('extra');
156156
this.view.$body = $(this.view.paneltemplate(args));
157157
this.view.$dialog = new AboutDialog();
158+
this.view.$dialog.setBody(this.view.$body)
158159
} else {
159160
if ( !!args.opts && !!args.opts.edition ) {
160161
$('#idx-ver-edition').html(args.opts.edition);
@@ -277,7 +278,6 @@
277278
const onPanelShow = function(panel) {
278279
if (panel === this.action) {
279280
this.view.$dialog.show();
280-
this.view.$dialog.setBody(this.view.$body);
281281
}
282282
}
283283

common/loginpage/src/panelrecent.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,30 @@
7474
${welcomeBannerTemplate}
7575
<section id="area-dnd-file"></section>
7676
77-
<div id="box-recovery">
78-
<div class="file-list-title">
79-
<h3 l10n>${_lang.listRecoveryTitle}</h3>
77+
<div id="box-container">
78+
<div id="box-recovery">
79+
<div class="file-list-title">
80+
<h3 l10n>${_lang.listRecoveryTitle}</h3>
81+
</div>
82+
<div class="file-list-head text-normal">
83+
<div class="col-name" l10n>${_lang.colFileName}</div>
84+
<div class="col-location" l10n>${_lang.colLocation}</div>
85+
<div class="col-date" l10n>${_lang.colLastOpened}</div>
86+
</div>
87+
<div class="file-list-body scrollable"></div>
8088
</div>
81-
<div class="file-list-head text-normal">
82-
<div class="col-name" l10n>${_lang.colFileName}</div>
83-
<div class="col-location" l10n>${_lang.colLocation}</div>
84-
<div class="col-date" l10n>${_lang.colLastOpened}</div>
85-
</div>
86-
<div class="file-list-body scrollable"></div>
87-
</div>
8889
89-
<div id="box-recent">
90-
<div class="file-list-title">
91-
<h3 l10n>${_lang.listRecentFileTitle}</h3>
90+
<div id="box-recent">
91+
<div class="file-list-title">
92+
<h3 l10n>${_lang.listRecentFileTitle}</h3>
93+
</div>
94+
<div class="file-list-head text-normal">
95+
<div class="col-name" l10n>${_lang.colFileName}</div>
96+
<div class="col-location" l10n>${_lang.colLocation}</div>
97+
<div class="col-date" l10n>${_lang.colLastOpened}</div>
98+
</div>
99+
<div class="file-list-body scrollable"></div>
92100
</div>
93-
<div class="file-list-head text-normal">
94-
<div class="col-name" l10n>${_lang.colFileName}</div>
95-
<div class="col-location" l10n>${_lang.colLocation}</div>
96-
<div class="col-date" l10n>${_lang.colLastOpened}</div>
97-
</div>
98-
<div class="file-list-body scrollable"></div>
99-
</div>
100101
</div>
101102
</div>
102103
</div>`;

common/loginpage/src/paneltemplates.js

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,18 @@
173173
});
174174

175175
collection.events.inserted.attach((col, model) => {
176-
const $item = $(this.view.listitemtemplate(model));
177-
if (!model.isCloud) {
176+
let $item, isprepend = false;
177+
if ( model instanceof Array ) {
178+
const items = model;
179+
$item = [], isprepend = true;
180+
items.forEach(m => {
181+
$item.push($(this.view.listitemtemplate(m)));
182+
});
183+
} else {
184+
$item = $(this.view.listitemtemplate(model));
185+
}
186+
187+
if ( isprepend === true ) {
178188
col.list.prepend($item);
179189
} else {
180190
col.list.append($item);
@@ -183,6 +193,21 @@
183193
applyFilter(this.view.$panel);
184194
});
185195

196+
collection.events.reset.attach((col, models) => {
197+
let elms = [];
198+
models.forEach(m => {
199+
const $item = $(this.view.listitemtemplate(m));
200+
elms.push($item);
201+
});
202+
203+
if ( elms.length ) {
204+
col.list.prepend(elms);
205+
col.list.parent().removeClass('empty');
206+
207+
applyFilter(this.view.$panel);
208+
}
209+
});
210+
186211
collection.events.click.attach((col, model) => {
187212
if (model.isCloud) {
188213
window.sdk.openTemplate(model.path, model.name);
@@ -201,24 +226,54 @@
201226
}
202227

203228
Collection.prototype.emptyLocal = function() {
204-
const cloudItems = this.items.filter(item => item.isCloud);
205-
this.empty();
206-
cloudItems.forEach(item => {
207-
this.add(item);
208-
});
229+
// const cloudItems = this.items.filter(item => item.isCloud);
230+
// this.empty();
231+
// cloudItems.forEach(item => {
232+
// this.add(item);
233+
// });
234+
235+
this.items.forEach(m => {
236+
if ( !m.isCloud ) {
237+
const el = document.getElementById(m.uid);
238+
if ( el ) el.remove();
239+
}
240+
});
241+
242+
const cloud_items = this.items.filter(item => item.isCloud);
243+
this.items = cloud_items;
209244
};
210245

211246
const _on_add_local_templates = function(tmpls) {
212-
this.templates.emptyLocal();
213-
214-
[...tmpls]
215-
.reverse()
216-
.forEach(item => {
217-
const type = utils.formatToEditor(item.type);
218-
if (['word', 'cell', 'slide', 'pdf'].includes(type)) {
219-
this.templates.add(new FileTemplateModel(item));
220-
}
221-
});
247+
const _func_ = () => {
248+
this.templates.emptyLocal();
249+
250+
let items = [];
251+
// [...tmpls]
252+
// .reverse()
253+
(this.tmpls || tmpls)
254+
.forEach(item => {
255+
const type = utils.formatToEditor(item.type);
256+
if (['word', 'cell', 'slide', 'pdf'].includes(type)) {
257+
// this.templates.add(new FileTemplateModel(item));
258+
items.push(new FileTemplateModel(item));
259+
}
260+
});
261+
262+
this.templates.add(items);
263+
};
264+
265+
// if ( this.timer_id )
266+
// this.tmpls = tmpls;
267+
// else {
268+
// this.timer_id = setTimeout(e => {
269+
// this.timer_id = undefined;
270+
// _func_();
271+
272+
// delete this.tmpls;
273+
// }, 2000);
274+
275+
_func_();
276+
// }
222277
};
223278

224279
const _on_add_cloud_templates = function(data) {

0 commit comments

Comments
 (0)