[Client] Fix bug

This commit is contained in:
syuilo 2017-02-23 17:12:09 +09:00
parent 2e99f57cf8
commit d4f245f51c
6 changed files with 39 additions and 39 deletions

View File

@ -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 => {

View File

@ -1,4 +1,4 @@
<mk-drive-browser-file data-is-selected={ (file._selected || false).toString() } data-is-contextmenu-showing={ isContextmenuShowing.toString() } onclick={ onclick } oncontextmenu={ oncontextmenu } draggable="true" ondragstart={ ondragstart } ondragend={ ondragend } title={ title }>
<mk-drive-browser-file data-is-selected={ isSelected } data-is-contextmenu-showing={ isContextmenuShowing.toString() } onclick={ onclick } oncontextmenu={ oncontextmenu } draggable="true" ondragstart={ ondragstart } ondragend={ ondragend } title={ title }>
<div class="label" if={ I.avatar_id == file.id }><img src="/resources/label.svg"/>
<p>アバター</p>
</div>
@ -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 => {

View File

@ -1,13 +1,17 @@
<mk-select-file-from-drive-window>
<mk-window ref="window" is-modal={ true } width={ '800px' } height={ '500px' }><yield to="header">
<mk-raw content={ parent.title }></mk-raw><span class="count" if={ parent.multiple && parent.file.length > 0 }>({ parent.file.length }ファイル選択中)</span></yield>
<mk-window ref="window" is-modal={ true } width={ '800px' } height={ '500px' }>
<yield to="header">
<mk-raw content={ parent.title }></mk-raw>
<span class="count" if={ parent.multiple && parent.files.length > 0 }>({ parent.files.length }ファイル選択中)</span>
</yield>
<yield to="content">
<mk-drive-browser ref="browser" multiple={ parent.multiple }></mk-drive-browser>
<div>
<button class="upload" title="PCからドライブにファイルをアップロード" onclick={ parent.upload }><i class="fa fa-upload"></i></button>
<button class="cancel" onclick={ parent.close }>キャンセル</button>
<button class="ok" disabled={ parent.multiple && parent.file.length == 0 } onclick={ parent.ok }>決定</button>
</div></yield>
<button class="ok" disabled={ parent.multiple && parent.files.length == 0 } onclick={ parent.ok }>決定</button>
</div>
</yield>
</mk-window>
<style>
:scope
@ -131,20 +135,21 @@
</style>
<script>
this.file = [];
this.files = [];
this.multiple = this.opts.multiple != null ? this.opts.multiple : false;
this.title = this.opts.title || '<i class="fa fa-file-o"></i>ファイルを選択';
this.on('mount', () => {
this.refs.window.refs.browser.on('selected', file => {
this.file = file;
this.files = file;
this.ok();
});
this.refs.window.refs.browser.on('change-selection', files => {
this.file = files;
this.update();
this.update({
files: files
});
});
this.refs.window.on('closed', () => {
@ -161,7 +166,7 @@
};
this.ok = () => {
this.trigger('selected', this.file);
this.trigger('selected', this.files);
this.refs.window.close();
};
</script>

View File

@ -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
});

View File

@ -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);
}

View File

@ -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);
});