From a3d703b2d1ae46c97b62b2cfc5bc1620f7c95b40 Mon Sep 17 00:00:00 2001 From: Tomas Goncalves <43731728+Runner-dev@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:36:03 -0500 Subject: [PATCH 1/2] Converted coffeescript files into JS Compiled js files using npm coffeescript pacakge. Note: This technically makes all javascript files have the same scope as I removed the IIFE that the compiler generated by default --- app/javascript/src/attachments.coffee | 3 - app/javascript/src/attachments.js | 2 + app/javascript/src/blackouts.coffee | 3 - app/javascript/src/blackouts.js | 2 + app/javascript/src/comments.coffee | 3 - app/javascript/src/comments.js | 2 + app/javascript/src/email_forms.coffee | 3 - app/javascript/src/email_forms.js | 2 + app/javascript/src/emails.coffee | 95 ------ app/javascript/src/emails.js | 118 +++++++ app/javascript/src/equipment_profile.coffee | 27 -- app/javascript/src/equipment_profile.js | 41 +++ app/javascript/src/events.coffee | 215 ------------ app/javascript/src/events.js | 355 ++++++++++++++++++++ app/javascript/src/invoice_items.coffee | 3 - app/javascript/src/invoice_items.js | 2 + app/javascript/src/invoices.coffee | 49 --- app/javascript/src/invoices.js | 76 +++++ app/javascript/src/layout.coffee | 3 - app/javascript/src/layout.js | 5 + app/javascript/src/locations.coffee | 3 - app/javascript/src/locations.js | 2 + app/javascript/src/members.coffee | 6 - app/javascript/src/members.js | 8 + app/javascript/src/organizations.coffee | 3 - app/javascript/src/organizations.js | 2 + app/javascript/src/timecard_entries.coffee | 3 - app/javascript/src/timecard_entries.js | 2 + app/javascript/src/timecards.coffee | 7 - app/javascript/src/timecards.js | 7 + 30 files changed, 626 insertions(+), 426 deletions(-) delete mode 100644 app/javascript/src/attachments.coffee create mode 100644 app/javascript/src/attachments.js delete mode 100644 app/javascript/src/blackouts.coffee create mode 100644 app/javascript/src/blackouts.js delete mode 100644 app/javascript/src/comments.coffee create mode 100644 app/javascript/src/comments.js delete mode 100644 app/javascript/src/email_forms.coffee create mode 100644 app/javascript/src/email_forms.js delete mode 100644 app/javascript/src/emails.coffee create mode 100644 app/javascript/src/emails.js delete mode 100644 app/javascript/src/equipment_profile.coffee create mode 100644 app/javascript/src/equipment_profile.js delete mode 100644 app/javascript/src/events.coffee create mode 100644 app/javascript/src/events.js delete mode 100644 app/javascript/src/invoice_items.coffee create mode 100644 app/javascript/src/invoice_items.js delete mode 100644 app/javascript/src/invoices.coffee create mode 100644 app/javascript/src/invoices.js delete mode 100644 app/javascript/src/layout.coffee create mode 100644 app/javascript/src/layout.js delete mode 100644 app/javascript/src/locations.coffee create mode 100644 app/javascript/src/locations.js delete mode 100644 app/javascript/src/members.coffee create mode 100644 app/javascript/src/members.js delete mode 100644 app/javascript/src/organizations.coffee create mode 100644 app/javascript/src/organizations.js delete mode 100644 app/javascript/src/timecard_entries.coffee create mode 100644 app/javascript/src/timecard_entries.js delete mode 100644 app/javascript/src/timecards.coffee create mode 100644 app/javascript/src/timecards.js diff --git a/app/javascript/src/attachments.coffee b/app/javascript/src/attachments.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/javascript/src/attachments.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/javascript/src/attachments.js b/app/javascript/src/attachments.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/javascript/src/attachments.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/javascript/src/blackouts.coffee b/app/javascript/src/blackouts.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/javascript/src/blackouts.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/javascript/src/blackouts.js b/app/javascript/src/blackouts.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/javascript/src/blackouts.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/javascript/src/comments.coffee b/app/javascript/src/comments.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/javascript/src/comments.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/javascript/src/comments.js b/app/javascript/src/comments.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/javascript/src/comments.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/javascript/src/email_forms.coffee b/app/javascript/src/email_forms.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/javascript/src/email_forms.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/javascript/src/email_forms.js b/app/javascript/src/email_forms.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/javascript/src/email_forms.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/javascript/src/emails.coffee b/app/javascript/src/emails.coffee deleted file mode 100644 index 5e4bc5c4..00000000 --- a/app/javascript/src/emails.coffee +++ /dev/null @@ -1,95 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ - -window.setupAjaxLoader = () -> - $.ajaxSetup({ - beforeSend: -> - $('#loader').show(); - , complete: -> - $('#loader').hide(); - , success: -> - }) - -window.hideOptionsMenu = (menu) -> - menu.removeClass("visible") - menu.parent().children(".email-options-link").removeClass("invisible") - -$ -> - $(".hidden-header-toggle").click -> - if $(this).data("clicked") == "no" - $(this).data("clicked", "yes") - $(this).text("Hide Extra Headers") - $(this).parent().parent().find(".hidden-header").css("display", "block") - else - $(this).data("clicked", "no") - $(this).text("Show Hidden Headers") - $(this).parent().parent().find(".hidden-header").css("display", "none") - window.hideOptionsMenu($(this).parent()) - $(".email-contents-quote-mode").click -> - contents = $(this).parent().parent().parent().find(".the-content") - contents.data("quote-mode", $(this).data("quote-mode")) - contents.html(window.simpleFormat(contents.data($(this).data("quote-mode")))) - $(this).parent().children(".email-contents-quote-mode").removeClass("active") - $(this).addClass("active") - window.hideOptionsMenu($(this).parent()) - $(".email-options-link").click -> - $(this).addClass("invisible") - $(this).parent().children(".email-options").addClass("visible") - $(".close-options").click -> - window.hideOptionsMenu($(this).parent()) - $(".email-unread-toggle").click -> - if $(this).data("clicked") == "no" - $(this).text("Mark Read") - $(this).data("clicked","yes") - window.setupAjaxLoader() - $.ajax({ - url: $(this).data("url"), - type: "put", - data: "email[unread]=1" - }) - else - link = $(this) - window.setupAjaxLoader() - $.ajax({ - url: $(this).data("url"), - type: "put", - data: "email[unread]=0", - success: -> - link.text("Mark Unread") - link.data("clicked","no") - }) - window.hideOptionsMenu($(this).parent()) - $(".email-reply-link").click -> - window.setupAjaxLoader() - $.ajax({ - url: window.reply_email_path, - data: "id=" + $(this).data("email-id"), - dataType: "script", - success: "success" - }) - $(".email-new-event-link").click -> - window.setupAjaxLoader() - $.ajax({ - url: window.new_event_email_path, - data: "id=" + $(this).data("email-id"), - dataType: "script", - success: "success" - }) - $(".email-existing-event-link").click -> - window.setupAjaxLoader() - $.ajax({ - url: window.existing_event_email_path, - data: "id=" + $(this).data("email-id"), - dataType: "script", - success: "success" - }) - $(".email-unfile-link").click -> - window.setupAjaxLoader() - $.ajax({ - url: $(this).data("url"), - type: "put", - data: "email[event_id]=nil", - success: -> - window.location.reload(true) - }) \ No newline at end of file diff --git a/app/javascript/src/emails.js b/app/javascript/src/emails.js new file mode 100644 index 00000000..33e3b59e --- /dev/null +++ b/app/javascript/src/emails.js @@ -0,0 +1,118 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. +window.setupAjaxLoader = function () { + return $.ajaxSetup({ + beforeSend: function () { + return $("#loader").show(); + }, + complete: function () { + return $("#loader").hide(); + }, + success: function () {}, + }); +}; + +window.hideOptionsMenu = function (menu) { + menu.removeClass("visible"); + return menu.parent().children(".email-options-link").removeClass("invisible"); +}; + +$(function () { + $(".hidden-header-toggle").click(function () { + if ($(this).data("clicked") === "no") { + $(this).data("clicked", "yes"); + $(this).text("Hide Extra Headers"); + $(this).parent().parent().find(".hidden-header").css("display", "block"); + } else { + $(this).data("clicked", "no"); + $(this).text("Show Hidden Headers"); + $(this).parent().parent().find(".hidden-header").css("display", "none"); + } + return window.hideOptionsMenu($(this).parent()); + }); + $(".email-contents-quote-mode").click(function () { + var contents; + contents = $(this).parent().parent().parent().find(".the-content"); + contents.data("quote-mode", $(this).data("quote-mode")); + contents.html( + window.simpleFormat(contents.data($(this).data("quote-mode"))), + ); + $(this) + .parent() + .children(".email-contents-quote-mode") + .removeClass("active"); + $(this).addClass("active"); + return window.hideOptionsMenu($(this).parent()); + }); + $(".email-options-link").click(function () { + $(this).addClass("invisible"); + return $(this).parent().children(".email-options").addClass("visible"); + }); + $(".close-options").click(function () { + return window.hideOptionsMenu($(this).parent()); + }); + $(".email-unread-toggle").click(function () { + var link; + if ($(this).data("clicked") === "no") { + $(this).text("Mark Read"); + $(this).data("clicked", "yes"); + window.setupAjaxLoader(); + $.ajax({ + url: $(this).data("url"), + type: "put", + data: "email[unread]=1", + }); + } else { + link = $(this); + window.setupAjaxLoader(); + $.ajax({ + url: $(this).data("url"), + type: "put", + data: "email[unread]=0", + success: function () { + link.text("Mark Unread"); + return link.data("clicked", "no"); + }, + }); + } + return window.hideOptionsMenu($(this).parent()); + }); + $(".email-reply-link").click(function () { + window.setupAjaxLoader(); + return $.ajax({ + url: window.reply_email_path, + data: "id=" + $(this).data("email-id"), + dataType: "script", + success: "success", + }); + }); + $(".email-new-event-link").click(function () { + window.setupAjaxLoader(); + return $.ajax({ + url: window.new_event_email_path, + data: "id=" + $(this).data("email-id"), + dataType: "script", + success: "success", + }); + }); + $(".email-existing-event-link").click(function () { + window.setupAjaxLoader(); + return $.ajax({ + url: window.existing_event_email_path, + data: "id=" + $(this).data("email-id"), + dataType: "script", + success: "success", + }); + }); + return $(".email-unfile-link").click(function () { + window.setupAjaxLoader(); + return $.ajax({ + url: $(this).data("url"), + type: "put", + data: "email[event_id]=nil", + success: function () { + return window.location.reload(true); + }, + }); + }); +}); diff --git a/app/javascript/src/equipment_profile.coffee b/app/javascript/src/equipment_profile.coffee deleted file mode 100644 index 34ec21e3..00000000 --- a/app/javascript/src/equipment_profile.coffee +++ /dev/null @@ -1,27 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ - -$ -> - $("#equipment-profile-list").masonry({ - "itemSelector": ".equipment-profile-category", - "columnWidth": ".equipment-profile-category", - "percentPosition": true - }) - $("#equipment-profile-calendar").fullCalendar({ - events: '/equipment_profile/' + $("#equipment-profile-calendar").data("id") + '.json', - left: 'title', - center: '', - right: 'today prev,next' - }) - $("#equipment_profile_category").change -> - $("#equipment_profile_subcategory").html($("#equipment_profile_category option:selected").data("subcategories")) - $(".edit_equipment_profile_category").click -> - $("#equipment_profile_category").replaceWith($("#equipment_profile_category").data("text")) - if $("#equipment_profile_subcategory").data("did") != true - $("#equipment_profile_subcategory").replaceWith($("#equipment_profile_subcategory").data("text")) - $(".edit_equipment_profile_category").remove() - $(".edit_equipment_profile_subcategory").remove() - $(".edit_equipment_profile_subcategory").click -> - $("#equipment_profile_subcategory").replaceWith($("#equipment_profile_subcategory").data("text")) - $(".edit_equipment_profile_subcategory").remove() \ No newline at end of file diff --git a/app/javascript/src/equipment_profile.js b/app/javascript/src/equipment_profile.js new file mode 100644 index 00000000..79337f61 --- /dev/null +++ b/app/javascript/src/equipment_profile.js @@ -0,0 +1,41 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. +$(function () { + $("#equipment-profile-list").masonry({ + itemSelector: ".equipment-profile-category", + columnWidth: ".equipment-profile-category", + percentPosition: true, + }); + $("#equipment-profile-calendar").fullCalendar({ + events: + "/equipment_profile/" + + $("#equipment-profile-calendar").data("id") + + ".json", + left: "title", + center: "", + right: "today prev,next", + }); + $("#equipment_profile_category").change(function () { + return $("#equipment_profile_subcategory").html( + $("#equipment_profile_category option:selected").data("subcategories"), + ); + }); + $(".edit_equipment_profile_category").click(function () { + $("#equipment_profile_category").replaceWith( + $("#equipment_profile_category").data("text"), + ); + if ($("#equipment_profile_subcategory").data("did") !== true) { + $("#equipment_profile_subcategory").replaceWith( + $("#equipment_profile_subcategory").data("text"), + ); + } + $(".edit_equipment_profile_category").remove(); + return $(".edit_equipment_profile_subcategory").remove(); + }); + return $(".edit_equipment_profile_subcategory").click(function () { + $("#equipment_profile_subcategory").replaceWith( + $("#equipment_profile_subcategory").data("text"), + ); + return $(".edit_equipment_profile_subcategory").remove(); + }); +}); diff --git a/app/javascript/src/events.coffee b/app/javascript/src/events.coffee deleted file mode 100644 index 828e536f..00000000 --- a/app/javascript/src/events.coffee +++ /dev/null @@ -1,215 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ - -window.simpleFormat = (str) -> - str = str.replace(/\r\n?/, "\n") - str = $.trim(str) - if str.length > 0 - str = str.replace(/\n\n+/g, '

') - str = str.replace(/\n/g, '
') - str = '

' + str + '

' - return str - -window.setUpDeleteFields = () -> - $("a.delete_field.undestroyable").click -> - $(this).prev("input[type=hidden]").val("1") - $(this).closest(".fields").hide() - $("a.delete_field.destroyable").click -> - $(this).closest(".fields").remove() - -window.setUpSuperTicAdd = (parent) -> - parent.find(".supertic_add_role_button").click -> - new_id = new Date().getTime() - regexp = new RegExp("new_event_roles", "g") - whereToAdd = $(this).parents("table").first().children("tbody").children("tr").last() - toAdd = $(this).prev().children("option:selected").data("role").replace(regexp, new_id) - whereToAdd.before(toAdd) - $(".association-" + new_id + " a.delete_field").click -> - $(this).closest(".fields").remove() - -window.setUpSuperTicEdit = (ed,roles) -> - ed.find(".start-time-field").children(".day, .month, .year").change -> - day = parseInt($(this).parent().children(".day").val()) - month = parseInt($(this).parent().children(".month").val())-1 - year = parseInt($(this).parent().children(".year").val()) - dayOfWeek = new Date(year, month, day).getDay() - if dayOfWeek == 0 - dayOfWeek = 7 - roles.find(".supertic_add_role_select").val(dayOfWeek) - -window.setUpEventDate = (ed) -> - ed.find(".datetime_select").each -> - parent = $(this) - window.setDateMonths(parent) - $(this).children(".month, .year").change -> - window.setDateMonths(parent) - ed.find(".copy_start_time").click -> - starttime = $(this).parents(".event-date-form").find(".start-time-field") - $(this).parent().each -> - $(this).children(".month").val(starttime.children(".month").val()) - $(this).children(".year").val(starttime.children(".year").val()) - window.setDateMonths($(this)) - $(this).children(".day").val(starttime.children(".day").val()) - $(this).siblings(".field_with_errors").each -> - $(this).children(".month").val(starttime.children(".month").val()) - $(this).children(".year").val(starttime.children(".year").val()) - window.setDateMonths($(this)) - $(this).children(".day").val(starttime.children(".day").val()) - ed.find(".call-time-field, .strike-time-field").each -> - parent = $(this) - if parent.prev().val() == "literal" - parent.show() - else - parent.hide() - parent.prev().change -> - if parent.prev().val() == "literal" - parent.show() - else - parent.hide() - window.setUpSuperTicEdit(ed, ed.find(".event-form-roles")) - ed.find(".eventdate_big_select").chosen({width: "95%"}) - -window.setUpAddFields = () -> - $("a.add_field").click -> - new_id = new Date().getTime() - regexp = new RegExp("new_" + $(this).data("association"), "g") - - if $(this).data("association") == "eventdates" - prev = $(this).parents("#event-form-dates").children(".event-date-form").last() - $(this).parent().before($(this).data("content").replace(regexp, new_id)) - added = $(this).parents("#event-form-dates").children(".event-date-form").last() - if prev.length > 0 - window.setDateMonths(added.find(".call-time-field"), prev.find(".call-time-field")) - window.setDateMonths(added.find(".start-time-field"), prev.find(".start-time-field")) - window.setDateMonths(added.find(".end-time-field"), prev.find(".end-time-field")) - window.setDateMonths(added.find(".strike-time-field"), prev.find(".strike-time-field")) - added.find(".eventdate_locations").val(prev.find(".eventdate_locations").val()) - window.setUpEventDate(added) - window.setUpSuperTicAdd(added) - else - $(this).parent().before($(this).data("content").replace(regexp, new_id)) - - $(".association-" + new_id + " a.delete_field").click -> - $(this).closest(".fields").remove() - window.setUpAddFields() - $("a.add_field2").click -> - new_id = new Date().getTime() - regexp = new RegExp("new_" + $(this).data("association"), "g") - $(this).parent().parent().before($(this).data("content").replace(regexp, new_id)) - $(".association-" + new_id + " a.delete_field").click -> - $(this).closest(".fields").remove() - window.setUpAddFields() - $("a.add_field").removeClass("add_field") - $("a.add_field2").removeClass("add_field2") - -window.setDateMonths = (parent, other = null) -> - if other == null - year = parseInt(parent.children(".year").children(":selected").val()) - month = parseInt(parent.children(".month").children(":selected").val()) - day = parseInt(parent.children(".day").children(":selected").val()) - else - year = parseInt(other.children(".year").children(":selected").val()) - month = parseInt(other.children(".month").children(":selected").val()) - day = parseInt(other.children(".day").children(":selected").val()) - parent.children(".year").val(year) - parent.children(".month").val(month) - days = new Date(year, month, 0).getDate() - if days < day - day = 1 - day_select = parent.children(".day") - day_select.empty() - for d in [1..days] - if d == day - day_select.append("") - else - day_select.append("") - -window.updateCalendarExportLink = () -> - param = $("#gencalex_form input[name=gen_param]:checked").val() - root = $("#gencalex_root").val() - output = "" - if param == "range" - output += "?startdate=" - output += $("#gencalex_startdate_year").val() - output += "-" - output += $("#gencalex_startdate_month").val() - output += "-" - output += $("#gencalex_startdate_day").val() - output += "&enddate=" - output += $("#gencalex_enddate_year").val() - output += "-" - output += $("#gencalex_enddate_month").val() - output += "-" - output += $("#gencalex_enddate_day").val() - else if param == "matchdate" - output += "?matchdate=" - output += $("#gencalex_matchdate_year").val() - output += "-" - output += $("#gencalex_matchdate_month").val() - output += "-" - output += $("#gencalex_matchdate_day").val() - else if param == "soon" - output += "?period=soon" - else if param == "period" - output += "?period=" - output += $("#gencalex_period").val() - output += $("#gencalex_period_year_year").val() - if $("#gencalex_form input[name=gen_hidecompleted]:checked").val() - output += "&hidecompleted" - $("#gencalex_ical_result").html("" + root + "calendar/generate.ics" + output + "") - $("#gencalex_text_result").html("" + root + "calendar/generate.schedule" + output + "") - -$ -> - window.updateCalendarExportLink() - $("#gencalex_form input, #gencalex_form select").change -> - window.updateCalendarExportLink() - -$ -> - $("#event-emails h5").click -> - email = $(this).parent().children(".email") - if $(this).data("visible") == "yes" - $(this).data("visible", "no") - $(this).children(".arrow").html("▶") - else - $(this).data("visible", "yes") - $(this).children(".arrow").html("▼") - email.toggle("blind") - -window.setupForms = () -> - window.setUpAddFields() - window.setUpDeleteFields() - $(".event-form-roles").each -> - window.setUpSuperTicAdd($(this)) - $(".event-date-form").each -> - window.setUpEventDate($(this)) - window.setUpSuperTicEdit($(".event-date-form").first(), $("fieldset.event-form-roles")) - $(".eventdate_big_select").chosen({width: "95%"}) - if $("#event_blackout_attributes__destroy").prop("checked") - $(".event-blackout-fields").show() - $("#event_blackout_attributes__destroy").change -> - if $("#event_blackout_attributes__destroy").prop("checked") - $(".event-blackout-fields").show() - else - $(".event-blackout-fields").hide() - if $("#event_org_type").val() == "new" - $("#event_organization_id").hide() - $("#event_org_new").show() - $("#event_org_type").change -> - if $("#event_org_type").val() == "new" - $("#event_organization_id").hide() - $("#event_org_new").show() - else - $("#event_org_new").hide() - $("#event_organization_id").show() - -$ -> - window.setupForms() - -$ -> - $("#search.search_empty").focus -> - $(this).removeClass("search_empty") - $(this).addClass("search_full") - $("#search.search_full").blur -> - $(this).removeClass("search_full") - $(this).addClass("search_empty") diff --git a/app/javascript/src/events.js b/app/javascript/src/events.js new file mode 100644 index 00000000..34e20841 --- /dev/null +++ b/app/javascript/src/events.js @@ -0,0 +1,355 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. +window.simpleFormat = function (str) { + str = str.replace(/\r\n?/, "\n"); + str = $.trim(str); + if (str.length > 0) { + str = str.replace(/\n\n+/g, "

"); + str = str.replace(/\n/g, "
"); + str = "

" + str + "

"; + } + return str; +}; + +window.setUpDeleteFields = function () { + $("a.delete_field.undestroyable").click(function () { + $(this).prev("input[type=hidden]").val("1"); + return $(this).closest(".fields").hide(); + }); + return $("a.delete_field.destroyable").click(function () { + return $(this).closest(".fields").remove(); + }); +}; + +window.setUpSuperTicAdd = function (parent) { + return parent.find(".supertic_add_role_button").click(function () { + var new_id, regexp, toAdd, whereToAdd; + new_id = new Date().getTime(); + regexp = new RegExp("new_event_roles", "g"); + whereToAdd = $(this) + .parents("table") + .first() + .children("tbody") + .children("tr") + .last(); + toAdd = $(this) + .prev() + .children("option:selected") + .data("role") + .replace(regexp, new_id); + whereToAdd.before(toAdd); + return $(".association-" + new_id + " a.delete_field").click(function () { + return $(this).closest(".fields").remove(); + }); + }); +}; + +window.setUpSuperTicEdit = function (ed, roles) { + return ed + .find(".start-time-field") + .children(".day, .month, .year") + .change(function () { + var day, dayOfWeek, month, year; + day = parseInt($(this).parent().children(".day").val()); + month = parseInt($(this).parent().children(".month").val()) - 1; + year = parseInt($(this).parent().children(".year").val()); + dayOfWeek = new Date(year, month, day).getDay(); + if (dayOfWeek === 0) { + dayOfWeek = 7; + } + return roles.find(".supertic_add_role_select").val(dayOfWeek); + }); +}; + +window.setUpEventDate = function (ed) { + ed.find(".datetime_select").each(function () { + var parent; + parent = $(this); + window.setDateMonths(parent); + return $(this) + .children(".month, .year") + .change(function () { + return window.setDateMonths(parent); + }); + }); + ed.find(".copy_start_time").click(function () { + var starttime; + starttime = $(this).parents(".event-date-form").find(".start-time-field"); + $(this) + .parent() + .each(function () { + $(this).children(".month").val(starttime.children(".month").val()); + $(this).children(".year").val(starttime.children(".year").val()); + window.setDateMonths($(this)); + return $(this).children(".day").val(starttime.children(".day").val()); + }); + return $(this) + .siblings(".field_with_errors") + .each(function () { + $(this).children(".month").val(starttime.children(".month").val()); + $(this).children(".year").val(starttime.children(".year").val()); + window.setDateMonths($(this)); + return $(this).children(".day").val(starttime.children(".day").val()); + }); + }); + ed.find(".call-time-field, .strike-time-field").each(function () { + var parent; + parent = $(this); + if (parent.prev().val() === "literal") { + parent.show(); + } else { + parent.hide(); + } + return parent.prev().change(function () { + if (parent.prev().val() === "literal") { + return parent.show(); + } else { + return parent.hide(); + } + }); + }); + window.setUpSuperTicEdit(ed, ed.find(".event-form-roles")); + return ed.find(".eventdate_big_select").chosen({ + width: "95%", + }); +}; + +window.setUpAddFields = function () { + $("a.add_field").click(function () { + var added, new_id, prev, regexp; + new_id = new Date().getTime(); + regexp = new RegExp("new_" + $(this).data("association"), "g"); + if ($(this).data("association") === "eventdates") { + prev = $(this) + .parents("#event-form-dates") + .children(".event-date-form") + .last(); + $(this).parent().before($(this).data("content").replace(regexp, new_id)); + added = $(this) + .parents("#event-form-dates") + .children(".event-date-form") + .last(); + if (prev.length > 0) { + window.setDateMonths( + added.find(".call-time-field"), + prev.find(".call-time-field"), + ); + window.setDateMonths( + added.find(".start-time-field"), + prev.find(".start-time-field"), + ); + window.setDateMonths( + added.find(".end-time-field"), + prev.find(".end-time-field"), + ); + window.setDateMonths( + added.find(".strike-time-field"), + prev.find(".strike-time-field"), + ); + } + added + .find(".eventdate_locations") + .val(prev.find(".eventdate_locations").val()); + window.setUpEventDate(added); + window.setUpSuperTicAdd(added); + } else { + $(this).parent().before($(this).data("content").replace(regexp, new_id)); + } + $(".association-" + new_id + " a.delete_field").click(function () { + return $(this).closest(".fields").remove(); + }); + return window.setUpAddFields(); + }); + $("a.add_field2").click(function () { + var new_id, regexp; + new_id = new Date().getTime(); + regexp = new RegExp("new_" + $(this).data("association"), "g"); + $(this) + .parent() + .parent() + .before($(this).data("content").replace(regexp, new_id)); + $(".association-" + new_id + " a.delete_field").click(function () { + return $(this).closest(".fields").remove(); + }); + return window.setUpAddFields(); + }); + $("a.add_field").removeClass("add_field"); + return $("a.add_field2").removeClass("add_field2"); +}; + +window.setDateMonths = function (parent, other = null) { + var d, day, day_select, days, i, month, ref, results, year; + if (other === null) { + year = parseInt(parent.children(".year").children(":selected").val()); + month = parseInt(parent.children(".month").children(":selected").val()); + day = parseInt(parent.children(".day").children(":selected").val()); + } else { + year = parseInt(other.children(".year").children(":selected").val()); + month = parseInt(other.children(".month").children(":selected").val()); + day = parseInt(other.children(".day").children(":selected").val()); + parent.children(".year").val(year); + parent.children(".month").val(month); + } + days = new Date(year, month, 0).getDate(); + if (days < day) { + day = 1; + } + day_select = parent.children(".day"); + day_select.empty(); + results = []; + for ( + d = i = 1, ref = days; + 1 <= ref ? i <= ref : i >= ref; + d = 1 <= ref ? ++i : --i + ) { + if (d === day) { + results.push( + day_select.append( + '", + ), + ); + } else { + results.push( + day_select.append('"), + ); + } + } + return results; +}; + +window.updateCalendarExportLink = function () { + var output, param, root; + param = $("#gencalex_form input[name=gen_param]:checked").val(); + root = $("#gencalex_root").val(); + output = ""; + if (param === "range") { + output += "?startdate="; + output += $("#gencalex_startdate_year").val(); + output += "-"; + output += $("#gencalex_startdate_month").val(); + output += "-"; + output += $("#gencalex_startdate_day").val(); + output += "&enddate="; + output += $("#gencalex_enddate_year").val(); + output += "-"; + output += $("#gencalex_enddate_month").val(); + output += "-"; + output += $("#gencalex_enddate_day").val(); + } else if (param === "matchdate") { + output += "?matchdate="; + output += $("#gencalex_matchdate_year").val(); + output += "-"; + output += $("#gencalex_matchdate_month").val(); + output += "-"; + output += $("#gencalex_matchdate_day").val(); + } else if (param === "soon") { + output += "?period=soon"; + } else if (param === "period") { + output += "?period="; + output += $("#gencalex_period").val(); + output += $("#gencalex_period_year_year").val(); + } + if ($("#gencalex_form input[name=gen_hidecompleted]:checked").val()) { + output += "&hidecompleted"; + } + $("#gencalex_ical_result").html( + '' + + root + + "calendar/generate.ics" + + output + + "", + ); + return $("#gencalex_text_result").html( + '' + + root + + "calendar/generate.schedule" + + output + + "", + ); +}; + +$(function () { + window.updateCalendarExportLink(); + return $("#gencalex_form input, #gencalex_form select").change(function () { + return window.updateCalendarExportLink(); + }); +}); + +$(function () { + return $("#event-emails h5").click(function () { + var email; + email = $(this).parent().children(".email"); + if ($(this).data("visible") === "yes") { + $(this).data("visible", "no"); + $(this).children(".arrow").html("▶"); + } else { + $(this).data("visible", "yes"); + $(this).children(".arrow").html("▼"); + } + return email.toggle("blind"); + }); +}); + +window.setupForms = function () { + window.setUpAddFields(); + window.setUpDeleteFields(); + $(".event-form-roles").each(function () { + return window.setUpSuperTicAdd($(this)); + }); + $(".event-date-form").each(function () { + return window.setUpEventDate($(this)); + }); + window.setUpSuperTicEdit( + $(".event-date-form").first(), + $("fieldset.event-form-roles"), + ); + $(".eventdate_big_select").chosen({ + width: "95%", + }); + if ($("#event_blackout_attributes__destroy").prop("checked")) { + $(".event-blackout-fields").show(); + } + $("#event_blackout_attributes__destroy").change(function () { + if ($("#event_blackout_attributes__destroy").prop("checked")) { + return $(".event-blackout-fields").show(); + } else { + return $(".event-blackout-fields").hide(); + } + }); + if ($("#event_org_type").val() === "new") { + $("#event_organization_id").hide(); + $("#event_org_new").show(); + } + return $("#event_org_type").change(function () { + if ($("#event_org_type").val() === "new") { + $("#event_organization_id").hide(); + return $("#event_org_new").show(); + } else { + $("#event_org_new").hide(); + return $("#event_organization_id").show(); + } + }); +}; + +$(function () { + return window.setupForms(); +}); + +$(function () { + $("#search.search_empty").focus(function () { + $(this).removeClass("search_empty"); + return $(this).addClass("search_full"); + }); + return $("#search.search_full").blur(function () { + $(this).removeClass("search_full"); + return $(this).addClass("search_empty"); + }); +}); diff --git a/app/javascript/src/invoice_items.coffee b/app/javascript/src/invoice_items.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/javascript/src/invoice_items.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/javascript/src/invoice_items.js b/app/javascript/src/invoice_items.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/javascript/src/invoice_items.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/javascript/src/invoices.coffee b/app/javascript/src/invoices.coffee deleted file mode 100644 index a9e2c175..00000000 --- a/app/javascript/src/invoices.coffee +++ /dev/null @@ -1,49 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ - -$ -> - $('#invoice_payment_type').change -> - if $(this).val() == "Oracle" - $('#oracleString').show('Blind') - else - $('#oracleString').hide('Blind') - $('#invoice_status').change -> - if $(this).val() == "Loan Agreement" - $('#loan-agreement-notice').show('Blind') - else - $('#loan-agreement-notice').hide('Blind') - -window.chooseLinePreset = (id) -> - if $("#invoice-line-preset-" + id).val() != "" - selected = $("#invoice-line-preset-" + id + " option:selected").first() - $("#invoice_invoice_lines_attributes_" + id + "_category").val(selected.data('category')) - $("#invoice_invoice_lines_attributes_" + id + "_memo").val(selected.data('memo')) - $("#invoice_invoice_lines_attributes_" + id + "_quantity").val("1") - $("#invoice_invoice_lines_attributes_" + id + "_price").val(selected.data('price')) - -window.toggleNotes = (id) -> - note = $("#notes" + id) - link = $("#notesToggle" + id) - if note.css("display") == "none" - note.css("display","block") - link.html("^") - else - note.css("display","none") - link.html("V") - -window.indexList = () -> - $('input.index').each( (i) -> - $(this).val(i)) - -$ -> - window.indexList() - -$ -> - $('#sortable').sortable({stop: window.indexList, items: 'tr.fields'}); - -$ -> - $("a.replace_field").click -> - new_id = new Date().getTime() - regexp = new RegExp("new_" + $(this).data("association"), "g") - $("#" + $(this).data("repid")).html($(this).data("content").replace(regexp, new_id)) \ No newline at end of file diff --git a/app/javascript/src/invoices.js b/app/javascript/src/invoices.js new file mode 100644 index 00000000..9f5c744c --- /dev/null +++ b/app/javascript/src/invoices.js @@ -0,0 +1,76 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. +$(function () { + $("#invoice_payment_type").change(function () { + if ($(this).val() === "Oracle") { + return $("#oracleString").show("Blind"); + } else { + return $("#oracleString").hide("Blind"); + } + }); + return $("#invoice_status").change(function () { + if ($(this).val() === "Loan Agreement") { + return $("#loan-agreement-notice").show("Blind"); + } else { + return $("#loan-agreement-notice").hide("Blind"); + } + }); +}); + +window.chooseLinePreset = function (id) { + var selected; + if ($("#invoice-line-preset-" + id).val() !== "") { + selected = $("#invoice-line-preset-" + id + " option:selected").first(); + $("#invoice_invoice_lines_attributes_" + id + "_category").val( + selected.data("category"), + ); + $("#invoice_invoice_lines_attributes_" + id + "_memo").val( + selected.data("memo"), + ); + $("#invoice_invoice_lines_attributes_" + id + "_quantity").val("1"); + return $("#invoice_invoice_lines_attributes_" + id + "_price").val( + selected.data("price"), + ); + } +}; + +window.toggleNotes = function (id) { + var link, note; + note = $("#notes" + id); + link = $("#notesToggle" + id); + if (note.css("display") === "none") { + note.css("display", "block"); + return link.html("^"); + } else { + note.css("display", "none"); + return link.html("V"); + } +}; + +window.indexList = function () { + return $("input.index").each(function (i) { + return $(this).val(i); + }); +}; + +$(function () { + return window.indexList(); +}); + +$(function () { + return $("#sortable").sortable({ + stop: window.indexList, + items: "tr.fields", + }); +}); + +$(function () { + return $("a.replace_field").click(function () { + var new_id, regexp; + new_id = new Date().getTime(); + regexp = new RegExp("new_" + $(this).data("association"), "g"); + return $("#" + $(this).data("repid")).html( + $(this).data("content").replace(regexp, new_id), + ); + }); +}); diff --git a/app/javascript/src/layout.coffee b/app/javascript/src/layout.coffee deleted file mode 100644 index 2e11a7dc..00000000 --- a/app/javascript/src/layout.coffee +++ /dev/null @@ -1,3 +0,0 @@ -$ -> - $('.toggle-div').click -> - $("#" + $(this).data('div')).toggle("Blind") diff --git a/app/javascript/src/layout.js b/app/javascript/src/layout.js new file mode 100644 index 00000000..27f3812b --- /dev/null +++ b/app/javascript/src/layout.js @@ -0,0 +1,5 @@ +$(function () { + return $(".toggle-div").click(function () { + return $("#" + $(this).data("div")).toggle("Blind"); + }); +}); diff --git a/app/javascript/src/locations.coffee b/app/javascript/src/locations.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/javascript/src/locations.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/javascript/src/locations.js b/app/javascript/src/locations.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/javascript/src/locations.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/javascript/src/members.coffee b/app/javascript/src/members.coffee deleted file mode 100644 index a535c954..00000000 --- a/app/javascript/src/members.coffee +++ /dev/null @@ -1,6 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ - -$ -> - $(".members-to-edit").multiSelect({selectableOptgroup: true, cssClass: "members-to-edit-css"}) \ No newline at end of file diff --git a/app/javascript/src/members.js b/app/javascript/src/members.js new file mode 100644 index 00000000..e691740b --- /dev/null +++ b/app/javascript/src/members.js @@ -0,0 +1,8 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. +$(function () { + return $(".members-to-edit").multiSelect({ + selectableOptgroup: true, + cssClass: "members-to-edit-css", + }); +}); diff --git a/app/javascript/src/organizations.coffee b/app/javascript/src/organizations.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/javascript/src/organizations.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/javascript/src/organizations.js b/app/javascript/src/organizations.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/javascript/src/organizations.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/javascript/src/timecard_entries.coffee b/app/javascript/src/timecard_entries.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/javascript/src/timecard_entries.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/javascript/src/timecard_entries.js b/app/javascript/src/timecard_entries.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/javascript/src/timecard_entries.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/javascript/src/timecards.coffee b/app/javascript/src/timecards.coffee deleted file mode 100644 index 05d01cfd..00000000 --- a/app/javascript/src/timecards.coffee +++ /dev/null @@ -1,7 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ - -$ -> - $("#timecard-dropdown").change -> - window.location = $(this).children(":selected").val() diff --git a/app/javascript/src/timecards.js b/app/javascript/src/timecards.js new file mode 100644 index 00000000..14da17a7 --- /dev/null +++ b/app/javascript/src/timecards.js @@ -0,0 +1,7 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. +$(function () { + return $("#timecard-dropdown").change(function () { + return (window.location = $(this).children(":selected").val()); + }); +}); From c1fdbe11daf49058767201a3b57a76e2c7d14a56 Mon Sep 17 00:00:00 2001 From: Tomas Goncalves <43731728+Runner-dev@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:52:55 -0500 Subject: [PATCH 2/2] Remove all references to coffeescript in the codebase (loaders, packages, comments) --- app/assets/javascripts/application.js | 2 +- config/webpack/environment.js | 6 ++---- config/webpack/loaders/coffee.js | 6 ------ config/webpacker.yml | 1 - package.json | 2 -- yarn.lock | 13 ------------- 6 files changed, 3 insertions(+), 27 deletions(-) delete mode 100644 config/webpack/loaders/coffee.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 6a05a2f6..19d787e3 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,7 +1,7 @@ // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// Any JavaScript file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the diff --git a/config/webpack/environment.js b/config/webpack/environment.js index 89edc45f..4c26baad 100644 --- a/config/webpack/environment.js +++ b/config/webpack/environment.js @@ -1,5 +1,3 @@ -const { environment } = require('@rails/webpacker') -const coffee = require('./loaders/coffee') +const { environment } = require("@rails/webpacker"); -environment.loaders.prepend('coffee', coffee) -module.exports = environment +module.exports = environment; diff --git a/config/webpack/loaders/coffee.js b/config/webpack/loaders/coffee.js deleted file mode 100644 index 4666716d..00000000 --- a/config/webpack/loaders/coffee.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - test: /\.coffee(\.erb)?$/, - use: [{ - loader: 'coffee-loader' - }] -} diff --git a/config/webpacker.yml b/config/webpacker.yml index 1b724de3..a6b14656 100644 --- a/config/webpacker.yml +++ b/config/webpacker.yml @@ -33,7 +33,6 @@ default: &default - .woff2 extensions: - - .coffee - .mjs - .js - .sass diff --git a/package.json b/package.json index e31750f1..a1dff986 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,6 @@ "private": true, "dependencies": { "@rails/webpacker": "5.4.3", - "coffee-loader": "^1.0.1", - "coffeescript": "^2.6.1", "puppeteer": "^13.0.1", "webpack": "^4.46.0", "webpack-cli": "^3.3.12" diff --git a/yarn.lock b/yarn.lock index f14a9777..72ceb638 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1906,19 +1906,6 @@ coa@^2.0.2: chalk "^2.4.1" q "^1.1.2" -coffee-loader@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/coffee-loader/-/coffee-loader-1.0.1.tgz#f672c4b2ea358e039f702ad590148f7a1dda77f0" - integrity sha512-l3lcWeyNE11ZXNYEpkIkerrvBdSpT06/kcR7MyY+0ys38MOuqzhr+s+s7Tsvv2QH1+qEmhvG8mGuUWIO2zH7Bg== - dependencies: - loader-utils "^2.0.0" - schema-utils "^3.0.0" - -coffeescript@^2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/coffeescript/-/coffeescript-2.6.1.tgz#f9e5d4930e1b8a1c5cfba7f95eebd18694ce58fd" - integrity sha512-GG5nkF93qII8HmHqnnibkgpp/SV7PSnSPiWsbinwya7nNOe95aE/x2xrKZJFks8Qpko3TNrC+/LahaKgrz5YCg== - collection-visit@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0"