|
|
@ -1,4 +1,8 @@
|
|
|
|
|
|
|
|
var _ = require('underscore');
|
|
|
|
|
|
|
|
var $ = require('jquery');
|
|
|
|
|
|
|
|
var Config = require('../../Config');
|
|
|
|
var Marionette = require('marionette');
|
|
|
|
var Marionette = require('marionette');
|
|
|
|
|
|
|
|
var moment = require('moment');
|
|
|
|
require('../../Mixins/FileBrowser');
|
|
|
|
require('../../Mixins/FileBrowser');
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = Marionette.ItemView.extend({
|
|
|
|
module.exports = Marionette.ItemView.extend({
|
|
|
@ -13,7 +17,14 @@ module.exports = Marionette.ItemView.extend({
|
|
|
|
'click .x-manual-import' : '_manualImport',
|
|
|
|
'click .x-manual-import' : '_manualImport',
|
|
|
|
'click .x-automatic-import' : '_automaticImport',
|
|
|
|
'click .x-automatic-import' : '_automaticImport',
|
|
|
|
'change .x-path' : '_updateButtons',
|
|
|
|
'change .x-path' : '_updateButtons',
|
|
|
|
'keyup .x-path' : '_updateButtons'
|
|
|
|
'keyup .x-path' : '_updateButtons',
|
|
|
|
|
|
|
|
'click .x-recent-folder' : '_selectRecentFolder'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initialize : function () {
|
|
|
|
|
|
|
|
this.templateHelpers = {
|
|
|
|
|
|
|
|
recentFolders: Config.getValueJson('manualimport.recentfolders', [])
|
|
|
|
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onRender : function() {
|
|
|
|
onRender : function() {
|
|
|
@ -26,14 +37,20 @@ module.exports = Marionette.ItemView.extend({
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_manualImport : function () {
|
|
|
|
_manualImport : function () {
|
|
|
|
if (this.ui.path.val()) {
|
|
|
|
var path = this.ui.path.val();
|
|
|
|
this.trigger('manualImport', { folder: this.ui.path.val() });
|
|
|
|
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
|
|
|
|
this._setRecentFolders(path);
|
|
|
|
|
|
|
|
this.trigger('manualImport', { folder: path });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_automaticImport : function () {
|
|
|
|
_automaticImport : function () {
|
|
|
|
if (this.ui.path.val()) {
|
|
|
|
var path = this.ui.path.val();
|
|
|
|
this.trigger('automaticImport', { folder: this.ui.path.val() });
|
|
|
|
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
|
|
|
|
this._setRecentFolders(path);
|
|
|
|
|
|
|
|
this.trigger('automaticImport', { folder: path });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -45,5 +62,23 @@ module.exports = Marionette.ItemView.extend({
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
this.ui.buttons.attr('disabled', 'disabled');
|
|
|
|
this.ui.buttons.attr('disabled', 'disabled');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_selectRecentFolder : function (e) {
|
|
|
|
|
|
|
|
var path = $(e.target).closest('tr').data('path');
|
|
|
|
|
|
|
|
this.ui.path.val(path);
|
|
|
|
|
|
|
|
this.ui.path.trigger('change');
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_setRecentFolders : function (path) {
|
|
|
|
|
|
|
|
var recentFolders = Config.getValueJson('manualimport.recentfolders', []);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recentFolders = _.filter(recentFolders, function (folder) {
|
|
|
|
|
|
|
|
return folder.path.toLowerCase() !== path.toLowerCase();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recentFolders.unshift({ path: path, lastUsed: moment.utc().toISOString() });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Config.setValueJson('manualimport.recentfolders', _.take(recentFolders, 5));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|