Skip to content

Commit

Permalink
Correctly initialise the custom repository modal on open. Show/hide t…
Browse files Browse the repository at this point in the history
…he various inputs based on the type of repository selected in the drop down.
  • Loading branch information
james-strauss-uwa committed Nov 1, 2024
1 parent 159ccbe commit 4cf254d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Modals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,7 @@ export class Modals {
$('#gitCustomRepositoryModal').data('completed', false);
});
$('#gitCustomRepositoryModalRepositoryServiceSelect').on('change', function(){
const repositoryService : Repository.Service = <Repository.Service>$('#gitCustomRepositoryModalRepositoryServiceSelect').val();
const showLocalDirectorySection = repositoryService === Repository.Service.LocalDirectory;

$('#gitCustomRepositoryModalSectionGit').toggle(!showLocalDirectorySection);
$('#gitCustomRepositoryModalSectionLocal').toggle(showLocalDirectorySection);
Modals.showCorrectCustomRepositoryInputs();
});
$('#gitCustomRepositoryModal').on('shown.bs.modal', function(){
$('#gitCustomRepositoryModalRepositoryNameInput').removeClass('is-invalid');
Expand All @@ -221,9 +217,7 @@ export class Modals {
$('#gitCustomRepositoryModalAffirmativeButton').prop('disabled', true);
$('#gitCustomRepositoryModalAffirmativeButton').trigger("focus");

// TODO: this might not be right, depending on state
$('#gitCustomRepositoryModalSectionGit').show();
$('#gitCustomRepositoryModalSectionLocal').hide();
Modals.showCorrectCustomRepositoryInputs();
});
$('#gitCustomRepositoryModal').on('hidden.bs.modal', function(){
const callback : (completed : boolean, repositoryService : string, repositoryName : string, repositoryBranch : string) => void = $('#gitCustomRepositoryModal').data('callback');
Expand Down Expand Up @@ -471,6 +465,15 @@ export class Modals {
}
}

// check which "repository service" has been selected in the dropdown, and show/hide other inputs as appropriate
static showCorrectCustomRepositoryInputs(){
const repositoryService : Repository.Service = <Repository.Service>$('#gitCustomRepositoryModalRepositoryServiceSelect').val();
const showLocalDirectorySection = repositoryService === Repository.Service.LocalDirectory;

$('#gitCustomRepositoryModalSectionGit').toggle(!showLocalDirectorySection);
$('#gitCustomRepositoryModalSectionLocal').toggle(showLocalDirectorySection);
}

static _updateFieldModalDataType(dataType: string){

//reset value fields dataType specific attributes
Expand Down

0 comments on commit 4cf254d

Please sign in to comment.