allow to add multiple files

This commit is contained in:
antelle 2016-07-31 10:47:56 +03:00
parent f10fd3172e
commit 8093279b95
4 changed files with 19 additions and 13 deletions

View File

@ -72,17 +72,19 @@ var AppModel = Backbone.Model.extend({
applyUserConfig(config) { applyUserConfig(config) {
this.settings.set(config.settings); this.settings.set(config.settings);
if (config.file && config.file.storage && config.file.name && config.file.path) { if (config.files) {
if (!this.fileInfos.getMatch(config.file.storage, config.file.name, config.file.path)) { config.files
var fileInfo = new FileInfoModel({ .filter(file => file && file.storage && file.name && file.path &&
!this.fileInfos.getMatch(file.storage, file.name, file.path))
.map(file => new FileInfoModel({
id: IdGenerator.uuid(), id: IdGenerator.uuid(),
name: config.file.name, name: file.name,
storage: config.file.storage, storage: file.storage,
path: config.file.path, path: file.path,
opts: config.file.options opts: file.options
}); }))
this.fileInfos.unshift(fileInfo); .reverse()
} .forEach(fi => this.fileInfos.unshift(fi));
} }
}, },
@ -358,7 +360,7 @@ var AppModel = Backbone.Model.extend({
logger.info('Load from storage'); logger.info('Load from storage');
storage.load(params.path, params.opts, (err, data, stat) => { storage.load(params.path, params.opts, (err, data, stat) => {
if (err) { if (err) {
if (fileInfo) { if (fileInfo && fileInfo.openDate) {
logger.info('Open file from cache because of storage load error', err); logger.info('Open file from cache because of storage load error', err);
that.openFileFromCache(params, callback, fileInfo); that.openFileFromCache(params, callback, fileInfo);
} else { } else {

View File

@ -169,6 +169,7 @@ var Locale = {
openConfigErrorNotFound: 'File not found', openConfigErrorNotFound: 'File not found',
openError: 'Error', openError: 'Error',
openErrorDescription: 'There was an error opening file', openErrorDescription: 'There was an error opening file',
openErrorFileNotFound: 'File not found',
detAttDownload: 'Shift-click attachment button to download or ', detAttDownload: 'Shift-click attachment button to download or ',
detAttDelToRemove: 'Delete to remove', detAttDelToRemove: 'Delete to remove',

View File

@ -471,6 +471,9 @@ var OpenView = Backbone.View.extend({
this.inputEl[0].selectionStart = 0; this.inputEl[0].selectionStart = 0;
this.inputEl[0].selectionEnd = this.inputEl.val().length; this.inputEl[0].selectionEnd = this.inputEl.val().length;
if (err.code !== 'InvalidKey') { if (err.code !== 'InvalidKey') {
if (err.notFound) {
err = Locale.openErrorFileNotFound;
}
Alerts.error({ Alerts.error({
header: Locale.openError, header: Locale.openError,
body: Locale.openErrorDescription + '<pre class="modal__pre">' + _.escape(err.toString()) + '</pre>' body: Locale.openErrorDescription + '<pre class="modal__pre">' + _.escape(err.toString()) + '</pre>'

View File

@ -35,10 +35,10 @@
"onedrive": true, "onedrive": true,
"onedriveClientId": null "onedriveClientId": null
}, },
"file": { "files": [{
"storage": "webdav", "storage": "webdav",
"name": "", "name": "",
"path": "", "path": "",
"options": { "user": "", "password": "" } "options": { "user": "", "password": "" }
} }]
} }