From d4f245f51c021e7993817a02665c9c124f0450ee Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 23 Feb 2017 17:12:09 +0900 Subject: [PATCH] [Client] Fix bug --- src/web/app/desktop/tags/drive/browser.tag | 11 +++++-- src/web/app/desktop/tags/drive/file.tag | 28 +++++----------- .../tags/select-file-from-drive-window.tag | 33 +++++++++++-------- src/web/app/mobile/tags/drive-selector.tag | 2 +- src/web/app/mobile/tags/drive.tag | 2 +- src/web/app/mobile/tags/drive/file.tag | 2 +- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/web/app/desktop/tags/drive/browser.tag b/src/web/app/desktop/tags/drive/browser.tag index 1e8b17cfcd..afaa452ed2 100644 --- a/src/web/app/desktop/tags/drive/browser.tag +++ b/src/web/app/desktop/tags/drive/browser.tag @@ -248,6 +248,7 @@ this.files = []; this.folders = []; this.hierarchyFolders = []; + this.selectedFiles = []; this.uploads = []; @@ -514,8 +515,14 @@ this.refs.uploader.upload(file, folder); }; - this.getSelection = () => { - this.files.filter(file => file._selected); + this.chooseFile = file => { + if (this.selectedFiles.some(f => f.id == file.id)) { + this.selectedFiles = this.selectedFiles.filter(f => f.id != file.id); + } else { + this.selectedFiles.push(file); + } + this.update(); + this.trigger('change-selection', this.selectedFiles); }; this.newWindow = folderId => { diff --git a/src/web/app/desktop/tags/drive/file.tag b/src/web/app/desktop/tags/drive/file.tag index a7502c1001..47416db0bd 100644 --- a/src/web/app/desktop/tags/drive/file.tag +++ b/src/web/app/desktop/tags/drive/file.tag @@ -1,4 +1,4 @@ - +

アバター

@@ -38,7 +38,7 @@ &:after background #0b588c - &[data-is-selected='true'] + &[data-is-selected] background $theme-color &:hover @@ -150,28 +150,16 @@ this.file = this.opts.file; this.browser = this.parent; - this.title = `${this.file.name}\n${this.file.type} ${this.bytesToSize(this.file.datasize)}`; - this.isContextmenuShowing = false; + this.isSelected = this.browser.selectedFiles.some(f => f.id == this.file.id); + + this.browser.on('change-selection', selections => { + this.isSelected = selections.some(f => f.id == this.file.id); + }); this.onclick = () => { - if (this.browser.multiple) { - if (this.file._selected != null) { - this.file._selected = !this.file._selected; - } else { - this.file._selected = true; - } - this.browser.trigger('change-selection', this.browser.getSelection()); - } else { - if (this.file._selected) { - this.browser.trigger('selected', this.file); - } else { - this.browser.files.forEach(file => file._selected = false); - this.file._selected = true; - this.browser.trigger('change-selection', this.file); - } - } + this.browser.chooseFile(this.file); }; this.oncontextmenu = e => { diff --git a/src/web/app/desktop/tags/select-file-from-drive-window.tag b/src/web/app/desktop/tags/select-file-from-drive-window.tag index 777073583f..ed1c1bce6c 100644 --- a/src/web/app/desktop/tags/select-file-from-drive-window.tag +++ b/src/web/app/desktop/tags/select-file-from-drive-window.tag @@ -1,13 +1,17 @@ - - 0 }>({ parent.file.length }ファイル選択中) - - -
- - - -
+ + + + 0 }>({ parent.files.length }ファイル選択中) + + + +
+ + + +
+
diff --git a/src/web/app/mobile/tags/drive-selector.tag b/src/web/app/mobile/tags/drive-selector.tag index 753a2c3a9b..0122ad3fc4 100644 --- a/src/web/app/mobile/tags/drive-selector.tag +++ b/src/web/app/mobile/tags/drive-selector.tag @@ -59,7 +59,7 @@ this.files = []; this.on('mount', () => { - this.refs.browser.on('change-selected', files => { + this.refs.browser.on('change-selection', files => { this.update({ files: files }); diff --git a/src/web/app/mobile/tags/drive.tag b/src/web/app/mobile/tags/drive.tag index 35b9b65417..051482ae19 100644 --- a/src/web/app/mobile/tags/drive.tag +++ b/src/web/app/mobile/tags/drive.tag @@ -358,7 +358,7 @@ this.selectedFiles.push(file); } this.update(); - this.trigger('change-selected', this.selectedFiles); + this.trigger('change-selection', this.selectedFiles); } else { this.cf(file); } diff --git a/src/web/app/mobile/tags/drive/file.tag b/src/web/app/mobile/tags/drive/file.tag index 4b8216219b..1ee114fde7 100644 --- a/src/web/app/mobile/tags/drive/file.tag +++ b/src/web/app/mobile/tags/drive/file.tag @@ -128,7 +128,7 @@ this.file = this.opts.file; this.isSelected = this.browser.selectedFiles.some(f => f.id == this.file.id); - this.browser.on('change-selected', selections => { + this.browser.on('change-selection', selections => { this.isSelected = selections.some(f => f.id == this.file.id); });