From d24e8fad14ed21a1bb1b6cba6efc48da902b64e9 Mon Sep 17 00:00:00 2001 From: farhatahmad <35435341+farhatahmad@users.noreply.github.com> Date: Wed, 6 Feb 2019 16:13:53 -0500 Subject: [PATCH] Added the ability to choose which room settings are available using env variable (#363) --- app/assets/javascripts/rename.js | 49 ++++--------------- app/assets/javascripts/room.js | 10 ++-- .../shared/components/_room_block.html.erb | 3 -- .../shared/modals/_create_room_modal.html.erb | 46 +++++++++-------- config/application.rb | 3 ++ sample.env | 11 ++++- 6 files changed, 51 insertions(+), 71 deletions(-) diff --git a/app/assets/javascripts/rename.js b/app/assets/javascripts/rename.js index e920f05c..7cd7069f 100644 --- a/app/assets/javascripts/rename.js +++ b/app/assets/javascripts/rename.js @@ -20,31 +20,6 @@ $(document).on('turbolinks:load', function(){ if(controller == "rooms" && action == "show" || controller == "rooms" && action == "update"){ - // Set a room block rename event - var configure_room_block = function(room_block){ - if(!room_block.is('#home_room_block')){ - - // Register a click event on each room_block rename dropdown - room_block.find('#rename-room-button').on('click', function(e){ - - room_block.find('#room-name-editable-input').on('focusout', function(){ - submit_rename_request(room_block.find('.card')); - $(window).off('mousedown keydown'); - }); - - room_block.click(function(linkEvent) { linkEvent.preventDefault(); }); - room_block.find('#room-name').hide(); - room_block.find('#room-name-editable').show(); - room_block.find('#room-name-editable-input').select() - - // Stop automatic refresh - e.preventDefault(); - - register_window_event(room_block.find('.card'), 'room-name-editable-input', null); - }); - } - } - // Set a room header rename event var configure_room_header = function(room_title){ @@ -61,10 +36,10 @@ $(document).on('turbolinks:load', function(){ room_title.find('#user-text').fadeTo('medium', 0.7); room_title.find('#user-text').attr("contenteditable", true); room_title.find('#user-text').focus(); - + // Stop automatic refresh e.preventDefault(); - + register_window_event(room_title, 'user-text', '#edit-room', 'edit-room'); } @@ -90,18 +65,18 @@ $(document).on('turbolinks:load', function(){ submit_rename_request(recording_title); return; } - + recording_title.addClass("dotted_underline"); recording_title.fadeTo('medium', 0.7); recording_title.find('text').attr("contenteditable", true); recording_title.find('text').focus(); - + // Stop automatic refresh e.preventDefault(); - + register_window_event(recording_title, 'recording-text', '#edit-record', 'edit-recordid'); } - + recording_title.find('a').on('click focusout', function(e){ register_recording_title_event(e); }); @@ -126,12 +101,12 @@ $(document).on('turbolinks:load', function(){ $(clickEvent.target).data(edit_button_data) === element.find(edit_button_id).data(edit_button_data)){ return; } - + // Check if event is keydown and enter key is not pressed if(clickEvent.type == "keydown" && clickEvent.which !== 13){ return; } - + clickEvent.preventDefault(); submit_rename_request(element); @@ -182,15 +157,9 @@ $(document).on('turbolinks:load', function(){ // Configure renaming for room header configure_room_header(room_title); - // Configure renaming for room blocks - room_blocks.each(function(){ - var room_block = $(this) - configure_room_block(room_block) - }); - // Configure renaming for recording rows recording_rows.each(function(){ - var recording_title = $(this).find('#recording-title'); + var recording_title = $(this).find('#recording-title'); configure_recording_row(recording_title); }); } diff --git a/app/assets/javascripts/room.js b/app/assets/javascripts/room.js index 4624588d..9dbcbd52 100644 --- a/app/assets/javascripts/room.js +++ b/app/assets/javascripts/room.js @@ -58,7 +58,6 @@ $(document).on('turbolinks:load', function(){ $("#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() { @@ -68,8 +67,8 @@ $(document).on('turbolinks:load', function(){ //hide all elements & their children with a update-only class $(".update-only").each(function() { - $(this).hide() - if($(this).children().length > 0) $(this).children().hide() + $(this).attr('style',"display:none !important") + if($(this).children().length > 0) $(this).children().attr('style',"display:none !important") }) }) @@ -78,7 +77,6 @@ $(document).on('turbolinks:load', 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() { @@ -88,8 +86,8 @@ $(document).on('turbolinks:load', function(){ //hide all elements & their children with a create-only class $(".create-only").each(function() { - $(this).hide() - if($(this).children().length > 0) $(this).children().hide() + $(this).attr('style',"display:none !important") + if($(this).children().length > 0) $(this).children().attr('style',"display:none !important") }) updateCurrentSettings($(this).closest("#room-block").data("room-settings")) diff --git a/app/views/shared/components/_room_block.html.erb b/app/views/shared/components/_room_block.html.erb index d10925cb..64c7e732 100644 --- a/app/views/shared/components/_room_block.html.erb +++ b/app/views/shared/components/_room_block.html.erb @@ -47,9 +47,6 @@ <%= form_for(:room, url: rooms_path) do |f| %> -
+
@@ -32,33 +32,37 @@
<%= t("modal.create_room.not_blank") %>
-