GRN-11: Ability to configure room specific settings (#348)

* Added the ability to set room settings on create or update

* Added room settings alerts and made fixes to other alerts

* Small bug fixes related to rubocop and the create room modal

* Update test case and fixed issue with small edge case

* Update room.js
This commit is contained in:
farhatahmad
2019-02-06 11:08:19 -05:00
committed by Jesus Federico
parent 992c154c10
commit 2e8670a8ab
21 changed files with 284 additions and 74 deletions

View File

@ -51,4 +51,72 @@ $(document).on('turbolinks:load', function(){
});
});
}
// Display and update all fields related to creating a room in the createRoomModal
$("#create-room").click(function(){
$("#create-room-name").val("")
$("#createRoomModal form").attr("action", "/")
updateDropdown($(".dropdown-item[value='default']"))
$("#room_mute_on_join").prop("checked", false)
$("#auto-join-label").addClass("mt-3 mb-6")
//show all elements & their children with a create-only class
$(".create-only").each(function() {
$(this).show()
if($(this).children().length > 0) $(this).children().show()
})
//hide all elements & their children with a update-only class
$(".update-only").each(function() {
$(this).hide()
if($(this).children().length > 0) $(this).children().hide()
})
})
// Display and update all fields related to creating a room in the createRoomModal
$(".update-room").click(function(){
var room_block_uid = $(this).closest("#room-block").data("room-uid")
$("#create-room-name").val($(this).closest("tbody").find("#room-name h4").text())
$("#createRoomModal form").attr("action", "/" + room_block_uid + "/update_settings")
$("#auto-join-label").removeClass("mt-3 mb-6")
//show all elements & their children with a update-only class
$(".update-only").each(function() {
$(this).show()
if($(this).children().length > 0) $(this).children().show()
})
//hide all elements & their children with a create-only class
$(".create-only").each(function() {
$(this).hide()
if($(this).children().length > 0) $(this).children().hide()
})
updateCurrentSettings($(this).closest("#room-block").data("room-settings"))
})
//Update the createRoomModal to show the correct current settings
function updateCurrentSettings(settings){
//set checkbox
if(settings.muteOnStart){
$("#room_mute_on_join").prop("checked", true)
} else { //default option
$("#room_mute_on_join").prop("checked", false)
}
//set dropdown value
if (settings.joinViaHtml5) {
updateDropdown($(".dropdown-item[value='html5']"))
} else if (settings.joinViaHtml5 == false) {
updateDropdown($(".dropdown-item[value='flash']"))
} else { //default option
updateDropdown($(".dropdown-item[value='default']"))
}
}
});
// Updates the dropdown element to show the clicked/correct text
function updateDropdown(element) {
$("#dropdown-trigger").text(element.text())
$("#room_client").val(element.val())
}