Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Implementation for the repo selection modal #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/static/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -691,4 +691,11 @@ header > div.menu .menu-item:last-child{
grid-column-end: 12;
margin-bottom: 20px;

}

.max-500 {
max-height: 500px;
}
.scroll {
overflow-x: auto;
}
85 changes: 56 additions & 29 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,44 +103,59 @@

<div class="body-row modal-msg mt27 main-text">
<!--search:start-->
<form method="POST" action="" id="attach-repos-form">
<!-- <form method="POST" action="" id="attach-repos-form"> -->
<!--tabled-row-->
<div class="tabled-row code-repo-field">
<div class="row-left">
Code Repository:
</div>
<div class="row-right">
<select name="code_repo_id" class="combo_black">
{% for repo in available_repos_for_mapping %}
<option value="{{repo.id}}">{{repo.repo_full_name}}</option>
{% endfor %}
</select>
<div class="tabled-row">
<div class="search" method="GET">
<input type="text" placeholder="Search" class="modal-repo-filter" name="q" value="{{q}}"/>
</div>
</div>
<div class="tabled-row doc-repo-field">
<div class="row-left">
Documentation Repository:
<div class="tabled-row code-repo-field repo-connection-list max-500 scroll">
{% for repo in available_repos_for_mapping %}
<div class="doc-history repo-connection-list-item" data-repo-full-name="{{repo.repo_full_name}}">
<form method="POST" action="" class="attach-repos-form doc-history-row">
<div class="row-left">
<div class="cell-group">{{repo.repo_full_name}}</div>
</div>
<div class="row-right">
<input type="hidden" name="integration_id" value="{{current_installation.id}}" />
<input type="hidden" name="code_repo_id" value="{{repo.id}}" />
<input type="hidden" name="documentation_repo_id" />
<input type="hidden" name="integration_type" value="FULL" />
<button type="submit" class="cta cta-primary">Attach</button>
</div>
</form>
</div>
<div class="row-right">
<select name="documentation_repo_id" class="combo_black">
{% for repo in available_repos_for_mapping %}
<option value="{{repo.id}}">{{repo.repo_full_name}}</option>
{% endfor %}
</select>
{% endfor %}
</div>
<div class="tabled-row doc-repo-field repo-connection-list max-500 scroll">
{% for repo in available_repos_for_mapping %}
<div class="doc-history repo-connection-list-item" data-repo-full-name="{{repo.repo_full_name}}">
<form method="POST" action="" class="attach-repos-form doc-history-row">
<div class="row-left">
<div class="cell-group">{{repo.repo_full_name}}</div>
</div>
<div class="row-right">
<input type="hidden" name="integration_id" value="{{current_installation.id}}" />
<input type="hidden" name="code_repo_id" />
<input type="hidden" name="documentation_repo_id" value="{{repo.id}}" />
<input type="hidden" name="integration_type" value="FULL" />
<button type="submit" class="cta cta-primary">Attach</button>
</div>
</form>
</div>
{% endfor %}
</div>
<div class="tabled-row">
<div class="row-left">
</div>
<div class="row-right button-row">
<input type="hidden" name="integration_id" value="{{current_installation.id}}" />
<input type="hidden" name="integration_type" value="FULL" />
<button type="submit" class="cta cta-primary">Attach</button>

</div>
</div>
<!--tabled-row-->

</form>
<!-- </form> -->

</div>

Expand Down Expand Up @@ -205,10 +220,12 @@
$("#code-or-doc-repo-modal #code-repo-btn").click(function() {

// Set code repo val and reset doc repo val
$('select[name="code_repo_id"]').val($(this).attr("data-code-repo-id"));
$('select[name="documentation_repo_id"]').prop('selectedIndex',0);
// $('select[name="documentation_repo_id"]').prop('selectedIndex',0);
$("#attach-documentation-modal div.modal-title span").first().text("Attach Documentation repository");
$("#attach-documentation-modal .for-repo-text").text("For "+ $(this).attr("data-code-repo-full-name"));
$("#attach-documentation-modal .doc-repo-field input[name='code_repo_id']").val($(this).attr("data-code-repo-id"));


// Show hide appropriate fields
$("#attach-documentation-modal .code-repo-field").hide();
$("#attach-documentation-modal .doc-repo-field").show();
Expand All @@ -223,13 +240,16 @@


// Set code repo val and reset doc repo val
$('select[name="documentation_repo_id"]').val($(this).attr("data-doc-repo-id"));
$('select[name="code_repo_id"]').prop('selectedIndex',0);
// $('select[name="documentation_repo_id"]').val($(this).attr("data-doc-repo-id"));
// $('select[name="code_repo_id"]').prop('selectedIndex',0);
$("#attach-documentation-modal div.modal-title span").first().text("Attach Code repository");
// Show hide appropriate fields
$("#attach-documentation-modal .doc-repo-field").hide();
$("#attach-documentation-modal .code-repo-field").show();
$("#attach-documentation-modal .for-repo-text").text("For "+ $(this).attr("data-doc-repo-full-name"));

$("#attach-documentation-modal .code-repo-field input[name='documentation_repo_id']").val($(this).attr("data-doc-repo-id"));

// Open the modal
$("#attach-documentation-modal").addClass("opened");

Expand Down Expand Up @@ -269,7 +289,7 @@
});


$("#attach-repos-form").submit(function() {
$("form.attach-repos-form").submit(function() {
data = objectifyForm($(this).serializeArray());
if (data["documentation_repo_id"] == data["code_repo_id"]){
alert("Documentation and Code Repository cannot be same");
Expand All @@ -290,6 +310,13 @@
$(".clickable-row").click(function(){
window.location.href = $(this).find("a.cta").attr("href")
});
$(".search .modal-repo-filter").on("keyup change", function() {
search_query = $(this).val();
$(".repo-connection-list .repo-connection-list-item").hide().filter(function( index ) {
return $( this ).attr("data-repo-full-name").toLowerCase().includes(search_query.toLowerCase());
})
.show();
});
</script>
{% else %}
<script type="text/javascript">
Expand Down