mirror of https://github.com/keeweb/keeweb.git
auto-lock changed
This commit is contained in:
parent
3e4a458780
commit
0c63d7738d
|
@ -197,10 +197,6 @@ var AppModel = Backbone.Model.extend({
|
|||
createNewGroup: function() {
|
||||
var sel = this.getFirstSelectedGroup();
|
||||
return GroupModel.newGroup(sel.group, sel.file);
|
||||
},
|
||||
|
||||
setVisualLock: function(visualLock) {
|
||||
this.visualLock = visualLock;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ var AppSettingsModel = Backbone.Model.extend({
|
|||
tagsViewHeight: null,
|
||||
autoUpdate: 'install',
|
||||
clipboardSeconds: 0,
|
||||
autoSave: false,
|
||||
autoSave: true,
|
||||
idleMinutes: 15
|
||||
},
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ var Backbone = require('backbone'),
|
|||
GrpView = require('../views/grp-view'),
|
||||
OpenView = require('../views/open-view'),
|
||||
SettingsView = require('../views/settings/settings-view'),
|
||||
VisualLockView = require('../views/visual-lock-view'),
|
||||
Alerts = require('../comp/alerts'),
|
||||
Keys = require('../const/keys'),
|
||||
KeyHandler = require('../comp/key-handler'),
|
||||
|
@ -260,7 +259,7 @@ var AppView = Backbone.View.extend({
|
|||
|
||||
lockWorkspace: function(autoInit) {
|
||||
var that = this;
|
||||
if (Alerts.alertDisplayed || this.model.visualLock) {
|
||||
if (Alerts.alertDisplayed) {
|
||||
return;
|
||||
}
|
||||
if (this.model.files.hasUnsavedFiles()) {
|
||||
|
@ -268,7 +267,7 @@ var AppView = Backbone.View.extend({
|
|||
this.saveAndLock(autoInit);
|
||||
} else {
|
||||
if (autoInit) {
|
||||
this.showVisualLock({ reason: 'autoSaveDisabled' });
|
||||
this.showVisualLock('Auto-save is disabled. Please, enable it, to allow auto-locking');
|
||||
return;
|
||||
}
|
||||
Alerts.alert({
|
||||
|
@ -298,22 +297,17 @@ var AppView = Backbone.View.extend({
|
|||
}
|
||||
},
|
||||
|
||||
showVisualLock: function(config) {
|
||||
if (this.model.visualLock) {
|
||||
showVisualLock: function(message) {
|
||||
// TODO: remove this
|
||||
if (Alerts.alertDisplayed) {
|
||||
return;
|
||||
}
|
||||
this.views.menu.hide();
|
||||
this.views.menuDrag.hide();
|
||||
this.views.list.hide();
|
||||
this.views.listDrag.hide();
|
||||
this.views.details.hide();
|
||||
this.views.grp.hide();
|
||||
this.views.footer.toggle(this.model.files.hasOpenFiles());
|
||||
this.hideSettings();
|
||||
this.hideOpenFile();
|
||||
this.views.visualLock = new VisualLockView({model: config}).render();
|
||||
this.model.setVisualLock(true);
|
||||
this.views.footer.render();
|
||||
message += '<div class="muted-color">Note: this will be removed once 2-way sync is implemented</div>';
|
||||
Alerts.info({
|
||||
header: 'Auto-lock failed',
|
||||
body: message,
|
||||
icon: 'lock'
|
||||
});
|
||||
},
|
||||
|
||||
saveAndLock: function(autoInit) {
|
||||
|
@ -322,7 +316,7 @@ var AppView = Backbone.View.extend({
|
|||
errorFiles = [],
|
||||
that = this;
|
||||
if (this.model.files.some(function(file) { return file.get('modified') && !file.get('path'); })) {
|
||||
this.showVisualLock({ reason: 'localFiles' }); // TODO: removed once sync is implemented
|
||||
this.showVisualLock('You have unsaved files, locking is not possible.');
|
||||
return;
|
||||
}
|
||||
this.model.files.forEach(function(file) {
|
||||
|
@ -349,7 +343,7 @@ var AppView = Backbone.View.extend({
|
|||
if (--pendingCallbacks === 0) {
|
||||
if (errorFiles.length) {
|
||||
if (autoInit) {
|
||||
that.showVisualLock({ reason: 'saveError', errorFiles: errorFiles });
|
||||
that.showVisualLock('Failed to save files: ' + errorFiles.join(', '));
|
||||
} else if (!Alerts.alertDisplayed) {
|
||||
Alerts.error({
|
||||
header: 'Save Error',
|
||||
|
|
|
@ -35,23 +35,16 @@ var FooterView = Backbone.View.extend({
|
|||
render: function () {
|
||||
this.$el.html(this.template({
|
||||
files: this.model.files,
|
||||
updateAvailable: ['ready', 'found'].indexOf(UpdateModel.instance.get('updateStatus')) >= 0,
|
||||
visualLock: this.model.visualLock
|
||||
updateAvailable: ['ready', 'found'].indexOf(UpdateModel.instance.get('updateStatus')) >= 0
|
||||
}));
|
||||
return this;
|
||||
},
|
||||
|
||||
lockWorkspace: function() {
|
||||
if (this.model.visualLock) {
|
||||
return;
|
||||
}
|
||||
Backbone.trigger('lock-workspace');
|
||||
},
|
||||
|
||||
genPass: function(e) {
|
||||
if (this.model.visualLock) {
|
||||
return;
|
||||
}
|
||||
e.stopPropagation();
|
||||
if (this.views.gen) {
|
||||
this.views.gen.remove();
|
||||
|
@ -68,9 +61,6 @@ var FooterView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
showFile: function(e) {
|
||||
if (this.model.visualLock) {
|
||||
return;
|
||||
}
|
||||
var fileId = $(e.target).closest('.footer__db-item').data('file-id');
|
||||
if (fileId) {
|
||||
Backbone.trigger('show-file', { fileId: fileId });
|
||||
|
@ -78,37 +68,22 @@ var FooterView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
openFile: function() {
|
||||
if (this.model.visualLock) {
|
||||
return;
|
||||
}
|
||||
Backbone.trigger('open-file');
|
||||
},
|
||||
|
||||
saveAll: function() {
|
||||
if (this.model.visualLock) {
|
||||
return;
|
||||
}
|
||||
Backbone.trigger('save-all');
|
||||
},
|
||||
|
||||
switchView: function() {
|
||||
if (this.model.visualLock) {
|
||||
return;
|
||||
}
|
||||
Backbone.trigger('switch-view');
|
||||
},
|
||||
|
||||
toggleHelp: function() {
|
||||
if (this.model.visualLock) {
|
||||
return;
|
||||
}
|
||||
Backbone.trigger('toggle-settings', 'help');
|
||||
},
|
||||
|
||||
toggleSettings: function() {
|
||||
if (this.model.visualLock) {
|
||||
return;
|
||||
}
|
||||
Backbone.trigger('toggle-settings', 'general');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var Backbone = require('backbone');
|
||||
|
||||
var VisualLockView = Backbone.View.extend({
|
||||
template: require('templates/visual-lock.html'),
|
||||
el: '.app__body',
|
||||
|
||||
events: {
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.renderTemplate($.extend(this.model, { fileName: 'TODO' }));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = VisualLockView;
|
|
@ -11,13 +11,6 @@
|
|||
padding: $medium-padding;
|
||||
padding-right: 1.3em;
|
||||
white-space: nowrap;
|
||||
.footer--locked>& {
|
||||
cursor: default;
|
||||
&:hover {
|
||||
background: transparent;
|
||||
border-top-color: transparent;
|
||||
}
|
||||
}
|
||||
&.footer__db--dimmed {
|
||||
@include th {
|
||||
color: muted-color();
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
.vlock {
|
||||
@include flex(1);
|
||||
@include display(flex);
|
||||
@include align-self(stretch);
|
||||
@include align-items(center);
|
||||
@include flex-direction(column);
|
||||
@include justify-content(center);
|
||||
|
||||
&__input-wrap, &__text {
|
||||
width: 30em;
|
||||
position: relative;
|
||||
}
|
||||
&-enter-btn {
|
||||
padding: .6em $base-spacing;
|
||||
position: absolute;
|
||||
left: 100%;
|
||||
top: 0;
|
||||
cursor: pointer;
|
||||
>i { font-size: 3em; }
|
||||
@include mobile { display: none; }
|
||||
@include th { color: muted-color(); }
|
||||
&:hover {
|
||||
@include th { color: medium-color(); }
|
||||
}
|
||||
}
|
||||
input[type=password].vlock__input {
|
||||
font-size: $large-pass-font-size;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
|
@ -29,4 +29,3 @@
|
|||
@import "areas/menu";
|
||||
@import "areas/open";
|
||||
@import "areas/settings";
|
||||
@import "areas/visual-lock";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="footer <%= visualLock ? 'footer--locked' : '' %>">
|
||||
<div class="footer">
|
||||
<% files.forEach(function(file) { %>
|
||||
<div class="footer__db footer__db-item <%= file.get('open') ? '' : 'footer__db--dimmed' %>" data-file-id="<%= file.cid %>">
|
||||
<i class="fa fa-<%= file.get('open') ? 'unlock' : 'lock' %>"></i> <%- file.get('name') %>
|
||||
|
@ -6,7 +6,6 @@
|
|||
<% if (file.get('syncing')) { %><i class="fa fa-refresh fa-spin footer__db-sign"></i><% } %>
|
||||
</div>
|
||||
<% }); %>
|
||||
<% if (!visualLock) { %>
|
||||
<div class="footer__db footer__db--dimmed footer__db--expanded footer__db-open"><i class="fa fa-plus"></i> Open / New</div>
|
||||
<!--<div class="footer__btn footer__btn-view"><i class="fa fa-list-ul"></i></div>-->
|
||||
<div class="footer__btn footer__btn-help"><i class="fa fa-question"></i></div>
|
||||
|
@ -19,5 +18,4 @@
|
|||
</div>
|
||||
<div class="footer__btn footer__btn-generate"><i class="fa fa-bolt"></i></div>
|
||||
<div class="footer__btn footer__btn-lock"><i class="fa fa-lock"></i></div>
|
||||
<% } %>
|
||||
</div>
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<div>
|
||||
<input type="checkbox" class="settings__input input-base settings__general-auto-save" id="settings__general-auto-save"
|
||||
<%- autoSave ? 'checked' : '' %> />
|
||||
<label for="settings__general-auto-save">Auto-save on lock</label>
|
||||
<label for="settings__general-auto-save">Automatically save and sync</label>
|
||||
</div>
|
||||
<div>
|
||||
<label for="settings__general-idle-minutes">Auto-lock if the app is inactive:</label>
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<div class="vlock">
|
||||
<div class="vlock__input-wrap">
|
||||
<input type="password" class="vlock__input" autofocus placeholder="Password for <%- fileName %>"
|
||||
size="30" autocomplete="off" />
|
||||
<div class="vlock-enter-btn"><i class="fa fa-level-down fa-rotate-90"></i></div>
|
||||
</div>
|
||||
<div class="vlock__text">
|
||||
<div>To continue, please, enter password for <%- fileName %>.</div>
|
||||
<div>
|
||||
<% if (reason === 'localFiles') { %>
|
||||
You have opened some files which cannot be auto-saved.
|
||||
<% } else if (reason === 'saveError') { %>
|
||||
Failed to save file<%- (errorFiles.length > 1 ? 's: ' : ' ') + errorFiles.join(', ') %>.
|
||||
<% } else if (reason === 'autoSaveDisabled') { %>
|
||||
Your files are still not saved because auto-save is disabled.
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue