AutoComplete and file browser will show files when appropriate
Fixed: File browser for Custom Script shows files Closes #1084
This commit is contained in:
parent
9f523bb167
commit
56da824e98
|
@ -26,6 +26,7 @@ namespace NzbDrone.Core.Annotations
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Select,
|
Select,
|
||||||
Path,
|
Path,
|
||||||
|
FilePath,
|
||||||
Hidden,
|
Hidden,
|
||||||
Tag,
|
Tag,
|
||||||
Action,
|
Action,
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
|
||||||
{
|
{
|
||||||
private static readonly CustomScriptSettingsValidator Validator = new CustomScriptSettingsValidator();
|
private static readonly CustomScriptSettingsValidator Validator = new CustomScriptSettingsValidator();
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "Path", Type = FieldType.Path)]
|
[FieldDefinition(0, Label = "Path", Type = FieldType.FilePath)]
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(1, Label = "Arguments", HelpText = "Arguments to pass to the script")]
|
[FieldDefinition(1, Label = "Arguments", HelpText = "Arguments to pass to the script")]
|
||||||
|
|
|
@ -3,5 +3,4 @@
|
||||||
<component name="ProjectKey">
|
<component name="ProjectKey">
|
||||||
<option name="state" value="git@github.com:NzbDrone/NzbDrone.git" />
|
<option name="state" value="git@github.com:NzbDrone/NzbDrone.git" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" />
|
|
||||||
</project>
|
</project>
|
|
@ -37,7 +37,7 @@ var _fieldBuilder = function(field) {
|
||||||
return _templateRenderer.call(field, 'Form/HiddenTemplate');
|
return _templateRenderer.call(field, 'Form/HiddenTemplate');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.type === 'path') {
|
if (field.type === 'path' || field.type === 'filepath') {
|
||||||
return _templateRenderer.call(field, 'Form/PathTemplate');
|
return _templateRenderer.call(field, 'Form/PathTemplate');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ var _fieldBuilder = function(field) {
|
||||||
return _templateRenderer.call(field, 'Form/ActionTemplate');
|
return _templateRenderer.call(field, 'Form/ActionTemplate');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return _templateRenderer.call(field, 'Form/TextboxTemplate');
|
return _templateRenderer.call(field, 'Form/TextboxTemplate');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<label class="col-sm-3 control-label">{{label}}</label>
|
<label class="col-sm-3 control-label">{{label}}</label>
|
||||||
|
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
<input type="text" name="fields.{{order}}.value" validation-name="{{name}}" class="form-control x-path"/>
|
<input type="text" name="fields.{{order}}.value" validation-name="{{name}}" class="form-control x-path {{#if_eq type compare="filepath"}}x-filepath{{/if_eq}}"/>
|
||||||
</div>
|
</div>
|
||||||
{{> FormHelpPartial}}
|
{{> FormHelpPartial}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -23,7 +23,7 @@ $.fn.autoComplete = function(options) {
|
||||||
name : options.resource.replace('/'),
|
name : options.resource.replace('/'),
|
||||||
displayKey : '',
|
displayKey : '',
|
||||||
source : function(filter, callback) {
|
source : function(filter, callback) {
|
||||||
var data = {};
|
var data = options.data || {};
|
||||||
data[options.query] = filter;
|
data[options.query] = filter;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : window.NzbDrone.ApiRoot + options.resource,
|
url : window.NzbDrone.ApiRoot + options.resource,
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
var $ = require('jquery');
|
var $ = require('jquery');
|
||||||
require('./AutoComplete');
|
require('./AutoComplete');
|
||||||
|
|
||||||
$.fn.directoryAutoComplete = function() {
|
$.fn.directoryAutoComplete = function(options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
var query = 'path';
|
var query = 'path';
|
||||||
|
var data = {
|
||||||
|
includeFiles: options.includeFiles || false
|
||||||
|
};
|
||||||
|
|
||||||
$(this).autoComplete({
|
$(this).autoComplete({
|
||||||
resource : '/filesystem',
|
resource : '/filesystem',
|
||||||
query : query,
|
query : query,
|
||||||
|
data : data,
|
||||||
filter : function(filter, response, callback) {
|
filter : function(filter, response, callback) {
|
||||||
var matches = [];
|
var matches = [];
|
||||||
|
var results = response.directories.concat(response.files);
|
||||||
|
|
||||||
$.each(response.directories, function(i, d) {
|
$.each(results, function(i, d) {
|
||||||
if (d[query] && d[query].startsWith(filter)) {
|
if (d[query] && d[query].startsWith(filter)) {
|
||||||
matches.push({ value : d[query] });
|
matches.push({ value : d[query] });
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ $.fn.fileBrowser = function(options) {
|
||||||
|
|
||||||
inputs.each(function() {
|
inputs.each(function() {
|
||||||
var input = $(this);
|
var input = $(this);
|
||||||
var inputOptions = $.extend({ input : input }, options);
|
var inputOptions = $.extend({ input : input, showFiles: input.hasClass('x-filepath') }, options);
|
||||||
var inputGroup = $('<div class="input-group"></div>');
|
var inputGroup = $('<div class="input-group"></div>');
|
||||||
var inputGroupButton = $('<span class="input-group-btn"></span>');
|
var inputGroupButton = $('<span class="input-group-btn"></span>');
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ $.fn.fileBrowser = function(options) {
|
||||||
button.on('click', function() {
|
button.on('click', function() {
|
||||||
vent.trigger(vent.Commands.ShowFileBrowser, inputOptions);
|
vent.trigger(vent.Commands.ShowFileBrowser, inputOptions);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
input.directoryAutoComplete({ includeFiles: inputOptions.showFiles });
|
||||||
});
|
});
|
||||||
|
|
||||||
inputs.directoryAutoComplete();
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue