Skip to content

Commit

Permalink
Basic working filter for path selector
Browse files Browse the repository at this point in the history
  • Loading branch information
HazelGrant committed Dec 5, 2024
1 parent cff7bb0 commit bb1a8dd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function getPathSelectorOptions(element) {
options.inputFieldId = element.dataset['inputFieldId'];
options.showFiles = element.dataset['showFiles'];
options.showHidden = element.dataset['showHidden'];
options.filePattern = element.dataset['filePattern']
options.modalId = element.id;

return options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class PathSelectorTable {
modalId = undefined;
showHidden = undefined;
showFiles = undefined;
filePattern = undefined;

constructor(options) {
this.tableId = options.tableId;
Expand All @@ -23,6 +24,7 @@ export class PathSelectorTable {
this.modalId = options.modalId;
this.showHidden = options.showHidden === 'true';
this.showFiles = options.showFiles === 'true';
this.filePattern = options.filePattern;

this.initDataTable();
this.reloadTable(this.initialUrl());
Expand Down Expand Up @@ -216,7 +218,16 @@ export class PathSelectorTable {
} else if(isHidden) {
return this.showHidden;
} else if(isFile) {
return this.showFiles;
if (this.filePattern !== "") {
if (file.name.match(RegExp(this.filePattern))) {
return this.showFiles;
} else {
return false;
}
}
else {
return this.showFiles;
}
} else {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
locals = {
show_hidden: field_options.fetch(:show_hidden, false),
show_files: field_options.fetch(:show_files, true),
file_pattern: field_options.fetch(:file_pattern, ''),
initial_directory: field_options.fetch(:directory, CurrentUser.home),
favorites: pathselector_favorites(field_options.try(:[], :favorites)),

Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/app/views/projects/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
breadcrumb_id: "#{path_selector_id}_breadcrumb",
button_id: "#{path_selector_id}_button",
input_field_id: 'project_directory',
favorites: false
favorites: false,
}
%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
data-breadcrumb-id="<%= breadcrumb_id %>"
data-select-button-id="<%= button_id %>"
data-input-field-id="<%= input_field_id %>"
data-file-pattern="<%= file_pattern %>"
>

<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg" role="document">
Expand Down

0 comments on commit bb1a8dd

Please sign in to comment.