mirror of https://github.com/keeweb/keeweb.git
fixed entry creation on a yubikey
This commit is contained in:
parent
3cd9bf6505
commit
db31e65cdf
|
@ -340,7 +340,7 @@ class AppModel {
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFirstSelectedGroup() {
|
getFirstSelectedGroupForCreation() {
|
||||||
const selGroupId = this.filter.group;
|
const selGroupId = this.filter.group;
|
||||||
let file, group;
|
let file, group;
|
||||||
if (selGroupId) {
|
if (selGroupId) {
|
||||||
|
@ -351,7 +351,7 @@ class AppModel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!group) {
|
if (!group) {
|
||||||
file = this.files[0];
|
file = this.files.find(f => f.active && !f.readOnly);
|
||||||
group = file.groups[0];
|
group = file.groups[0];
|
||||||
}
|
}
|
||||||
return { group, file };
|
return { group, file };
|
||||||
|
@ -391,7 +391,7 @@ class AppModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
createNewEntry(args) {
|
createNewEntry(args) {
|
||||||
const sel = this.getFirstSelectedGroup();
|
const sel = this.getFirstSelectedGroupForCreation();
|
||||||
if (args && args.template) {
|
if (args && args.template) {
|
||||||
if (sel.file !== args.template.file) {
|
if (sel.file !== args.template.file) {
|
||||||
sel.file = args.template.file;
|
sel.file = args.template.file;
|
||||||
|
@ -409,12 +409,12 @@ class AppModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
createNewGroup() {
|
createNewGroup() {
|
||||||
const sel = this.getFirstSelectedGroup();
|
const sel = this.getFirstSelectedGroupForCreation();
|
||||||
return GroupModel.newGroup(sel.group, sel.file);
|
return GroupModel.newGroup(sel.group, sel.file);
|
||||||
}
|
}
|
||||||
|
|
||||||
createNewTemplateEntry() {
|
createNewTemplateEntry() {
|
||||||
const file = this.getFirstSelectedGroup().file;
|
const file = this.getFirstSelectedGroupForCreation().file;
|
||||||
const group = file.getEntryTemplatesGroup() || file.createEntryTemplatesGroup();
|
const group = file.getEntryTemplatesGroup() || file.createEntryTemplatesGroup();
|
||||||
return EntryModel.newEntry(group, file);
|
return EntryModel.newEntry(group, file);
|
||||||
}
|
}
|
||||||
|
@ -1184,6 +1184,10 @@ class AppModel {
|
||||||
});
|
});
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canCreateEntries() {
|
||||||
|
return this.files.some(f => f.active && !f.readOnly);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { AppModel };
|
export { AppModel };
|
||||||
|
|
|
@ -22,6 +22,7 @@ class ExternalDeviceModel extends Model {
|
||||||
ExternalDeviceModel.defineModelProperties({
|
ExternalDeviceModel.defineModelProperties({
|
||||||
id: '',
|
id: '',
|
||||||
external: true,
|
external: true,
|
||||||
|
readOnly: true,
|
||||||
active: false,
|
active: false,
|
||||||
entries: undefined,
|
entries: undefined,
|
||||||
groups: undefined,
|
groups: undefined,
|
||||||
|
|
|
@ -55,8 +55,11 @@ function createDetailsFields(detailsView) {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (model.isJustCreated && AppModel.instance.files.length > 1) {
|
const writeableFiles = AppModel.instance.files.filter(
|
||||||
const fileNames = AppModel.instance.files.map(file => {
|
file => file.active && !file.readOnly
|
||||||
|
);
|
||||||
|
if (model.isJustCreated && writeableFiles.length > 1) {
|
||||||
|
const fileNames = writeableFiles.map(file => {
|
||||||
return { id: file.id, value: file.name, selected: file === model.file };
|
return { id: file.id, value: file.name, selected: file === model.file };
|
||||||
});
|
});
|
||||||
fieldViews.push(
|
fieldViews.push(
|
||||||
|
|
|
@ -127,6 +127,7 @@ class ListSearchView extends View {
|
||||||
this.listenTo(Events, 'filter', this.filterChanged);
|
this.listenTo(Events, 'filter', this.filterChanged);
|
||||||
this.listenTo(Events, 'set-locale', this.setLocale);
|
this.listenTo(Events, 'set-locale', this.setLocale);
|
||||||
this.listenTo(Events, 'page-blur', this.pageBlur);
|
this.listenTo(Events, 'page-blur', this.pageBlur);
|
||||||
|
this.listenTo(this.model.files, 'change', this.fileListUpdated);
|
||||||
|
|
||||||
this.once('remove', () => {
|
this.once('remove', () => {
|
||||||
this.removeKeypressHandler();
|
this.removeKeypressHandler();
|
||||||
|
@ -176,7 +177,8 @@ class ListSearchView extends View {
|
||||||
}
|
}
|
||||||
super.render({
|
super.render({
|
||||||
adv: this.advancedSearch,
|
adv: this.advancedSearch,
|
||||||
advEnabled: this.advancedSearchEnabled
|
advEnabled: this.advancedSearchEnabled,
|
||||||
|
canCreate: this.model.canCreateEntries()
|
||||||
});
|
});
|
||||||
this.inputEl = this.$el.find('.list__search-field');
|
this.inputEl = this.$el.find('.list__search-field');
|
||||||
if (searchVal) {
|
if (searchVal) {
|
||||||
|
@ -422,6 +424,10 @@ class ListSearchView extends View {
|
||||||
addArrow(str) {
|
addArrow(str) {
|
||||||
return str.replace('{}', '→');
|
return str.replace('{}', '→');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileListUpdated() {
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ListSearchView };
|
export { ListSearchView };
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
&-field-wrap {
|
&-field-wrap {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
margin-right: $small-spacing;
|
||||||
}
|
}
|
||||||
&-field {
|
&-field {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -72,7 +73,6 @@
|
||||||
}
|
}
|
||||||
&-btn-new {
|
&-btn-new {
|
||||||
@include icon-btn;
|
@include icon-btn;
|
||||||
margin-left: $small-spacing;
|
|
||||||
}
|
}
|
||||||
&-btn-sort {
|
&-btn-sort {
|
||||||
@include icon-btn;
|
@include icon-btn;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<i class="fa fa-caret-down"></i>
|
<i class="fa fa-caret-down"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="list__search-btn-new" title="{{res 'searchAddNew'}}">
|
<div class="list__search-btn-new {{#unless canCreate}}hide{{/unless}}" title="{{res 'searchAddNew'}}">
|
||||||
<i class="fa fa-plus"></i>
|
<i class="fa fa-plus"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="list__search-btn-sort" title="{{res 'searchSort'}}">
|
<div class="list__search-btn-sort" title="{{res 'searchSort'}}">
|
||||||
|
|
Loading…
Reference in New Issue