Skip to content

Commit 7e69378

Browse files
committed
Started on multiselect support (#22)
1 parent 893bccc commit 7e69378

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

index.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ const createInitialPaths = (core, proc) => {
128128
/**
129129
* Formats file status message
130130
*/
131-
const formatFileMessage = file => `${file.filename} (${file.size} bytes)`;
131+
const formatFileMessage = files => files
132+
.map(file => `${file.filename} (${file.size} bytes)`)
133+
.join(', ');
132134

133135
/**
134136
* Formats directory status message
@@ -332,7 +334,7 @@ const vfsActionFactory = (core, proc, win, dialog, state) => {
332334
} catch (error) {
333335
dialog('error', error, __('MSG_READDIR_ERROR', dir.path));
334336
} finally {
335-
state.currentFile = undefined;
337+
state.currentFile = [];
336338
win.setState('loading', false);
337339
}
338340
};
@@ -659,7 +661,8 @@ const createApplication = (core, proc) => {
659661
}),
660662

661663
fileview: listView.state({
662-
columns: []
664+
columns: [],
665+
multiselect: true
663666
})
664667
};
665668

@@ -696,12 +699,12 @@ const createApplication = (core, proc) => {
696699
setStatus: status => ({status}),
697700
setMinimalistic: minimalistic => ({minimalistic}),
698701
setList: ({list, path, selectFile}) => ({fileview, mountview}) => {
699-
let selectedIndex;
702+
let selectedIndex = [];
700703

701704
if (selectFile) {
702705
const foundIndex = list.findIndex(file => file.filename === selectFile);
703706
if (foundIndex !== -1) {
704-
selectedIndex = foundIndex;
707+
selectedIndex = [foundIndex];
705708
}
706709
}
707710

@@ -725,7 +728,7 @@ const createApplication = (core, proc) => {
725728

726729
fileview: listView.actions({
727730
select: ({data}) => win.emit('filemanager:select', data),
728-
activate: ({data}) => win.emit(`filemanager:${data.isFile ? 'open' : 'navigate'}`, data),
731+
activate: ({data}) => data.forEach(d => win.emit(`filemanager:${d.isFile ? 'open' : 'navigate'}`, d)),
729732
contextmenu: args => win.emit('filemanager:contextmenu', args),
730733
created: ({el, data}) => {
731734
if (data.isFile) {
@@ -747,7 +750,7 @@ const createApplication = (core, proc) => {
747750
*/
748751
const createWindow = (core, proc) => {
749752
let wired;
750-
const state = {currentFile: undefined, currentPath: undefined};
753+
const state = {currentFile: [], currentPath: undefined};
751754
const {homePath, initialPath} = createInitialPaths(core, proc);
752755

753756
const title = core.make('osjs/locale').translatableFlat(proc.metadata.title);
@@ -766,8 +769,8 @@ const createWindow = (core, proc) => {
766769
const onDrop = (...args) => vfs.drop(...args);
767770
const onHome = () => vfs.readdir(homePath, 'clear');
768771
const onNavigate = (...args) => vfs.readdir(...args);
769-
const onSelectItem = file => (state.currentFile = file);
770-
const onSelectStatus = file => win.emit('filemanager:status', formatFileMessage(file));
772+
const onSelectItem = files => (state.currentFile = files);
773+
const onSelectStatus = files => win.emit('filemanager:status', formatFileMessage(files));
771774
const onContextMenu = ({ev, data}) => createMenu({ev, name: 'edit'}, data, true);
772775
const onReaddirRender = args => wired.setList(args);
773776
const onRefresh = (...args) => vfs.refresh(...args);

0 commit comments

Comments
 (0)