mirror of
https://dev.sigpipe.me/dashie/git.txt
synced 2025-10-05 23:32:48 +02:00
Improve the new file javascript; Still getting that issue
This commit is contained in:
2
TODO.org
2
TODO.org
@@ -8,7 +8,7 @@
|
||||
|
||||
** TODO Add line-break option
|
||||
** TODO Add more checks for <nil> fields wrongly used, like issue with non existant file
|
||||
** TODO Add pictures from git with zz_.png; Edit web interface, and add file; wrong duplicate !!
|
||||
** TODO If a binary file, or huge one is added from git, we get weird submit results and can't update from interface
|
||||
|
||||
** DONE Non existant file in git for raw file: git_object_lookup_prefix: Assertion `repo && object_out && id' failed.
|
||||
** DONE Can't add files with filename "/some/thing/foo.bar"
|
||||
|
@@ -351,4 +351,8 @@ div.admin-dashboard div.divider {
|
||||
border-top: 1px solid rgba(34,36,38,.15);
|
||||
border-bottom: 1px solid rgba(255,255,255,.1);
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
div.form.placeholders {
|
||||
display: none;
|
||||
}
|
@@ -5,26 +5,29 @@
|
||||
$(document).on("click", "#add_new_form", function() {
|
||||
console.log("adding a new file fields");
|
||||
// Clone the file template
|
||||
let new_file = $("div.files > div").last().clone();
|
||||
let last_file = $("div.files > div").last();
|
||||
let last_index = parseInt(last_file.data("id"));
|
||||
|
||||
// Empty the inputs
|
||||
new_file.find("input[type='text']").val("");
|
||||
new_file.find("textarea[type='text']").val("");
|
||||
// Clone the template on end of form
|
||||
let new_file = $("div.form.placeholders > div").clone();
|
||||
|
||||
// Update the index
|
||||
let index = parseInt(new_file.data("id"));
|
||||
let newIndex = index + 1;
|
||||
let newIndex = last_index + 1;
|
||||
|
||||
// Empty fields
|
||||
new_file.find("input[type='text']").val("");
|
||||
new_file.find("textarea[type='text']").val("");
|
||||
|
||||
// This only works in debugger, not here, thank you JS
|
||||
//new_file.data("id", newIndex);
|
||||
new_file.attr("data-id", newIndex);
|
||||
|
||||
new_file.attr("class", "form_" + newIndex + " gitxt_new_file");
|
||||
new_file.find("label[for='file_"+index+"_filename']").attr("for", "file_"+newIndex+"_filename");
|
||||
new_file.find("label[for='file_"+index+"_content']").attr("for", "file_"+newIndex+"_content");
|
||||
new_file.find("label[for='file_INDEX_filename']").attr("for", "file_"+newIndex+"_filename");
|
||||
new_file.find("label[for='file_INDEX_content']").attr("for", "file_"+newIndex+"_content");
|
||||
|
||||
new_file.find("input[id='file_"+index+"_filename']").attr("id", "file_"+newIndex+"_filename");
|
||||
new_file.find("textarea[id='file_"+index+"_content']").attr("id", "file_"+newIndex+"_content");
|
||||
new_file.find("input[id='file_INDEX_filename']").attr("id", "file_"+newIndex+"_filename");
|
||||
new_file.find("textarea[id='file_INDEX_content']").attr("id", "file_"+newIndex+"_content");
|
||||
|
||||
new_file.find("div[class='file_idx']").html("file " + newIndex);
|
||||
|
||||
|
@@ -32,6 +32,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form placeholders">
|
||||
<div class="form_INDEX gitxt_new_file" data-id="INDEX">
|
||||
<div class="filename">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon"><i class="fa fa-file-code-o" aria-hidden="true"></i></div>
|
||||
<input type="text" name="files_filename" id="file_INDEX_filename" class="form-control" value="" placeholder='{{$.i18n.Tr "gitxt.file_filename_placeholder"}}'>
|
||||
<div class="input-group-addon btn btn-delete-file"><i class="fa fa-remove" aria-hidden="true"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content form-group">
|
||||
<textarea rows="15" type="text" name="files_content" id="file_INDEX_content" class="form-control" placeholder='{{$.i18n.Tr "gitxt.file_content_placeholder"}}'></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="files">
|
||||
{{range $index, $value := .FilesContent}}
|
||||
<div class="form_{{$index}} gitxt_new_file" data-id="{{$index}}">
|
||||
|
@@ -32,6 +32,22 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form placeholders">
|
||||
<div class="form_INDEX gitxt_new_file" data-id="INDEX">
|
||||
<div class="filename">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon"><i class="fa fa-file-code-o" aria-hidden="true"></i></div>
|
||||
<input type="text" name="files_filename" id="file_INDEX_filename" class="form-control" value="" placeholder='{{$.i18n.Tr "gitxt.file_filename_placeholder"}}'>
|
||||
<div class="input-group-addon btn btn-delete-file"><i class="fa fa-remove" aria-hidden="true"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content form-group">
|
||||
<textarea rows="15" type="text" name="files_content" id="file_NUMBER_content" class="form-control" placeholder='{{$.i18n.Tr "gitxt.file_content_placeholder"}}'></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="files">
|
||||
{{range $index, $value := .FilesContent}}
|
||||
<div class="form_{{$index}} gitxt_new_file" data-id="{{$index}}">
|
||||
|
Reference in New Issue
Block a user