mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
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 @@ public enum FieldType
|
||||
Checkbox,
|
||||
Select,
|
||||
Path,
|
||||
FilePath,
|
||||
Hidden,
|
||||
Tag,
|
||||
Action,
|
||||
|
@ -19,7 +19,7 @@ public class CustomScriptSettings : IProviderConfig
|
||||
{
|
||||
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; }
|
||||
|
||||
[FieldDefinition(1, Label = "Arguments", HelpText = "Arguments to pass to the script")]
|
||||
|
@ -3,5 +3,4 @@
|
||||
<component name="ProjectKey">
|
||||
<option name="state" value="git@github.com:NzbDrone/NzbDrone.git" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" />
|
||||
</project>
|
@ -37,7 +37,7 @@ var _fieldBuilder = function(field) {
|
||||
return _templateRenderer.call(field, 'Form/HiddenTemplate');
|
||||
}
|
||||
|
||||
if (field.type === 'path') {
|
||||
if (field.type === 'path' || field.type === 'filepath') {
|
||||
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/TextboxTemplate');
|
||||
};
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<label class="col-sm-3 control-label">{{label}}</label>
|
||||
|
||||
<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>
|
||||
{{> FormHelpPartial}}
|
||||
</div>
|
||||
|
@ -23,7 +23,7 @@ $.fn.autoComplete = function(options) {
|
||||
name : options.resource.replace('/'),
|
||||
displayKey : '',
|
||||
source : function(filter, callback) {
|
||||
var data = {};
|
||||
var data = options.data || {};
|
||||
data[options.query] = filter;
|
||||
$.ajax({
|
||||
url : window.NzbDrone.ApiRoot + options.resource,
|
||||
|
@ -1,16 +1,23 @@
|
||||
var $ = require('jquery');
|
||||
require('./AutoComplete');
|
||||
|
||||
$.fn.directoryAutoComplete = function() {
|
||||
$.fn.directoryAutoComplete = function(options) {
|
||||
options = options || {};
|
||||
|
||||
var query = 'path';
|
||||
var data = {
|
||||
includeFiles: options.includeFiles || false
|
||||
};
|
||||
|
||||
$(this).autoComplete({
|
||||
resource : '/filesystem',
|
||||
query : query,
|
||||
data : data,
|
||||
filter : function(filter, response, callback) {
|
||||
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)) {
|
||||
matches.push({ value : d[query] });
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ $.fn.fileBrowser = function(options) {
|
||||
|
||||
inputs.each(function() {
|
||||
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 inputGroupButton = $('<span class="input-group-btn"></span>');
|
||||
|
||||
@ -25,7 +25,8 @@ $.fn.fileBrowser = function(options) {
|
||||
button.on('click', function() {
|
||||
vent.trigger(vent.Commands.ShowFileBrowser, inputOptions);
|
||||
});
|
||||
|
||||
input.directoryAutoComplete({ includeFiles: inputOptions.showFiles });
|
||||
});
|
||||
|
||||
inputs.directoryAutoComplete();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user