fix #336: moving entries across files

This commit is contained in:
antelle 2019-09-22 09:56:48 +02:00
parent b83e2519ac
commit ae72b55a2e
6 changed files with 48 additions and 29 deletions

View File

@ -516,6 +516,13 @@ class EntryModel extends Model {
}
}
detach() {
this.file.setModified();
this.file.db.move(this.entry, null);
this.file.reload();
return this.entry;
}
moveToFile(file) {
if (this.canBeDeleted) {
this.removeWithoutHistory();

View File

@ -272,27 +272,38 @@ class GroupModel extends MenuItemModel {
}
moveHere(object) {
if (!object || object.id === this.id || object.file !== this.file) {
if (!object || object.id === this.id) {
return;
}
this.file.setModified();
if (object instanceof GroupModel) {
for (let parent = this; parent; parent = parent.parentGroup) {
if (object === parent) {
if (object.file === this.file) {
this.file.setModified();
if (object instanceof GroupModel) {
for (let parent = this; parent; parent = parent.parentGroup) {
if (object === parent) {
return;
}
}
if (this.group.groups.indexOf(object.group) >= 0) {
return;
}
this.file.db.move(object.group, this.group);
this.file.reload();
} else if (object instanceof EntryModel) {
if (this.group.entries.indexOf(object.entry) >= 0) {
return;
}
this.file.db.move(object.entry, this.group);
this.file.reload();
}
if (this.group.groups.indexOf(object.group) >= 0) {
return;
} else {
if (object instanceof EntryModel) {
this.file.setModified();
const detachedEntry = object.detach();
this.file.db.importEntry(detachedEntry, this.group, object.file.db);
this.file.reload();
} else {
// moving groups between files is not supported for now
}
this.file.db.move(object.group, this.group);
this.file.reload();
} else if (object instanceof EntryModel) {
if (this.group.entries.indexOf(object.entry) >= 0) {
return;
}
this.file.db.move(object.entry, this.group);
this.file.reload();
}
}

View File

@ -58,14 +58,14 @@ function config(grunt, mode = 'production') {
],
alias: {
'babel-helpers': path.join(rootDir, 'app/lib/babel-helpers.js'),
jquery: `jquery/dist/jquery${devMode ? '.min' : ''}.js`,
morphdom: `morphdom/dist/morphdom-umd${devMode ? '.min' : ''}.js`,
kdbxweb: 'kdbxweb/dist/kdbxweb.js',
baron: `baron/baron${devMode ? '.min' : ''}.js`,
qrcode: `jsqrcode/dist/qrcode${devMode ? '.min' : ''}.js`,
jquery: `jquery/dist/jquery${devMode ? '' : '.min'}.js`,
morphdom: `morphdom/dist/morphdom-umd${devMode ? '' : '.min'}.js`,
kdbxweb: `kdbxweb/dist/kdbxweb${devMode ? '' : '.min'}.js`,
baron: `baron/baron${devMode ? '' : '.min'}.js`,
qrcode: `jsqrcode/dist/qrcode${devMode ? '' : '.min'}.js`,
argon2: 'argon2-browser/dist/argon2.js',
marked: devMode ? 'marked/lib/marked.js' : 'marked/marked.min.js',
dompurify: `dompurify/dist/purify${devMode ? '.min' : ''}.js`,
dompurify: `dompurify/dist/purify${devMode ? '' : '.min'}.js`,
hbs: 'handlebars/runtime.js',
'argon2-wasm': 'argon2-browser/dist/argon2.wasm',
templates: path.join(rootDir, 'app/templates'),

12
package-lock.json generated
View File

@ -7660,9 +7660,9 @@
"integrity": "sha512-pBxcB3LFc8QVgdggvZWyeys+hnrNWg4OcZIU/1X59k5jQdLBlCsYGRQaz234SqoRLTCgMH00fY0xRJH+F9METQ=="
},
"kdbxweb": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/kdbxweb/-/kdbxweb-1.4.2.tgz",
"integrity": "sha512-K7e+jjLqp2sRmUcq3EKooI6/Y1zb9G9ztWnkURhtbAUiXjerlFnrq9kA3hzQAsJ2R8j6Z5+nHWnsXAhhfmyr1Q==",
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/kdbxweb/-/kdbxweb-1.5.2.tgz",
"integrity": "sha512-AcWVnI4dTpsA62TYc1qGTeri4sdzuU2Y1LiGkeoXWyf/fNtjEZtR22wXuDXGiTbQzXGccc4QAgOkD4/vJ0Hw3A==",
"requires": {
"pako": "github:keeweb/pako#653c0b00d8941c89d09ed4546d2179001ec44efc",
"text-encoding": "github:keeweb/text-encoding#4dfb7cb0954c222852092f8b06ae4f6b4f60bfbb",
@ -8204,9 +8204,9 @@
}
},
"morphdom": {
"version": "2.5.6",
"resolved": "https://registry.npmjs.org/morphdom/-/morphdom-2.5.6.tgz",
"integrity": "sha512-uw+fgVRCV7DK9EWJ87NeiFXTDdLklajJQNLHCAJStqTY/uwFpK5ormeU2PYSX5DDk+cI9dtFli/MHKd2wP/KGg=="
"version": "2.5.8",
"resolved": "https://registry.npmjs.org/morphdom/-/morphdom-2.5.8.tgz",
"integrity": "sha512-w2DG6zJaI83oAv3Acimoj45AWTkKh57swi70NsxixHnalxrbNcy81TGk24YZRVSU82BeX8BH9wf8Df7A5DVu9Q=="
},
"move-concurrently": {
"version": "1.0.1",

View File

@ -55,12 +55,12 @@
"jquery": "3.4.1",
"json-loader": "^0.5.7",
"jsqrcode": "github:antelle/jsqrcode#0.1.3",
"kdbxweb": "1.4.2",
"kdbxweb": "1.5.2",
"load-grunt-tasks": "5.1.0",
"lodash": "^4.17.15",
"marked": "^0.7.0",
"mini-css-extract-plugin": "^0.8.0",
"morphdom": "^2.5.6",
"morphdom": "^2.5.8",
"node-sass": "^4.12.0",
"node-stream-zip": "1.8.2",
"normalize.css": "8.0.1",

View File

@ -9,6 +9,7 @@ Release notes
`+` #348: configurable system-wide shortcuts
`+` #743: copying entry fields to clipboard
`+` #713: markdown notes
`+` #336: moving entries across files
`*` devtools are now opened with alt-cmd-I
`-` fix #764: multiple attachments display
`-` fix multi-line fields display in history