Skip to content
Snippets Groups Projects
Commit 12d2ca4a authored by Steinwender, Tamara's avatar Steinwender, Tamara Committed by Reiter, Christoph
Browse files

Tabulator table shift select with mobile support

parent e8f6564b
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -21,7 +21,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
this.webDavUrl = ''; this.webDavUrl = '';
this.loginWindow = null; this.loginWindow = null;
this.isPickerActive = false; this.isPickerActive = false;
this.selectButtonText = i18n.t('nextcloud-file-picker.select-files');
this.statusText = ''; this.statusText = '';
this.lastDirectoryPath = '/'; this.lastDirectoryPath = '/';
this.directoryPath = '/'; this.directoryPath = '/';
...@@ -29,6 +28,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -29,6 +28,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
this.tabulatorTable = null; this.tabulatorTable = null;
this.allowedMimeTypes = '*/*'; this.allowedMimeTypes = '*/*';
this.directoriesOnly = null; this.directoriesOnly = null;
this.selectNum = true;
this._onReceiveWindowMessage = this.onReceiveWindowMessage.bind(this); this._onReceiveWindowMessage = this.onReceiveWindowMessage.bind(this);
} }
...@@ -53,7 +53,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -53,7 +53,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
directoryPath: { type: String, attribute: false }, directoryPath: { type: String, attribute: false },
allowedMimeTypes: { type: String, attribute: 'allowed-mime-types' }, allowedMimeTypes: { type: String, attribute: 'allowed-mime-types' },
directoriesOnly: { type: Boolean, attribute: 'directories-only' }, directoriesOnly: { type: Boolean, attribute: 'directories-only' },
selectButtonText: { type: String, attribute: 'select-button-text' }, selectNum: { type: Number, attribute: 'select-num' },
}; };
} }
...@@ -72,7 +72,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -72,7 +72,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
disconnectedCallback() { disconnectedCallback() {
window.removeEventListener('message', this._onReceiveWindowMessage); window.removeEventListener('message', this._onReceiveWindowMessage);
super.disconnectedCallback(); super.disconnectedCallback();
} }
connectedCallback() { connectedCallback() {
super.connectedCallback(); super.connectedCallback();
...@@ -85,7 +85,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -85,7 +85,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
// TODO: translation of column headers // TODO: translation of column headers
this.tabulatorTable = new Tabulator(this._("#directory-content-table"), { this.tabulatorTable = new Tabulator(this._("#directory-content-table"), {
layout: "fitDataStretch", layout: "fitDataStretch",
selectable: true, selectable: this.selectNum,
selectableRangeMode: "drag",
columns: [ columns: [
{title: "Type", field: "type", align:"center", formatter: (cell, formatterParams, onRendered) => { {title: "Type", field: "type", align:"center", formatter: (cell, formatterParams, onRendered) => {
const icon_tag = that.constructor.getScopedTagName("vpu-icon"); const icon_tag = that.constructor.getScopedTagName("vpu-icon");
...@@ -140,13 +141,18 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -140,13 +141,18 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
} }
}, },
rowDblClick: (e, row) => { rowDblClick: (e, row) => {
const data = row.getData();
if(this.directoriesOnly) { if(this.directoriesOnly) {
const data = row.getData();
this.directoryClicked(e, data); this.directoryClicked(e, data);
} }
} }
}); });
console.log("table: ", this.tabulatorTable);
if(this.tabulatorTable.browserMobile === false)
{
this.tabulatorTable.options.selectableRangeMode = "click";
}
function checkFileType(data, filterParams) { function checkFileType(data, filterParams) {
// check if file is allowed // check if file is allowed
if(typeof data.mime === 'undefined') { if(typeof data.mime === 'undefined') {
...@@ -264,9 +270,9 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -264,9 +270,9 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
this.statusText = ""; this.statusText = "";
}).catch(error => { }).catch(error => {
console.error(error.message); console.error(error.message);
this.statusText = error.message; this.statusText = error.message;
}); });
} }
/** /**
...@@ -290,6 +296,13 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -290,6 +296,13 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
.block { .block {
margin-bottom: 10px; margin-bottom: 10px;
} }
.force-no-select{
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
`; `;
} }
...@@ -319,9 +332,9 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -319,9 +332,9 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
<button class="button is-small" <button class="button is-small"
title="${i18n.t('nextcloud-file-picker.folder-up')}" title="${i18n.t('nextcloud-file-picker.folder-up')}"
@click="${() => { this.loadDirectory(this.getParentDirectoryPath()); }}">&#8679;</button> @click="${() => { this.loadDirectory(this.getParentDirectoryPath()); }}">&#8679;</button>
<table id="directory-content-table"></table> <table id="directory-content-table" class="force-no-select"></table>
<button class="button" <button class="button"
@click="${() => { this.downloadFiles(this.tabulatorTable.getSelectedData()); }}">${this.selectButtonText}</button> @click="${() => { this.downloadFiles(this.tabulatorTable.getSelectedData()); }}">${i18n.t('nextcloud-file-picker.select-files')}</button>
</div> </div>
`; `;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment